选题添加最多次数

This commit is contained in:
2025-06-24 16:55:39 +08:00
parent c6af350e4b
commit 5eafb11f0b
2 changed files with 20 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
import math
import os
import traceback
@@ -39,11 +40,13 @@ class DTGWorker(QObject):
students = Student.load_from_xls(self.input_filepath)
questions = Question.load_from_xls(self.input_question_filepath)
d = DocPaper(self.output_filename, template_path=resource_path("template/template.docx"))
max_question_count = math.ceil(len(students) * 3 / len(questions))
d = DocPaper(self.output_filename, template_path=resource_path("template/template-2.docx"))
for index, student in enumerate(students):
if (p := int((index + 1) / len(students) * 100)) != 100:
self.progress[int].emit(p)
student.pick_question(questions)
student.pick_question(questions, max_count=max_question_count)
d.add_paper(course, student)
d.save(self.output_filepath)