修改database_tools.py中讲义生成功能的小bug
This commit is contained in:
parent
382c27be06
commit
0d07076f83
|
|
@ -724,6 +724,7 @@ def GenerateValueColorCode(matchobj): # 生成三位小数代表的颜色方框(
|
||||||
|
|
||||||
def StudentsGetAfterContent(id,prodict,answered,spaceflag): #生成学生版讲义后的答案及空格, answered表示有无答案, spaceflag表示有无空格
|
def StudentsGetAfterContent(id,prodict,answered,spaceflag): #生成学生版讲义后的答案及空格, answered表示有无答案, spaceflag表示有无空格
|
||||||
string = ""
|
string = ""
|
||||||
|
if "ans" in prodict[id]:
|
||||||
if answered:
|
if answered:
|
||||||
string += "答案: \\textcolor{red}{%s}\n\n"%(prodict[id]["ans"] if prodict[id]["ans"] != "" else "暂无答案")
|
string += "答案: \\textcolor{red}{%s}\n\n"%(prodict[id]["ans"] if prodict[id]["ans"] != "" else "暂无答案")
|
||||||
if spaceflag:
|
if spaceflag:
|
||||||
|
|
@ -1258,24 +1259,22 @@ def select_grade_from_pro_dict(prodict,grades):
|
||||||
return adict
|
return adict
|
||||||
|
|
||||||
def GenerateSingleLessonNote(id,notesdict,metadict,templatepath,outputfilepath,consecutivenumbering = False, answered = False): #20231215版讲义生成
|
def GenerateSingleLessonNote(id,notesdict,metadict,templatepath,outputfilepath,consecutivenumbering = False, answered = False): #20231215版讲义生成
|
||||||
notetitle = id+ r" \ " + notesdict["notes"][id]["name"]
|
notetitle = id + r" \ " + notesdict["notes"][id]["name"]
|
||||||
structure = notesdict["structures"][id[0].upper()]
|
structure = notesdict["structures"][id[0].upper()]
|
||||||
note_contents = notesdict["notes"][id]
|
note_contents = notesdict["notes"][id]
|
||||||
print(structure)
|
|
||||||
output = ""
|
output = ""
|
||||||
sections_list = []
|
sections_list = []
|
||||||
problems_list = []
|
problems_list = []
|
||||||
for key in structure:
|
for key in structure:
|
||||||
print(structure[key])
|
|
||||||
if not len(note_contents[key]) == 0:
|
if not len(note_contents[key]) == 0:
|
||||||
sections_list.append(key)
|
sections_list.append(key)
|
||||||
problems_list.append(",".join(note_contents[key]))
|
problems_list.append(",".join(note_contents[key]))
|
||||||
rawoutput = GenerateStudentBodyString(problems=problems_list,secidontitles=sections_list,pro_dict=metadict,consecutivenumbering= False, answered= False, spaceflag = True)
|
rawoutput = GenerateStudentBodyString(problems=problems_list,sectiontitles=sections_list,pro_dict=metadict,consecutivenumbering= consecutivenumbering, answered= answered, spaceflag = True)
|
||||||
paragraphs = [p for p in rawoutput.split("\\section") if not p.strip() == ""]
|
paragraphs = [p for p in rawoutput.split("\\section") if not p.strip() == ""]
|
||||||
for item in paragraphs:
|
for item in paragraphs:
|
||||||
sectionkey, content = re.findall(r"\{([\S]*)\}\n([\S\s]*)$",item)[0]
|
sectionkey, content = re.findall(r"\{([\S]*)\}\n([\S\s]*)$",item)[0]
|
||||||
output += "\\section{" + structure[sectionkey]["name"] + "}\n\n"
|
output += "\\section{" + structure[sectionkey]["name"] + "}\n\n"
|
||||||
if not structure[sectionkey]["spaceflag"]:
|
if not structure[sectionkey]["spaceflag"] or answered:
|
||||||
content = re.sub(r"\\vspace[\*]?\{[\S]*\}","\n",content)
|
content = re.sub(r"\\vspace[\*]?\{[\S]*\}","\n",content)
|
||||||
output += content + "\n\n"
|
output += content + "\n\n"
|
||||||
|
|
||||||
|
|
|
||||||
Reference in New Issue