From 6c0367197cc5bbc01c6ff3e50aa75dbf88e52bac Mon Sep 17 00:00:00 2001 From: wangweiye7840 Date: Thu, 1 Feb 2024 14:35:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BD=95=E5=85=A5=E7=AD=94?= =?UTF-8?q?=E9=A2=98=E7=BA=B8=E4=BF=A1=E6=81=AF.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/录入答题纸对应信息.py | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 工具v2/录入答题纸对应信息.py diff --git a/工具v2/录入答题纸对应信息.py b/工具v2/录入答题纸对应信息.py new file mode 100644 index 00000000..e12b4c5d --- /dev/null +++ b/工具v2/录入答题纸对应信息.py @@ -0,0 +1,62 @@ +pid = "G20260201" #第一个字母是分类的代号, 1-4为数字是届别, 5-6位数字一般是学期序号(01-06), 特殊情况酌情分类, 假期作业归属于前一个学期 +xiaoxianid = "222817032234165544979" #小闲平台的试卷编号 + + +from database_tools import * + +grade = pid[3:5] +answersheetjson = f"../备课组/{grade}届/答题纸对应.json" +notesjson = f"../备课组/{grade}届/校本材料.json" + +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") + else: + new_dict["idlist"].append(id.zfill(6)) + count += 1 + 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() + + 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} 个位置):") + + + answersheet_dict[xiaoxianid] = new_dict.copy() + save_dict(answersheet_dict,answersheetjson) +