database_tools增加一个函数ChooseIDsByUsageInterval选择一段时间内某年级平均正确率在区间内的题号
This commit is contained in:
parent
e1292587cf
commit
f78599c1fe
|
|
@ -1,5 +1,6 @@
|
||||||
import json,re,os,Levenshtein,fitz,time,sys,subprocess
|
import json,re,os,Levenshtein,fitz,time,sys,subprocess
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
import pyperclip
|
import pyperclip
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2251,5 +2252,35 @@ def RefineExclude(excludejson): #将excludejson的key变为6位题号
|
||||||
newjson[key.zfill(6)] = excludejson[key]
|
newjson[key.zfill(6)] = excludejson[key]
|
||||||
return newjson
|
return newjson
|
||||||
|
|
||||||
|
|
||||||
|
def ChooseIDsByUsageInterval(startdate,enddate,interval,grade,prodict): #返回根据条件选出的题号字典及对应小题, 需要留意的记录长度不一的题号, 以及所有使用过的题号
|
||||||
|
used_problems = []
|
||||||
|
for id in prodict:
|
||||||
|
currentproblem = prodict[id]
|
||||||
|
currentusages = [parseUsage(u) for u in currentproblem["usages"] if startdate <= parseUsage(u)["date"] <= enddate and grade+"届" in parseUsage(u)["classid"]]
|
||||||
|
if not currentusages == []:
|
||||||
|
used_problems.append((id,currentusages))
|
||||||
|
cautionids = [] #使用记录长度不一的题目id
|
||||||
|
chosenproblems = {} #使用记录的平均值在thresholds中的题目id(键值为题号id, 内容为小题号, 内容为空表示没有小题)
|
||||||
|
for item in used_problems:
|
||||||
|
id,usages = item
|
||||||
|
subproblems = [u["subproblems"] for u in usages]
|
||||||
|
if max(subproblems) != min(subproblems):
|
||||||
|
cautionids.append(id)
|
||||||
|
print(f"!!! 题号 {id} 的使用记录中小题数目不全相同, 请检查")
|
||||||
|
else:
|
||||||
|
for i in range(subproblems[0]):
|
||||||
|
difflist = [u["difficulties"][i] for u in usages]
|
||||||
|
diffmean = np.mean(difflist)
|
||||||
|
if interval[0] <= diffmean <= interval[1]:
|
||||||
|
if subproblems[0] == 1:
|
||||||
|
chosenproblems[id] = []
|
||||||
|
elif not id in chosenproblems:
|
||||||
|
chosenproblems[id] = [i+1]
|
||||||
|
else:
|
||||||
|
chosenproblems[id].append(i+1)
|
||||||
|
return (chosenproblems,cautionids,used_problems) #返回根据条件选出的题号字典及对应小题, 需要留意的记录长度不一的题号, 以及所有使用过的题号
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("数据库工具, import用.")
|
print("数据库工具, import用.")
|
||||||
Reference in New Issue