删除提问功能、替换答辩模板

This commit is contained in:
2025-08-22 20:07:17 +08:00
parent da723409ca
commit 39fcaf35ca
8 changed files with 27 additions and 18 deletions

View File

@@ -17,6 +17,7 @@ import pathlib
from copy import deepcopy
from docx import Document
from docx.enum.text import WD_BREAK
from docx.shared import Cm, Mm
from module.schema import Course, Student
@@ -37,10 +38,11 @@ class DocPaper:
section.right_margin = Cm(2)
def add_paper(self, course: Course, student: Student):
temp_table = self._template.tables[0]
new_table = deepcopy(temp_table)
new_table = deepcopy(self._template.tables[0])
para = self._doc.add_paragraph()
para._p.addprevious(new_table._element)
para.add_run().add_break(WD_BREAK.PAGE)
data_list = {
'%CNAME%': course.name,
@@ -48,9 +50,7 @@ class DocPaper:
'%SNAME%': student.name,
'%NO%': student.no,
'%SO%': student.so,
'%Q1%': student.picked_questions[0].topic,
'%Q2%': student.picked_questions[1].topic,
'%Q3%': student.picked_questions[2].topic
'%Q%': '\n'.join([f'\t{idx + 1}{i.topic}' for idx, i in enumerate(student.picked_questions)])
}
# 替换表格中的占位符