答题纸对应 功能 迁移到工具v3

This commit is contained in:
wangweiye7840 2024-04-15 10:59:14 +08:00
parent 8fb3d2d1f0
commit 5748e02135
3 changed files with 519 additions and 0 deletions

View File

@ -0,0 +1,156 @@
# -*- 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, QComboBox, QHBoxLayout, QLabel,
QLineEdit, QPlainTextEdit, QPushButton, QSizePolicy,
QWidget)
class Ui_Form(object):
def setupUi(self, Form):
if not Form.objectName():
Form.setObjectName(u"Form")
Form.resize(399, 302)
self.label_2 = QLabel(Form)
self.label_2.setObjectName(u"label_2")
self.label_2.setGeometry(QRect(10, 50, 81, 16))
self.pushButton_exec = QPushButton(Form)
self.pushButton_exec.setObjectName(u"pushButton_exec")
self.pushButton_exec.setEnabled(False)
self.pushButton_exec.setGeometry(QRect(270, 100, 111, 191))
font = QFont()
font.setBold(True)
self.pushButton_exec.setFont(font)
self.layoutWidget = QWidget(Form)
self.layoutWidget.setObjectName(u"layoutWidget")
self.layoutWidget.setGeometry(QRect(10, 20, 371, 22))
self.horizontalLayout = QHBoxLayout(self.layoutWidget)
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.label = QLabel(self.layoutWidget)
self.label.setObjectName(u"label")
self.horizontalLayout.addWidget(self.label)
self.lineEdit_xiaoxianid = QLineEdit(self.layoutWidget)
self.lineEdit_xiaoxianid.setObjectName(u"lineEdit_xiaoxianid")
self.horizontalLayout.addWidget(self.lineEdit_xiaoxianid)
self.layoutWidget1 = QWidget(Form)
self.layoutWidget1.setObjectName(u"layoutWidget1")
self.layoutWidget1.setGeometry(QRect(10, 70, 371, 23))
self.horizontalLayout_2 = QHBoxLayout(self.layoutWidget1)
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.label_3 = QLabel(self.layoutWidget1)
self.label_3.setObjectName(u"label_3")
self.horizontalLayout_2.addWidget(self.label_3)
self.lineEdit_structure = QLineEdit(self.layoutWidget1)
self.lineEdit_structure.setObjectName(u"lineEdit_structure")
self.lineEdit_structure.setMaximumSize(QSize(20, 16777215))
self.horizontalLayout_2.addWidget(self.lineEdit_structure)
self.label_4 = QLabel(self.layoutWidget1)
self.label_4.setObjectName(u"label_4")
self.horizontalLayout_2.addWidget(self.label_4)
self.comboBox_grade = QComboBox(self.layoutWidget1)
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.addItem("")
self.comboBox_grade.setObjectName(u"comboBox_grade")
self.horizontalLayout_2.addWidget(self.comboBox_grade)
self.label_5 = QLabel(self.layoutWidget1)
self.label_5.setObjectName(u"label_5")
self.horizontalLayout_2.addWidget(self.label_5)
self.comboBox_semester = QComboBox(self.layoutWidget1)
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.addItem("")
self.comboBox_semester.setObjectName(u"comboBox_semester")
self.horizontalLayout_2.addWidget(self.comboBox_semester)
self.label_6 = QLabel(self.layoutWidget1)
self.label_6.setObjectName(u"label_6")
self.horizontalLayout_2.addWidget(self.label_6)
self.comboBox_index = QComboBox(self.layoutWidget1)
self.comboBox_index.setObjectName(u"comboBox_index")
self.horizontalLayout_2.addWidget(self.comboBox_index)
self.plainTextEdit_marks = QPlainTextEdit(Form)
self.plainTextEdit_marks.setObjectName(u"plainTextEdit_marks")
self.plainTextEdit_marks.setGeometry(QRect(10, 120, 251, 171))
self.label_7 = QLabel(Form)
self.label_7.setObjectName(u"label_7")
self.label_7.setGeometry(QRect(10, 100, 111, 16))
self.retranslateUi(Form)
QMetaObject.connectSlotsByName(Form)
# setupUi
def retranslateUi(self, Form):
Form.setWindowTitle(QCoreApplication.translate("Form", u"\u7b54\u9898\u7eb8\u5bf9\u5e94", None))
self.label_2.setText(QCoreApplication.translate("Form", u"\u5bf9\u5e94\u8bb2\u4e49\u4ee3\u7801", None))
self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u6dfb\u52a0\u7b54\u9898\u7eb8\u5bf9\u5e94", None))
self.label.setText(QCoreApplication.translate("Form", u"\u5c0f\u95f2\u8bd5\u5377ID", None))
self.label_3.setText(QCoreApplication.translate("Form", u"\u7c7b\u578b", None))
self.label_4.setText(QCoreApplication.translate("Form", u"\u5c4a\u522b", None))
self.comboBox_grade.setItemText(0, QCoreApplication.translate("Form", u"2022", None))
self.comboBox_grade.setItemText(1, QCoreApplication.translate("Form", u"2023", None))
self.comboBox_grade.setItemText(2, QCoreApplication.translate("Form", u"2024", None))
self.comboBox_grade.setItemText(3, QCoreApplication.translate("Form", u"2025", None))
self.comboBox_grade.setItemText(4, QCoreApplication.translate("Form", u"2026", None))
self.comboBox_grade.setItemText(5, QCoreApplication.translate("Form", u"2027", None))
self.comboBox_grade.setItemText(6, QCoreApplication.translate("Form", u"2028", None))
self.comboBox_grade.setItemText(7, QCoreApplication.translate("Form", u"2029", None))
self.label_5.setText(QCoreApplication.translate("Form", u"\u5b66\u671f", None))
self.comboBox_semester.setItemText(0, QCoreApplication.translate("Form", u"00", None))
self.comboBox_semester.setItemText(1, QCoreApplication.translate("Form", u"01", None))
self.comboBox_semester.setItemText(2, QCoreApplication.translate("Form", u"02", None))
self.comboBox_semester.setItemText(3, QCoreApplication.translate("Form", u"03", None))
self.comboBox_semester.setItemText(4, QCoreApplication.translate("Form", u"04", None))
self.comboBox_semester.setItemText(5, QCoreApplication.translate("Form", u"05", None))
self.comboBox_semester.setItemText(6, QCoreApplication.translate("Form", u"06", None))
self.label_6.setText(QCoreApplication.translate("Form", u"\u5e8f\u53f7", None))
self.plainTextEdit_marks.setPlaceholderText(QCoreApplication.translate("Form", u"\u5c06\u5c0f\u95f2\u5e73\u53f0\u7b54\u9898\u7eb8 \u4fee\u6539 \u754c\u9762\u4e2d\u95f4\u9760\u53f3\u7684\u6240\u6709\u5206\u6570\u590d\u5236\u5230\u8be5\u6587\u672c\u6846, \u7559\u7a7a\u8868\u793a\u5747\u4e3a1\u5206", None))
self.label_7.setText(QCoreApplication.translate("Form", u"\u5c0f\u95f2\u5e73\u53f0\u5404\u9898\u6ee1\u5206", None))
# retranslateUi

126
工具v3/答题纸对应.py Normal file
View File

@ -0,0 +1,126 @@
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog
from Ui_答题纸对应 import Ui_Form
from database_tools_2 import *
def getindices(string):
indices_list = []
notesjsonpath = f"../备课组/{string[3:5]}届/校本材料.json"
try:
notesjson = load_dict(notesjsonpath)
for id in notesjson["notes"]:
if id.startswith(string):
indices_list.append(id[-2:])
return indices_list
except:
return []
class MyWindow(QWidget,Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.bind()
def bind(self):
self.comboBox_grade.activated.connect(self.setindex)
self.comboBox_semester.activated.connect(self.setindex)
self.lineEdit_structure.textChanged.connect(self.setindex)
self.comboBox_index.activated.connect(self.activateexec)
self.pushButton_exec.clicked.connect(self.exec)
def setindex(self):
self.comboBox_index.clear()
self.structure = self.lineEdit_structure.text().upper()
self.grade = self.comboBox_grade.currentText()
self.semester = self.comboBox_semester.currentText()
self.initialstring = f"{self.structure}{self.grade}{self.semester}"
self.indices = getindices(self.initialstring)
self.comboBox_index.addItems(self.indices)
if self.indices == []:
self.pushButton_exec.setDisabled(True)
else:
self.pushButton_exec.setEnabled(True)
def activateexec(self):
self.pushButton_exec.setEnabled(True)
def exec(self):
pid = f"{self.structure}{self.grade}{self.semester}{self.comboBox_index.currentText()}"
answersheetjson = f"../备课组/{self.grade[-2:]}届/答题纸对应.json"
notesjson = f"../备课组/{self.grade[-2:]}届/校本材料.json"
marks_list = re.findall(r"(?:(?:^)|(?:\n))(\d+)分",self.plainTextEdit_marks.toPlainText())
marks_list = [int(mark) for mark in marks_list]
answersheet_dict = load_dict(answersheetjson)
notes_dict = load_dict(notesjson)
new_dict = {}
if not pid in notes_dict["notes"]:
print("讲义编号有误.")
else:
new_dict["id"] = pid
corresponding_method = input("用何种方式对应? 题号(I)/章节标题(P):")
if corresponding_method[0].upper() == "I":
new_dict["idlist"] = []
count = 1
id = input(f"输入第 {count} 题的题号(S表示跳过, E表示结束):")
while len(re.findall(r"[Ss\d,:]",id)) == len(id):
if "S" in id.upper():
new_dict["idlist"].append("999999")
count += 1
else:
new_id_list = generate_number_set(id)
new_dict["idlist"] += [i.zfill(6) for i in new_id_list]
count += len(new_id_list)
id = input(f"输入第 {count} 题的题号(S表示跳过, E表示结束):")
elif corresponding_method[0].upper() == "P":
structure = notes_dict["structures"][pid[0]]["structure"]
count = 1
partslist = []
for key in structure:
print(f"{count}. {key}: {structure[key]['name']}")
count += 1
partslist.append(key)
parts_selected_string = input("使用哪些部分(输入数字编号, 用';'分隔):")
parts_selected_index = parts_selected_string.strip().split(";")
parts_selected = []
for i in parts_selected_index:
parts_selected.append(partslist[int(i)-1])
new_dict["parts"] = parts_selected.copy()
if marks_list == []:
marksflag = input("是否为每个结果赋分(Y/N):")
if marksflag[0].upper() == "Y":
new_dict["marks"] = []
count = 1
mark = input(f"依次输入分数, 非自然数作为结束(第 {count} 个位置):")
while len(re.findall(r"\d",mark)) == len(mark):
new_dict["marks"].append(int(mark))
count += 1
mark = input(f"依次输入分数, 非自然数作为结束(第 {count} 个位置):")
else:
new_dict["marks"] = marks_list.copy()
answersheet_dict[self.lineEdit_xiaoxianid.text()] = new_dict.copy()
save_dict(answersheet_dict,answersheetjson)
print("设置完成")
if __name__ == '__main__':
app = QApplication([])
windows = MyWindow()
windows.show()
app.exec()

237
工具v3/答题纸对应.ui Normal file
View File

@ -0,0 +1,237 @@
<?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>399</width>
<height>302</height>
</rect>
</property>
<property name="windowTitle">
<string>答题纸对应</string>
</property>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>对应讲义代码</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_exec">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>270</x>
<y>100</y>
<width>111</width>
<height>191</height>
</rect>
</property>
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>添加答题纸对应</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>371</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>小闲试卷ID</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_xiaoxianid"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>371</width>
<height>23</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>类型</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_structure">
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>届别</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_grade">
<item>
<property name="text">
<string>2022</string>
</property>
</item>
<item>
<property name="text">
<string>2023</string>
</property>
</item>
<item>
<property name="text">
<string>2024</string>
</property>
</item>
<item>
<property name="text">
<string>2025</string>
</property>
</item>
<item>
<property name="text">
<string>2026</string>
</property>
</item>
<item>
<property name="text">
<string>2027</string>
</property>
</item>
<item>
<property name="text">
<string>2028</string>
</property>
</item>
<item>
<property name="text">
<string>2029</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>学期</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_semester">
<item>
<property name="text">
<string>00</string>
</property>
</item>
<item>
<property name="text">
<string>01</string>
</property>
</item>
<item>
<property name="text">
<string>02</string>
</property>
</item>
<item>
<property name="text">
<string>03</string>
</property>
</item>
<item>
<property name="text">
<string>04</string>
</property>
</item>
<item>
<property name="text">
<string>05</string>
</property>
</item>
<item>
<property name="text">
<string>06</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>序号</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_index"/>
</item>
</layout>
</widget>
<widget class="QPlainTextEdit" name="plainTextEdit_marks">
<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<width>251</width>
<height>171</height>
</rect>
</property>
<property name="placeholderText">
<string>将小闲平台答题纸 修改 界面中间靠右的所有分数复制到该文本框, 留空表示均为1分</string>
</property>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>小闲平台各题满分</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>