统考数据导入 Qt重写, 并加入Qt面板及工具面板
This commit is contained in:
parent
8adeb9f39c
commit
a23cd7c3b5
|
|
@ -33,7 +33,7 @@ class MyWindow(QMainWindow,Ui_MainWindow):
|
|||
self.action_bjtm.triggered.connect(lambda: run_command("编辑题目信息",[]))
|
||||
self.action_xxdr.triggered.connect(lambda: run_command("获取小闲平台使用数据",[]))
|
||||
self.action_sddr.triggered.connect(lambda: run_command("手动统计结果导入",["临时文件/手动统计结果.txt"]))
|
||||
self.action_tkdr.triggered.connect(lambda: run_command("统考数据导入",["统考数据导入.py"]))
|
||||
self.action_tkdr.triggered.connect(lambda: run_command("统考数据导入",[]))
|
||||
self.action_dygg.triggered.connect(lambda: run_command("单元挂钩",["单元挂钩.py"]))
|
||||
self.action_tqda.triggered.connect(lambda: run_command("文件或剪贴板提取答案",["文件或剪贴板提取答案.py"]))
|
||||
self.action_hbsy.triggered.connect(lambda: run_command("合并使用记录并排序",[]))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,176 @@
|
|||
# -*- 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, QHBoxLayout, QLabel, QLineEdit,
|
||||
QPlainTextEdit, QPushButton, QSizePolicy, QVBoxLayout,
|
||||
QWidget)
|
||||
|
||||
class Ui_Form(object):
|
||||
def setupUi(self, Form):
|
||||
if not Form.objectName():
|
||||
Form.setObjectName(u"Form")
|
||||
Form.resize(552, 220)
|
||||
self.layoutWidget = QWidget(Form)
|
||||
self.layoutWidget.setObjectName(u"layoutWidget")
|
||||
self.layoutWidget.setGeometry(QRect(10, 70, 381, 54))
|
||||
self.verticalLayout_2 = QVBoxLayout(self.layoutWidget)
|
||||
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
|
||||
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
|
||||
self.horizontalLayout_2 = QHBoxLayout()
|
||||
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
|
||||
self.label_2 = QLabel(self.layoutWidget)
|
||||
self.label_2.setObjectName(u"label_2")
|
||||
self.label_2.setMinimumSize(QSize(180, 0))
|
||||
self.label_2.setMaximumSize(QSize(180, 16777215))
|
||||
|
||||
self.horizontalLayout_2.addWidget(self.label_2)
|
||||
|
||||
self.pushButton_excel = QPushButton(self.layoutWidget)
|
||||
self.pushButton_excel.setObjectName(u"pushButton_excel")
|
||||
self.pushButton_excel.setMinimumSize(QSize(60, 0))
|
||||
|
||||
self.horizontalLayout_2.addWidget(self.pushButton_excel)
|
||||
|
||||
|
||||
self.verticalLayout_2.addLayout(self.horizontalLayout_2)
|
||||
|
||||
self.lineEdit_excelfile = QLineEdit(self.layoutWidget)
|
||||
self.lineEdit_excelfile.setObjectName(u"lineEdit_excelfile")
|
||||
self.lineEdit_excelfile.setReadOnly(True)
|
||||
|
||||
self.verticalLayout_2.addWidget(self.lineEdit_excelfile)
|
||||
|
||||
self.layoutWidget_2 = QWidget(Form)
|
||||
self.layoutWidget_2.setObjectName(u"layoutWidget_2")
|
||||
self.layoutWidget_2.setGeometry(QRect(10, 160, 194, 22))
|
||||
self.horizontalLayout_4 = QHBoxLayout(self.layoutWidget_2)
|
||||
self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
|
||||
self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0)
|
||||
self.label_4 = QLabel(self.layoutWidget_2)
|
||||
self.label_4.setObjectName(u"label_4")
|
||||
self.label_4.setMinimumSize(QSize(100, 0))
|
||||
|
||||
self.horizontalLayout_4.addWidget(self.label_4)
|
||||
|
||||
self.lineEdit_grade = QLineEdit(self.layoutWidget_2)
|
||||
self.lineEdit_grade.setObjectName(u"lineEdit_grade")
|
||||
|
||||
self.horizontalLayout_4.addWidget(self.lineEdit_grade)
|
||||
|
||||
self.layoutWidget_3 = QWidget(Form)
|
||||
self.layoutWidget_3.setObjectName(u"layoutWidget_3")
|
||||
self.layoutWidget_3.setGeometry(QRect(10, 190, 194, 22))
|
||||
self.horizontalLayout_5 = QHBoxLayout(self.layoutWidget_3)
|
||||
self.horizontalLayout_5.setObjectName(u"horizontalLayout_5")
|
||||
self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0)
|
||||
self.label_5 = QLabel(self.layoutWidget_3)
|
||||
self.label_5.setObjectName(u"label_5")
|
||||
self.label_5.setMinimumSize(QSize(100, 0))
|
||||
|
||||
self.horizontalLayout_5.addWidget(self.label_5)
|
||||
|
||||
self.lineEdit_classnum = QLineEdit(self.layoutWidget_3)
|
||||
self.lineEdit_classnum.setObjectName(u"lineEdit_classnum")
|
||||
|
||||
self.horizontalLayout_5.addWidget(self.lineEdit_classnum)
|
||||
|
||||
self.plainTextEdit = QPlainTextEdit(Form)
|
||||
self.plainTextEdit.setObjectName(u"plainTextEdit")
|
||||
self.plainTextEdit.setGeometry(QRect(400, 10, 141, 201))
|
||||
self.plainTextEdit.setReadOnly(True)
|
||||
self.pushButton_exec = QPushButton(Form)
|
||||
self.pushButton_exec.setObjectName(u"pushButton_exec")
|
||||
self.pushButton_exec.setGeometry(QRect(210, 130, 181, 81))
|
||||
font = QFont()
|
||||
font.setBold(True)
|
||||
self.pushButton_exec.setFont(font)
|
||||
self.widget = QWidget(Form)
|
||||
self.widget.setObjectName(u"widget")
|
||||
self.widget.setGeometry(QRect(10, 10, 381, 54))
|
||||
self.verticalLayout = QVBoxLayout(self.widget)
|
||||
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.horizontalLayout = QHBoxLayout()
|
||||
self.horizontalLayout.setObjectName(u"horizontalLayout")
|
||||
self.label = QLabel(self.widget)
|
||||
self.label.setObjectName(u"label")
|
||||
self.label.setMinimumSize(QSize(180, 0))
|
||||
self.label.setMaximumSize(QSize(180, 16777215))
|
||||
|
||||
self.horizontalLayout.addWidget(self.label)
|
||||
|
||||
self.pushButton_paper = QPushButton(self.widget)
|
||||
self.pushButton_paper.setObjectName(u"pushButton_paper")
|
||||
self.pushButton_paper.setMinimumSize(QSize(60, 0))
|
||||
|
||||
self.horizontalLayout.addWidget(self.pushButton_paper)
|
||||
|
||||
|
||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||
|
||||
self.lineEdit_paperfile = QLineEdit(self.widget)
|
||||
self.lineEdit_paperfile.setObjectName(u"lineEdit_paperfile")
|
||||
self.lineEdit_paperfile.setReadOnly(True)
|
||||
|
||||
self.verticalLayout.addWidget(self.lineEdit_paperfile)
|
||||
|
||||
self.widget1 = QWidget(Form)
|
||||
self.widget1.setObjectName(u"widget1")
|
||||
self.widget1.setGeometry(QRect(10, 130, 194, 22))
|
||||
self.horizontalLayout_3 = QHBoxLayout(self.widget1)
|
||||
self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
|
||||
self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
|
||||
self.label_3 = QLabel(self.widget1)
|
||||
self.label_3.setObjectName(u"label_3")
|
||||
self.label_3.setMinimumSize(QSize(100, 0))
|
||||
|
||||
self.horizontalLayout_3.addWidget(self.label_3)
|
||||
|
||||
self.lineEdit_date = QLineEdit(self.widget1)
|
||||
self.lineEdit_date.setObjectName(u"lineEdit_date")
|
||||
self.lineEdit_date.setMaximumSize(QSize(100, 16777215))
|
||||
|
||||
self.horizontalLayout_3.addWidget(self.lineEdit_date)
|
||||
|
||||
|
||||
self.retranslateUi(Form)
|
||||
|
||||
QMetaObject.connectSlotsByName(Form)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, Form):
|
||||
Form.setWindowTitle(QCoreApplication.translate("Form", u"\u7edf\u8003\u6570\u636e\u5bfc\u5165", None))
|
||||
self.label_2.setText(QCoreApplication.translate("Form", u"\u7edf\u8ba1\u6587\u4ef6(.xlsx)", None))
|
||||
self.pushButton_excel.setText(QCoreApplication.translate("Form", u"\u6587\u4ef6\u9009\u62e9", None))
|
||||
self.label_4.setText(QCoreApplication.translate("Form", u"\u5e74\u7ea7", None))
|
||||
self.lineEdit_grade.setPlaceholderText(QCoreApplication.translate("Form", u"\u5982 2026\u5c4a\u9ad8\u4e00", None))
|
||||
self.label_5.setText(QCoreApplication.translate("Form", u"\u73ed\u7ea7\u6570", None))
|
||||
self.lineEdit_classnum.setPlaceholderText(QCoreApplication.translate("Form", u"\u5982 12", None))
|
||||
self.plainTextEdit.setDocumentTitle("")
|
||||
self.plainTextEdit.setPlainText(QCoreApplication.translate("Form", u"\u8bf4\u660e:\n"
|
||||
".xlsx\u6587\u4ef6\u9700\u8981\u6709\u4e00\u4e2a\u540d\u4e3a\"\u96be\u5ea6\u7edf\u8ba1\"\u7684\u6570\u636e\u8868.\n"
|
||||
"\u7b2c\u4e00\u5217\u4ece\u7b2c\u4e8c\u884c\u8d77\u4e3a\u73ed\u7ea7\u53f7, \u7b2c\u4e00\u884c\u4ece\u7b2c\u4e8c\u5217\u8d77\u4e3a\u9898\u53f7.\n"
|
||||
"\u4f8b\u5982: 1,2,3,4,5,61,62,71,72,73,8,9,101,102,...\n"
|
||||
"", None))
|
||||
self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u7edf\u8003\u6570\u636e\u5bfc\u5165\n"
|
||||
"metadata.txt", None))
|
||||
self.label.setText(QCoreApplication.translate("Form", u"\u8bd5\u5377\u6587\u4ef6(.tex\u6216.pdf)", None))
|
||||
self.pushButton_paper.setText(QCoreApplication.translate("Form", u"\u6587\u4ef6\u9009\u62e9", None))
|
||||
self.label_3.setText(QCoreApplication.translate("Form", u"\u65e5\u671f(yyyymmdd)", None))
|
||||
self.lineEdit_date.setPlaceholderText(QCoreApplication.translate("Form", u"\u5982 20240101", None))
|
||||
# retranslateUi
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ MaintainenceMenu.add_command(label = "编辑题目", command = lambda: SetButton
|
|||
MaintainenceMenu.add_separator()
|
||||
MaintainenceMenu.add_command(label = "合并使用记录并排序", command = lambda: SetButton("合并使用记录并排序",[]))
|
||||
MaintainenceMenu.add_separator()
|
||||
MaintainenceMenu.add_command(label = "统考数据导入", command = lambda: SetButton("统考数据导入",["统考数据导入.py"]))
|
||||
MaintainenceMenu.add_command(label = "统考数据导入", command = lambda: SetButton("统考数据导入",[]))
|
||||
MaintainenceMenu.add_command(label = "手动统计结果导入", command = lambda: SetButton("手动统计结果导入",["临时文件/手动统计结果.txt"]))
|
||||
MaintainenceMenu.add_separator()
|
||||
MaintainenceMenu.add_command(label = "文件或剪贴板提取答案", command = lambda: SetButton("文件或剪贴板提取答案",["文件或剪贴板提取答案.py"]))
|
||||
|
|
|
|||
|
|
@ -1,17 +1,38 @@
|
|||
texfile = r"D:\mathdeptv2\工具\临时文件\临时_学生用_20230622.tex" # 试卷的.tex源文件(要求每个题号都是左右带有小括号的六位数, 且没有其他这种格式的内容)
|
||||
excelfile = r"C:\Users\weiye\Documents\wwy sync\临时工作区\高一期末.xlsx" # 统考难度数据所在的excel文件, 小题号为从小到大排列的字符串, 例如 1 2 3 41 42 51 52 6 71 72 73等
|
||||
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
|
||||
from Ui_统考数据导入 import Ui_Form
|
||||
import os
|
||||
from database_tools import *
|
||||
|
||||
|
||||
class MyWindow(QWidget,Ui_Form):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setupUi(self)
|
||||
self.bind()
|
||||
|
||||
def bind(self):
|
||||
self.pushButton_paper.clicked.connect(self.selectpaper)
|
||||
self.pushButton_excel.clicked.connect(self.selectexcel)
|
||||
self.pushButton_exec.clicked.connect(self.exec)
|
||||
|
||||
def selectpaper(self):
|
||||
self.texfile = QFileDialog.getOpenFileName(self,"选择试卷文件",os.getcwd(),"试卷文件(*.tex *.pdf);;所有文件(*)")[0]
|
||||
self.lineEdit_paperfile.setText(self.texfile)
|
||||
def selectexcel(self):
|
||||
self.excelfile = QFileDialog.getOpenFileName(self,"选择统计文件",os.getcwd(),"Excel文件(*.xlsx);;所有文件(*)")[0]
|
||||
self.lineEdit_excelfile.setText(self.excelfile)
|
||||
def exec(self):
|
||||
sheetname = "难度统计" # excel中难度数据所在的工作表名
|
||||
date = "20230620" # 考试日期
|
||||
grade = "2025届高一" # 考试年级
|
||||
max_classnum = 12 # 年级参加考试的最大班级班号
|
||||
date = self.lineEdit_date.text().strip() # 考试日期
|
||||
grade = self.lineEdit_grade.text().strip() # 考试年级
|
||||
max_classnum = int(self.lineEdit_classnum.text().strip()) # 年级参加考试的最大班级班号
|
||||
outputfilepath = r"文本文件/metadata.txt" # 输出的用于导入的metadata.txt文件位置
|
||||
checkingfilepath = r"临时文件/手动统计结果.txt" # 用于检查结构的文件所在位置
|
||||
|
||||
from database_tools import *
|
||||
|
||||
df = pd.read_excel(excelfile,sheet_name = sheetname)
|
||||
data = ReadTextFile(texfile)
|
||||
problems_list = re.findall(r"\((\d{6})\)",data)
|
||||
|
||||
df = pd.read_excel(self.excelfile,sheet_name = sheetname)
|
||||
problems_list = generate_number_set(extractIDs(self.texfile))
|
||||
|
||||
#生成题号(1~n)与题库id对应
|
||||
id_dict = {}
|
||||
|
|
@ -37,7 +58,7 @@ for i in id_dict:
|
|||
classrows_dict = {}
|
||||
for row in df.iloc[:,0]:
|
||||
if type(row) == int or type(row) == float:
|
||||
if 1<=row<=12:
|
||||
if 1<=row<=max_classnum:
|
||||
row = int(row)
|
||||
classrows_dict[list(df.iloc[:,0]).index(row)] = str(row).zfill(2) + "班"
|
||||
|
||||
|
|
@ -60,3 +81,17 @@ for cl in classrows_dict:
|
|||
SaveTextFile(output,outputfilepath)
|
||||
print("可以在 %s 文件中检查结构"%(SaveTextFile(checkoutput,checkingfilepath)))
|
||||
os.system("code -w %s"%checkingfilepath)
|
||||
self.close()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication([])
|
||||
windows = MyWindow()
|
||||
windows.show()
|
||||
app.exec()
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,273 @@
|
|||
<?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>552</width>
|
||||
<height>220</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>统考数据导入</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>381</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>统计文件(.xlsx)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_excel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>文件选择</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_excelfile">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>160</y>
|
||||
<width>194</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>年级</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_grade">
|
||||
<property name="placeholderText">
|
||||
<string>如 2026届高一</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>190</y>
|
||||
<width>194</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>班级数</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_classnum">
|
||||
<property name="placeholderText">
|
||||
<string>如 12</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>400</x>
|
||||
<y>10</y>
|
||||
<width>141</width>
|
||||
<height>201</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="documentTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="plainText">
|
||||
<string>说明:
|
||||
.xlsx文件需要有一个名为"难度统计"的数据表.
|
||||
第一列从第二行起为班级号, 第一行从第二列起为题号.
|
||||
例如: 1,2,3,4,5,61,62,71,72,73,8,9,101,102,...
|
||||
</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_exec">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>130</y>
|
||||
<width>181</width>
|
||||
<height>81</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>统考数据导入
|
||||
metadata.txt</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>381</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>试卷文件(.tex或.pdf)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_paper">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>文件选择</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_paperfile">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>130</y>
|
||||
<width>194</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>日期(yyyymmdd)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_date">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>如 20240101</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
texfile = r"D:\mathdeptv2\工具\临时文件\临时_学生用_20230622.tex" # 试卷的.tex源文件(要求每个题号都是左右带有小括号的六位数, 且没有其他这种格式的内容)
|
||||
excelfile = r"C:\Users\weiye\Documents\wwy sync\临时工作区\高一期末.xlsx" # 统考难度数据所在的excel文件, 小题号为从小到大排列的字符串, 例如 1 2 3 41 42 51 52 6 71 72 73等
|
||||
sheetname = "难度统计" # excel中难度数据所在的工作表名
|
||||
date = "20230620" # 考试日期
|
||||
grade = "2025届高一" # 考试年级
|
||||
max_classnum = 12 # 年级参加考试的最大班级班号
|
||||
outputfilepath = r"文本文件/metadata.txt" # 输出的用于导入的metadata.txt文件位置
|
||||
checkingfilepath = r"临时文件/手动统计结果.txt" # 用于检查结构的文件所在位置
|
||||
|
||||
from database_tools import *
|
||||
|
||||
df = pd.read_excel(excelfile,sheet_name = sheetname)
|
||||
data = ReadTextFile(texfile)
|
||||
problems_list = re.findall(r"\((\d{6})\)",data)
|
||||
|
||||
#生成题号(1~n)与题库id对应
|
||||
id_dict = {}
|
||||
for i in range(len(problems_list)):
|
||||
id_dict[i+1] = problems_list[i]
|
||||
|
||||
output = "usages\n\n"
|
||||
checkoutput = ""
|
||||
#生成题号(1~n)与表格中数据列的对应
|
||||
idcol_dict = {}
|
||||
for i in id_dict:
|
||||
idcol_dict[i] = []
|
||||
mincol = -1
|
||||
for col_index in range(mincol+1,len(df.columns)):
|
||||
col = df.columns[col_index]
|
||||
if str(col).startswith(str(i)):
|
||||
idcol_dict[i].append(col_index)
|
||||
mincol = col_index
|
||||
if str(i) == str(col):
|
||||
break
|
||||
|
||||
#生成行号与班级的对应列表
|
||||
classrows_dict = {}
|
||||
for row in df.iloc[:,0]:
|
||||
if type(row) == int or type(row) == float:
|
||||
if 1<=row<=12:
|
||||
row = int(row)
|
||||
classrows_dict[list(df.iloc[:,0]).index(row)] = str(row).zfill(2) + "班"
|
||||
|
||||
#生成手动统计列表
|
||||
for cl in classrows_dict:
|
||||
classname = grade + classrows_dict[cl]
|
||||
checkoutput += "[BEGIN]\n"
|
||||
checkoutput += "## "+date+"\n"
|
||||
checkoutput += "** "+classname+"\n"
|
||||
for i in range(len(problems_list)):
|
||||
id = id_dict[i+1]
|
||||
results_cols = idcol_dict[i+1]
|
||||
results = []
|
||||
for col in results_cols:
|
||||
results.append("%.3f"%df.iloc[cl,col])
|
||||
checkoutput += id+"\t"+"\t".join(results) + "\n"
|
||||
output += id + "\n" + "\t".join([date,classname]+results) + "\n\n"
|
||||
checkoutput += "[END]\n\n\n"
|
||||
|
||||
SaveTextFile(output,outputfilepath)
|
||||
print("可以在 %s 文件中检查结构"%(SaveTextFile(checkoutput,checkingfilepath)))
|
||||
os.system("code -w %s"%checkingfilepath)
|
||||
Reference in New Issue