diff --git a/工具/寻找未赋答案题目.py b/工具/寻找未赋答案题目.py new file mode 100644 index 00000000..8e5dfc9c --- /dev/null +++ b/工具/寻找未赋答案题目.py @@ -0,0 +1,29 @@ +import os,json,re + +#这里需要修改, 设定路径与选择文件 +directories = [r"C:\Users\weiye\Documents\wwy sync\23届\上学期测验卷", +r"C:\Users\weiye\Documents\wwy sync\23届\上学期周末卷", +r"C:\Users\weiye\Documents\wwy sync\23届\第一轮复习讲义", +r"C:\Users\weiye\Documents\wwy sync\23届\赋能", +r"C:\Users\weiye\Documents\wwy sync\23届\一模后春考前试卷备选", +r"C:\Users\weiye\Documents\wwy sync\23届\第二轮复习讲义", +r"C:\Users\weiye\Documents\wwy sync\23届\下学期测验卷", +r"C:\Users\weiye\Documents\wwy sync\23届\下学期周末卷", +r"C:\Users\weiye\Documents\wwy sync\23届\寒假作业", +r"C:\Users\weiye\Documents\wwy sync\23届\正态分布及成对数据新课" +] + +with open("../题库0.3/Problems.json","r",encoding = "utf8") as f: + jsondata = f.read() +pro_dict = json.loads(jsondata) + +for directory in directories: + filelist = [f for f in os.listdir(directory) if ".tex" in f] + for file in filelist: + print(file) + with open(os.path.join(directory,file),"r",encoding = "utf8") as f: + data = f.read() + idlist = re.findall(r"\(([\d]{6})\)",data) + for id in idlist: + if pro_dict[id]["ans"].strip() == "": + print(id+"\n\n") \ No newline at end of file diff --git a/工具/工具面板.py b/工具/工具面板.py index 4e9ad10d..6ccd6fca 100644 --- a/工具/工具面板.py +++ b/工具/工具面板.py @@ -58,7 +58,13 @@ def run_command1(): elif selectedtool == "讲义生成": call(["python","讲义生成.py"]) elif selectedtool == "课时目标划分信息汇总": - call(["python","课时目标划分信息汇总.py"]) + 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() @@ -99,12 +105,12 @@ MaintainenceMenu.add_command(label = "修改题目", command = lambda: SetButton # 设置 使用 菜单项 UseMenu = Menu(menubar, tearoff = False) -menubar.add_cascade(label = "使用", menu = UseMenu) +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) @@ -116,6 +122,14 @@ ObjTagMenu.add_command(label = "目标表体生成", command = lambda: SetButton ObjTagMenu.add_command(label = "课时目标寻找题目", command = lambda: SetButton("课时目标寻找题目",1,["课时目标寻找题目.py"])) ObjTagMenu.add_command(label = "课时目标划分信息汇总", command = lambda: SetButton("课时目标划分信息汇总",1,[])) +# 设置 备课组 菜单项 +BKZMenu = Menu(menubar, tearoff=False) +menubar.add_cascade(label = "备课组材料相关", menu = BKZMenu) +BKZMenu.add_command(label = "试卷答案生成", command = lambda: SetButton("试卷答案生成",1,["试卷答案生成.py"])) +BKZMenu.add_command(label = "题号清单生成", command = lambda: SetButton("题号清单生成",1,["题号清单生成.py"])) +BKZMenu.add_command(label = "已用题号剔除", command = lambda: SetButton("已用题号剔除",1,["已用题号剔除.py"])) +BKZMenu.add_command(label = "寻找未赋答案题目", command = lambda: SetButton("寻找未赋答案题目",1,["寻找未赋答案题目.py"])) + # 设置 其他 菜单项 OtherMenu = Menu(menubar, tearoff = False) menubar.add_cascade(label = "其他", menu = OtherMenu) diff --git a/工具/已用题号剔除.py b/工具/已用题号剔除.py new file mode 100644 index 00000000..27726d0c --- /dev/null +++ b/工具/已用题号剔除.py @@ -0,0 +1,82 @@ +import os,re,json + +"""---设置题号列表所在文件, 仅第一行有用---""" +id_list_file = "文本文件/题号筛选.txt" +"""---设置题号列表文件结束---""" + +"""---设置要排除的题号所在的绝对路径---""" +mainpath = r"C:/Users/Weiye/Documents/wwy sync/23届/" + +used_path_list = [ +mainpath + "第一轮复习讲义/", +mainpath + "上学期测验卷/", +mainpath + "上学期周末卷/", +mainpath + "赋能/", +mainpath + "寒假作业/", +mainpath + "下学期测验卷/", +mainpath + "下学期周末卷/", +mainpath + "第二轮复习讲义/", +# mainpath + "简单题/", +] +"""---路径设置完毕---""" + +# 从字符串中获取题号列表 +def extract_idlist(string): + idlist = re.findall(r"\(([\d]{6})\)",string) + return idlist + +# 生成题号列表 +def generate_number_set(string,dict): + 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 + +#读取题库json文件并转化为字典 +with open(r"../题库0.3/Problems.json","r",encoding = "utf8") as f: + database = f.read() +pro_dict = json.loads(database) + +# 生成首行题号列表并输出数量 +with open(id_list_file,"r",encoding = "utf8") as f: + data = f.read() + "\n" + +# id_list = re.findall(r"^([^\n]*)\n",data)[0].split(",") +id_list = generate_number_set(data,pro_dict) +print("首行题目数量: ",len(id_list)) + +# 生成已使用题号列表 +used_id_list = [] + +for path in used_path_list: + filelist = [f for f in os.listdir(path) if ".tex" in f] + for f in filelist: + with open(path+f,"r",encoding = "utf8") as texfile: + texdata = texfile.read() + used_id_list += extract_idlist(texdata) + +# 去除已使用题号 +checked_id_list = [] +ripped_id_list = [] +for id in id_list: + if not id in used_id_list: + checked_id_list.append(id) + else: + ripped_id_list.append(id) + +print("剩余题目数量: ",len(checked_id_list)) + +# 写入文件 +with open(id_list_file,"a",encoding = "utf8") as f: + f.write("\n\n") + f.write("未使用题号:\n") + f.write(",".join(checked_id_list)) + f.write("\n\n已使用题号:\n") + f.write(",".join(ripped_id_list)) \ No newline at end of file diff --git a/工具/题号清单生成.py b/工具/题号清单生成.py new file mode 100644 index 00000000..37eaf052 --- /dev/null +++ b/工具/题号清单生成.py @@ -0,0 +1,57 @@ +import os,re +"---此处输入文件夹列表---" +directories = [r"C:\Users\weiye\Documents\wwy sync\23届\上学期测验卷", +r"C:\Users\weiye\Documents\wwy sync\23届\上学期周末卷", +r"C:\Users\weiye\Documents\wwy sync\23届\第一轮复习讲义", +r"C:\Users\weiye\Documents\wwy sync\23届\赋能", +r"C:\Users\weiye\Documents\wwy sync\23届\一模后春考前试卷备选", +r"C:\Users\weiye\Documents\wwy sync\23届\正态分布及成对数据新课", +r"C:\Users\weiye\Documents\wwy sync\23届\寒假作业", +r"C:\Users\weiye\Documents\wwy sync\23届\下学期测验卷", +r"C:\Users\weiye\Documents\wwy sync\23届\下学期周末卷", +r"C:\Users\weiye\Documents\wwy sync\23届\第二轮复习讲义", +r"d:\mathdeptv2\工具\临时文件" +] +"---文件夹列表输入结束---" + +for directory in directories: + filelist = [filename for filename in os.listdir(directory) if ".tex" in filename] + + output = "" + outputv2 = "" + + for filename in filelist: + print(os.path.join(directory,filename)) + output += filename + "\n" + outputv2 += filename + "\n" + with open(os.path.join(directory,filename),"r",encoding = "u8") as f: + try: + data = re.findall(r"\\begin{document}([\s\S]*?)\\end{document}",f.read())[0] + data = data.replace(r"\section","endsecbeginsec") + "endsec" + if not "beginsec" in data: + data = "beginsec" + data + sectionlist = re.findall(r"beginsec([\s\S]*?)endsec",data) + for sec in sectionlist: + secname = re.findall(r"{([\S]*)}",sec)[0] + output += secname + "\n" + # print(secname) + v2idlist = [] + for id in re.findall(r"\(\d{6}\)",sec): + # print(id) + v2idlist.append(id[1:-1]) + output += id + "\n" + outputv2 += '"'+",".join(v2idlist)+'",' + except: + pass + output += "\n\n" + outputv2 = outputv2[:-1] + "\n\n" + # print("\n\n") + + with open(os.path.join(directory,"题号清点.txt"),"w",encoding = "u8") as f: + f.write(output + "\n\n\n以下题号不含括号\n\n\n" + output.replace("(","").replace(")","")+outputv2) + + + + + +