This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mathdeptv2/工具v2/收集使用记录.py

53 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from database_tools import *
import zipfile,shutil
configjson = load_dict("文本文件/config.json")["收集使用记录.py"]
zipfilepath = configjson["zip文件路径"]
date = configjson["日期"]
threshold = configjson["提交人数比例最小值"]
tempdir = "临时文件/zips"
statsfilename = "小题分_按学号数学.xlsx"
answersheetseekingpath = "../备课组"
try:
shutil.rmtree(tempdir)
except:
pass
makedir(tempdir)
xiaoxianpid = ParseZipname(zipfilepath)
paperinfo = FindPaper(xiaoxianpid, answersheetseekingpath)
gradename = paperinfo[1]
idlist = paperinfo[2]
zf = zipfile.ZipFile(zipfilepath)
zf.extractall(tempdir) #解压zip文件中的所有内容到tempdir
# papertype = CheckPaperType(tempdir,statsfilename)
statsfilepathlist = FindFile(tempdir,statsfilename)
validcols,marks = generateColIndexandMarks(statsfilepathlist,statsfilename,paperinfo)
dfcurrent = pd.read_excel(os.path.join(statsfilepathlist[0],statsfilename))
correspondence_dict = generateIDtoUsageCorrespondence(idlist,validcols,dfcurrent.iloc[1,validcols])
output = CalculateUsages(statsfilepathlist,statsfilename,gradename,threshold,marks,correspondence_dict,validcols,date)
if CheckUsagesValidity(output) == 0:
SaveTextFile(output,"文本文件/metadata.txt")
print("数据文件已输出至metadata.txt")
os.system("code 文本文件/metadata.txt")
else:
print("数据有误, 可能需要检查每一题的满分数据")