This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mathdeptv2/工具v2/添加关联题目old.py

29 lines
1.3 KiB
Python

old_ids = "20462,20463" # 需要添加关联题目的id字符串
starting_id = "1" # 目的地的id字符串从这个位置后的首个空闲开始, 其中空闲位置需不少于old_ids中的题目数量 20040124修改
editor = "王伟叶" # 修改人姓名
from database_tools import *
tempfilepath = "临时文件/problem_edit.json"
pro_dict = load_dict("../题库0.3/Problems.json")
obj_dict = load_dict("../题库0.3/LessonObj.json")
pro_dict_raw_string = ReadTextFile("../题库0.3/Problems.json")
configjson = load_dict("文本文件/config.json")["默认完整编译题目模式"]
links = CreateIDLinks(generate_number_set(old_ids),generate_number_set(NextSpareIDBlock(starting_id,pro_dict)),pro_dict)
CreateRelatedProblems(links,pro_dict,tempfilepath,editor)
print("编辑完毕后, 保存关闭文件继续.")
os.system("code -w -g "+tempfilepath) #-w表示关闭窗口后继续下一步
editedid_list = ImportRelatedProblems(tempfilepath,"../题库0.3/Problems.json")
pro_dict = load_dict("../题库0.3/Problems.json")
if not XeLaTeXTest(editedid_list,pro_dict,obj_dict,configjson,templatepath="模板文件/讲义模板.txt",outdir = "临时文件",outfile = "problems_test.tex"):
SaveTextFile(pro_dict_raw_string,"../题库0.3/Problems.json")
print("编译失败, 题库文件退回原状")
else:
print("编译成功, 已汇入题库")