优化讲义生成功能, 目前能够生成跨年级的材料和合集
This commit is contained in:
parent
bf391e2966
commit
cc3550de49
|
|
@ -1416,7 +1416,7 @@ def select_grade_from_pro_dict(prodict,grades):
|
||||||
|
|
||||||
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()]["structure"]
|
||||||
note_contents = notesdict["notes"][id]
|
note_contents = notesdict["notes"][id]
|
||||||
output = ""
|
output = ""
|
||||||
sections_list = []
|
sections_list = []
|
||||||
|
|
|
||||||
30
工具v2/讲义生成.py
30
工具v2/讲义生成.py
|
|
@ -1,12 +1,19 @@
|
||||||
notes_dict_path = "../备课组/26届/校本材料.json" # 讲义(题,基础知识,目标)号码所在json数据库路径
|
lessonpattern = r"[GJE]202[456]0\d0[123]" # 正则表达式, 数据库中讲义的编号([A-Z][0-9]{4}[(01)|(02)][[0-9]{2}), 字母表示类型, 四位数字表示届别, 2位数字表示学期及其他, 2位数字表示序号
|
||||||
lessonpattern = r"G202602((4[0-8])|(53))" # 正则表达式, 数据库中讲义的编号([A-Z][0-9]{4}[(01)|(02)][[0-9]{2}), 字母表示类型, 四位数字表示届别, 2位数字表示学期及其他, 2位数字表示序号
|
|
||||||
outputdir = "d:/temp/26届材料" # 输出文件夹, 不建议修改
|
outputdir = "d:/temp/26届材料" # 输出文件夹, 不建议修改
|
||||||
answered = True # 设置是否编译答案
|
answered = True # 设置是否编译答案
|
||||||
consecutivenumbering = False # 设置是否用连续编号, 试卷请设为True, 普通讲义请设为False
|
consecutivenumbering = False # 设置是否用连续编号, 试卷请设为True, 普通讲义请设为False
|
||||||
|
|
||||||
|
jsonpath = "../备课组" #有json文件的根目录, 文件名需为"校本材料.json"
|
||||||
|
|
||||||
from database_tools import *
|
from database_tools import *
|
||||||
|
|
||||||
notes_dict = load_dict(notes_dict_path)
|
|
||||||
|
jsondicts = []
|
||||||
|
for loc,dirs,files in os.walk(jsonpath):
|
||||||
|
if "校本材料.json" in files:
|
||||||
|
jsondicts.append(load_dict(os.path.join(loc,"校本材料.json")))
|
||||||
|
|
||||||
|
|
||||||
pro_dict = load_dict("../题库0.3/problems.json")
|
pro_dict = load_dict("../题库0.3/problems.json")
|
||||||
obj_dict = load_dict("../题库0.3/LessonObj.json")
|
obj_dict = load_dict("../题库0.3/LessonObj.json")
|
||||||
basicknowledge_dict = load_dict("../题库0.3/BasicKnowledge.json")
|
basicknowledge_dict = load_dict("../题库0.3/BasicKnowledge.json")
|
||||||
|
|
@ -17,12 +24,17 @@ for t in (obj_dict,basicknowledge_dict,pro_dict):
|
||||||
|
|
||||||
papernames = []
|
papernames = []
|
||||||
multitexdata = []
|
multitexdata = []
|
||||||
for lessonid in notes_dict["notes"]:
|
|
||||||
if re.findall(lessonpattern,lessonid) != []:
|
for notes_dict in jsondicts:
|
||||||
filename = notes_dict["notes"][lessonid]["id"]+notes_dict["notes"][lessonid]["filename"]+".tex"
|
for lessonid in notes_dict["notes"]:
|
||||||
texdata = GenerateSingleLessonNote(id = lessonid,notesdict = notes_dict, metadict = dictionaries, templatepath = ".\模板文件\讲义模板.txt", outputfilepath = os.path.join(outputdir,filename),consecutivenumbering=consecutivenumbering,answered=answered)
|
if re.findall(lessonpattern,lessonid) != []:
|
||||||
papernames.append(notes_dict["notes"][lessonid]["id"]+" \\ "+notes_dict["notes"][lessonid]["name"])
|
filename = notes_dict["notes"][lessonid]["id"]+notes_dict["notes"][lessonid]["filename"]+".tex"
|
||||||
multitexdata.append(re.findall(r"\\begin{center}\n{\\bf\\large \\papername}\n\\end{center}([\s\S]*\\end\{enumerate\})",texdata)[0])
|
papertype = lessonid[0]
|
||||||
|
consecutivenumbering = notes_dict["structures"][papertype]["consecutivenumbering"]
|
||||||
|
texdata = GenerateSingleLessonNote(id = lessonid,notesdict = notes_dict, metadict = dictionaries, templatepath = ".\模板文件\讲义模板.txt", outputfilepath = os.path.join(outputdir,filename),consecutivenumbering=consecutivenumbering,answered=answered)
|
||||||
|
papernames.append(notes_dict["notes"][lessonid]["id"]+" \\ "+notes_dict["notes"][lessonid]["name"])
|
||||||
|
multitexdata.append(re.findall(r"\\begin{center}\n{\\bf\\large \\papername}\n\\end{center}([\s\S]*\\end\{enumerate\})",texdata)[0])
|
||||||
|
|
||||||
|
|
||||||
merged = ""
|
merged = ""
|
||||||
for i in range(len(papernames)):
|
for i in range(len(papernames)):
|
||||||
|
|
|
||||||
Reference in New Issue