From 3a14be5815fdaf1018dee815e8ec9be8fdf1f49c Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Sun, 2 Apr 2023 23:25:05 +0800 Subject: [PATCH] 20230402 night --- 工具/修改题目数据库.py | 2 +- 工具/关键字筛选题号.py | 73 ++++++ 工具/单元标记.ipynb | 6 +- 工具/单元标记转换.py | 20 ++ 工具/单元课时目标题目数据清点.ipynb | 4 +- 工具/单元课时目标题目数据清点.py | 82 +++++++ 工具/在讲义tex文件中提取题号.ipynb | 68 ------ 工具/工具面板.py | 48 +++- 工具/文本文件/metadata.txt | 322 +------------------------- 工具/文本文件/题号筛选.txt | 7 +- 工具/根据范围提取课时目标.ipynb | 6 +- 工具/根据范围提取课时目标.py | 41 ++++ 工具/添加关联题目.py | 4 +- 工具/讲义生成.py | 169 ++++++++++++++ 工具/课时目标划分信息汇总.py | 137 +++++++++++ 工具/课时目标及课时划分信息汇总.ipynb | 6 +- 工具/课时目标寻找题目.py | 40 ++++ 17 files changed, 634 insertions(+), 401 deletions(-) create mode 100644 工具/关键字筛选题号.py create mode 100644 工具/单元标记转换.py create mode 100644 工具/单元课时目标题目数据清点.py delete mode 100644 工具/在讲义tex文件中提取题号.ipynb create mode 100644 工具/根据范围提取课时目标.py create mode 100644 工具/讲义生成.py create mode 100644 工具/课时目标划分信息汇总.py create mode 100644 工具/课时目标寻找题目.py diff --git a/工具/修改题目数据库.py b/工具/修改题目数据库.py index 9e897465..ff99e922 100644 --- a/工具/修改题目数据库.py +++ b/工具/修改题目数据库.py @@ -1,6 +1,6 @@ import os,re,json """这里编辑题号(列表)后将在vscode中打开窗口, 编辑后保存关闭, 随后运行第二个代码块""" -problems = "14092,13218,13237,14085" +problems = "1" def generate_number_set(string,dict): string = re.sub(r"[\n\s]","",string) diff --git a/工具/关键字筛选题号.py b/工具/关键字筛选题号.py new file mode 100644 index 00000000..c0fe31ea --- /dev/null +++ b/工具/关键字筛选题号.py @@ -0,0 +1,73 @@ +import os,re,json + +"""---设置关键字, 同一field下不同选项为or关系, 同一字典中不同字段间为and关系, 不同字典间为or关系, _not表示列表中的关键字都不含, 同一字典中的数字用来供应同一字段不同的条件之间的and---""" +keywords_dict_table = [ + {"origin":["一模"]} +] +"""---关键字设置完毕---""" +# 示例: keywords_dict_table = [ +# {"tags": ["第三单元"], "content1": [r"[\d]\alpha","2x"], "content2": ["sin"], "content3": ["cos"],"content4": ["cot"], "content5": ["tan"]}, +# ] +# 实例2: keywords_dict_table = [ +# {"tags":["第三单元"],"content":["f\(","y=","函数"],"usages":[r"0\.9",r"0\.8[3-9]"],"usages_not":[r"0\.[0-7]",r"0\.8[0-2]"],"usages1":["2023届"]}, +# {"tags":["第五单元"],"usages":[r"0\.9"],"usages_not":[r"0\.[0-7]",r"0\.8[0-2]"],"usages1":["2023届"]} +# ] +# 实例3: +# keywords_dict_table = [ +# {"usages":[r"2023届高三02班"],"usages2":[r"202209",r"20221[012]"],"usages3":[r"0\.[678][\d]{2}"],"usages_not":[r"2023届高三02班[^\n]*0\.[0-59][\d]{2}"]} + +# ] + + +"""---设置输出文件名---""" +filename = "文本文件/题号筛选.txt" +"""---文件名设置完毕---""" + + +def match_condition(problem,condition_dict): + match = True + for field1 in [c for c in condition_dict if not "_not" in c]: + cond_list = condition_dict[field1] + field = re.sub("\d","",field1) + if type(problem[field]) == list: + string = "\n".join((problem[field])) + else: + string = str(problem[field]) + current_match = False + for cond in cond_list: + if len(re.findall(cond,string)) > 0: + current_match = True + if current_match == False: + match = False + for field1 in [c for c in condition_dict if "_not" in c]: + cond_list = condition_dict[field1] + field1 = field1.replace("_not","") + field = re.sub("\d","",field1) + if type(problem[field]) == list: + string = "\n".join((problem[field])) + else: + string = str(problem[field]) + current_match = True + for cond in cond_list: + if len(re.findall(cond,string)) > 0: + current_match = False + if current_match == False: + match = False + + return match + +#读取题库json文件并转化为字典 +with open(r"../题库0.3/Problems.json","r",encoding = "utf8") as f: + database = f.read() +pro_dict = json.loads(database) + +match_list = [] +for condition in keywords_dict_table: + for id in pro_dict: + if match_condition(pro_dict[id],condition) and not id in match_list: + match_list.append(id) + +with open(filename,"w",encoding="utf8") as f: + f.write(",".join(match_list)) + +os.system("code "+filename) \ No newline at end of file diff --git a/工具/单元标记.ipynb b/工具/单元标记.ipynb index 3ee76940..eace414b 100644 --- a/工具/单元标记.ipynb +++ b/工具/单元标记.ipynb @@ -6,8 +6,12 @@ "metadata": {}, "outputs": [], "source": [ + "filename = r\"D:\\temp\\tag.txt\"\n", + "# 设置一个从excel文件复制出来的txt\n", + "# 每一行的格式如下: <题号>\\t<对应单元(若干位0-9的数字)>\n", + "\n", "taglist = [\"暂无对应\",\"第一单元\",\"第二单元\",\"第三单元\",\"第四单元\",\"第五单元\",\"第六单元\",\"第七单元\",\"第八单元\",\"第九单元\"]\n", - "with open(r\"D:\\temp\\tag.txt\",\"r\",encoding = \"u8\") as f:\n", + "with open(filename,\"r\",encoding = \"u8\") as f:\n", " data = f.read()\n", "pros = data.strip().split(\"\\n\")\n", "dic= {}\n", diff --git a/工具/单元标记转换.py b/工具/单元标记转换.py new file mode 100644 index 00000000..cd0f4249 --- /dev/null +++ b/工具/单元标记转换.py @@ -0,0 +1,20 @@ +filename = r"D:\temp\tag.txt" +# 设置一个从excel文件复制出来的txt +# 每一行的格式如下: <题号>\t<对应单元(若干位0-9的数字)> + +taglist = ["暂无对应","第一单元","第二单元","第三单元","第四单元","第五单元","第六单元","第七单元","第八单元","第九单元"] +with open(filename,"r",encoding = "u8") as f: + data = f.read() +pros = data.strip().split("\n") +dic= {} +for p in pros: + a,b=p.split("\t") + dic[a] = "" + for t in b: + dic[a] += taglist[int(t)]+"\n" +output = "tags\n\n" +for d in dic: + output += d + "\n" + output += dic[d] + "\n\n" +with open(r"文本文件\metadata.txt","w",encoding = "u8") as f: + f.write(output) \ No newline at end of file diff --git a/工具/单元课时目标题目数据清点.ipynb b/工具/单元课时目标题目数据清点.ipynb index 214be97a..f77f8048 100644 --- a/工具/单元课时目标题目数据清点.ipynb +++ b/工具/单元课时目标题目数据清点.ipynb @@ -85,7 +85,9 @@ " f.write(\"\\n\"*5+\"---课时详细清点结果数据库---\\n\")\n", " f.write(json.dumps(lessons_dict,indent = 4,ensure_ascii = False))\n", " f.write(\"\\n\"*5+\"---目标详细清点结果数据库---\\n\")\n", - " f.write(json.dumps(objs_dict,indent = 4,ensure_ascii = False))\n" + " f.write(json.dumps(objs_dict,indent = 4,ensure_ascii = False))\n", + "\n", + "print(\"已输出至文件\",r\"临时文件\\单元课时目标题目数据清点结果.txt\")" ] }, { diff --git a/工具/单元课时目标题目数据清点.py b/工具/单元课时目标题目数据清点.py new file mode 100644 index 00000000..f2e49e2a --- /dev/null +++ b/工具/单元课时目标题目数据清点.py @@ -0,0 +1,82 @@ +import os,re,json + +#读取题库json文件并转化为字典 +with open(r"../题库0.3/Problems.json","r",encoding = "utf8") as f: + database = f.read() +pro_dict = json.loads(database) + +#读取目标数据库json并转化为字典 +with open(r"../题库0.3/LessonObj.json","r",encoding = "utf8") as f: + database = f.read() +obj_dict = json.loads(database) + +#以下是单元题目统计 +tags_descr = ["第一单元","第二单元","第三单元","第四单元","第五单元","第六单元","第七单元","第八单元","第九单元","暂无对应"] +tags_dict = {} +units_string = "" +for t in tags_descr: + tags_dict[t] = [0,""] +for p in pro_dict: + for t in tags_descr: + if t in pro_dict[p]["tags"]: + tags_dict[t][0] += 1 + tags_dict[t][1] += p + "," +#units_string是简要列表, tags_dict是详细清单 +for t in tags_descr: + units_string += t + ": " + str(tags_dict[t][0]) + "\n" +#单元统计完成 + +#以下是课时题目统计 +#生成单元课时列表(Kddll) +lessons_descr = [] +for o in obj_dict: + if not o[:5] in lessons_descr: + lessons_descr.append(o[:5]) +lessons_dict = {} +lessons_string = "" +for l in lessons_descr: + lessons_dict[l] = [0,""] +for p in pro_dict: + for l in lessons_descr: + for o in pro_dict[p]["objs"]: + if l in o: + lessons_dict[l][0] += 1 + lessons_dict[l][1] += p + "," + break +#lessons_string是简要列表, lessons_dict是详细清单 +for l in lessons_descr: + lessons_string += l + ": " + str(lessons_dict[l][0]) + "\n" +#课时统计完成 + +#以下是目标题目统计 +objs_dict = {} +objs_string = "" +for o in obj_dict: + objs_dict[o] = [0,""] +for p in pro_dict: + for o in obj_dict: + if o in pro_dict[p]["objs"]: + objs_dict[o][0] += 1 + objs_dict[o][1] += p + "," +# objs_string是简要列表, objs_dict是详细清单 +for o in obj_dict: + objs_string += o + ": " + str(objs_dict[o][0]) + "\n" +#课时统计完成 + +#以下为清点结果输出 +with open(r"临时文件\单元课时目标题目数据清点结果.txt","w",encoding = "utf8") as f: + f.write("---单元清点结果---\n") + f.write(units_string) + f.write("\n---课时清点结果---\n") + f.write(lessons_string) + f.write("\n---目标清点结果---\n") + f.write(objs_string) + f.write("\n"*10) + f.write("---单元详细清点结果数据库---\n") + f.write(json.dumps(tags_dict,indent = 4,ensure_ascii = False)) + f.write("\n"*5+"---课时详细清点结果数据库---\n") + f.write(json.dumps(lessons_dict,indent = 4,ensure_ascii = False)) + f.write("\n"*5+"---目标详细清点结果数据库---\n") + f.write(json.dumps(objs_dict,indent = 4,ensure_ascii = False)) + +print("已输出至文件",r"临时文件\单元课时目标题目数据清点结果.txt") \ No newline at end of file diff --git a/工具/在讲义tex文件中提取题号.ipynb b/工具/在讲义tex文件中提取题号.ipynb deleted file mode 100644 index 52214c45..00000000 --- a/工具/在讲义tex文件中提取题号.ipynb +++ /dev/null @@ -1,68 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "ename": "FileNotFoundError", - "evalue": "[Errno 2] No such file or directory: 'C:\\\\Users\\\\weiye\\\\Documents\\\\wwy sync\\\\23届\\\\上学期测验卷\\\\月考01.tex'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_18232\\1245693629.py\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mtex_file\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34mr\"C:\\Users\\weiye\\Documents\\wwy sync\\23届\\上学期测验卷\\月考01.tex\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m \u001b[1;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtex_file\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"r\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mencoding\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"utf8\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 7\u001b[0m \u001b[0mtex_data\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 8\u001b[0m \u001b[0mproblems_list\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mre\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfindall\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mr\"\\(([\\d]{6})\\)\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mtex_data\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'C:\\\\Users\\\\weiye\\\\Documents\\\\wwy sync\\\\23届\\\\上学期测验卷\\\\月考01.tex'" - ] - } - ], - "source": [ - "import re\n", - "\n", - "#输入文件名\n", - "tex_file = r\"C:\\Users\\weiye\\Documents\\wwy sync\\23届\\上学期测验卷\\月考01.tex\"\n", - "\n", - "with open(tex_file,\"r\",encoding = \"utf8\") as f:\n", - " tex_data = f.read()\n", - "problems_list = re.findall(r\"\\(([\\d]{6})\\)\",tex_data)\n", - "\n", - "print(\",\".join(problems_list))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.9.13 ('base')", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.13" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "ad2bdc8ecc057115af97d19610ffacc2b4e99fae6737bb82f5d7fb13d2f2c186" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/工具/工具面板.py b/工具/工具面板.py index c948ae24..4e9ad10d 100644 --- a/工具/工具面板.py +++ b/工具/工具面板.py @@ -4,7 +4,7 @@ import os root = Tk() -root.geometry('800x600') +root.geometry('400x600') root.title('题库v2.0工具面板') @@ -14,15 +14,17 @@ def temp(): def SetButton(str,numbuttons,openfilelist): commandname.set(str) LabelTool.config(text = str) - button1.place(x = 600, y = 550) + button1.place(x = 10, y = 10) + button1.configure(bg = "green") if numbuttons == 1: button2.place_forget() else: - button2.place(x=700, y=550) + button2.place(x=10, y=50) + button2.configure(bg = "red") for f in openfilelist: os.system("code "+f) - +# 按钮STEP1执行的命令 def run_command1(): selectedtool = commandname.get() if selectedtool == "题号选题pdf生成": @@ -33,15 +35,34 @@ def run_command1(): call(["python","批量收录题目.py"]) elif selectedtool == "添加关联题目": call(["python","添加关联题目.py"]) + button2.configure(bg = "green") elif selectedtool == "修改题目数据库": call(["python","修改题目数据库.py"]) + button2.configure(bg = "green") elif selectedtool == "mathpix预处理": call(["python","../文本处理工具/剪贴板文本整理_mathpix.py"]) elif selectedtool == "带圈数字处理": call(["python","../文本处理工具/带圈数字处理.py"]) elif selectedtool == "试卷答案生成": call(["python","试卷答案生成.py"]) - LabelTool.config(text = selectedtool+" STEP1命令执行完毕") + elif selectedtool == "单元标记转换": + call(["python","单元标记转换.py"]) + elif selectedtool == "目标清点": + call(["python","单元课时目标题目数据清点.py"]) + elif selectedtool == "目标表体生成": + call(["python","根据范围提取课时目标.py"]) + elif selectedtool == "课时目标寻找题目": + call(["python","课时目标寻找题目.py"]) + elif selectedtool == "关键字筛选题号": + call(["python","关键字筛选题号.py"]) + elif selectedtool == "讲义生成": + call(["python","讲义生成.py"]) + elif selectedtool == "课时目标划分信息汇总": + call(["python","课时目标划分信息汇总.py"]) + LabelTool.config(text = selectedtool+"STEP1命令执行完毕") + button1.place_forget() + +# 按钮STEP2执行的命令 def run_command2(): selectedtool = commandname.get() @@ -50,11 +71,12 @@ def run_command2(): elif selectedtool == "修改题目数据库": call(["python","修改结果汇入.py"]) LabelTool.config(text = selectedtool+ "STEP2命令执行完毕") + button2.place_forget() commandname = StringVar() commandname.set("none") -LabelTool = Label(root, text = "工具选择待定", height = 1, width = 40, anchor=W) -LabelTool.place(x=420,y=50) +LabelTool = Label(root, text = "请在菜单栏选择工具", height = 1, width = 40, anchor=W) +LabelTool.place(x=10,y=100) button1 = Button(root, text = "运行STEP1", command = run_command1) button2 = Button(root, text = "运行STEP2", command = run_command2) @@ -78,9 +100,21 @@ MaintainenceMenu.add_command(label = "修改题目", command = lambda: SetButton # 设置 使用 菜单项 UseMenu = Menu(menubar, tearoff = False) menubar.add_cascade(label = "使用", menu = UseMenu) +UseMenu.add_command(label = "关键字筛选题号", command = lambda: SetButton("关键字筛选题号",1,["关键字筛选题号.py"])) +UseMenu.add_separator() +UseMenu.add_command(label = "讲义试卷生成", command = lambda: SetButton("讲义生成",1,["讲义生成.py"])) UseMenu.add_command(label = "题号选题pdf生成", command = lambda: SetButton("题号选题pdf生成",1,["题号选题pdf生成.py"])) UseMenu.add_command(label = "试卷答案生成", command = lambda: SetButton("试卷答案生成",1,["试卷答案生成.py"])) +# 设置 目标及标签 菜单项 +ObjTagMenu = Menu(menubar, tearoff = False) +menubar.add_cascade(label = "目标及标签", menu = ObjTagMenu) +ObjTagMenu.add_command(label = "单元标记转换", command = lambda: SetButton("单元标记转换",1,["单元标记转换.py"])) +ObjTagMenu.add_separator() +ObjTagMenu.add_command(label = "目标清点", command = lambda: SetButton("目标清点",1,[])) +ObjTagMenu.add_command(label = "目标表体生成", command = lambda: SetButton("目标表体生成",1,["根据范围提取课时目标.py"])) +ObjTagMenu.add_command(label = "课时目标寻找题目", command = lambda: SetButton("课时目标寻找题目",1,["课时目标寻找题目.py"])) +ObjTagMenu.add_command(label = "课时目标划分信息汇总", command = lambda: SetButton("课时目标划分信息汇总",1,[])) # 设置 其他 菜单项 OtherMenu = Menu(menubar, tearoff = False) diff --git a/工具/文本文件/metadata.txt b/工具/文本文件/metadata.txt index d8d7ca79..d669feef 100644 --- a/工具/文本文件/metadata.txt +++ b/工具/文本文件/metadata.txt @@ -1,318 +1,18 @@ -ans +tags +1 +第一单元 +第二单元 +第三单元 -040422 -$(-1,3)$ -040423 -$(-\infty,-1)$ +2 +第三单元 -040424 -$\sqrt{5}$ -040425 -$5$ +4 +第三单元 +第五单元 +第六单元 -040426 -$\dfrac{24}{7}$ -040427 -$0.12$ - -040428 -$52$ - -040429 -$2$ - -040430 -$60^{\circ}$ - -040431 -$\dfrac{4}{5}$ - -040432 -$\dfrac{\sqrt{10}}{10}$ - -040433 -$(-\infty,-\frac{2}{\mathrm{e}}) \cup(\frac{2}{\mathrm{e}},+\infty)$ - -040434 -D - -040435 -C - -040436 -B - -040437 -D - -040438 -(1) 略; (2) $\dfrac{\sqrt{15}}{15}$ - -040439 -(1) $a_1+a_2=6$, 公差为$4$; (2) $S_n=\begin{cases}n^2+n, & n=2 k, \\ n^2+n+2, & n=2 k-1\end{cases}$, $k$为正整数 - -040440 -(1) $y=0.1 x-0.2$; (2) (i) $5900$万元; (ii) $[\dfrac{1}{3}, \dfrac{5}{8}]$ - -040441 -(1) $\dfrac{x^2}{8}+\dfrac{y^2}{4}=1$; (2) $y= \pm \dfrac{\sqrt{30}}{10} x+1$; (3) $-\dfrac{1}{2}$ - -040442 -(1) $y=(1+a) x$; (2) $-1$; (3) $(-\infty,-1)$ - -040443 -$\{1,2,3\}$ - -040444 -$\sqrt{10}$ - -040445 -$2 \pi$ - -040446 -$-\dfrac{1}{3}$ - -040447 -$24$ - -040448 -$-5$ - -040449 -$(\dfrac{7}{2}, 0, \dfrac{7}{2})$ - -040450 -$(-\dfrac{1}{3}, 1)$ - -040451 -$17$或$18$ - -040452 -支持 - -040453 -$\sqrt{6}-\sqrt{3}$ - -040454 -$\{(4,-4),(4,1)\}$ - -040455 -C - -040456 -A - -040457 -B - -040458 -B - -040459 -(1) $[-\dfrac{\pi}{2}+k \pi, k \pi]$, $k \in \mathbf{Z}$; (2) $\dfrac{15 \sqrt{3}}{4}$ - -040460 -(1) 略; (2) $\dfrac{1}{2}$ - -040461 -(1) $\dfrac{3}{256}$; (2) 选择A同学 - -040462 -(1) $\sqrt{3}$; (2) 略; (3) 存在, $k=\dfrac{\sqrt{3}}{2}$, $P(-3 \sqrt{3}, 0)$ - -040463 -(1) $y=2 x$; (2) $(-\infty, 0] \cup[1,+\infty)$; (3) $(-\infty,\dfrac{2}{\mathrm{e}})$ - -040464 -$(-2,1]$ - -040465 -$1$ - -040466 -$\dfrac{2 \pi}{3}$ - -040467 -$\sqrt{3}$ - -040468 -$(-\infty,-2] \cup[0,2]$ - -040469 -$y^2=4 x$ - -040470 -$\dfrac{14}{15}$ - -040471 -$5$ - -040472 -$\dfrac{6+2 \sqrt{3}}{5}$ - -040473 -$1-2^{2023}$ - -040474 -$\dfrac{2 \sqrt{3}}{3}$ - -040475 -$6+4 \sqrt{2}$ - -040476 -B - -040477 -D - -040478 -C - -040479 -B - -040480 -(1) 略; (2) $\arccos \dfrac{2}{3}$ - -040481 -(1) $[k \pi-\dfrac{3 \pi}{8}, k \pi+\dfrac{\pi}{8}]$, $k \in \mathbf{Z}$; (2) $\{x | x=\dfrac{k \pi}{2}+\dfrac{\pi}{8},\ k \in \mathbf{Z}\}$ - -040482 -(1) $1.4$米; (2) $\arcsin \dfrac{5 \sqrt{3}}{14}$ - -040483 -(1) $\dfrac{6 \sqrt{5}}{5}$; (2) 略; (3) $\dfrac{3 \sqrt{3}}{4}$ - - -040484 -(1) 略; (2) $a_n=\dfrac{(n+3)(n+4)}{2}$, $b_n=\dfrac{(n+4)^2}{2}$; (3) $(-\infty,1]$ - -040485 -$4$ - -040486 -四 - -040487 -$2$ - -040488 -$\dfrac 23$ - -040489 -$12$ - -040490 -$40$ - -040491 -$2$ - -040492 -$72$ - -040493 -$3$ - -040494 -$\dfrac{4\pi}3$ - -040495 -$\sqrt{3}$ - -040496 -$-2+\sqrt{7}$ - -040497 -B - -040498 -C - -040499 -D - -040500 -D - -040501 -(1) 证明略; (2) $\dfrac{\sqrt{14}}7$ - -040502 -(1) $y=0.072x-0.046$; (2) (i) $1060$万; (ii) $(\dfrac 13,\dfrac 58]$ - -040503 -(1) $[k\pi,\dfrac\pi 4+k\pi]$, $k\in \mathbf{Z}$; (2) $\dfrac\pi 4$ - -040504 -(1) $\dfrac{x^2}{4}-y^2=1$; (2) 存在, $t=\pm \sqrt{3}$或$t=\pm \sqrt{\dfrac{76}{15}}$; (3) $(-8-5\sqrt{3},-\dfrac 12)\cup (\dfrac 12,-8+5\sqrt{3})$ - -040505 -(1) $f(g(x))$的导函数为$y=-a\sin x$, $g(f(x))$的导函数为$y=-a\sin (ax)$; (2) $(-\infty,-1]$; (3) $[\dfrac 32,3)$ - -040506 -$4$ - -040507 -$1$ - -040508 -$24$ - -040509 -$x^2+(y-1)^2=4$ - -040510 -$(-1,1]$ - -040511 -$300(4+\sqrt{3})$ - -040512 -$\dfrac{1}{2}$ - -040513 -$92$ - -040514 -$\dfrac{1}{2}$ - -040515 -$\dfrac{\sqrt{21}}{6}$ - -040516 -$2 \sqrt{2}$ - -040517 -$2$ - -040518 -C - -040519 -A - -040520 -A - -040521 -C - -040522 -(1) $2n$; (2) $n^2+n+\dfrac{4^{n+1}}{3}-\dfrac{4}{3}$ - -040523 -(1) $\begin{pmatrix}0 & 1 & 2 \\ \dfrac{7}{15} & \dfrac{7}{15} & \dfrac{1}{15}\end{pmatrix}$, 期望为$\dfrac{3}{5}$; (2) $\chi^2 \approx 0.794<3.841$, 不能认为有关 - -040524 -(1) 略; (2) $\dfrac{\sqrt{10}}{5}$ - -040525 -(1) $\dfrac{x^2}{4}+y^2=1$; (2) 最大值为$3$; 最小值为$\dfrac{\sqrt{6}}{3}$; (3) $(0,3)$ - -040526 -(1) $y=x+1$; (2) 略; (3) $2$ diff --git a/工具/文本文件/题号筛选.txt b/工具/文本文件/题号筛选.txt index 12c46789..d94772b2 100644 --- a/工具/文本文件/题号筛选.txt +++ b/工具/文本文件/题号筛选.txt @@ -1,6 +1 @@ -031332,031333,031334,031335,031336,031337,031338,031339,031340,031341,031342,031343,031344,031345,031346,031347,031348,031349,031350,031351,031352 - -未使用题号: -031332,031333,031334,031335,031336,031337,031338,031339,031340,031341,031342,031343,031344,031345,031346,031347,031348,031349,031350,031351,031352 - -已使用题号: +004682,004683,004684,004685,004686,004687,004688,004689,004690,004691,004692,004693,004694,004695,004696,004697,004698,004699,004700,004701,004702,012117,012118,012119,012120,012121,012122,012123,012124,012125,012126,012127,012128,012129,012130,012131,012132,012133,012134,012135,012136,012137,012287,012288,012289,012290,012291,012292,012293,012294,012295,012296,012297,012298,012299,012300,012301,012302,012303,012304,012305,012306,012307,012308,012309,012310,012311,012312,012313,012314,012315,012316,012317,012318,012319,012320,012321,012322,012323,012324,012325,012326,012327,012328,012487,012488,012489,012490,012491,012492,012493,012494,012495,012496,012497,012498,012499,012500,012501,012502,012503,012504,012505,012506,012507,012508,012509,012510,012511,012512,012513,012514,012515,012516,012517,012518,012519,012520,012521,012522,012523,012524,012525,012526,012527,012528,012529,012530,012531,012532,012533,012534,012535,012536,012537,012538,012539,012540,012541,012542,012543,012544,012545,012546,012547,012548,012549,012550,012551,012552,012553,012554,012555,012556,012557,012558,012559,012560,012561,012562,012563,012564,012565,012566,012567,012568,012569,012570,012571,012572,012573,012574,012575,012576,012577,012578,012579,012580,012581,012582,012583,012584,012585,012586,012587,012588,012589,012590,012591,012592,012593,012594,012595,012596,012597,012598,012599,012600,012601,012602,012603,012604,012605,012606,012607,012608,012609,012610,012611,012612,012613,012614,012615,012616,012617,012618,012619,012620,012621,012622,012623,012624,012625,012626,012627,012628,012629,012630,012631,012632,012633,012634,012635,012636,012637,012638,012639,012640,012641,012642,012643,012644,012645,012646,012647,012648,012649,012650,012651,012652,012653,012654,012655,012656,012657,012658,012659,012660,012661,012662,012663,012664,012665,012666,012667,012668,012669,012670,012671,012672,012673,012674,012675,012676,012677,012678,012679,012680,012681,012682,012683,012684,012685,012686,012687,012688,012689,012690,012691,012692,012693,012694,012695,012696,012697,012698,012699,012700,012701,012702,012703,012704,012705,012706,012707,012708,012709,012710,012711,012712,012713,012714,012715,012716,012717,012718,012719,012720,012721,012722,012723,012724,012725,012726,012727,012728,012729,012730,012731,012732,012733,012734,012735,012736,012737,012738,012760,012761,012762,012763,012764,012765,012766,012767,012768,012769,012770,012771,012772,012773,012774,012775,012776,012777,012778,012779,012780,014511,014512,014513,014514,014515,014516,014517,014518,014519,014520,014521,014522,014523,014524,014525,014526,014527,014528,014529,014530,014531,030008,030009,030010,030011,030601,030602,030603,030604,030606,030607,030609,030610,030611,030612,030613,030614,030617,030622,030623,030625,030626,030627,030629,030630,030631,030634,030638,030639,030640,030642,030646,030647,030649,030650,030653,030654,030655,030656,030657,030658,030660,030661,030663,030664,030667,030670,030671,030672,030673,030675,030676,030677,030678,030680,030682,030683,030684,030685,030690,030691,030693,030697,030699,030700,030701,030703,030704,030705,030706,030707,030708,030709,030710,030717,030718,030719,030720,030722,030723,030727,030730,030731,030732,030733,030734,030741,030742,030744,030745,030748,030750,030755,030759,030761,030763,030764,030768,030769,030770,030772,030773,030776,030777,030780,030781,030783,030784,030786,030789,030790,030791,030793,030794,030795,030796,030797,030799,030800,030801,030802,030803,030807,030808,030809,030819,030820,030823,030824,030825,030826,030827,030828,030829,030830,030831,030837,030841,030842,030844,030845,030846,030847,030848,030851,030861,030865,030866,030867,030869,030871,030873,030874,030875,030879,030882,030883,030886,030889,030890,030891,030894,030897,030898,030900,030901,030902,030903,030904,030905,030908,030910,030911,030912,030913,030914,030915,030916,030917,030918,030919,030931,030932,030934,030935,030936,030938,030939,030942,030943,030948,030950,030954,030956,030958,030959,030960,030961,030962,030963,030968,030975,030976,030980,030981,030982,030984,030986,030988,030992,030994,030995,030996,030998,031001,031004,031005,031007,031008,031009,031012,031013,031014,031015,031016,031017,031018,031019,031025,031028,031029,031030,031031,031032,031033,031034,031035,031036,031037,031042,031043,031044,031051,031052,031053,031057,031059,031060,031061,031062,031064,031066,031067,031070,031071,031075,031076,031077,031078,031079,031080,031081,031082,031083,031089,031090,031096,031097,031098,031099,031100,031101,031102,031108,031109,031110,031111,031116,031118,031120,031122,031124,031126,031127,031128,031129,031130,031132,031134,031135,031141,031142,031143,031145,031150 \ No newline at end of file diff --git a/工具/根据范围提取课时目标.ipynb b/工具/根据范围提取课时目标.ipynb index e6b5a985..e60bef53 100644 --- a/工具/根据范围提取课时目标.ipynb +++ b/工具/根据范围提取课时目标.ipynb @@ -43,8 +43,10 @@ " output_string += obj_id + \" & \" + obj_dict[obj_id][\"content\"] + \" & \" + r\"\\\\ \\hline\" + \"\\n\"\n", "\n", "#输出到临时文件夹\n", - "with open(r\"临时文件/课时目标提取结果.tex\",\"w\",encoding = \"utf8\") as f:\n", - " f.write(output_string)" + "with open(r\"临时文件/课时目标提取结果.txt\",\"w\",encoding = \"utf8\") as f:\n", + " f.write(output_string)\n", + "\n", + "print(\"已输出至文件\",r\"临时文件/课时目标提取结果.txt\")" ] }, { diff --git a/工具/根据范围提取课时目标.py b/工具/根据范围提取课时目标.py new file mode 100644 index 00000000..d061aa6a --- /dev/null +++ b/工具/根据范围提取课时目标.py @@ -0,0 +1,41 @@ +import os,re,json + +#范围定义在使用前需要替换 +"""使用前替换范围定义""" +obj_range = "K0227001X:K0240999X" +"""范围定义到此结束""" + + +# 检查某一字符串是否在由,:的表达式给出的范围内 +def within_range(string,list): + flag = False + for item in list: + if string == item.strip(): + flag = True + break + elif ":" in item: + start, end = item.split(":") + if start <= string <= end: + flag = True + break + return flag + +# 读取课时目标数据库 +with open(r"../题库0.3/LessonObj.json","r",encoding = "utf8") as f: + database = f.read() +obj_dict = json.loads(database) + +# 根据范围生成若干用于检查的闭区间范围 +obj_range_list = obj_range.split(",") +output_string = "" + +# 逐一选择目标, 并整合成表格的内容部分 +for obj_id in obj_dict: + if within_range(obj_id,obj_range_list): + output_string += obj_id + " & " + obj_dict[obj_id]["content"] + " & " + r"\\ \hline" + "\n" + +#输出到临时文件夹 +with open(r"临时文件/课时目标提取结果.txt","w",encoding = "utf8") as f: + f.write(output_string) + +print("已输出至文件",r"临时文件/课时目标提取结果.txt") \ No newline at end of file diff --git a/工具/添加关联题目.py b/工具/添加关联题目.py index 3d0f4f10..24c3bcba 100644 --- a/工具/添加关联题目.py +++ b/工具/添加关联题目.py @@ -1,8 +1,8 @@ import os,re,json,time """---设置原题目id与新题目id列表, 新id的数目不能小于旧id的数目---""" -old_ids = "603,604" -new_ids = "50000:60000" +old_ids = "601" +new_ids = "50000" """---设置完毕---""" """---完成编辑后记得运行第二个单元格---""" diff --git a/工具/讲义生成.py b/工具/讲义生成.py new file mode 100644 index 00000000..92ef8109 --- /dev/null +++ b/工具/讲义生成.py @@ -0,0 +1,169 @@ +import os,re,json,time,sys + +"""---设置讲义种类 papertype---""" +"""1: 高三复习讲义(课前, 课后)""" +"""2: 测验卷与周末卷(填空题, 选择题, 解答题)""" +"""3: 日常选题讲义(一个section)""" + +paper_type = 2 # 随后设置一下后续的讲义标题 + +"""---设置题块编号---""" + +problems = [ +"031332,031333,031334,031335,031336,031337,031338,031339,031340,031341,031342,031343","031344,031345,031346,031347","031348,031349,031350,031351,031352" +] + +"""---设置结束---""" + + +if paper_type == 1: + enumi_mode = 0 #设置模式(1为整卷统一编号, 0为每一部分从1开始编号) + template_file = "模板文件/复习讲义模板.txt" #设置模板文件名 + exec_list = [("标题数字待处理","05"),("标题文字待处理","概率与统计")] #设置讲义标题 + destination_file = "临时文件/"+exec_list[0][1]+"_"+exec_list[1][1] # 设置输出文件名 +elif paper_type == 2: + enumi_mode = 1 #设置模式(1为整卷统一编号, 0为每一部分从1开始编号) + template_file = "模板文件/测验周末卷模板.txt" #设置模板文件名 + exec_list = [("标题替换","高三下学期测验05")] #设置讲义标题 + destination_file = "临时文件/"+exec_list[0][1] # 设置输出文件名 +elif paper_type == 3: + enumi_mode = 0 #设置模式(1为整卷统一编号, 0为每一部分从1开始编号) + template_file = "模板文件/日常选题讲义模板.txt" #设置模板文件名 + exec_list = [("标题文字待处理","第四讲")] #设置讲义标题 + destination_file = "临时文件/"+exec_list[0][1] # 设置输出文件名 + + + + + +#生成数码列表, 逗号分隔每个区块, 区块内部用:表示整数闭区间 +def generate_number_set(string): + string = re.sub(r"[\n\s]","",string) + string_list = string.split(",") + numbers_list = [] + for s in string_list: + if not ":" in s: + numbers_list.append(s.zfill(6)) + else: + start,end = s.split(":") + for ind in range(int(start),int(end)+1): + numbers_list.append(str(ind).zfill(6)) + return numbers_list + +#将正确率转化为含颜色代码的字符串 +def get_color(value): + value = float(value) + if value>=0.5: + (r,g,b)=(1,2-2*value,0) + else: + (r,g,b)=(2*value,1,0) + return "{" + "%.3f" %(r) + "," + "%.3f" %(g) + ",0}" + + +def color_value(matchobj): + value = matchobj.group(1) + return "\t"+"\\fcolorbox[rgb]{0,0,0}"+ get_color(value) +"{" + value +"}" + + +#读取题库json文件并转化为字典 +with open(r"../题库0.3/Problems.json","r",encoding = "utf8") as f: + database = f.read() +pro_dict = json.loads(database) + +#读取目标数据库json并转化为字典 +with open(r"../题库0.3/LessonObj.json","r",encoding = "utf8") as f: + database = f.read() +obj_dict = json.loads(database) + +#读取系统日期 +current_time = time.localtime() +time_string = "_"+str(current_time.tm_year).zfill(4)+str(current_time.tm_mon).zfill(2)+str(current_time.tm_mday).zfill(2) + +#生成目标文件名和目标文件目录 +teachers_latex_file = destination_file + "_教师" + time_string + ".tex" +students_latex_file = destination_file + "_学生" + time_string + ".tex" +d = re.search("/[^/]*$",destination_file).span()[0] +destination_dir = destination_file[:d] + +#读取模板 +with open(template_file,"r",encoding="utf8") as f: + latex_raw = f.read() + +#识别操作系统 +if sys.platform != "win32": + latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",latex_raw) + latex_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",latex_raw) + +#预处理 +for command in exec_list: + latex_raw = re.sub(command[0],command[1],latex_raw) + +data_teachers = latex_raw +data_students = latex_raw + +#计数待替换部分 +blocks_count = len(re.findall("待替换[\d]",latex_raw)) + +if not len(problems) == blocks_count: + print("题号块数与模板待替换块数不符, 请检查") +else: + problems_count = 0 + for blockid in range(1,blocks_count+1): + print("正在处理题块",blockid,".") + string_to_replace = "待替换" + str(blockid) + teachers_string = "" + students_string = "" + problem_list = [id for id in generate_number_set(problems[blockid-1].strip()) if id in pro_dict] + #生成教师题目字符串与学生题目字符串, 准备替换至latex文件 + for id in problem_list: + problemset = pro_dict[id] + problem = problemset["content"] + solution = (problemset["solution"] if problemset["solution"] != "" else "暂无解答与提示") + answer = "\\textcolor{red}{" + (problemset["ans"] if problemset["ans"] != "" else "暂无答案") + "}" + remarks = (problemset["remark"] if problemset["remark"] != "" else "暂无备注") + usages_list = problemset["usages"] + if len(usages_list) > 0: + usage = re.sub("\\t([\d]\.[\d]{0,10})",color_value,"\n\n".join(usages_list)) + usage = re.sub("[\\t ]([\d]\.[\d]{0,10})",color_value,usage) + else: + usage = "暂无使用记录" + origin = (problemset["origin"] if problemset["origin"] != "" else "出处不详") + objects = problemset["objs"] + if len(objects) == 0: + objects = "暂未关联目标\n\n" + elif "KNONE" in [o.upper() for o in objects]: + objects = "该题的考查目标不在目前的集合中\n\n" + else: + objects_string = "" + for obj in objects: + if not obj in obj_dict: + objects_string = "目标" + obj + "有误\n\n" + break + else: + objects_string += "\\textcolor{blue}{" + obj + "|" + obj_dict[obj]["content"] + "}\n\n" + objects = objects_string + space = ("" if problemset["space"] == "" else "\n"+r"\vspace*{"+problemset["space"]+"}\n") + tags = ("|".join(problemset["tags"]) if len(problemset["origin"])>0 else "暂无标签") + raw_string = "\\item " + "{\\tiny ("+id+")} "+problem + teachers_string += raw_string.replace("\\tiny","")+"\n\n关联目标:\n\n"+ objects + "\n\n标签: " + tags + "\n\n答案: "+answer + "\n\n" + "解答或提示: " + solution + "\n\n使用记录:\n\n"+ usage + "\n" + "\n\n出处: "+origin + "\n" + students_string += raw_string + space + "\n\n" + teachers_string = r"\setcounter{enumi}{"+ str(enumi_mode * problems_count) + "}\n\n" + teachers_string + students_string = r"\setcounter{enumi}{"+ str(enumi_mode * problems_count) + "}\n\n" + students_string + problems_count += len(problem_list) + + #替换源文件中的字符串 + data_teachers = data_teachers.replace(string_to_replace,teachers_string) + data_students = data_students.replace(string_to_replace,students_string) + print("题块",blockid,"处理完毕.") + + #保存和编译latex文件 + with open(teachers_latex_file,"w",encoding = "utf8") as f: + f.write(data_teachers) + print("开始编译教师版本pdf文件: ", teachers_latex_file) + os.system("xelatex -interaction=batchmode -output-directory=" + destination_dir + " "+ teachers_latex_file) + print(os.system("xelatex -interaction=batchmode -output-directory=" + destination_dir + " "+ teachers_latex_file)) + with open(students_latex_file,"w",encoding = "utf8") as f: + f.write(data_students) + print("开始编译学生版本pdf文件: ", students_latex_file) + os.system("xelatex -interaction=batchmode -output-directory=" + destination_dir + " "+ students_latex_file) + print(os.system("xelatex -interaction=batchmode -output-directory=" + destination_dir + " "+ students_latex_file)) \ No newline at end of file diff --git a/工具/课时目标划分信息汇总.py b/工具/课时目标划分信息汇总.py new file mode 100644 index 00000000..8bc1d358 --- /dev/null +++ b/工具/课时目标划分信息汇总.py @@ -0,0 +1,137 @@ +import os,re,time,json,sys + +""" +"/模板文件"目录下 课时划分.txt 与 课时目标及单元目标.txt 文件不能缺失 +""" + +"""---设置文件名---""" +#目录和文件的分隔务必用/ +lessoncut_file = "临时文件/按课时分类目标及题目清单" +lessonobj_file = "临时文件/课时目标及单元目标表" +"""---设置文件名结束---""" + +#读取系统日期 +current_time = time.localtime() +time_string = "_"+str(current_time.tm_year).zfill(4)+str(current_time.tm_mon).zfill(2)+str(current_time.tm_mday).zfill(2) + + +lessoncut_file += time_string +".tex" +lessonobj_file += time_string +".tex" + + +#读取题库json文件并转化为字典 +with open(r"../题库0.3/Problems.json","r",encoding = "utf8") as f: + database = f.read() +pro_dict = json.loads(database) + +#读取目标数据库json并转化为字典 +with open(r"../题库0.3/LessonObj.json","r",encoding = "utf8") as f: + database = f.read() +lessonobj_dict = json.loads(database) + +#读取课时数据库json并转化为字典 +with open(r"../题库0.3/LessonsCut.json","r",encoding = "utf8") as f: + database = f.read() +lessoncut_dict = json.loads(database) + +#读取单元目标数据库json并转化为字典 +with open(r"../题库0.3/UnitObj.json","r",encoding = "utf8") as f: + database = f.read() +unitobj_dict = json.loads(database) + +#以下是课时题目统计 +#生成单元课时列表(Kddll) +lessons_descr = [] +for o in lessonobj_dict: + if not o[:5] in lessons_descr: + lessons_descr.append(o[:5]) +lessons_dict = {} +lessons_string = "" +for l in lessons_descr: + lessons_dict[l] = [0,""] +for p in pro_dict: + for l in lessons_descr: + for o in pro_dict[p]["objs"]: + if l in o: + lessons_dict[l][0] += 1 + lessons_dict[l][1] += p + "," + break +#lessons_string是简要列表, lessons_dict是详细清单 +for l in lessons_descr: + lessons_string += l + ": " + str(lessons_dict[l][0]) + "\n" +#课时统计完成 + +#以下是目标题目统计 +objs_dict = {} +objs_string = "" +for o in lessonobj_dict: + objs_dict[o] = [0,""] +for p in pro_dict: + for o in lessonobj_dict: + if o in pro_dict[p]["objs"]: + objs_dict[o][0] += 1 + objs_dict[o][1] += p + "," +# objs_string是简要列表, objs_dict是详细清单 +for o in lessonobj_dict: + objs_string += o + ": " + str(objs_dict[o][0]) + "\n" +#课时统计完成 + +#生成课时目标汇总的latex文件内容lessons_obj_string, 准备放到latex文件中 +lessons_obj_string = "" +for obj in lessonobj_dict: + lessons_obj_string += lessonobj_dict[obj]["id"] + " & " + lessonobj_dict[obj]["unit_obj"] + " & " + lessonobj_dict[obj]["content"] + r"\\ \hline" + "\n" + +#生成单元目标汇总的latex文件内容units_obj_string, 准备放到latex文件中 +units_obj_string = "" +for obj in unitobj_dict: + units_obj_string += unitobj_dict[obj]["id"] + "&" + unitobj_dict[obj]["content"] + r"\\ \hline" + "\n" + +#生成课时统计的latex文件内容lessons_cut_string, 准备放到latex文件中 +lessons_cut_string = "" +for lesson in lessons_dict: + unit_index = lesson[1:3] + lesson_index = lesson[3:5] + lessons_cut_string += r"\section*{第" + unit_index + "单元, 第" + lesson_index +r"课时}"+ "\n\n" + lessons_cut_string += r"起始页码: " + lessoncut_dict[lesson]["start"] + "; 终止页码: " + lessoncut_dict[lesson]["end"] + ".\n\n" + lessons_cut_string += r"\begin{itemize}" + "\n\n" + for o in lessonobj_dict: + if lesson in o: + lessons_cut_string += r"\item " + o + "|" + lessonobj_dict[o]["unit_obj"] + "|" + lessonobj_dict[o]["content"] + "\n\n" + lessons_cut_string += "关联题目数: " + str(objs_dict[o][0]) + ". 列表: " + objs_dict[o][1].replace(",",", ") + "\n\n" + lessons_cut_string += r"\item 课时汇总" + "\n\n" + "本课时总题目数: " + str(lessons_dict[lesson][0]) + ".\n\n" + "列表: " + lessons_dict[lesson][1].replace(",",", ") + "\n\n" + lessons_cut_string += r"\end{itemize}" + "\n\n" + + +#替换单元课时目标的latex文件的内容并编译 +with open("模板文件/课时目标及单元目标.txt","r",encoding = "utf8") as f: + obj_latex_file_raw = f.read() +#识别操作系统 +if sys.platform != "win32": + obj_latex_file_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",obj_latex_file_raw) + obj_latex_file_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",obj_latex_file_raw) +obj_latex_file_new = obj_latex_file_raw.replace("课时目标待替换",lessons_obj_string).replace("单元目标待替换",units_obj_string) +with open(lessonobj_file,"w",encoding = "utf8") as f: + f.write(obj_latex_file_new) +print("开始编译单元与课时目标信息pdf文件:", lessonobj_file) +d = re.search("/[^/]*$",lessonobj_file).span()[0] +lessonobj_dir = lessonobj_file[:d] +os.system("xelatex -interaction=batchmode -output-directory=" + lessonobj_dir + " "+ lessonobj_file) +os.system("xelatex -interaction=batchmode -output-directory=" + lessonobj_dir + " "+ lessonobj_file) + +#替换课时划分的latex文件的内容并编译 +with open("模板文件/课时划分.txt","r",encoding = "utf8") as f: + lessons_cut_latex_file_raw = f.read() +#识别操作系统 +if sys.platform != "win32": + lessons_cut_latex_file_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",lessons_cut_latex_file_raw) + lessons_cut_latex_file_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",lessons_cut_latex_file_raw) +lessons_cut_latex_file_new = lessons_cut_latex_file_raw.replace("待替换",lessons_cut_string) +with open(lessoncut_file,"w",encoding = "utf8") as f: + f.write(lessons_cut_latex_file_new) +print("开始编译课时划分信息pdf文件:", lessoncut_file) +d = re.search("/[^/]*$",lessoncut_file).span()[0] +lessoncut_dir = lessoncut_file[:d] +os.system("xelatex -interaction=batchmode -output-directory=" + lessoncut_dir + " "+ lessoncut_file) +os.system("xelatex -interaction=batchmode -output-directory=" + lessoncut_dir + " "+ lessoncut_file) + +print("已输出至pdf文件",r"临时文件/课时目标及单元目标表","及",r"临时文件/按课时分类目标及题目清单") \ No newline at end of file diff --git a/工具/课时目标及课时划分信息汇总.ipynb b/工具/课时目标及课时划分信息汇总.ipynb index 53d3f1b3..4f43eefe 100644 --- a/工具/课时目标及课时划分信息汇总.ipynb +++ b/工具/课时目标及课时划分信息汇总.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -159,7 +159,9 @@ "d = re.search(\"/[^/]*$\",lessoncut_file).span()[0]\n", "lessoncut_dir = lessoncut_file[:d]\n", "os.system(\"xelatex -interaction=batchmode -output-directory=\" + lessoncut_dir + \" \"+ lessoncut_file)\n", - "os.system(\"xelatex -interaction=batchmode -output-directory=\" + lessoncut_dir + \" \"+ lessoncut_file)\n" + "os.system(\"xelatex -interaction=batchmode -output-directory=\" + lessoncut_dir + \" \"+ lessoncut_file)\n", + "\n", + "print(\"已输出至pdf文件\",r\"临时文件/课时目标及单元目标表\",\"及\",r\"临时文件/按课时分类目标及题目清单\")\n" ] }, { diff --git a/工具/课时目标寻找题目.py b/工具/课时目标寻找题目.py new file mode 100644 index 00000000..d7b4e4b3 --- /dev/null +++ b/工具/课时目标寻找题目.py @@ -0,0 +1,40 @@ +# 输入目标列表 +t = """K0819001X +K0819002X +K0819003X +K0819004X +K0819005X +K0819006X +K0820001X +K0820002X +K0820003X +""" + +import json +with open("../题库0.3/Problems.json","r",encoding = "utf8") as f: + database = f.read() +pro_dict = json.loads(database) + +dict1 = {} +for o in [l.strip() for l in t.split("\n") if len(l.strip())>0]: + dict1[o] = [] +for id in pro_dict: + for o in dict1: + objs = pro_dict[id]["objs"] + flag = True + if not o in objs: + flag = False + for obj in objs: + if obj > o: + flag = False + break + if flag: + dict1[o].append(id) +output = "" +for o in dict1: + if not dict1[o] == []: + print('"'+o+'":"'+",".join(dict1[o])+'",') + output += '"'+o+'":"'+",".join(dict1[o])+'",'+"\n" + +with open(r"临时文件\课时目标寻找题目结果.txt","w",encoding = "utf8") as f: + f.write(output)