44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
from openpyxl import load_workbook
|
|
|
|
from modules.tag import Tag
|
|
from modules.task import QTask
|
|
from modules.variant_builder import VariantFactory
|
|
|
|
wb = load_workbook(filename="./clean.xlsx")
|
|
ws = wb["data"]
|
|
|
|
for i in list(range(6 * 5))[::5]:
|
|
tasks: list[QTask] = []
|
|
|
|
name = str(ws.cell(column=1, row=(i + 1)).value)
|
|
|
|
wb.create_sheet(name)
|
|
ws_sp = wb[name]
|
|
|
|
for ind, col in enumerate(
|
|
ws.iter_cols(min_col=2, max_col=8, min_row=i + 1, max_row=i + 5)
|
|
):
|
|
for cell in col:
|
|
tasks.append(
|
|
QTask[str, str, str, str | None](
|
|
question=str(cell.value), tags=Tag("topic", str(ind))
|
|
)
|
|
)
|
|
|
|
vf = VariantFactory(7, tasks)
|
|
_ = vf.task[0].must.include_tag("topic", "0")
|
|
_ = vf.task[1].must.include_tag("topic", "1")
|
|
_ = vf.task[2].must.include_tag("topic", "2")
|
|
_ = vf.task[3].must.include_tag("topic", "3")
|
|
_ = vf.task[4].must.include_tag("topic", "4")
|
|
_ = vf.task[5].must.include_tag("topic", "5")
|
|
_ = vf.task[6].must.include_tag("topic", "6")
|
|
variants = vf.generate_variants(number_of_variants=8)
|
|
|
|
for ind, variant in enumerate(variants):
|
|
cell = ws_sp.cell(column=1, row=ind + 1, value=f"Вариант {ind + 1}")
|
|
for task_ind, task in enumerate(variant.tasks):
|
|
cell = ws_sp.cell(column=task_ind + 2, row=ind + 1, value=task.question)
|
|
|
|
wb.save("parserd.xlsx")
|