编写 合并使用记录并排序 工具并加入工具面板
This commit is contained in:
parent
801eca65ce
commit
ff5f16d540
|
|
@ -0,0 +1,34 @@
|
||||||
|
# 合并相同题目的使用记录
|
||||||
|
|
||||||
|
import re,json,os
|
||||||
|
|
||||||
|
with open(r"../题库0.3/Problems.json","r",encoding = "utf8") as f:
|
||||||
|
database = f.read()
|
||||||
|
pro_dict = json.loads(database)
|
||||||
|
same_groups = []
|
||||||
|
|
||||||
|
# 生成有使用记录的相同题目组
|
||||||
|
for id in pro_dict:
|
||||||
|
same = pro_dict[id]["same"]
|
||||||
|
if not len(pro_dict[id]["usages"]) == 0 and len(same) > 0:
|
||||||
|
same_groups.append([id]+same)
|
||||||
|
|
||||||
|
# 合并使用记录并排序
|
||||||
|
for same_group in same_groups:
|
||||||
|
current_usages = []
|
||||||
|
for id in same_group:
|
||||||
|
for usage in pro_dict[id]["usages"]:
|
||||||
|
if not usage in current_usages:
|
||||||
|
current_usages.append(usage)
|
||||||
|
current_usages.sort()
|
||||||
|
for id in same_group:
|
||||||
|
pro_dict[id]["usages"] = current_usages.copy()
|
||||||
|
|
||||||
|
# 对所有使用记录排序
|
||||||
|
for id in pro_dict:
|
||||||
|
usages = pro_dict[id]["usages"].copy()
|
||||||
|
usages.sort()
|
||||||
|
pro_dict[id]["usages"] = usages.copy()
|
||||||
|
|
||||||
|
with open(r"../题库0.3/Problems.json","w",encoding = "u8") as f:
|
||||||
|
f.write(json.dumps(pro_dict,indent = 4, ensure_ascii= False))
|
||||||
|
|
@ -106,6 +106,8 @@ def run_command1():
|
||||||
call(["python","错题重做来源清点.py"])
|
call(["python","错题重做来源清点.py"])
|
||||||
elif selectedtool == "统考数据导入":
|
elif selectedtool == "统考数据导入":
|
||||||
call(["python","统考数据导入.py"])
|
call(["python","统考数据导入.py"])
|
||||||
|
elif selectedtool == "合并使用记录并排序":
|
||||||
|
call(["python","合并使用记录并排序.py"])
|
||||||
LabelTool.config(text = selectedtool+"STEP1命令执行完毕")
|
LabelTool.config(text = selectedtool+"STEP1命令执行完毕")
|
||||||
button1.place_forget()
|
button1.place_forget()
|
||||||
|
|
||||||
|
|
@ -148,6 +150,7 @@ MaintainenceMenu = Menu(menubar, tearoff = False)
|
||||||
menubar.add_cascade(label = "维护", menu = MaintainenceMenu)
|
menubar.add_cascade(label = "维护", menu = MaintainenceMenu)
|
||||||
MaintainenceMenu.add_command(label = "批量添加字段数据", command = lambda: SetButton("批量添加字段数据",1,["文本文件/metadata.txt","批量添加字段数据.py"]))
|
MaintainenceMenu.add_command(label = "批量添加字段数据", command = lambda: SetButton("批量添加字段数据",1,["文本文件/metadata.txt","批量添加字段数据.py"]))
|
||||||
MaintainenceMenu.add_command(label = "手动统计结果转换", command = lambda: SetButton("手动统计结果转换",1,["文本文件/metadata.txt","文本文件/手动统计结果.txt"]))
|
MaintainenceMenu.add_command(label = "手动统计结果转换", command = lambda: SetButton("手动统计结果转换",1,["文本文件/metadata.txt","文本文件/手动统计结果.txt"]))
|
||||||
|
MaintainenceMenu.add_command(label = "合并使用记录并排序", command = lambda: SetButton("合并使用记录并排序",1,[]))
|
||||||
MaintainenceMenu.add_separator()
|
MaintainenceMenu.add_separator()
|
||||||
MaintainenceMenu.add_command(label = "LaTeX界面修改题目内容", command = lambda: SetButton("latex修改题目",2,["latex界面修改题目内容.py"]))
|
MaintainenceMenu.add_command(label = "LaTeX界面修改题目内容", command = lambda: SetButton("latex修改题目",2,["latex界面修改题目内容.py"]))
|
||||||
MaintainenceMenu.add_command(label = "修改题目综合信息", command = lambda: SetButton("修改题目数据库",2,["修改题目数据库.py"]))
|
MaintainenceMenu.add_command(label = "修改题目综合信息", command = lambda: SetButton("修改题目数据库",2,["修改题目数据库.py"]))
|
||||||
|
|
|
||||||
Reference in New Issue