Merge commit '8220d2fab253a9d3a69ebe9625ddc85b10b3d214'
This commit is contained in:
commit
7209efd01d
|
|
@ -411,7 +411,7 @@ def AddProblemstoDict(startingid,raworigin,problems,editor,indexdescription,thed
|
|||
return 0
|
||||
|
||||
|
||||
def AddProblemstoDict2024(startingid,raworigin,problems,editor,indexdescription,thedict): #将来自GenerateProblemListFromString的列表中的题目添加到thedict字典, 返回题号列表(包括用老题号替代的题目)
|
||||
def AddProblemstoDict2024(startingid,raworigin,problems,editor,indexed,thedict): #将来自GenerateProblemListFromString的列表中的题目添加到thedict字典, 返回题号列表(包括用老题号替代的题目)
|
||||
idlist = []
|
||||
id = int(startingid)
|
||||
currentsuffix = problems[0][1]
|
||||
|
|
@ -428,7 +428,10 @@ def AddProblemstoDict2024(startingid,raworigin,problems,editor,indexdescription,
|
|||
else:
|
||||
problemindex = 1
|
||||
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:
|
||||
newproblem = CreateNewProblem(pid,p.strip(),origin,thedict,GetDate() + "\t" + editor)
|
||||
if "blank" in p:
|
||||
|
|
@ -486,7 +489,7 @@ def CreateRelatedProblems(links,thedict,filepath,editor): # 根据links关联生
|
|||
new_dict[old_id]["same"] = []
|
||||
new_dict[old_id]["unrelated"] = []
|
||||
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)
|
||||
except:
|
||||
return 1 #异常返回1
|
||||
|
|
@ -914,12 +917,22 @@ def StripSuffix(string, suf_words): #除去字符串前后的空格及suf_words
|
|||
return(string) # 返回处理以后的字符串
|
||||
|
||||
|
||||
def MatchCondition2014(problem,condition_list): #判断problem这一字典是否符合condition_list中的所有筛选条件
|
||||
def generate_origin(origin_dict):
|
||||
data = origin_dict["来源"]
|
||||
if "题号" in origin_dict:
|
||||
data = f"{data}试题{origin_dict['题号']}"
|
||||
if "前序" in origin_dict:
|
||||
data = f"{data}-改编自{origin_dict['前序']}"
|
||||
return data
|
||||
|
||||
def MatchCondition2024(problem,condition_list): #判断problem这一字典是否符合condition_list中的所有筛选条件
|
||||
match = True #初始设定符合条件
|
||||
for field, flag_not, matchexp in condition_list:
|
||||
exps = [i.strip() for i in matchexp.split(",")]
|
||||
if problem[field] == list:
|
||||
if type(problem[field]) == list:
|
||||
data = "\n".join(problem[field])
|
||||
elif field == "origin":
|
||||
data = generate_origin(problem[field])
|
||||
else:
|
||||
data = str(problem[field]) #至此将每个字段中的内容都转为string
|
||||
if flag_not == False: #表示肯定的筛选
|
||||
|
|
@ -1191,7 +1204,7 @@ def generateLaTeXBodyContent(id,adict,objdict,misc): #根据id,读取的json内
|
|||
usages = f"\n\n使用记录:\n\n{GenerateUsageTexCode(id,adict,misc['字段显示设置']['使用记录'])}\n\n"
|
||||
output += usages
|
||||
if "来源" in misc["字段显示设置"] and misc["字段显示设置"]["来源"] == True:
|
||||
origin = adict[id]["origin"] if len(adict[id]["origin"]) > 0 else "未记录来源"
|
||||
origin = generate_origin(adict[id]["origin"]) if len(adict[id]["origin"]) > 0 else "未记录来源"
|
||||
output += f"\n\n来源: {origin}\n\n"
|
||||
return output
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class MyWindow(QWidget,Ui_Form):
|
|||
self.matchlist = []
|
||||
self.conditions.append(("content",True,"OBSOLETE"))
|
||||
for id in self.pro_dict:
|
||||
if MatchCondition2014(self.pro_dict[id],self.conditions):
|
||||
if MatchCondition2024(self.pro_dict[id],self.conditions):
|
||||
self.matchlist.append(id)
|
||||
self.conditions = self.conditions[:-1].copy()
|
||||
self.lcdNumber_resCount.display(len(self.matchlist))
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ class MyWindow(QWidget,Ui_Form):
|
|||
filename = "临时文件/新题比对.tex" #题目的来源.tex文件
|
||||
editor = self.lineEdit_editor.text().strip()
|
||||
if self.checkBox_suffix.isChecked():
|
||||
IndexDescription = self.lineEdit_suffix.text().strip()
|
||||
Indexed = True
|
||||
else:
|
||||
IndexDescription = ""
|
||||
Indexed = False
|
||||
idlistpath = "文本文件/新题收录列表.txt"
|
||||
problems = GenerateProblemListFromString2024(ReadTextFile(filename))
|
||||
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")
|
||||
AppendTextFile(f"{GetDate()}-{GetTime()}\n{generate_exp(idlist)}",idlistpath)
|
||||
os.system(f"code {idlistpath}")
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
},
|
||||
"origin": {
|
||||
"FieldName": "origin",
|
||||
"FieldType": "str",
|
||||
"FieldType": "dict",
|
||||
"Method": "fixed"
|
||||
},
|
||||
"edit": {
|
||||
|
|
|
|||
117857
题库0.3/Problems.json
117857
题库0.3/Problems.json
File diff suppressed because it is too large
Load Diff
Reference in New Issue