20230330 night

This commit is contained in:
weiye.wang 2023-03-30 22:41:29 +08:00
parent d3caf90c35
commit 3a1cf44d1c
2 changed files with 62 additions and 3 deletions

View File

@ -39,7 +39,9 @@ def run_command1():
call(["python","../文本处理工具/剪贴板文本整理_mathpix.py"])
elif selectedtool == "带圈数字处理":
call(["python","../文本处理工具/带圈数字处理.py"])
LabelTool.config(text = "STEP1命令执行完毕")
elif selectedtool == "试卷答案生成":
call(["python","试卷答案生成.py"])
LabelTool.config(text = selectedtool+" STEP1命令执行完毕")
def run_command2():
selectedtool = commandname.get()
@ -47,11 +49,11 @@ def run_command2():
call(["python","导入关联题目.py"])
elif selectedtool == "修改题目数据库":
call(["python","修改结果汇入.py"])
LabelTool.config(text = "STEP2命令执行完毕")
LabelTool.config(text = selectedtool+ "STEP2命令执行完毕")
commandname = StringVar()
commandname.set("none")
LabelTool = Label(root, text = "工具选择待定", height = 1, width = 25, anchor=W)
LabelTool = Label(root, text = "工具选择待定", height = 1, width = 40, anchor=W)
LabelTool.place(x=420,y=50)
button1 = Button(root, text = "运行STEP1", command = run_command1)
@ -77,6 +79,8 @@ MaintainenceMenu.add_command(label = "修改题目", command = lambda: SetButton
UseMenu = Menu(menubar, tearoff = False)
menubar.add_cascade(label = "使用", menu = UseMenu)
UseMenu.add_command(label = "题号选题pdf生成", command = lambda: SetButton("题号选题pdf生成",1,["题号选题pdf生成.py"]))
UseMenu.add_command(label = "试卷答案生成", command = lambda: SetButton("试卷答案生成",1,["试卷答案生成.py"]))
# 设置 其他 菜单项
OtherMenu = Menu(menubar, tearoff = False)

View File

@ -0,0 +1,55 @@
file_dir = r"C:\Users\weiye\Documents\wwy sync\23届\上学期周末卷"
filelist = [] #列表为空默认处理所有讲义
output_gloss_filename = "23届高三上学期周末卷参考答案"
import os,re,json
if len(filelist) == 0:
filelist = [f for f in os.listdir(file_dir) if ".tex" in f]
with open("../题库0.3/Problems.json","r",encoding = "u8") as f:
pro_dict = json.loads(f.read())
output_data = ""
for filename in filelist:
outfilename = os.path.split(filename)[1][:-4]+"答案"
with open(os.path.join(file_dir,filename),"r",encoding = "u8") as f:
data = f.read()
ids = re.findall(r"\((\d{6})\)",data)
if len(ids) > 0:
print("正在生成: ",outfilename)
output_data += ("\n\n"+r"\section{"+outfilename.replace("_","-")+"}\n\n")
output_data += ("\n\n"+r"\begin{enumerate}"+"\n\n")
for id in ids:
problemset = pro_dict[id]
content = problemset["content"]
solution = problemset["solution"]
answer = "\\textcolor{red}{" + (problemset["ans"] if problemset["ans"] != "" else "\\textcolor{blue}{暂无答案}") + "}"
output_data += "\\item " + "("+id+") " + content + "\n\n" + "答案: " + answer + "\n\n"
output_data += ("\n\n"+r"\end{enumerate}"+"\n\\newpage\n\n")
with open("模板文件/试卷答案模板.txt","r",encoding = "u8") as f:
outlatex = f.read()
outlatex = outlatex.replace("内容待替换",output_data)
outlatex = outlatex.replace("标题文字待处理",output_gloss_filename.replace("_","-"))
outfile = os.path.join("临时文件",output_gloss_filename+".tex")
with open(outfile,"w",encoding="u8") as f:
f.write(outlatex)
outfile = outfile.replace("\\","/")
print("编译 "+outfile+"")
os.system("xelatex -interaction=batchmode -output-directory=临时文件 " + outfile)
print(os.system("xelatex -interaction=batchmode -output-directory=临时文件 " + outfile))