新增单元挂钩功能并加入工具面板

This commit is contained in:
weiye.wang 2024-02-07 09:52:25 +08:00
parent 963b8f8423
commit 8d5bb08377
3 changed files with 36 additions and 1 deletions

27
工具v2/单元挂钩.py Normal file
View File

@ -0,0 +1,27 @@
from database_tools import *
pro_dict = load_dict("../题库0.3/problems.json")
configjson = load_dict("文本文件/config.json")["单元挂钩.py"]
if str(configjson["阶段"]).strip() == "1":
idexp = configjson["题号表达式"]
if idexp.strip() == "":
idlist = unUnitted(pro_dict)
else:
idlist = generate_number_set(idexp)
latex_body,tagrec = AutoAssignTagNotoLaTeX(idlist,pro_dict)
latex_raw = ReadTextFile("模板文件/讲义模板.txt")
latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,("待检查单元",latex_body))
SaveTextFile(tagrec,"临时文件/单元对应.txt")
SaveTextFile(latex_data,"临时文件/待检查单元.tex")
if XeLaTeXCompile("临时文件","待检查单元.tex") == True:
print("处理成功.")
os.system("code 临时文件/单元对应.txt 临时文件/待检查单元.pdf")
else:
print("处理失败.")
elif str(configjson["阶段"]).strip() == "2":
output = UnitRectoMetadataText(ReadTextFile("临时文件/单元对应.txt"))
SaveTextFile(output,"文本文件/metadata.txt")
os.system("code 文本文件/metadata.txt")

View File

@ -7,7 +7,7 @@ root = Tk()
root.geometry('500x600')
root.title('题库0.3工具面板v2')
root.title('题库0.3工具面板v2-20240207')
def temp():
pass
@ -92,7 +92,9 @@ MaintainenceMenu.add_command(label = "合并使用记录并排序", command = la
MaintainenceMenu.add_separator()
MaintainenceMenu.add_command(label = "统考数据导入", command = lambda: SetButton("统考数据导入",["统考数据导入.py"]))
MaintainenceMenu.add_command(label = "手动统计结果导入", command = lambda: SetButton("手动统计结果导入",["临时文件/手动统计结果.txt"]))
MaintainenceMenu.add_separator()
MaintainenceMenu.add_command(label = "文件或剪贴板提取答案", command = lambda: SetButton("文件或剪贴板提取答案",["文件或剪贴板提取答案.py"]))
MaintainenceMenu.add_command(label = "单元挂钩", command = lambda: SetButton("单元挂钩",["单元挂钩.py"]))
MaintainenceMenu.add_separator()
MaintainenceMenu.add_command(label = "移除关联题号", command = lambda: SetButton("移除关联题号",["文本文件/metadata.txt"]))
MaintainenceMenu.add_separator()

View File

@ -72,5 +72,11 @@
"来自剪贴板": true,
"文件地址": "d:/temp/test5.tex",
"前缀": "答案: \\textcolor{red}{"
},
"单元挂钩.py": {
"阶段": 2,
"阶段说明": "阶段为1表示对题号列表的题目自动赋单元, 阶段为2表示将 临时文件/单元对应.txt 中的数据转化为metadata.txt",
"题号表达式": "",
"题号说明": "此处仅针对第1阶段: 题号表达式为空字符串表示处理未赋单元的题目, 否则表示处理表达式所表示的那些题目"
}
}