排序材料内难度 开发中

This commit is contained in:
wangweiye7840 2024-05-10 17:22:11 +08:00
parent 9d63eaca68
commit b379805e13
3 changed files with 254 additions and 0 deletions

View File

@ -0,0 +1,62 @@
# -*- 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, QLabel, QLineEdit, QPlainTextEdit,
QPushButton, QSizePolicy, QTextBrowser, QWidget)
class Ui_Form(object):
def setupUi(self, Form):
if not Form.objectName():
Form.setObjectName(u"Form")
Form.resize(758, 479)
self.pushButton_selectfilepath = QPushButton(Form)
self.pushButton_selectfilepath.setObjectName(u"pushButton_selectfilepath")
self.pushButton_selectfilepath.setGeometry(QRect(20, 20, 91, 24))
self.lineEdit_filepath = QLineEdit(Form)
self.lineEdit_filepath.setObjectName(u"lineEdit_filepath")
self.lineEdit_filepath.setGeometry(QRect(20, 50, 341, 20))
self.textBrowser_result = QTextBrowser(Form)
self.textBrowser_result.setObjectName(u"textBrowser_result")
self.textBrowser_result.setGeometry(QRect(380, 80, 361, 381))
self.pushButton_exec = QPushButton(Form)
self.pushButton_exec.setObjectName(u"pushButton_exec")
self.pushButton_exec.setGeometry(QRect(510, 20, 231, 51))
font = QFont()
font.setBold(True)
self.pushButton_exec.setFont(font)
self.label = QLabel(Form)
self.label.setObjectName(u"label")
self.label.setGeometry(QRect(380, 30, 141, 16))
self.lineEdit_classregex = QLineEdit(Form)
self.lineEdit_classregex.setObjectName(u"lineEdit_classregex")
self.lineEdit_classregex.setGeometry(QRect(380, 50, 113, 20))
self.plainTextEdit_idexp = QPlainTextEdit(Form)
self.plainTextEdit_idexp.setObjectName(u"plainTextEdit_idexp")
self.plainTextEdit_idexp.setGeometry(QRect(20, 80, 341, 381))
self.retranslateUi(Form)
QMetaObject.connectSlotsByName(Form)
# setupUi
def retranslateUi(self, Form):
Form.setWindowTitle(QCoreApplication.translate("Form", u"\u6392\u5e8f\u6750\u6599\u5185\u96be\u5ea6", None))
self.pushButton_selectfilepath.setText(QCoreApplication.translate("Form", u"TeX\u6587\u4ef6\u8def\u5f84", None))
self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u6392\u5e8f\u96be\u5ea6\u6570\u636e", None))
self.label.setText(QCoreApplication.translate("Form", u"\u5c4a\u522b(\u73ed\u7ea7)regex", None))
# retranslateUi

View File

@ -0,0 +1,89 @@
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
from Ui_排序材料内难度 import Ui_Form
from database_tools_2 import *
class MyWindow_pxnd(QWidget,Ui_Form):
def __init__(self,database_name):
super().__init__()
self.database_name = database_name
self.setupUi(self)
self.bind()
def setdbname(self,string):
self.database_name = string
# print(self.database_name)
def bind(self):
self.pushButton_selectfilepath.clicked.connect(self.choosefile)
self.pushButton_exec.clicked.connect(self.exec)
self.lineEdit_filepath.setText(r"C:\Users\wangweiye\Documents\wwy sync\26届\高一第二学期\周末卷\W20260207高一下学期周末卷07.tex") # to remove
self.lineEdit_classregex.setText(r"2026届高一1\d班") # to remove
def choosefile(self):
self.texfile = QFileDialog.getOpenFileName(self,"选择.tex文件",os.getcwd(),".tex文件(*.tex);;所有文件(*)")[0]
self.lineEdit_filepath.setText(self.texfile)
def exec(self):
# self.latex_data = ReadTextFile(self.lineEdit_filepath.text())
self.raw_idlist = ExportIDList(self.lineEdit_filepath.text())
self.raw_parts_and_idlist = ExtractIDList(self.lineEdit_filepath.text())
self.raw_idparts = {}
part_ind = 0
for index,id in self.raw_parts_and_idlist:
if index == 1:
part_ind += 1
self.raw_idparts[f"{part_ind}部分"] = {}
self.raw_idparts[f"{part_ind}部分"][index] = id
print(self.raw_idparts)
outputleft = f"原来材料各板块的题号:\n{self.raw_idlist}"
mydb = connect(hostname = db_host, port = db_port, username = db_user, pwd = db_pwd, db = self.database_name)
mycursor = mydb.cursor()
pro_dict,obj_dict,bn_dict,unit_obj_dict = generateDictsfromMariaDB(mycursor)
mydb.close()
classregex = self.lineEdit_classregex.text()
for id in tqdm.tqdm(pro_dict, desc = "筛选有效使用记录中:"):
pro_dict[id]["usages"] = [u for u in pro_dict[id]["usages"] if re.findall(classregex,u) != []]
diff_dict = generate_diff_dict(pro_dict)
outputright = "各题难度中位数(-1表示无记录):\n"
for part in self.raw_idparts:
outputright += f" {part}:\n"
tk_dict = {}
xz_dict = {}
jd_dict = {}
count = 0
for ind in self.raw_idparts[part]:
count += 1
id = self.raw_idparts[part][ind]
outputright += f" {count} {id} ({pro_dict[id]['genre']}): {diff_dict[id]['median']:.3f}\n"
if pro_dict[id]["genre"] == "填空题":
tk_dict[id] = diff_dict[id]
elif pro_dict[id]["genre"] == "选择题":
xz_dict[id] = diff_dict[id]
elif pro_dict[id]["genre"] == "解答题":
jd_dict[id] = diff_dict[id]
# print(tk_list,xz_list,jd_list)
self.textBrowser_result.setText(outputright)
self.plainTextEdit_idexp.setPlainText(outputleft)
if __name__ == '__main__':
app = QApplication([])
windows = MyWindow_pxnd("tikutest")
windows.show()
app.exec()

View File

@ -0,0 +1,103 @@
<?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>758</width>
<height>479</height>
</rect>
</property>
<property name="windowTitle">
<string>排序材料内难度</string>
</property>
<widget class="QPushButton" name="pushButton_selectfilepath">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>91</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>TeX文件路径</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_filepath">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>341</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QTextBrowser" name="textBrowser_result">
<property name="geometry">
<rect>
<x>380</x>
<y>80</y>
<width>361</width>
<height>381</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton_exec">
<property name="geometry">
<rect>
<x>510</x>
<y>20</y>
<width>231</width>
<height>51</height>
</rect>
</property>
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>排序难度数据</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>380</x>
<y>30</y>
<width>141</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>届别(班级)regex</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_classregex">
<property name="geometry">
<rect>
<x>380</x>
<y>50</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QPlainTextEdit" name="plainTextEdit_idexp">
<property name="geometry">
<rect>
<x>20</x>
<y>80</y>
<width>341</width>
<height>381</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>