From adf3c3a78ee496af71c7f870d36fdcfd786dd179 Mon Sep 17 00:00:00 2001 From: wangweiye7840 Date: Mon, 10 Jul 2023 15:55:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E9=AA=8C=E2=80=9D=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A2=98=E7=9B=AE=E9=93=BE=EF=BC=88=E7=BB=84?= =?UTF-8?q?=EF=BC=89=E2=80=9C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/生成关联题目组.py | 35 +++++++++++++++++++++++++++++++++++ 工具v2/生成关联题目链.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 工具v2/生成关联题目组.py create mode 100644 工具v2/生成关联题目链.py diff --git a/工具v2/生成关联题目组.py b/工具v2/生成关联题目组.py new file mode 100644 index 00000000..5adffeb0 --- /dev/null +++ b/工具v2/生成关联题目组.py @@ -0,0 +1,35 @@ +starting_id = "18067:18070" # 初始题号字符串 +threshold = 0.8 # 关联度下限 +maxlength = 50 # 题目链长度 + +outputfilename = "测试题目组" +outputfilepath = "临时文件" + +from database_tools import * + + +if not outputfilename.endswith(".tex"): + outputfilename += ".tex" + + +pro_dict = load_dict("../题库0.3/problems.json") + +id_string = generate_sim_group(starting_id,pro_dict,maxlength,threshold) + +latex_raw = ReadTextFile("模板文件/讲义模板.txt") +latex_raw = latex_raw.replace(r"学号\blank{50} \ 姓名\blank{80}","上海市控江中学") + +if sys.platform != "win32": #非win系统用默认字体 + latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",latex_raw) + latex_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",latex_raw) + + +bodystring = GenerateStudentBodyString([id_string],["关联题目组"],pro_dict,answered = True,spaceflag = False) #生成.tex中的内容主体字符串, 用于替换模板中的相应部分 + +latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,(outputfilename[:-4],bodystring)) #替换标题和bodystring +SaveTextFile(latex_data,os.path.join(outputfilepath,outputfilename)) #保存.tex文件 + +if XeLaTeXCompile(outputfilepath,outputfilename): + print("编译成功") +else: + print("编译失败") \ No newline at end of file diff --git a/工具v2/生成关联题目链.py b/工具v2/生成关联题目链.py new file mode 100644 index 00000000..64d38496 --- /dev/null +++ b/工具v2/生成关联题目链.py @@ -0,0 +1,33 @@ +starting_id = "018067" # 初始题号 +length = 50 # 题目链长度 +outputfilename = "测试题目链" +outputfilepath = "临时文件" + +from database_tools import * + +starting_id = str(starting_id).zfill(6) +if not outputfilename.endswith(".tex"): + outputfilename += ".tex" + + +pro_dict = load_dict("../题库0.3/problems.json") + +id_string = generate_problem_series(starting_id,length,pro_dict) + +latex_raw = ReadTextFile("模板文件/讲义模板.txt") +latex_raw = latex_raw.replace(r"学号\blank{50} \ 姓名\blank{80}","上海市控江中学") + +if sys.platform != "win32": #非win系统用默认字体 + latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",latex_raw) + latex_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",latex_raw) + + +bodystring = GenerateStudentBodyString([id_string],["关联题目链"],pro_dict,answered = True,spaceflag = False) #生成.tex中的内容主体字符串, 用于替换模板中的相应部分 + +latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,(outputfilename[:-4],bodystring)) #替换标题和bodystring +SaveTextFile(latex_data,os.path.join(outputfilepath,outputfilename)) #保存.tex文件 + +if XeLaTeXCompile(outputfilepath,outputfilename): + print("编译成功") +else: + print("编译失败") \ No newline at end of file