diff --git a/工具v4/database_tools_2.py b/工具v4/database_tools_2.py index 18a382ef..f1e4e992 100644 --- a/工具v4/database_tools_2.py +++ b/工具v4/database_tools_2.py @@ -542,6 +542,7 @@ def AddRelatedProblemToDB(id,content,oid,editor,database): def AddProblemstoDict2024nocommit(startingid,raworigin,problems,editor,indexed,cursor): #将来自GenerateProblemListFromString的列表中的题目添加到thedict字典, 返回题号列表(包括用老题号替代的题目) mycursor = cursor idlist = [] + problemlist = [] id = int(startingid) currentsuffix = problems[0][1] problemindex = 0 @@ -549,6 +550,7 @@ def AddProblemstoDict2024nocommit(startingid,raworigin,problems,editor,indexed,c try: p, suffix, meta = p_and_suffix_and_meta p = re.sub(r"\n\s+","\n",p) + problemlist.append(p) pid = str(id).zfill(6) if suffix == currentsuffix: problemindex += 1 @@ -610,7 +612,7 @@ def AddProblemstoDict2024nocommit(startingid,raworigin,problems,editor,indexed,c print(f"错误的题目: {p_and_suffix_and_meta}") idlist = [] break - return idlist + return (idlist,problemlist) def CreateIDLinks(old_id_list,new_id_list): #建立已有id和新id之间的联系, thedict为可选, 选中的话即为当前字典, 会从new_id_list中排除当前字典中有的项 if len(old_id_list)>len(new_id_list): diff --git a/工具v4/批量收录新题.py b/工具v4/批量收录新题.py index 77709fce..18ed9f2a 100644 --- a/工具v4/批量收录新题.py +++ b/工具v4/批量收录新题.py @@ -21,6 +21,7 @@ class MyWindow_bdsl(QWidget,Ui_Form): self.pushButton_step2.clicked.connect(self.execstep2) self.pushButton_commit.clicked.connect(self.commitchange) self.plainTextEdit_compared.textChanged.connect(self.commitdisable) + self.problemstoimport = [] def togglesuffix(self): self.suffix_checked = self.checkBox_suffix.isChecked() if self.suffix_checked: @@ -99,7 +100,15 @@ class MyWindow_bdsl(QWidget,Ui_Form): self.db = connect(hostname = db_host, port= db_port, username= db_user, pwd = db_pwd, db= self.database_name) self.cursor = self.db.cursor() rolled_back = False - idlist = AddProblemstoDict2024nocommit(nextspareid,raworigin,problems,editor,Indexed,self.cursor) + idlist,newproblemlist = AddProblemstoDict2024nocommit(nextspareid,raworigin,problems,editor,Indexed,self.cursor) + for p in newproblemlist: + if p in self.problemstoimport: + print("有重复导入的题目, 改变已回滚!!!\n"*5) + self.db.rollback() + rolled_back = True + break + else: + self.problemstoimport.append(p) if idlist == []: print("有错误, 改变已回滚.") self.db.rollback() @@ -108,6 +117,8 @@ class MyWindow_bdsl(QWidget,Ui_Form): AppendTextFile(f"{GetDate()}-{GetTime()}\n{generate_exp(idlist)}",idlistpath) os.system(f"code {idlistpath}") self.pushButton_commit.setEnabled(True) + else: + self.pushButton_commit.setDisabled(True) def commitdisable(self): self.pushButton_commit.setDisabled(True) diff --git a/工具v4/文本文件/metadata.txt b/工具v4/文本文件/metadata.txt index d7882a15..7984bb95 100644 --- a/工具v4/文本文件/metadata.txt +++ b/工具v4/文本文件/metadata.txt @@ -1,109 +1,165 @@ -usages +tags +024840 +第二单元 023654 20240521 2025届高二01班 1.000 +024841 +第二单元 041191 20240521 2025届高二01班 0.972 +024842 +第二单元 041192 20240521 2025届高二01班 0.944 +024843 +第二单元 041193 20240521 2025届高二01班 0.806 +024844 +第二单元 041194 20240521 2025届高二01班 0.917 +024845 +第二单元 041195 20240521 2025届高二01班 0.111 +024846 +第二单元 041196 20240521 2025届高二01班 0.694 +024847 +第二单元 041197 20240521 2025届高二01班 0.944 0.944 0.889 0.889 +024848 +第二单元 +第四单元 041198 20240521 2025届高二01班 0.972 +024849 +第二单元 041199 20240521 2025届高二01班 0.944 +041191 +第七单元 041200 20240521 2025届高二01班 0.833 +041192 +第二单元 040325 20240521 2025届高二01班 0.833 +041193 +第二单元 041201 20240521 2025届高二01班 0.556 +041194 +第二单元 041202 20240521 2025届高二01班 1.000 1.000 +041195 +第九单元 040225 20240521 2025届高二01班 0.778 +041196 +第九单元 041203 20240521 2025届高二01班 0.972 0.903 +041197 +第二单元 041204 20240521 2025届高二01班 0.889 0.528 0.944 +041198 +第二单元 023654 20240521 2025届高二02班 0.950 +041199 +第二单元 041191 20240521 2025届高二02班 1.000 +041200 +第二单元 041192 20240521 2025届高二02班 0.950 +041201 +第二单元 041193 20240521 2025届高二02班 0.975 +041202 +第六单元 041194 20240521 2025届高二02班 0.975 +041203 +第二单元 041195 20240521 2025届高二02班 0.200 +041204 +第八单元 +第九单元 041196 20240521 2025届高二02班 0.600 +041205 +第七单元 041197 20240521 2025届高二02班 0.950 0.875 0.825 0.825 +041206 +第二单元 041198 20240521 2025届高二02班 0.975 +041207 +第二单元 041199 20240521 2025届高二02班 0.925