diff --git a/工具v4/database_tools_2.py b/工具v4/database_tools_2.py index 75c00d32..cf285914 100644 --- a/工具v4/database_tools_2.py +++ b/工具v4/database_tools_2.py @@ -2534,9 +2534,9 @@ def GenerateSingleLessonTeXfromDict(id,structuredict,notesdict,pro_dict,obj_dict return rawoutput def GenerateSingleLessonNotefromMariaDB(cursor,id,structuredict,notesdict,templatepath,outputfilepath,misc,consecutivenumbering = False): #20240415版讲义生成 - notetitle = id + r" \ " + notesdict["notes"][id]["name"] + notetitle = id + r" \ " + notesdict[id]["name"] structure = structuredict[id[0:5].upper()]["structure"] - note_contents = notesdict["notes"][id] + note_contents = notesdict[id] output = "" sections_list = [] problems_list = [] diff --git a/工具v4/系列讲义生成.py b/工具v4/系列讲义生成.py index 9d9ed08f..f10b8009 100644 --- a/工具v4/系列讲义生成.py +++ b/工具v4/系列讲义生成.py @@ -79,12 +79,6 @@ class MyWindow_jysc(QWidget,Ui_Form): def saveandbuild(self): patterns = self.lineEdit_regex.text().strip().split(",") - # jsonpath = "../备课组" #有json文件的根目录, 文件名需为"校本材料.json" - # jsondicts = [] - # for loc,dirs,files in os.walk(jsonpath): - # if "校本材料.json" in files: - # jsondicts.append(load_dict(os.path.join(loc,"校本材料.json"))) - mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name) mycursor = mydb.cursor() notes_dict = load_notes_dict_from_mariadb(mycursor) diff --git a/工具v4/网页获取讲义.py b/工具v4/网页获取讲义.py index 01c1ef66..d73ba719 100644 --- a/工具v4/网页获取讲义.py +++ b/工具v4/网页获取讲义.py @@ -7,7 +7,7 @@ from database_tools_2 import * # raw_pro_dict = load_dict("../题库0.3/Problems.json") # obj_dict = load_dict("../题库0.3/LessonObj.json") # basicknowledge_dict = load_dict("../题库0.3/BasicKnowledge.json") -jsonpath = "../备课组" +# jsonpath = "../备课组" # jsondicts = {} # for loc,dirs,files in os.walk(jsonpath): # if "校本材料.json" in files: @@ -23,14 +23,7 @@ app = Flask(__name__) @app.route('/', methods=['GET', 'POST']) def index(): if request.method == 'POST': - global pid,configjson,uuiddir,outputpath,jsondicts - jsondicts = {} - os.system("git pull origin master --force") - for loc,dirs,files in os.walk(jsonpath): - if "校本材料.json" in files: - currentdict = load_dict(os.path.join(loc,"校本材料.json")) - for key in currentdict["notes"]: - jsondicts[key] = currentdict["notes"][key].copy() + global pid,configjson,uuiddir,outputpath uuiddir = str(uuid.uuid4()) outputpath = os.path.join(os.getcwd(),f"临时文件/{uuiddir}") makedir(outputpath) @@ -41,10 +34,10 @@ def index(): configjson = {"教师版": True, "字段显示设置": { "题后空间": False, - "课时目标": False, - "题目标签": False, + "课时目标": True, + "题目标签": True, "答案": True, - "解答与提示": False, + "解答与提示": True, "使用记录": [-1,-1], "来源": True, "备注": True, @@ -88,18 +81,19 @@ def index(): global filename mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku") mycursor = mydb.cursor() + notes_dict = load_notes_dict_from_mariadb(mycursor) + structure_dict = load_structures_dict_from_mariadb(mycursor) if re.findall(r"[A-Za-z]",pid) != []: - if pid in jsondicts: + if pid in notes_dict: try: - filename = pid+jsondicts[pid]["filename"].replace("(","").replace(")","")+".tex" - papertype = pid[0] - grade = pid[3:5] + filename = pid+notes_dict[pid]["filename"].replace("(","").replace(")","")+".tex" + papertype = pid[0:5] + # grade = pid[3:5] # raw_pro_dict = load_dict("../题库0.3/Problems.json") # obj_dict = load_dict("../题库0.3/LessonObj.json") # basicknowledge_dict = load_dict("../题库0.3/BasicKnowledge.json") - notes_dict = load_dict(f"../备课组/{grade}届/校本材料.json") - consecutivenumbering = notes_dict["structures"][papertype]["consecutivenumbering"] - texdata = GenerateSingleLessonNotefromMariaDB(mycursor,pid,notes_dict,"../工具v3/模板文件/讲义模板.txt",os.path.join(outputpath,filename),configjson,consecutivenumbering) #20240415版讲义生成 + consecutivenumbering = structure_dict[papertype]["consecutivenumbering"] + texdata = GenerateSingleLessonNotefromMariaDB(mycursor,pid,structure_dict,notes_dict,"../工具v4/模板文件/讲义模板.txt",os.path.join(outputpath,filename),configjson,consecutivenumbering) #20240415版讲义生成 mydb.close() return f'''