Merge commit '85aa1a8d20015ac3cf1c7084f56b672bcf191a82'

This commit is contained in:
wangweiye7840 2024-06-17 11:13:07 +08:00
commit d52868f25e
8 changed files with 285 additions and 172 deletions

View File

@ -29,6 +29,11 @@ db_pwd = "Kjmathds_2024"
db_port = "13306" db_port = "13306"
db_host = "wwylss.synology.me" db_host = "wwylss.synology.me"
currentsemester = "2023"
def getgrade(currentsemester,gradeindex):
gradelist = {1: "高三", 2:"高二", 3:"高一"}
return gradelist[int(gradeindex)-int(currentsemester)]
def get_git_username(): def get_git_username():
command = "git config --global user.name" command = "git config --global user.name"
@ -293,7 +298,7 @@ def generate_classid(string): #返回班级列表
def generate_id_set(string,*thedict): #除了生成题号列表外, 还能根据首字母生成基础知识编号列表或课时目标列表 def generate_id_set(string,*thedict): #除了生成题号列表外, 还能根据首字母生成基础知识编号列表或课时目标列表
string = RefinePunctuations(string) string = RefinePunctuations(string).upper()
if re.findall(r"[BXK]",string) == []: if re.findall(r"[BXK]",string) == []:
if thedict == (): if thedict == ():
return generate_number_set(string) return generate_number_set(string)
@ -2519,9 +2524,9 @@ def GenerateSectionBodyStringfromDict(problems,sectiontitles,prodict,objdict,bnd
bodystring += sectionstring bodystring += sectionstring
return bodystring #返回主题内容字符串 return bodystring #返回主题内容字符串
def GenerateSingleLessonTeXfromDict(id,notesdict,pro_dict,obj_dict,bn_dict,misc,consecutivenumbering=False): def GenerateSingleLessonTeXfromDict(id,structuredict,notesdict,pro_dict,obj_dict,bn_dict,misc,consecutivenumbering=False):
structure = notesdict["structures"][id[0].upper()]["structure"] structure = structuredict[id[0:5].upper()]["structure"]
note_contents = notesdict["notes"][id] note_contents = notesdict[id]
sections_list = [] sections_list = []
problems_list = [] problems_list = []
for key in structure: for key in structure:
@ -2533,10 +2538,10 @@ def GenerateSingleLessonTeXfromDict(id,notesdict,pro_dict,obj_dict,bn_dict,misc,
rawoutput = re.sub(r"\\section\{[^\n]*","",rawoutput) rawoutput = re.sub(r"\\section\{[^\n]*","",rawoutput)
return rawoutput return rawoutput
def GenerateSingleLessonNotefromMariaDB(cursor,id,notesdict,templatepath,outputfilepath,misc,consecutivenumbering = False): #20240415版讲义生成 def GenerateSingleLessonNotefromMariaDB(cursor,id,structuredict,notesdict,templatepath,outputfilepath,misc,consecutivenumbering = False): #20240415版讲义生成
notetitle = id + r" \ " + notesdict["notes"][id]["name"] notetitle = id + r" \ " + notesdict[id]["name"]
structure = notesdict["structures"][id[0].upper()]["structure"] structure = structuredict[id[0:5].upper()]["structure"]
note_contents = notesdict["notes"][id] note_contents = notesdict[id]
output = "" output = ""
sections_list = [] sections_list = []
problems_list = [] problems_list = []
@ -2573,10 +2578,10 @@ def GenerateSingleLessonNotefromMariaDB(cursor,id,notesdict,templatepath,outputf
print("编译失败") print("编译失败")
return latex_data # 返回有错误的latex源代码 return latex_data # 返回有错误的latex源代码
def GenerateSingleLessonNote(id,notesdict,metadict,templatepath,outputfilepath,consecutivenumbering = False, answered = False): #20231215版讲义生成 def GenerateSingleLessonNote(id,structuredict, notesdict,metadict,templatepath,outputfilepath,consecutivenumbering = False, answered = False): #20231215版讲义生成
notetitle = id + r" \ " + notesdict["notes"][id]["name"] notetitle = id + r" \ " + notesdict["notes"][id]["name"]
structure = notesdict["structures"][id[0].upper()]["structure"] structure = structuredict[id[0:5].upper()]["structure"]
note_contents = notesdict["notes"][id] note_contents = notesdict[id]
output = "" output = ""
sections_list = [] sections_list = []
problems_list = [] problems_list = []
@ -2623,6 +2628,8 @@ def getUnitNumber(string):
unitlist = ["暂无对应","第一单元","第二单元","第三单元","第四单元","第五单元","第六单元","第七单元","第八单元","第九单元"] unitlist = ["暂无对应","第一单元","第二单元","第三单元","第四单元","第五单元","第六单元","第七单元","第八单元","第九单元"]
if string in unitlist[1:]: if string in unitlist[1:]:
return unitlist.index(string) return unitlist.index(string)
def ExtractProblemIDs(paperdict,pro_dict):#从备课组材料的每一张讲义的dict(paperdict)中提取题号 def ExtractProblemIDs(paperdict,pro_dict):#从备课组材料的每一张讲义的dict(paperdict)中提取题号
output = [] output = []
@ -2651,36 +2658,62 @@ def FindFile(dir,filename): #在指定目录及子目录下寻找特定文件名
pathlist.append(path) pathlist.append(path)
return pathlist return pathlist
def FindPaper(xiaoxianpid, answersheetpath): #根据小闲的试卷编号和答题纸对应json的根目录寻找题库的试卷编号,届别,题号, 返回(题库试卷编号,届别,题号列表), 如果未找到则返回False def FindPaper(xiaoxianpid, mycursor): #根据小闲的试卷编号和答题纸对应json的根目录寻找题库的试卷编号,届别,题号, 返回(题库试卷编号,届别,题号列表), 如果未找到则返回False
answersheetpathlist = FindFile(answersheetpath,"答题纸对应.json")
foundpid = False foundpid = False
for dir in answersheetpathlist: sql = "SELECT nid,parts,idlist,marks,exclude FROM answersheets WHERE not obsolete AND pid = %s;"
filepath = os.path.join(dir,"答题纸对应.json") val = (xiaoxianpid,)
anssheetjson = load_dict(filepath) mycursor.execute(sql,val)
if xiaoxianpid in anssheetjson: ret = mycursor.fetchall()
foundpid = True if len(ret) == 1:
grade = "20"+re.findall(r"\d{2}",dir)[0] foundpid = True
nid = anssheetjson[xiaoxianpid]["nid"] nid,parts,idlist,marksraw,excluderaw = ret[0]
notesjson = load_dict(os.path.join(dir,"校本材料.json")) if not parts is None:
if not "idlist" in anssheetjson[xiaoxianpid]: idlist = []
idlist = [] sql = "SELECT structure FROM notes WHERE nid = %s AND not obsolete;"
for part in anssheetjson[xiaoxianpid]["parts"]: val = (nid,)
idlist += notesjson["notes"][nid][part].copy() mycursor.execute(sql,val)
else: structure = mycursor.fetchall()[0][0]
idlist = anssheetjson[xiaoxianpid]["idlist"] for key in json.loads(parts):
if "marks" in anssheetjson[xiaoxianpid]: idlist += json.loads(structure)[key].copy()
marks = anssheetjson[xiaoxianpid]["marks"] else:
else: idlist = json.loads(idlist)
marks = [] marks = [] if marksraw is None else json.loads(marksraw)
if "exclude" in anssheetjson[xiaoxianpid]: exclude = {} if excluderaw is None else json.loads(excluderaw)
excludejson = anssheetjson[xiaoxianpid]["exclude"] grade = nid[1:5]+""
else: # grade = getgrade(currentsemester,gradeindex)
excludejson = {}
break
if foundpid: if foundpid:
return(nid,grade,idlist,marks,excludejson) return(nid,grade,idlist,marks,exclude)
else: else:
return False return False
# answersheetpathlist = FindFile(answersheetpath,"答题纸对应.json")
# foundpid = False
# for dir in answersheetpathlist:
# filepath = os.path.join(dir,"答题纸对应.json")
# anssheetjson = load_dict(filepath)
# if xiaoxianpid in anssheetjson:
# foundpid = True
# grade = "20"+re.findall(r"\d{2}届",dir)[0]
# nid = anssheetjson[xiaoxianpid]["nid"]
# notesjson = load_dict(os.path.join(dir,"校本材料.json"))
# if not "idlist" in anssheetjson[xiaoxianpid]:
# idlist = []
# for part in anssheetjson[xiaoxianpid]["parts"]:
# idlist += notesjson["notes"][nid][part].copy()
# else:
# idlist = anssheetjson[xiaoxianpid]["idlist"]
# if "marks" in anssheetjson[xiaoxianpid]:
# marks = anssheetjson[xiaoxianpid]["marks"]
# else:
# marks = []
# if "exclude" in anssheetjson[xiaoxianpid]:
# excludejson = anssheetjson[xiaoxianpid]["exclude"]
# else:
# excludejson = {}
# break
# if foundpid:
# return(nid,grade,idlist,marks,excludejson)
# else:
# return False
def CheckPaperType(filepath,filename): #根据filepath(通常是小闲的zip解压出的目录)和filename(通常是"小题分_按学号数学.xlsx")检测试卷类型, 未找到该文件则返回False, 找到文件且是日常试卷返回"日常卷", 找到文件且不是日常试卷返回"考试卷" def CheckPaperType(filepath,filename): #根据filepath(通常是小闲的zip解压出的目录)和filename(通常是"小题分_按学号数学.xlsx")检测试卷类型, 未找到该文件则返回False, 找到文件且是日常试卷返回"日常卷", 找到文件且不是日常试卷返回"考试卷"
statsfilepathlist = FindFile(filepath,filename) statsfilepathlist = FindFile(filepath,filename)
@ -3283,19 +3316,21 @@ def isIDpart(alist): #判断一个list是不是题号列表
return True return True
def findxiaobenIDs(jsonpath,grade = ""): #根据jsonpath中的校本材料获取grade做过的题目, grade为空则获取所有目录中的题目 def findxiaobenIDs(cursor,grade = ""): #根据jsonpath中的校本材料获取grade做过的题目, grade为空则获取所有目录中的题目
jsonlists = [] sql = 'SELECT nid,structure FROM notes WHERE NOT obsolete;'
cursor.execute(sql)
ret = cursor.fetchall()
grade = grade.strip()
if len(grade) == 2:
grade = "20"+grade
jsonIDs = [] jsonIDs = []
for loc,dirs,files in os.walk(jsonpath): for nid,structure in ret:
if "校本材料.json" in files: if grade == "" or nid[1:5] == grade:
jsonlists.append(os.path.join(loc,"校本材料.json")) structure = json.loads(structure)
for jsonfile in jsonlists: for key in structure:
jsondict = load_dict(jsonfile)["notes"] for id in structure[key]:
for pid in jsondict: if len(id) == 6:
if pid[1:5] == grade or grade == "": jsonIDs.append(id)
for part in jsondict[pid]:
if type(jsondict[pid][part]) == list and isIDpart(jsondict[pid][part]):
jsonIDs += jsondict[pid][part].copy()
return jsonIDs return jsonIDs
@ -3326,5 +3361,39 @@ def generateUsagedetail(zipfilepath,tempdir,answersheetseekingpath,statsfilename
return outputlist #返回由usages开始的使用记录列表 return outputlist #返回由usages开始的使用记录列表
def load_notes_dict_from_mariadb(cursor): #从mariadb获取讲义列表
sql = "SELECT nid,name,filename,structure,remarks FROM notes WHERE NOT obsolete;"
cursor.execute(sql)
ret = cursor.fetchall()
notes_dict = {}
for nid,name,filename,structure,remarks in ret:
temp_dict = json.loads(structure)
notes_dict[nid] = {'id':nid,'name':name,'filename':filename}
for key in temp_dict:
notes_dict[nid][key] = temp_dict[key]
notes_dict[nid]["remarks"] = "" if remarks is None else remarks
return notes_dict
def load_structures_dict_from_mariadb(cursor): # 从mariadb获取讲义结构列表
sql = "SELECT initial,description,consecutivenumbering,structure FROM notestructures WHERE NOT obsolete;"
cursor.execute(sql)
ret = cursor.fetchall()
structures_dict = {}
for initial,description,consecutivenumbering,structure in ret:
structures_dict[initial] = {'initial':initial,'description':description,'consecutivenumbering':bool(consecutivenumbering),'structure':json.loads(structure)}
return structures_dict
def load_answersheets_dict_from_mariadb(cursor): # 从mariadb获取答题纸列表
sql = "SELECT pid,nid,parts,idlist,marks,exclude FROM answersheets WHERE NOT obsolete;"
cursor.execute(sql)
ret = cursor.fetchall()
answersheet_dict = {}
for pid,nid,parts,idlist,marks,exclude in ret:
answersheet_dict[pid] = {'nid':nid}
for key,item in [('parts',parts),('idlist',idlist),('marks',marks),('exclude',exclude)]:
if not item is None:
answersheet_dict[pid][key] = item
return answersheet_dict
if __name__ == "__main__": if __name__ == "__main__":
print("数据库工具, import用.") print("数据库工具, import用.")

View File

@ -68,7 +68,7 @@ class MyWindow(QMainWindow,Ui_MainWindow):
self.layout_bjtm.addWidget(self.bjtm) #以上三行为初始化“编辑题目”tab self.layout_bjtm.addWidget(self.bjtm) #以上三行为初始化“编辑题目”tab
self.layout_xxdr = QVBoxLayout(self.tab_xxdr) self.layout_xxdr = QVBoxLayout(self.tab_xxdr)
self.xxdr = MyWindow_xxdr() self.xxdr = MyWindow_xxdr(self.database)
self.layout_xxdr.addWidget(self.xxdr) #以上三行为初始化“小闲统计数据导入”tab self.layout_xxdr.addWidget(self.xxdr) #以上三行为初始化“小闲统计数据导入”tab
@ -121,11 +121,11 @@ class MyWindow(QMainWindow,Ui_MainWindow):
self.layout_hqth.addWidget(self.hqth) #以上三行为初始化“获取题号”tab self.layout_hqth.addWidget(self.hqth) #以上三行为初始化“获取题号”tab
self.layout_jglr = QVBoxLayout(self.tab_jglr) self.layout_jglr = QVBoxLayout(self.tab_jglr)
self.jglr = MyWindow_jglr() self.jglr = MyWindow_jglr(self.database)
self.layout_jglr.addWidget(self.jglr) #以上三行为初始化“讲义结构编号录入”tab self.layout_jglr.addWidget(self.jglr) #以上三行为初始化“讲义结构编号录入”tab
self.layout_dtlr = QVBoxLayout(self.tab_dtlr) self.layout_dtlr = QVBoxLayout(self.tab_dtlr)
self.dtlr = MyWindow_dtlr() self.dtlr = MyWindow_dtlr(self.database)
self.layout_dtlr.addWidget(self.dtlr) #以上三行为初始化“答题纸对应信息录入”tab self.layout_dtlr.addWidget(self.dtlr) #以上三行为初始化“答题纸对应信息录入”tab
self.layout_jysc = QVBoxLayout(self.tab_jysc) self.layout_jysc = QVBoxLayout(self.tab_jysc)
@ -195,7 +195,10 @@ class MyWindow(QMainWindow,Ui_MainWindow):
self.xzgx.setdbname, self.xzgx.setdbname,
self.sjlb.setdbname, self.sjlb.setdbname,
self.fnsc.setdbname, self.fnsc.setdbname,
self.pxnd.setdbname self.pxnd.setdbname,
self.xxdr.setdbname,
self.jglr.setdbname,
self.dtlr.setdbname
]: #在列表中的tab里传送数据库名的连接 ]: #在列表中的tab里传送数据库名的连接
self.sendDBname.connect(func) self.sendDBname.connect(func)
def sendValue(self): def sendValue(self):

View File

@ -2,25 +2,25 @@ from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
from Ui_答题纸对应 import Ui_Form from Ui_答题纸对应 import Ui_Form
from database_tools_2 import * from database_tools_2 import *
def getindices(string): def getindices(string,cursor):#根据前七个字符获取以其为首的讲义的后两位
sql = "SELECT nid FROM notes WHERE NOT obsolete;"
cursor.execute(sql)
ret = cursor.fetchall()
indices_list = [] indices_list = []
notesjsonpath = f"../备课组/{string[3:5]}届/校本材料.json" for item in ret:
try: if item[0].startswith(string):
notesjson = load_dict(notesjsonpath) indices_list.append(item[0][-2:])
for id in notesjson["notes"]: return indices_list.copy()
if id.startswith(string):
indices_list.append(id[-2:])
return indices_list
except:
return []
class MyWindow_dtlr(QWidget,Ui_Form): class MyWindow_dtlr(QWidget,Ui_Form):
def __init__(self): def __init__(self,database_name):
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.database_name = database_name
self.bind() self.bind()
def bind(self): def bind(self):
self.label_next.setVisible(False) self.label_next.setVisible(False)
@ -29,46 +29,57 @@ class MyWindow_dtlr(QWidget,Ui_Form):
self.lineEdit_structure.textChanged.connect(self.setindex) self.lineEdit_structure.textChanged.connect(self.setindex)
self.comboBox_index.activated.connect(self.activateexec) self.comboBox_index.activated.connect(self.activateexec)
self.pushButton_exec.clicked.connect(self.exec) self.pushButton_exec.clicked.connect(self.exec)
def setdbname(self,string):
self.database_name = string
# print(self.database_name)
def setindex(self): def setindex(self):
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
mycursor = mydb.cursor()
self.comboBox_index.clear() self.comboBox_index.clear()
self.structure = self.lineEdit_structure.text().upper() self.structure = self.lineEdit_structure.text().upper()
self.grade = self.comboBox_grade.currentText() self.grade = self.comboBox_grade.currentText()
self.semester = self.comboBox_semester.currentText() self.semester = self.comboBox_semester.currentText()
self.initialstring = f"{self.structure}{self.grade}{self.semester}" self.initialstring = f"{self.structure}{self.grade}{self.semester}"
self.indices = getindices(self.initialstring) self.indices = getindices(self.initialstring,mycursor)
self.comboBox_index.addItems(self.indices) self.comboBox_index.addItems(self.indices)
if self.indices == []: if self.indices == []:
self.pushButton_exec.setDisabled(True) self.pushButton_exec.setDisabled(True)
else: else:
self.pushButton_exec.setEnabled(True) self.pushButton_exec.setEnabled(True)
mydb.close()
def activateexec(self): def activateexec(self):
self.pushButton_exec.setEnabled(True) self.pushButton_exec.setEnabled(True)
def unvisible(self): def unvisible(self):
self.label_next.setVisible(False) self.label_next.setVisible(False)
def exec(self): def exec(self):
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
mycursor = mydb.cursor()
nid = f"{self.structure}{self.grade}{self.semester}{self.comboBox_index.currentText()}" nid = f"{self.structure}{self.grade}{self.semester}{self.comboBox_index.currentText()}"
answersheetjson = f"../备课组/{self.grade[-2:]}届/答题纸对应.json" # answersheetjson = f"../备课组/{self.grade[-2:]}届/答题纸对应.json"
notesjson = f"../备课组/{self.grade[-2:]}届/校本材料.json" # notesjson = f"../备课组/{self.grade[-2:]}届/校本材料.json"
marks_list = re.findall(r"(?:(?:^)|(?:\n))(\d+)分",self.plainTextEdit_marks.toPlainText()) marks_list = re.findall(r"(?:(?:^)|(?:\n))(\d+)分",self.plainTextEdit_marks.toPlainText())
marks_list = [int(mark) for mark in marks_list] marks_list = [int(mark) for mark in marks_list]
answersheet_dict = load_dict(answersheetjson) answersheet_dict = load_answersheets_dict_from_mariadb(mycursor)
notes_dict = load_dict(notesjson) notes_dict = load_notes_dict_from_mariadb(mycursor)
structure_dict = load_structures_dict_from_mariadb(mycursor)
new_dict = {} new_dict = {}
if not nid in notes_dict["notes"]: if not nid in notes_dict:
print("讲义编号有误.") print("讲义编号有误.")
else: else:
self.label_next.setVisible(True) self.label_next.setVisible(True)
self.repaint() self.repaint()
new_dict["nid"] = nid new_dict["nid"] = nid
corresponding_method = input("用何种方式对应? 题号(I)/章节标题(P):") corresponding_method = input("用何种方式对应? 题号(I)/章节标题(P):")
if corresponding_method[0].upper() == "I": if corresponding_method.strip() != "" and corresponding_method[0].upper() == "I":
new_dict["idlist"] = [] new_dict["idlist"] = []
count = 1 count = 1
id = input(f"输入第 {count} 题的题号(S表示跳过, E表示结束):") id = input(f"输入第 {count} 题的题号(S表示跳过, E表示结束):")
id = RefinePunctuations(id)
while len(re.findall(r"[Ss\d,:]",id)) == len(id): while len(re.findall(r"[Ss\d,:]",id)) == len(id):
if "S" in id.upper(): if "S" in id.upper():
new_dict["idlist"].append("999999") new_dict["idlist"].append("999999")
@ -78,10 +89,11 @@ class MyWindow_dtlr(QWidget,Ui_Form):
new_dict["idlist"] += [i.zfill(6) for i in new_id_list] new_dict["idlist"] += [i.zfill(6) for i in new_id_list]
count += len(new_id_list) count += len(new_id_list)
id = input(f"输入第 {count} 题的题号(S表示跳过, E表示结束):") id = input(f"输入第 {count} 题的题号(S表示跳过, E表示结束):")
id = RefinePunctuations(id)
elif corresponding_method[0].upper() == "P": elif corresponding_method.strip() != "" and corresponding_method[0].upper() == "P":
structure = notes_dict["structures"][nid[0]]["structure"] structure = structure_dict[nid[0:5]]["structure"]
count = 1 count = 1
partslist = [] partslist = []
for key in structure: for key in structure:
@ -89,30 +101,40 @@ class MyWindow_dtlr(QWidget,Ui_Form):
count += 1 count += 1
partslist.append(key) partslist.append(key)
parts_selected_string = input("使用哪些部分(输入数字编号, 用';'分隔):") parts_selected_string = input("使用哪些部分(输入数字编号, 用';'分隔):")
parts_selected_string = RefinePunctuations(parts_selected_string).replace(",",";").replace(" ","")
parts_selected_index = parts_selected_string.strip().split(";") parts_selected_index = parts_selected_string.strip().split(";")
parts_selected = [] parts_selected = []
for i in parts_selected_index: for i in parts_selected_index:
parts_selected.append(partslist[int(i)-1]) parts_selected.append(partslist[int(i)-1])
new_dict["parts"] = parts_selected.copy() new_dict["parts"] = parts_selected.copy()
if marks_list == []: if marks_list == []:
marksflag = input("是否为每个结果赋分(Y/N):") marksflag = input("是否为每个结果赋分(Y/[N]):")
if marksflag[0].upper() == "Y": if marksflag.strip() != "" and marksflag[0].upper() == "Y":
new_dict["marks"] = [] new_dict["marks"] = []
count = 1 count = 1
mark = input(f"依次输入分数, 非自然数作为结束(第 {count} 个位置):") mark = input(f"依次输入分数, 非自然数作为结束(第 {count} 个位置):").strip()
while len(re.findall(r"\d",mark)) == len(mark): while len(re.findall(r"\d",mark)) == len(mark):
new_dict["marks"].append(int(mark)) new_dict["marks"].append(int(mark))
count += 1 count += 1
mark = input(f"依次输入分数, 非自然数作为结束(第 {count} 个位置):") mark = input(f"依次输入分数, 非自然数作为结束(第 {count} 个位置):").strip()
else: else:
new_dict["marks"] = marks_list.copy() new_dict["marks"] = marks_list.copy()
sql = "INSERT INTO answersheets (pid,nid,parts,idlist,marks) VALUES (%s,%s,%s,%s,%s);"
parts = None if not "parts" in new_dict else json.dumps(new_dict["parts"],ensure_ascii=False)
idlist = None if not "idlist" in new_dict else json.dumps(new_dict["idlist"],ensure_ascii=False)
marks = None if not "marks" in new_dict else json.dumps(new_dict["marks"],ensure_ascii=False)
val = (self.lineEdit_xiaoxianid.text(),nid,parts,idlist,marks)
mycursor.execute(sql,val)
sql = "INSERT INTO logs (DATE,TIME,username,action,db_content) VALUE (%s,%s,%s,%s,%s);"
val = (GetDate(),GetTime(),get_git_username(),"答题纸挂钩",self.lineEdit_xiaoxianid.text())
mydb.commit()
answersheet_dict[self.lineEdit_xiaoxianid.text()] = new_dict.copy() # answersheet_dict[self.lineEdit_xiaoxianid.text()] = new_dict.copy()
save_dict(answersheet_dict,answersheetjson) # save_dict(answersheet_dict,answersheetjson)
self.label_next.setVisible(False) self.label_next.setVisible(False)
print("设置完成") print("设置完成")
mydb.close()
@ -126,7 +148,7 @@ class MyWindow_dtlr(QWidget,Ui_Form):
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication([]) app = QApplication([])
windows = MyWindow() windows = MyWindow_dtlr("tikutest")
windows.show() windows.show()
app.exec() app.exec()

View File

@ -79,14 +79,10 @@ class MyWindow_jysc(QWidget,Ui_Form):
def saveandbuild(self): def saveandbuild(self):
patterns = self.lineEdit_regex.text().strip().split(",") patterns = self.lineEdit_regex.text().strip().split(",")
jsonpath = "../备课组" #有json文件的根目录, 文件名需为"校本材料.json"
jsondicts = []
for loc,dirs,files in os.walk(jsonpath):
if "校本材料.json" in files:
jsondicts.append(load_dict(os.path.join(loc,"校本材料.json")))
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name) mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
mycursor = mydb.cursor() mycursor = mydb.cursor()
notes_dict = load_notes_dict_from_mariadb(mycursor)
structures_dict = load_structures_dict_from_mariadb(mycursor)
raw_pro_dict,obj_dict,bn_dict,unit_obj_dict = generateDictsfromMariaDB(mycursor) raw_pro_dict,obj_dict,bn_dict,unit_obj_dict = generateDictsfromMariaDB(mycursor)
if self.radioButton_teacher.isChecked() and self.checkBox_usages.isChecked() and not self.lineEdit_grades.text().strip() == "": if self.radioButton_teacher.isChecked() and self.checkBox_usages.isChecked() and not self.lineEdit_grades.text().strip() == "":
grades = self.lineEdit_grades.text().strip().split(",") grades = self.lineEdit_grades.text().strip().split(",")
@ -114,41 +110,42 @@ class MyWindow_jysc(QWidget,Ui_Form):
} }
papernames = [] papernames = []
multitexdata = [] multitexdata = []
for notes_dict in jsondicts: for lessonid in sorted(notes_dict.keys()):
for lessonid in notes_dict["notes"]: coincideflag = False
coincideflag = False for lessonpattern in patterns:
for lessonpattern in patterns: if re.findall(lessonpattern,lessonid) != []:
if re.findall(lessonpattern,lessonid) != []: coincideflag = True
coincideflag = True break
break if coincideflag:
if coincideflag: print(f"正在生成 {lessonid} {notes_dict[lessonid]['filename']} 的 .tex 文件")
print(f"正在生成 {lessonid} {notes_dict['notes'][lessonid]['filename']} 的 .tex 文件") filename = notes_dict[lessonid]["id"]+notes_dict[lessonid]["filename"]+".tex"
filename = notes_dict["notes"][lessonid]["id"]+notes_dict["notes"][lessonid]["filename"]+".tex" papertype = lessonid[0:5]
papertype = lessonid[0] consecutivenumbering = structures_dict[papertype]["consecutivenumbering"]
consecutivenumbering = notes_dict["structures"][papertype]["consecutivenumbering"] texdata = GenerateSingleLessonTeXfromDict(id=lessonid, structuredict = structures_dict, notesdict=notes_dict, pro_dict=pro_dict, obj_dict=obj_dict,bn_dict=bn_dict,misc = configjson, consecutivenumbering= consecutivenumbering)
texdata = GenerateSingleLessonTeXfromDict(id=lessonid, notesdict=notes_dict, pro_dict=pro_dict, obj_dict=obj_dict,bn_dict=bn_dict,misc = configjson, consecutivenumbering= consecutivenumbering) if notes_dict[lessonid]["remarks"] != "":
papernames.append(notes_dict["notes"][lessonid]["id"]+" \\ "+notes_dict["notes"][lessonid]["name"]) texdata += f"\n\n\\newpage\n\n\\section{{备注}}\n\n{notes_dict[lessonid]['remarks']}\n\n"
print(f"已生成 {papernames[-1]} 文件") papernames.append(notes_dict[lessonid]["id"]+" \\ "+notes_dict[lessonid]["name"])
multitexdata.append(texdata) print(f"已生成 {papernames[-1]} 文件")
latex_raw = ReadTextFile("./模板文件/讲义模板.txt") multitexdata.append(texdata)
latex_raw = latex_raw.replace(r"学号\blank{50} \ 姓名\blank{80}","上海市控江中学") #替换掉模板中的姓名学号 latex_raw = ReadTextFile("./模板文件/讲义模板.txt")
latex_raw = latex_raw.replace(r"学号\blank{50} \ 姓名\blank{80}","上海市控江中学") #替换掉模板中的姓名学号
if sys.platform == "darwin": #非win系统用默认字体 if sys.platform == "darwin": #非win系统用默认字体
latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",latex_raw) latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",latex_raw)
latex_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",latex_raw) latex_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",latex_raw)
latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,(papernames[-1],texdata)) #替换标题和bodystring latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,(papernames[-1],texdata)) #替换标题和bodystring
outputfilepath = os.path.join(self.outputpath,filename) outputfilepath = os.path.join(self.outputpath,filename)
SaveTextFile(latex_data,outputfilepath) #保存.tex文件 SaveTextFile(latex_data,outputfilepath) #保存.tex文件
if configjson["编译单个文件"] == True: if configjson["编译单个文件"] == True:
outputdir,filename = os.path.split(outputfilepath) outputdir,filename = os.path.split(outputfilepath)
print(f"{filename}编译中...") print(f"{filename}编译中...")
if XeLaTeXCompile(outputdir,filename): if XeLaTeXCompile(outputdir,filename):
print("编译成功") print("编译成功")
else: else:
print("编译失败") print("编译失败")
# print(lessonid) # print(lessonid)
# print(configjson) # print(configjson)
# print("\n".join(patterns)) # print("\n".join(patterns))
mydb.close() mydb.close()

View File

@ -7,7 +7,7 @@ from database_tools_2 import *
# raw_pro_dict = load_dict("../题库0.3/Problems.json") # raw_pro_dict = load_dict("../题库0.3/Problems.json")
# obj_dict = load_dict("../题库0.3/LessonObj.json") # obj_dict = load_dict("../题库0.3/LessonObj.json")
# basicknowledge_dict = load_dict("../题库0.3/BasicKnowledge.json") # basicknowledge_dict = load_dict("../题库0.3/BasicKnowledge.json")
jsonpath = "../备课组" # jsonpath = "../备课组"
# jsondicts = {} # jsondicts = {}
# for loc,dirs,files in os.walk(jsonpath): # for loc,dirs,files in os.walk(jsonpath):
# if "校本材料.json" in files: # if "校本材料.json" in files:
@ -23,14 +23,7 @@ app = Flask(__name__)
@app.route('/', methods=['GET', 'POST']) @app.route('/', methods=['GET', 'POST'])
def index(): def index():
if request.method == 'POST': if request.method == 'POST':
global pid,configjson,uuiddir,outputpath,jsondicts global pid,configjson,uuiddir,outputpath
jsondicts = {}
os.system("git pull origin master --force")
for loc,dirs,files in os.walk(jsonpath):
if "校本材料.json" in files:
currentdict = load_dict(os.path.join(loc,"校本材料.json"))
for key in currentdict["notes"]:
jsondicts[key] = currentdict["notes"][key].copy()
uuiddir = str(uuid.uuid4()) uuiddir = str(uuid.uuid4())
outputpath = os.path.join(os.getcwd(),f"临时文件/{uuiddir}") outputpath = os.path.join(os.getcwd(),f"临时文件/{uuiddir}")
makedir(outputpath) makedir(outputpath)
@ -41,10 +34,10 @@ def index():
configjson = {"教师版": True, configjson = {"教师版": True,
"字段显示设置": { "字段显示设置": {
"题后空间": False, "题后空间": False,
"课时目标": False, "课时目标": True,
"题目标签": False, "题目标签": True,
"答案": True, "答案": True,
"解答与提示": False, "解答与提示": True,
"使用记录": [-1,-1], "使用记录": [-1,-1],
"来源": True, "来源": True,
"备注": True, "备注": True,
@ -88,18 +81,19 @@ def index():
global filename global filename
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku") mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="tikuuser", pwd="Kjmathds_2024", db = "tiku")
mycursor = mydb.cursor() mycursor = mydb.cursor()
notes_dict = load_notes_dict_from_mariadb(mycursor)
structure_dict = load_structures_dict_from_mariadb(mycursor)
if re.findall(r"[A-Za-z]",pid) != []: if re.findall(r"[A-Za-z]",pid) != []:
if pid in jsondicts: if pid in notes_dict:
try: try:
filename = pid+jsondicts[pid]["filename"].replace("(","").replace(")","")+".tex" filename = pid+notes_dict[pid]["filename"].replace("(","").replace(")","")+".tex"
papertype = pid[0] papertype = pid[0:5]
grade = pid[3:5] # grade = pid[3:5]
# raw_pro_dict = load_dict("../题库0.3/Problems.json") # raw_pro_dict = load_dict("../题库0.3/Problems.json")
# obj_dict = load_dict("../题库0.3/LessonObj.json") # obj_dict = load_dict("../题库0.3/LessonObj.json")
# basicknowledge_dict = load_dict("../题库0.3/BasicKnowledge.json") # basicknowledge_dict = load_dict("../题库0.3/BasicKnowledge.json")
notes_dict = load_dict(f"../备课组/{grade}届/校本材料.json") consecutivenumbering = structure_dict[papertype]["consecutivenumbering"]
consecutivenumbering = notes_dict["structures"][papertype]["consecutivenumbering"] texdata = GenerateSingleLessonNotefromMariaDB(mycursor,pid,structure_dict,notes_dict,"../工具v4/模板文件/讲义模板.txt",os.path.join(outputpath,filename),configjson,consecutivenumbering) #20240415版讲义生成
texdata = GenerateSingleLessonNotefromMariaDB(mycursor,pid,notes_dict,"../工具v3/模板文件/讲义模板.txt",os.path.join(outputpath,filename),configjson,consecutivenumbering) #20240415版讲义生成
mydb.close() mydb.close()
return f''' return f'''
<h1>{pid} PDF 文件生成完毕</h1> <h1>{pid} PDF 文件生成完毕</h1>
@ -128,7 +122,7 @@ def index():
for singleid in problems_list: for singleid in problems_list:
bodystring += generateLaTeXBodyContentfromMariaDB(mycursor,singleid,configjson) + "\n" bodystring += generateLaTeXBodyContentfromMariaDB(mycursor,singleid,configjson) + "\n"
bodystring += "\\end{enumerate}\n\n" bodystring += "\\end{enumerate}\n\n"
templatepath = "../工具v3/模板文件/讲义模板.txt" templatepath = "../工具v4/模板文件/讲义模板.txt"
outputfilepath = os.path.join(outputpath,filename) outputfilepath = os.path.join(outputpath,filename)
texdata = ReadTextFile(templatepath) texdata = ReadTextFile(templatepath)
texdata = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",texdata,("选题编译",bodystring)) texdata = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",texdata,("选题编译",bodystring))

View File

@ -20,14 +20,15 @@ class MyWindow_xxdr(QWidget,Ui_Form):
def __init__(self): def __init__(self,database_name):
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.database_name = database_name
self.bind() self.bind()
def bind(self): def bind(self):
self.tempdir = "临时文件/zips" self.tempdir = "临时文件/zips"
self.statsfilename = "小题分_按学号数学.xlsx" self.statsfilename = "小题分_按学号数学.xlsx"
self.answersheetseekingpath = "../备课组" # self.answersheetseekingpath = "../备课组"
self.lineEdit_threshold.setText("0.75") self.lineEdit_threshold.setText("0.75")
self.tableWidget.setColumnWidth(0,200) self.tableWidget.setColumnWidth(0,200)
self.tableWidget.setColumnWidth(1,280) self.tableWidget.setColumnWidth(1,280)
@ -51,7 +52,9 @@ class MyWindow_xxdr(QWidget,Ui_Form):
def setdbname(self,string):
self.database_name = string
# print(self.database_name)
def getDirPath(self): #选取文件夹中的所有符合答题纸特征的.zip文件并放置在tableWidget中 def getDirPath(self): #选取文件夹中的所有符合答题纸特征的.zip文件并放置在tableWidget中
dirpath = QFileDialog.getExistingDirectory(self,"选择文件夹") dirpath = QFileDialog.getExistingDirectory(self,"选择文件夹")
@ -128,9 +131,11 @@ class MyWindow_xxdr(QWidget,Ui_Form):
except: except:
pass pass
makedir(self.tempdir) makedir(self.tempdir)
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
mycursor = mydb.cursor()
try: try:
xiaoxianpid = ParseZipname(zipfilepath) xiaoxianpid = ParseZipname(zipfilepath)
paperinfo = FindPaper(xiaoxianpid, self.answersheetseekingpath) paperinfo = FindPaper(xiaoxianpid, mycursor)
gradename = paperinfo[1] gradename = paperinfo[1]
idlist = paperinfo[2] idlist = paperinfo[2]
excludejson = paperinfo[4] excludejson = paperinfo[4]
@ -144,8 +149,10 @@ class MyWindow_xxdr(QWidget,Ui_Form):
dfcurrent = pd.read_excel(os.path.join(statsfilepathlist[0],self.statsfilename)) dfcurrent = pd.read_excel(os.path.join(statsfilepathlist[0],self.statsfilename))
correspondence_dict = generateIDtoUsageCorrespondence(idlist,validcols,dfcurrent.iloc[1,validcols]) correspondence_dict = generateIDtoUsageCorrespondence(idlist,validcols,dfcurrent.iloc[1,validcols])
output = CalculateUsages(statsfilepathlist,self.statsfilename,gradename,threshold,marks,correspondence_dict,validcols,date,exclude=RefineExclude(excludejson)) output = CalculateUsages(statsfilepathlist,self.statsfilename,gradename,threshold,marks,correspondence_dict,validcols,date,exclude=RefineExclude(excludejson))
mydb.close()
return output #返回由usages开始的使用记录文本 return output #返回由usages开始的使用记录文本
except: except:
mydb.close()
return 1 #无法生成就返回1 return 1 #无法生成就返回1
@ -157,7 +164,7 @@ class MyWindow_xxdr(QWidget,Ui_Form):
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication([]) app = QApplication([])
windows = MyWindow_xxdr() windows = MyWindow_xxdr("tikutest")
windows.show() windows.show()
app.exec() app.exec()

View File

@ -4,9 +4,10 @@ from database_tools_2 import *
class MyWindow_jglr(QWidget,Ui_Form): class MyWindow_jglr(QWidget,Ui_Form):
def __init__(self): def __init__(self,database_name):
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.database_name = database_name
self.bind() self.bind()
def bind(self): def bind(self):
self.label_next.setVisible(False) self.label_next.setVisible(False)
@ -14,26 +15,31 @@ class MyWindow_jglr(QWidget,Ui_Form):
self.lineEdit_structure.textChanged.connect(self.unvisible) self.lineEdit_structure.textChanged.connect(self.unvisible)
self.comboBox_grade.currentIndexChanged.connect(self.unvisible) self.comboBox_grade.currentIndexChanged.connect(self.unvisible)
self.comboBox_semester.currentIndexChanged.connect(self.unvisible) self.comboBox_semester.currentIndexChanged.connect(self.unvisible)
def setdbname(self,string):
self.database_name = string
# print(self.database_name)
def unvisible(self): def unvisible(self):
self.label_next.setVisible(False) self.label_next.setVisible(False)
def exec(self): def exec(self):
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
mycursor = mydb.cursor()
if not len(self.lineEdit_structure.text()) == 1: if not len(self.lineEdit_structure.text()) == 1:
print("首字母有误") print("首字母有误")
else: else:
self.label_next.setVisible(True) self.label_next.setVisible(True)
self.repaint() self.repaint()
self.prefix = self.lineEdit_structure.text().upper()+self.comboBox_grade.currentText()+self.comboBox_semester.currentText() self.prefix = self.lineEdit_structure.text().upper()+self.comboBox_grade.currentText()+self.comboBox_semester.currentText()
jsonfile = f"../备课组/{self.prefix[3:5]}届/校本材料.json" notes_dict = load_notes_dict_from_mariadb(mycursor)
notes_dict = load_dict(jsonfile) structure_dict = load_structures_dict_from_mariadb(mycursor)
# print(len(notes_dict)) # print(len(notes_dict))
if not self.prefix[0] in notes_dict["structures"]: if not self.prefix[0:5] in structure_dict:
AddNew = input("此类型不在列表中, 新增(A)/退出(Q):") AddNew = input("此类型不在列表中, 新增(A)/退出([Q]):")
if AddNew[0].upper() == "A": if AddNew[0].upper() == "A":
descr = input("类型描述:") descr = input("类型描述:")
cn = input("编号是否连续(T/F):") cn = input("编号是否连续(T/[F]):")
if cn[0].upper() == "T": if len(cn) > 0 and cn[0].upper() == "T":
cn = True cn = True
else: else:
cn = False cn = False
@ -46,8 +52,8 @@ class MyWindow_jglr(QWidget,Ui_Form):
for i in range(partscount): for i in range(partscount):
partid = input(f"{i+1} 部分的代号:") partid = input(f"{i+1} 部分的代号:")
partname = input(f"部分 {partid} 的名称:") partname = input(f"部分 {partid} 的名称:")
spaceflag = input(f"部分 {partid}: {partname} 中是否要在题目后留空格(T/F):") spaceflag = input(f"部分 {partid}: {partname} 中是否要在题目后留空格(T/[F]):")
if spaceflag[0].upper() == "T": if len(spaceflag) > 0 and spaceflag[0].upper() == "T":
spaceflag = True spaceflag = True
else: else:
spaceflag = False spaceflag = False
@ -55,48 +61,63 @@ class MyWindow_jglr(QWidget,Ui_Form):
"name": partname, "name": partname,
"spaceflag": spaceflag "spaceflag": spaceflag
} }
notes_dict["structures"][self.prefix[0]] = new_struct_dict.copy() sql = "INSERT INTO notestructures (initial,description,consecutivenumbering,structure) VALUES (%s,%s,%s,%s);"
save_dict(notes_dict,jsonfile) val = (self.prefix[0:5],descr,cn,json.dumps(new_struct_dict["structure"],ensure_ascii = False))
mycursor.execute(sql,val)
sql = "INSERT INTO logs (DATE,TIME,username,action,db_content) VALUE (%s,%s,%s,%s,%s);"
val = (GetDate(),GetTime(),get_git_username(),"添加新讲义结构",self.prefix[0:5])
mycursor.execute(sql,val)
mydb.commit()
else: else:
pass pass
else: else:
numberlist = [] numberlist = []
for id in notes_dict["notes"]: for existing_nid in notes_dict:
if self.prefix in id: if self.prefix in existing_nid:
numberlist.append(id[-2:]) numberlist.append(existing_nid[-2:])
print("该分类下已有材料编号: "+generate_exp(numberlist)) print("该分类下已有材料编号: "+generate_exp(numberlist))
pid = self.prefix + input("请输入新材料编号(两位数):") nid = self.prefix + input("请输入新材料编号(两位数):")
while pid in notes_dict["notes"]: while nid in notes_dict:
print("编号重复, 请重新输入.") print("编号重复, 请重新输入.")
pid = self.prefix + input("请输入新材料编号(两位数):") nid = self.prefix + input("请输入新材料编号(两位数):")
name = input("请输入材料名称:") name = input("请输入材料名称:")
filenameraw = input("生成的文件名和材料名称是否一致?([Y]/如果不一致请输入文件名):") filenameraw = input("生成的文件名和材料名称是否一致?([Y]/如果不一致请输入文件名):")
if filenameraw.upper() == "Y": if filenameraw.upper() == "Y" or len(filenameraw.strip()) == 0:
filename = name filename = name
else: else:
filename = filenameraw filename = filenameraw
new_note_dict = { new_note_dict = {
"id": pid, "nid": nid,
"name": name, "name": name,
"filename": filename "filename": filename
} }
structure = notes_dict['structures'][self.prefix[0]]['structure'] new_note_dict_structure = {}
structure = structure_dict[self.prefix[0:5]]['structure']
print(f"此类材料共有 {len(structure)} 个部分, 分别是:") print(f"此类材料共有 {len(structure)} 个部分, 分别是:")
for p in structure: for p in structure:
print(f"{p}: {structure[p]['name']}") print(f"{p}: {structure[p]['name']}")
new_note_dict[p] = [] new_note_dict_structure[p] = []
for p in structure: for p in structure:
rawdata = input(f"现在输入 {p}: {structure[p]['name']} 部分的内容编号:") rawdata = input(f"现在输入 {p}: {structure[p]['name']} 部分的内容编号:")
rawdata = RefinePunctuations(rawdata)
rawdata = re.sub(r"[^BXK\d:,]","",rawdata) rawdata = re.sub(r"[^BXK\d:,]","",rawdata)
if re.findall(r"\d",rawdata) == []: if re.findall(r"\d",rawdata) == []:
new_note_dict[p] = [] new_note_dict[p] = []
else: else:
new_note_dict[p] = generate_id_set(rawdata) new_note_dict[p] = generate_id_set(rawdata)
print(f"{p}: {new_note_dict[p]}") print(f"{p}: {new_note_dict[p]}")
notes_dict["notes"][pid] = new_note_dict.copy() temp_dict = new_note_dict.copy()
notes_dict["notes"] = SortDict(notes_dict["notes"]) for key in ["nid","name","filename"]:
save_dict(notes_dict,jsonfile) temp_dict.pop(key)
sql = "INSERT INTO notes (nid,name,filename,structure) VALUES (%s,%s,%s,%s);"
val = (nid,name,filename,json.dumps(temp_dict,ensure_ascii = False))
mycursor.execute(sql,val)
sql = "INSERT INTO logs (DATE,TIME,username,action,db_content) VALUE (%s,%s,%s,%s,%s);"
val = (GetDate(),GetTime(),get_git_username(),"添加新讲义内容",nid)
mycursor.execute(sql,val)
mydb.commit()
print("处理完成") print("处理完成")
mydb.close()
@ -105,7 +126,7 @@ class MyWindow_jglr(QWidget,Ui_Form):
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication([]) app = QApplication([])
windows = MyWindow() windows = MyWindow_jglr("tikutest")
windows.show() windows.show()
app.exec() app.exec()

View File

@ -32,7 +32,6 @@ class MyWindow_fnsc(QWidget,Ui_Form):
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name) mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
mycursor = mydb.cursor() mycursor = mydb.cursor()
pro_dict,obj_dict,bn_dict,unit_obj_dict = generateDictsfromMariaDB(mycursor) pro_dict,obj_dict,bn_dict,unit_obj_dict = generateDictsfromMariaDB(mycursor)
mydb.close()
units_list = [] units_list = []
for self.checkbox in self.findChildren(QCheckBox): for self.checkbox in self.findChildren(QCheckBox):
if self.checkbox.isChecked(): if self.checkbox.isChecked():
@ -48,7 +47,8 @@ class MyWindow_fnsc(QWidget,Ui_Form):
elif self.radioButton_median.isChecked(): elif self.radioButton_median.isChecked():
method = "median" method = "median"
sim_threshold = float(self.lineEdit_threshold.text()) sim_threshold = float(self.lineEdit_threshold.text())
excludeids = findxiaobenIDs("../备课组",grade = self.lineEdit_grade.text()) excludeids = findxiaobenIDs(mycursor,grade = self.lineEdit_grade.text())
mydb.close()
papercount = int(self.lineEdit_papercount.text()) papercount = int(self.lineEdit_papercount.text())
output = "" output = ""
for i in range(papercount): for i in range(papercount):