添加新题和关联题的origin更新为最新版
This commit is contained in:
parent
439c5af4f0
commit
433533c5e9
|
|
@ -411,7 +411,7 @@ def AddProblemstoDict(startingid,raworigin,problems,editor,indexdescription,thed
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def AddProblemstoDict2024(startingid,raworigin,problems,editor,indexdescription,thedict): #将来自GenerateProblemListFromString的列表中的题目添加到thedict字典, 返回题号列表(包括用老题号替代的题目)
|
def AddProblemstoDict2024(startingid,raworigin,problems,editor,indexed,thedict): #将来自GenerateProblemListFromString的列表中的题目添加到thedict字典, 返回题号列表(包括用老题号替代的题目)
|
||||||
idlist = []
|
idlist = []
|
||||||
id = int(startingid)
|
id = int(startingid)
|
||||||
currentsuffix = problems[0][1]
|
currentsuffix = problems[0][1]
|
||||||
|
|
@ -428,7 +428,10 @@ def AddProblemstoDict2024(startingid,raworigin,problems,editor,indexdescription,
|
||||||
else:
|
else:
|
||||||
problemindex = 1
|
problemindex = 1
|
||||||
currentsuffix = suffix
|
currentsuffix = suffix
|
||||||
origin = raworigin + suffix + indexdescription.strip() + ("" if indexdescription.strip() == "" else str(problemindex))
|
if indexed:
|
||||||
|
origin = {"来源": raworigin + suffix, "题号": problemindex}
|
||||||
|
else:
|
||||||
|
origin = {"来源": raworigin + suffix}
|
||||||
if not "rep" in meta:
|
if not "rep" in meta:
|
||||||
newproblem = CreateNewProblem(pid,p.strip(),origin,thedict,GetDate() + "\t" + editor)
|
newproblem = CreateNewProblem(pid,p.strip(),origin,thedict,GetDate() + "\t" + editor)
|
||||||
if "blank" in p:
|
if "blank" in p:
|
||||||
|
|
@ -486,7 +489,7 @@ def CreateRelatedProblems(links,thedict,filepath,editor): # 根据links关联生
|
||||||
new_dict[old_id]["same"] = []
|
new_dict[old_id]["same"] = []
|
||||||
new_dict[old_id]["unrelated"] = []
|
new_dict[old_id]["unrelated"] = []
|
||||||
new_dict[old_id]["edit"] = new_dict[old_id]["edit"].copy() + [GetDate()+"\t"+editor]
|
new_dict[old_id]["edit"] = new_dict[old_id]["edit"].copy() + [GetDate()+"\t"+editor]
|
||||||
new_dict[old_id]["origin"] += "-" + GetDate() + "修改"
|
new_dict[old_id]["origin"] = {"来源": "改编题目", "前序": old_id}
|
||||||
save_dict(new_dict,filepath)
|
save_dict(new_dict,filepath)
|
||||||
except:
|
except:
|
||||||
return 1 #异常返回1
|
return 1 #异常返回1
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,13 @@ class MyWindow(QWidget,Ui_Form):
|
||||||
filename = "临时文件/新题比对.tex" #题目的来源.tex文件
|
filename = "临时文件/新题比对.tex" #题目的来源.tex文件
|
||||||
editor = self.lineEdit_editor.text().strip()
|
editor = self.lineEdit_editor.text().strip()
|
||||||
if self.checkBox_suffix.isChecked():
|
if self.checkBox_suffix.isChecked():
|
||||||
IndexDescription = self.lineEdit_suffix.text().strip()
|
Indexed = True
|
||||||
else:
|
else:
|
||||||
IndexDescription = ""
|
Indexed = False
|
||||||
idlistpath = "文本文件/新题收录列表.txt"
|
idlistpath = "文本文件/新题收录列表.txt"
|
||||||
problems = GenerateProblemListFromString2024(ReadTextFile(filename))
|
problems = GenerateProblemListFromString2024(ReadTextFile(filename))
|
||||||
pro_dict = load_dict("../题库0.3/Problems.json")
|
pro_dict = load_dict("../题库0.3/Problems.json")
|
||||||
idlist = AddProblemstoDict2024(NextSpareID(starting_id,pro_dict),raworigin,problems,editor,IndexDescription,pro_dict)
|
idlist = AddProblemstoDict2024(NextSpareID(starting_id,pro_dict),raworigin,problems,editor,Indexed,pro_dict)
|
||||||
save_dict(SortDict(pro_dict),r"../题库0.3/Problems.json")
|
save_dict(SortDict(pro_dict),r"../题库0.3/Problems.json")
|
||||||
AppendTextFile(f"{GetDate()}-{GetTime()}\n{generate_exp(idlist)}",idlistpath)
|
AppendTextFile(f"{GetDate()}-{GetTime()}\n{generate_exp(idlist)}",idlistpath)
|
||||||
os.system(f"code {idlistpath}")
|
os.system(f"code {idlistpath}")
|
||||||
|
|
|
||||||
Reference in New Issue