新增 单人讲义生成 功能并加入gui面板
This commit is contained in:
parent
4759c20103
commit
cdd7e68bdc
|
|
@ -120,6 +120,9 @@ class Ui_MainWindow(object):
|
|||
self.tab_pxnd = QWidget()
|
||||
self.tab_pxnd.setObjectName(u"tab_pxnd")
|
||||
self.tabWidget_beikezu.addTab(self.tab_pxnd, "")
|
||||
self.tab_drsc = QWidget()
|
||||
self.tab_drsc.setObjectName(u"tab_drsc")
|
||||
self.tabWidget_beikezu.addTab(self.tab_drsc, "")
|
||||
self.tabWidget_main.addTab(self.tab_beikezu, "")
|
||||
self.tab_latex = QWidget()
|
||||
self.tab_latex.setObjectName(u"tab_latex")
|
||||
|
|
@ -215,7 +218,7 @@ class Ui_MainWindow(object):
|
|||
self.tabWidget_luru.setCurrentIndex(0)
|
||||
self.tabWidget_weihu.setCurrentIndex(0)
|
||||
self.tabWidget_shiyong.setCurrentIndex(5)
|
||||
self.tabWidget_beikezu.setCurrentIndex(4)
|
||||
self.tabWidget_beikezu.setCurrentIndex(5)
|
||||
self.tabWidget_latex.setCurrentIndex(0)
|
||||
self.tabWidget_mubiaojichu.setCurrentIndex(0)
|
||||
self.tabWidget_syjl.setCurrentIndex(0)
|
||||
|
|
@ -247,6 +250,7 @@ class Ui_MainWindow(object):
|
|||
self.tabWidget_beikezu.setTabText(self.tabWidget_beikezu.indexOf(self.tab_jysc), QCoreApplication.translate("MainWindow", u"\u7cfb\u5217\u8bb2\u4e49\u751f\u6210", None))
|
||||
self.tabWidget_beikezu.setTabText(self.tabWidget_beikezu.indexOf(self.tab_fnsc), QCoreApplication.translate("MainWindow", u"\u8d4b\u80fd\u5377\u751f\u6210", None))
|
||||
self.tabWidget_beikezu.setTabText(self.tabWidget_beikezu.indexOf(self.tab_pxnd), QCoreApplication.translate("MainWindow", u"\u96be\u5ea6\u6392\u5e8f", None))
|
||||
self.tabWidget_beikezu.setTabText(self.tabWidget_beikezu.indexOf(self.tab_drsc), QCoreApplication.translate("MainWindow", u"\u5355\u4eba\u8bb2\u4e49\u751f\u6210", None))
|
||||
self.tabWidget_main.setTabText(self.tabWidget_main.indexOf(self.tab_beikezu), QCoreApplication.translate("MainWindow", u"\u5907\u8bfe\u7ec4", None))
|
||||
self.tabWidget_latex.setTabText(self.tabWidget_latex.indexOf(self.tab_wbzh), QCoreApplication.translate("MainWindow", u"\u6587\u672c\u8f6c\u6362\u5904\u7406", None))
|
||||
self.tabWidget_latex.setTabText(self.tabWidget_latex.indexOf(self.tab_hist), QCoreApplication.translate("MainWindow", u"\u76f4\u65b9\u56fe\u4ee3\u7801\u751f\u6210", None))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,192 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
################################################################################
|
||||
## Form generated from reading UI file '单人讲义生成.ui'
|
||||
##
|
||||
## Created by: Qt User Interface Compiler version 6.6.2
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
################################################################################
|
||||
|
||||
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||
QMetaObject, QObject, QPoint, QRect,
|
||||
QSize, QTime, QUrl, Qt)
|
||||
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QFont, QFontDatabase, QGradient, QIcon,
|
||||
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QApplication, QCheckBox, QLabel, QLineEdit,
|
||||
QPushButton, QRadioButton, QSizePolicy, QVBoxLayout,
|
||||
QWidget)
|
||||
|
||||
class Ui_Form(object):
|
||||
def setupUi(self, Form):
|
||||
if not Form.objectName():
|
||||
Form.setObjectName(u"Form")
|
||||
Form.resize(760, 490)
|
||||
self.lineEdit_regex = QLineEdit(Form)
|
||||
self.lineEdit_regex.setObjectName(u"lineEdit_regex")
|
||||
self.lineEdit_regex.setGeometry(QRect(120, 60, 431, 20))
|
||||
self.label = QLabel(Form)
|
||||
self.label.setObjectName(u"label")
|
||||
self.label.setGeometry(QRect(30, 60, 91, 16))
|
||||
self.label_2 = QLabel(Form)
|
||||
self.label_2.setObjectName(u"label_2")
|
||||
self.label_2.setGeometry(QRect(570, 60, 171, 16))
|
||||
self.pushButton_exec = QPushButton(Form)
|
||||
self.pushButton_exec.setObjectName(u"pushButton_exec")
|
||||
self.pushButton_exec.setGeometry(QRect(510, 310, 221, 131))
|
||||
font = QFont()
|
||||
font.setBold(True)
|
||||
self.pushButton_exec.setFont(font)
|
||||
self.label_3 = QLabel(Form)
|
||||
self.label_3.setObjectName(u"label_3")
|
||||
self.label_3.setGeometry(QRect(30, 90, 61, 16))
|
||||
self.lineEdit_path = QLineEdit(Form)
|
||||
self.lineEdit_path.setObjectName(u"lineEdit_path")
|
||||
self.lineEdit_path.setGeometry(QRect(30, 110, 701, 20))
|
||||
self.pushButton_SelectPath = QPushButton(Form)
|
||||
self.pushButton_SelectPath.setObjectName(u"pushButton_SelectPath")
|
||||
self.pushButton_SelectPath.setGeometry(QRect(660, 80, 75, 24))
|
||||
self.verticalLayoutWidget = QWidget(Form)
|
||||
self.verticalLayoutWidget.setObjectName(u"verticalLayoutWidget")
|
||||
self.verticalLayoutWidget.setGeometry(QRect(30, 170, 81, 111))
|
||||
self.verticalLayout = QVBoxLayout(self.verticalLayoutWidget)
|
||||
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.label_4 = QLabel(self.verticalLayoutWidget)
|
||||
self.label_4.setObjectName(u"label_4")
|
||||
self.label_4.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignVCenter)
|
||||
|
||||
self.verticalLayout.addWidget(self.label_4)
|
||||
|
||||
self.radioButton_student = QRadioButton(self.verticalLayoutWidget)
|
||||
self.radioButton_student.setObjectName(u"radioButton_student")
|
||||
self.radioButton_student.setChecked(True)
|
||||
|
||||
self.verticalLayout.addWidget(self.radioButton_student)
|
||||
|
||||
self.radioButton_teacher = QRadioButton(self.verticalLayoutWidget)
|
||||
self.radioButton_teacher.setObjectName(u"radioButton_teacher")
|
||||
|
||||
self.verticalLayout.addWidget(self.radioButton_teacher)
|
||||
|
||||
self.verticalLayoutWidget_2 = QWidget(Form)
|
||||
self.verticalLayoutWidget_2.setObjectName(u"verticalLayoutWidget_2")
|
||||
self.verticalLayoutWidget_2.setGeometry(QRect(250, 170, 151, 271))
|
||||
self.verticalLayout_2 = QVBoxLayout(self.verticalLayoutWidget_2)
|
||||
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
|
||||
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
|
||||
self.label_5 = QLabel(self.verticalLayoutWidget_2)
|
||||
self.label_5.setObjectName(u"label_5")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.label_5)
|
||||
|
||||
self.checkBox_space = QCheckBox(self.verticalLayoutWidget_2)
|
||||
self.checkBox_space.setObjectName(u"checkBox_space")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.checkBox_space)
|
||||
|
||||
self.checkBox_ans = QCheckBox(self.verticalLayoutWidget_2)
|
||||
self.checkBox_ans.setObjectName(u"checkBox_ans")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.checkBox_ans)
|
||||
|
||||
self.checkBox_objs = QCheckBox(self.verticalLayoutWidget_2)
|
||||
self.checkBox_objs.setObjectName(u"checkBox_objs")
|
||||
self.checkBox_objs.setCheckable(True)
|
||||
self.checkBox_objs.setTristate(False)
|
||||
|
||||
self.verticalLayout_2.addWidget(self.checkBox_objs)
|
||||
|
||||
self.checkBox_tags = QCheckBox(self.verticalLayoutWidget_2)
|
||||
self.checkBox_tags.setObjectName(u"checkBox_tags")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.checkBox_tags)
|
||||
|
||||
self.checkBox_solution = QCheckBox(self.verticalLayoutWidget_2)
|
||||
self.checkBox_solution.setObjectName(u"checkBox_solution")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.checkBox_solution)
|
||||
|
||||
self.checkBox_usages = QCheckBox(self.verticalLayoutWidget_2)
|
||||
self.checkBox_usages.setObjectName(u"checkBox_usages")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.checkBox_usages)
|
||||
|
||||
self.checkBox_origin = QCheckBox(self.verticalLayoutWidget_2)
|
||||
self.checkBox_origin.setObjectName(u"checkBox_origin")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.checkBox_origin)
|
||||
|
||||
self.checkBox_remark = QCheckBox(self.verticalLayoutWidget_2)
|
||||
self.checkBox_remark.setObjectName(u"checkBox_remark")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.checkBox_remark)
|
||||
|
||||
self.verticalLayoutWidget_4 = QWidget(Form)
|
||||
self.verticalLayoutWidget_4.setObjectName(u"verticalLayoutWidget_4")
|
||||
self.verticalLayoutWidget_4.setGeometry(QRect(30, 300, 81, 141))
|
||||
self.verticalLayout_3 = QVBoxLayout(self.verticalLayoutWidget_4)
|
||||
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
|
||||
self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
|
||||
self.label_8 = QLabel(self.verticalLayoutWidget_4)
|
||||
self.label_8.setObjectName(u"label_8")
|
||||
|
||||
self.verticalLayout_3.addWidget(self.label_8)
|
||||
|
||||
self.checkBox_singlenote = QCheckBox(self.verticalLayoutWidget_4)
|
||||
self.checkBox_singlenote.setObjectName(u"checkBox_singlenote")
|
||||
|
||||
self.verticalLayout_3.addWidget(self.checkBox_singlenote)
|
||||
|
||||
self.checkBox_seriesnote = QCheckBox(self.verticalLayoutWidget_4)
|
||||
self.checkBox_seriesnote.setObjectName(u"checkBox_seriesnote")
|
||||
self.checkBox_seriesnote.setChecked(True)
|
||||
|
||||
self.verticalLayout_3.addWidget(self.checkBox_seriesnote)
|
||||
|
||||
self.lineEdit_account = QLineEdit(Form)
|
||||
self.lineEdit_account.setObjectName(u"lineEdit_account")
|
||||
self.lineEdit_account.setGeometry(QRect(510, 190, 221, 20))
|
||||
self.label_6 = QLabel(Form)
|
||||
self.label_6.setObjectName(u"label_6")
|
||||
self.label_6.setGeometry(QRect(510, 170, 61, 16))
|
||||
self.label_7 = QLabel(Form)
|
||||
self.label_7.setObjectName(u"label_7")
|
||||
self.label_7.setGeometry(QRect(510, 240, 61, 16))
|
||||
self.lineEdit_class = QLineEdit(Form)
|
||||
self.lineEdit_class.setObjectName(u"lineEdit_class")
|
||||
self.lineEdit_class.setGeometry(QRect(510, 260, 221, 20))
|
||||
|
||||
self.retranslateUi(Form)
|
||||
|
||||
QMetaObject.connectSlotsByName(Form)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, Form):
|
||||
Form.setWindowTitle(QCoreApplication.translate("Form", u"\u7cfb\u5217\u8bb2\u4e49\u751f\u6210", None))
|
||||
self.label.setText(QCoreApplication.translate("Form", u"\u8bb2\u4e49\u7f16\u53f7\u8868\u8fbe\u5f0f", None))
|
||||
self.label_2.setText(QCoreApplication.translate("Form", u"\u7528 \",\" \u5206\u9694\u7684\u4e00\u7cfb\u5217\u6b63\u5219\u8868\u8fbe\u5f0f", None))
|
||||
self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u5f00\u59cb\u751f\u6210\u4e0e\u7f16\u8bd1", None))
|
||||
self.label_3.setText(QCoreApplication.translate("Form", u"\u6587\u4ef6\u8def\u5f84", None))
|
||||
self.pushButton_SelectPath.setText(QCoreApplication.translate("Form", u"\u9009\u62e9\u8def\u5f84", None))
|
||||
self.label_4.setText(QCoreApplication.translate("Form", u"\u7248\u5f0f\u9009\u62e9", None))
|
||||
self.radioButton_student.setText(QCoreApplication.translate("Form", u"\u5b66\u751f\u7248", None))
|
||||
self.radioButton_teacher.setText(QCoreApplication.translate("Form", u"\u6559\u5e08\u7248", None))
|
||||
self.label_5.setText(QCoreApplication.translate("Form", u"\u5185\u5bb9\u9009\u9879", None))
|
||||
self.checkBox_space.setText(QCoreApplication.translate("Form", u"\u9898\u540e\u7a7a\u95f4", None))
|
||||
self.checkBox_ans.setText(QCoreApplication.translate("Form", u"\u7b54\u6848", None))
|
||||
self.checkBox_objs.setText(QCoreApplication.translate("Form", u"\u8bfe\u65f6\u76ee\u6807", None))
|
||||
self.checkBox_tags.setText(QCoreApplication.translate("Form", u"\u9898\u76ee\u6807\u7b7e", None))
|
||||
self.checkBox_solution.setText(QCoreApplication.translate("Form", u"\u89e3\u7b54\u4e0e\u63d0\u793a", None))
|
||||
self.checkBox_usages.setText(QCoreApplication.translate("Form", u"\u4f7f\u7528\u8bb0\u5f55", None))
|
||||
self.checkBox_origin.setText(QCoreApplication.translate("Form", u"\u6765\u6e90", None))
|
||||
self.checkBox_remark.setText(QCoreApplication.translate("Form", u"\u5907\u6ce8", None))
|
||||
self.label_8.setText(QCoreApplication.translate("Form", u"\u7f16\u8bd1\u9009\u9879", None))
|
||||
self.checkBox_singlenote.setText(QCoreApplication.translate("Form", u"\u5355\u5f20\u7f16\u8bd1", None))
|
||||
self.checkBox_seriesnote.setText(QCoreApplication.translate("Form", u"\u5408\u96c6\u7f16\u8bd1", None))
|
||||
self.label_6.setText(QCoreApplication.translate("Form", u"\u5c0f\u95f2\u8d26\u53f7", None))
|
||||
self.label_7.setText(QCoreApplication.translate("Form", u"\u5bf9\u7167\u73ed\u7ea7", None))
|
||||
# retranslateUi
|
||||
|
||||
|
|
@ -1785,7 +1785,7 @@ def generateDictsfromMariaDB(mycursor):
|
|||
bn_dict[ret[0]]["objs"].append(ret[1])
|
||||
return pro_dict,obj_dict,bn_dict,unit_obj_dict
|
||||
|
||||
def generateLaTeXBodyContentFromDict(id,adict,objdict,misc): #根据id,读取的json内容adict,和字典misc来生成讲义
|
||||
def generateLaTeXBodyContentFromDict(id,adict,objdict,misc,studentid = "",usagedetaillist = []): #根据id,读取的json内容adict,和字典misc来生成讲义
|
||||
#misc 样例
|
||||
#{
|
||||
# "教师版": True, #如果设置为True则除了 题后空间 之外都进行判断并处理, 否则只处理 题后空间 和 答案
|
||||
|
|
@ -1835,6 +1835,12 @@ def generateLaTeXBodyContentFromDict(id,adict,objdict,misc): #根据id,读取的
|
|||
if "使用记录" in misc["字段显示设置"] and type(misc["字段显示设置"]["使用记录"]) in (list,tuple) and not -2 in misc["字段显示设置"]["使用记录"]:
|
||||
usages = f"\n\n使用记录:\n\n{GenerateUsageTexCodeFromDict(id,adict,misc['字段显示设置']['使用记录'])}\n\n"
|
||||
output += usages
|
||||
if not studentid == "":
|
||||
usages = [u for u in usagedetaillist if u[0] == id]
|
||||
if len(usages) >= 1:
|
||||
output += "个人记录:\n\n"
|
||||
for u in usages:
|
||||
output += f"{Polishusagedetail(u)}\n\n"
|
||||
if "来源" in misc["字段显示设置"] and misc["字段显示设置"]["来源"] == True:
|
||||
origin = generate_origin(adict[id]["origin"]) if len(adict[id]["origin"]) > 0 else "未记录来源"
|
||||
output += f"\n\n来源: {origin}\n\n"
|
||||
|
|
@ -2496,7 +2502,7 @@ def select_grade_from_pro_dict(prodict,grades):
|
|||
adict[id]["usages"] = new_usages.copy()
|
||||
return adict
|
||||
|
||||
def GenerateSectionBodyStringfromDict(problems,sectiontitles,prodict,objdict,bndict,misc,consecutivenumbering):
|
||||
def GenerateSectionBodyStringfromDict(problems,sectiontitles,prodict,objdict,bndict,misc,consecutivenumbering,studentid="",usagedetaillist=[]):
|
||||
bodystring = ""
|
||||
count = 0
|
||||
for i in range(len(problems)):
|
||||
|
|
@ -2505,7 +2511,7 @@ def GenerateSectionBodyStringfromDict(problems,sectiontitles,prodict,objdict,bnd
|
|||
sectionstring = f"\\section{{{sectiontitles[i]}}}\n\\begin{{enumerate}}\n\\setcounter{{enumi}}{{{count if consecutivenumbering else 0}}}\n\n"
|
||||
for id in idlist:
|
||||
count += 1
|
||||
sectionstring += generateLaTeXBodyContentFromDict(id,prodict,objdict,misc)
|
||||
sectionstring += generateLaTeXBodyContentFromDict(id,prodict,objdict,misc,studentid,usagedetaillist)
|
||||
sectionstring += "\\end{enumerate}\n\n"
|
||||
bodystring += sectionstring
|
||||
if problems[i][0] == "K":
|
||||
|
|
@ -2524,7 +2530,7 @@ def GenerateSectionBodyStringfromDict(problems,sectiontitles,prodict,objdict,bnd
|
|||
bodystring += sectionstring
|
||||
return bodystring #返回主题内容字符串
|
||||
|
||||
def GenerateSingleLessonTeXfromDict(id,structuredict,notesdict,pro_dict,obj_dict,bn_dict,misc,consecutivenumbering=False):
|
||||
def GenerateSingleLessonTeXfromDict(id,structuredict,notesdict,pro_dict,obj_dict,bn_dict,misc,consecutivenumbering=False,studentid = "",usagedetaillist = []):
|
||||
structure = structuredict[id[0:5].upper()]["structure"]
|
||||
note_contents = notesdict[id]
|
||||
sections_list = []
|
||||
|
|
@ -2533,7 +2539,7 @@ def GenerateSingleLessonTeXfromDict(id,structuredict,notesdict,pro_dict,obj_dict
|
|||
if not len(note_contents[key]) == 0:
|
||||
sections_list.append(structure[key]["name"])
|
||||
problems_list.append(",".join(note_contents[key]))
|
||||
rawoutput = GenerateSectionBodyStringfromDict(problems=problems_list,sectiontitles=sections_list,prodict=pro_dict,objdict=obj_dict,bndict=bn_dict,misc=misc,consecutivenumbering= consecutivenumbering)
|
||||
rawoutput = GenerateSectionBodyStringfromDict(problems=problems_list,sectiontitles=sections_list,prodict=pro_dict,objdict=obj_dict,bndict=bn_dict,misc=misc,consecutivenumbering= consecutivenumbering,studentid = studentid,usagedetaillist=usagedetaillist)
|
||||
if len(sections_list) == 1:
|
||||
rawoutput = re.sub(r"\\section\{[^\n]*","",rawoutput)
|
||||
return rawoutput
|
||||
|
|
@ -3400,5 +3406,18 @@ def load_answersheets_dict_from_mariadb(cursor): # 从mariadb获取答题纸列
|
|||
answersheet_dict[pid][key] = item
|
||||
return answersheet_dict
|
||||
|
||||
|
||||
def generateusagedetail(cursor,studentid): # 从mariadb获取某个学号的学生的全部答题记录
|
||||
sql = "SELECT ID,date,studentname,diff FROM usagedetail WHERE studentid = %s AND NOT obsolete;"
|
||||
val = (studentid,)
|
||||
cursor.execute(sql,val)
|
||||
ret = cursor.fetchall()
|
||||
return ret
|
||||
|
||||
def Polishusagedetail(udtuple):
|
||||
output = f"{udtuple[1]}\t{udtuple[2]}\t"
|
||||
output += re.sub("[\\t]([\d]\.[\d]{0,10})",GenerateValueColorCode,"\t"+"\t".join(json.loads(udtuple[3])))
|
||||
return output
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("数据库工具, import用.")
|
||||
|
|
@ -32,6 +32,7 @@ from 新增目标关系 import MyWindow_xzgx
|
|||
from 试卷列表 import MyWindow_sjlb
|
||||
from 赋能卷生成 import MyWindow_fnsc
|
||||
from 排序材料内难度 import MyWindow_pxnd
|
||||
from 单人讲义生成 import MyWindow_drsc
|
||||
from database_tools_2 import *
|
||||
|
||||
class MyWindow(QMainWindow,Ui_MainWindow):
|
||||
|
|
@ -172,6 +173,10 @@ class MyWindow(QMainWindow,Ui_MainWindow):
|
|||
self.pxnd = MyWindow_pxnd(self.database)
|
||||
self.layout_pxnd.addWidget(self.pxnd) #以上三行为初始化"难度排序"tab
|
||||
|
||||
self.layout_drsc = QVBoxLayout(self.tab_drsc)
|
||||
self.drsc = MyWindow_drsc(self.database)
|
||||
self.layout_drsc.addWidget(self.drsc)
|
||||
|
||||
|
||||
for func in [
|
||||
self.kxth.setdbname,
|
||||
|
|
@ -198,7 +203,8 @@ class MyWindow(QMainWindow,Ui_MainWindow):
|
|||
self.pxnd.setdbname,
|
||||
self.xxdr.setdbname,
|
||||
self.jglr.setdbname,
|
||||
self.dtlr.setdbname
|
||||
self.dtlr.setdbname,
|
||||
self.drsc.setdbname
|
||||
]: #在列表中的tab里传送数据库名的连接
|
||||
self.sendDBname.connect(func)
|
||||
def sendValue(self):
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@
|
|||
<enum>QTabWidget::Triangular</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_jglr">
|
||||
<attribute name="title">
|
||||
|
|
@ -219,6 +219,11 @@
|
|||
<string>难度排序</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_drsc">
|
||||
<attribute name="title">
|
||||
<string>单人讲义生成</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_latex">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,176 @@
|
|||
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
|
||||
from Ui_单人讲义生成 import Ui_Form
|
||||
from database_tools_2 import *
|
||||
import os
|
||||
|
||||
class MyWindow_drsc(QWidget,Ui_Form):
|
||||
def __init__(self,database_name):
|
||||
super().__init__()
|
||||
self.database_name = database_name
|
||||
self.setupUi(self)
|
||||
self.bind()
|
||||
|
||||
def bind(self):
|
||||
self.outputpath = os.path.join(os.getcwd(),"临时文件")
|
||||
self.lineEdit_path.setText(self.outputpath)
|
||||
self.TeachersCheckBoxList = [self.checkBox_ans,self.checkBox_objs,self.checkBox_tags,self.checkBox_solution,self.checkBox_usages,self.checkBox_origin,self.checkBox_remark]
|
||||
self.StudentsCheckBoxList = [self.checkBox_space,self.checkBox_ans]
|
||||
self.ContnetCheckBoxList = [self.checkBox_ans,self.checkBox_objs,self.checkBox_tags,self.checkBox_solution,self.checkBox_usages,self.checkBox_origin,self.checkBox_remark,self.checkBox_space]
|
||||
for widget in self.ContnetCheckBoxList:
|
||||
widget.setDisabled(True)
|
||||
self.studentlayout()
|
||||
# self.disableusagessetting()
|
||||
self.radioButton_teacher.clicked.connect(self.teacherlayout)
|
||||
self.radioButton_student.clicked.connect(self.studentlayout)
|
||||
# self.checkBox_usages.clicked.connect(self.toggleusagessetting)
|
||||
# self.radioButton_student.clicked.connect(self.toggleusagessetting)
|
||||
# self.radioButton_teacher.clicked.connect(self.toggleusagessetting)
|
||||
self.pushButton_exec.clicked.connect(self.saveandbuild)
|
||||
self.pushButton_SelectPath.clicked.connect(self.selectpath)
|
||||
|
||||
|
||||
|
||||
# def disableusagessetting(self):
|
||||
# self.lineEdit_high.setDisabled(True)
|
||||
# self.lineEdit_low.setDisabled(True)
|
||||
# self.lineEdit_grades.setDisabled(True)
|
||||
# def enableusagessetting(self):
|
||||
# self.lineEdit_high.setEnabled(True)
|
||||
# self.lineEdit_low.setEnabled(True)
|
||||
# self.lineEdit_grades.setEnabled(True)
|
||||
# def toggleusagessetting(self):
|
||||
# if self.checkBox_usages.isChecked() and self.radioButton_teacher.isChecked():
|
||||
# self.enableusagessetting()
|
||||
# else:
|
||||
# self.disableusagessetting()
|
||||
|
||||
def studentlayout(self):
|
||||
for widget in self.TeachersCheckBoxList:
|
||||
widget.setDisabled(True)
|
||||
for widget in self.StudentsCheckBoxList:
|
||||
widget.setEnabled(True)
|
||||
|
||||
def selectpath(self):
|
||||
self.outputpath = QFileDialog.getExistingDirectory(None, "选择文件夹")
|
||||
self.lineEdit_path.setText(self.outputpath)
|
||||
|
||||
def teacherlayout(self):
|
||||
for widget in self.StudentsCheckBoxList:
|
||||
widget.setDisabled(True)
|
||||
for widget in self.TeachersCheckBoxList:
|
||||
widget.setEnabled(True)
|
||||
def generate_usages(self):
|
||||
return [-1,-1]
|
||||
|
||||
def setdbname(self,string):
|
||||
self.database_name = string
|
||||
# print(self.database_name)
|
||||
|
||||
def saveandbuild(self):
|
||||
patterns = self.lineEdit_regex.text().strip().split(",")
|
||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
|
||||
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)
|
||||
if self.radioButton_teacher.isChecked() and self.checkBox_usages.isChecked() and not self.lineEdit_class.text().strip() == "":
|
||||
grades = self.lineEdit_class.text().strip().split(",")
|
||||
else:
|
||||
grades = []
|
||||
pro_dict = select_grade_from_pro_dict(raw_pro_dict,grades)
|
||||
# dictionaries = {} #合并字典
|
||||
# for t in (obj_dict,basicknowledge_dict,pro_dict):
|
||||
# dictionaries.update(t)
|
||||
configjson = {
|
||||
"教师版": self.radioButton_teacher.isChecked(),
|
||||
"字段显示设置": {
|
||||
"题后空间": self.checkBox_space.isChecked(),
|
||||
"课时目标": self.checkBox_objs.isChecked(),
|
||||
"题目标签": self.checkBox_tags.isChecked(),
|
||||
"答案": self.checkBox_ans.isChecked(),
|
||||
"解答与提示": self.checkBox_solution.isChecked(),
|
||||
"使用记录": self.generate_usages(),
|
||||
"来源": self.checkBox_origin.isChecked(),
|
||||
"备注": self.checkBox_remark.isChecked(),
|
||||
"届别": grades
|
||||
},
|
||||
"编译单个文件": self.checkBox_singlenote.isChecked(),
|
||||
"编译合集": self.checkBox_seriesnote.isChecked()
|
||||
}
|
||||
papernames = []
|
||||
multitexdata = []
|
||||
for lessonid in sorted(notes_dict.keys()):
|
||||
coincideflag = False
|
||||
for lessonpattern in patterns:
|
||||
if re.findall(lessonpattern,lessonid) != []:
|
||||
coincideflag = True
|
||||
break
|
||||
if coincideflag:
|
||||
print(f"正在生成 {lessonid} {notes_dict[lessonid]['filename']} 的 .tex 文件")
|
||||
filename = notes_dict[lessonid]["id"]+notes_dict[lessonid]["filename"]+".tex"
|
||||
papertype = lessonid[0:5]
|
||||
consecutivenumbering = structures_dict[papertype]["consecutivenumbering"]
|
||||
studentid = self.lineEdit_account.text()
|
||||
usagedetails = generateusagedetail(mycursor,studentid)
|
||||
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,studentid = studentid,usagedetaillist = usagedetails)
|
||||
if notes_dict[lessonid]["remarks"] != "":
|
||||
texdata += f"\n\n\\newpage\n\n\\section{{备注}}\n\n{notes_dict[lessonid]['remarks']}\n\n"
|
||||
papernames.append(notes_dict[lessonid]["id"]+" \\ "+notes_dict[lessonid]["name"])
|
||||
print(f"已生成 {papernames[-1]} 文件")
|
||||
multitexdata.append(texdata)
|
||||
latex_raw = ReadTextFile("./模板文件/讲义模板.txt")
|
||||
latex_raw = latex_raw.replace(r"学号\blank{50} \ 姓名\blank{80}","上海市控江中学") #替换掉模板中的姓名学号
|
||||
|
||||
if sys.platform == "darwin": #非win系统用默认字体
|
||||
latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",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
|
||||
outputfilepath = os.path.join(self.outputpath,filename)
|
||||
SaveTextFile(latex_data,outputfilepath) #保存.tex文件
|
||||
|
||||
if configjson["编译单个文件"] == True:
|
||||
outputdir,filename = os.path.split(outputfilepath)
|
||||
print(f"{filename}编译中...")
|
||||
if XeLaTeXCompile(outputdir,filename):
|
||||
print("编译成功")
|
||||
else:
|
||||
print("编译失败")
|
||||
# print(lessonid)
|
||||
# print(configjson)
|
||||
# print("\n".join(patterns))
|
||||
mydb.close()
|
||||
merged = ""
|
||||
for i in range(len(papernames)):
|
||||
merged += "\n\n\\chapter{"+papernames[i]+"}\n\n\n"
|
||||
merged += multitexdata[i]
|
||||
|
||||
print("已生成合集的 .tex 文件")
|
||||
|
||||
mergedtext = StringSubstitute(r"<<待替换[\d]+>>",ReadTextFile("./模板文件/合集模板.txt"),[merged])
|
||||
if sys.platform != "win32":
|
||||
mergedtext = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",mergedtext)
|
||||
mergedtext = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",mergedtext)
|
||||
SaveTextFile(mergedtext,os.path.join(self.outputpath,f"合集{GetDate()}.tex"))
|
||||
|
||||
# if not "编译合集" in configjson or configjson["编译合集"] == False:
|
||||
# tocompile = input("需要编译合集吗?(Y/[N]):")
|
||||
if configjson["编译合集"] == True:
|
||||
XeLaTeXCompile(self.outputpath,f"合集{GetDate()}.tex")
|
||||
print("合集编译完成")
|
||||
print("执行完毕.")
|
||||
startfile(self.outputpath)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication([])
|
||||
windows = MyWindow_drsc("tikutest")
|
||||
windows.show()
|
||||
app.exec()
|
||||
|
||||
|
|
@ -0,0 +1,311 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>760</width>
|
||||
<height>490</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>系列讲义生成</string>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="lineEdit_regex">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>60</y>
|
||||
<width>431</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>讲义编号表达式</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>570</x>
|
||||
<y>60</y>
|
||||
<width>171</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>用 "," 分隔的一系列正则表达式</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_exec">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>510</x>
|
||||
<y>310</y>
|
||||
<width>221</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>开始生成与编译</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>90</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>文件路径</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_path">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>110</y>
|
||||
<width>701</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_SelectPath">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>660</x>
|
||||
<y>80</y>
|
||||
<width>75</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>选择路径</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>170</y>
|
||||
<width>81</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>版式选择</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_student">
|
||||
<property name="text">
|
||||
<string>学生版</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_teacher">
|
||||
<property name="text">
|
||||
<string>教师版</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>170</y>
|
||||
<width>151</width>
|
||||
<height>271</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>内容选项</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_space">
|
||||
<property name="text">
|
||||
<string>题后空间</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_ans">
|
||||
<property name="text">
|
||||
<string>答案</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_objs">
|
||||
<property name="text">
|
||||
<string>课时目标</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_tags">
|
||||
<property name="text">
|
||||
<string>题目标签</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_solution">
|
||||
<property name="text">
|
||||
<string>解答与提示</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_usages">
|
||||
<property name="text">
|
||||
<string>使用记录</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_origin">
|
||||
<property name="text">
|
||||
<string>来源</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_remark">
|
||||
<property name="text">
|
||||
<string>备注</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>300</y>
|
||||
<width>81</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>编译选项</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_singlenote">
|
||||
<property name="text">
|
||||
<string>单张编译</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_seriesnote">
|
||||
<property name="text">
|
||||
<string>合集编译</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_account">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>510</x>
|
||||
<y>190</y>
|
||||
<width>221</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>510</x>
|
||||
<y>170</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>小闲账号</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>510</x>
|
||||
<y>240</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>对照班级</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_class">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>510</x>
|
||||
<y>260</y>
|
||||
<width>221</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue