总排名查询
This commit is contained in:
parent
ec7b0d0854
commit
66d3730917
BIN
ratedata.dat
BIN
ratedata.dat
Binary file not shown.
|
@ -6182,7 +6182,13 @@ def apiexamtestdetail(req):
|
|||
startnum, endnum = fenye(req)
|
||||
with open('ratedata.dat','rb') as f:
|
||||
data = pickle.load(f)
|
||||
data['rows'] = data['rows'][startnum:endnum]
|
||||
rows = data['rows']
|
||||
if req.GET.get('search',None):
|
||||
rows=[]
|
||||
for i in data['rows']:
|
||||
if req.GET.get('search') in i['user__name']:
|
||||
rows.append(i)
|
||||
data['rows'] = rows[startnum:endnum]
|
||||
return JsonResponse(data)
|
||||
|
||||
|
||||
|
@ -6195,8 +6201,11 @@ def apiexamtestrate(req):
|
|||
print(alltest)
|
||||
objs = ExamTestDetail.objects.filter(examtest__in=alltest,ison=1).values('user__userid','user__name','user__headimgurl','user__ubelongpart__partname').annotate(totalscore=Sum('score'),totaltook=Sum('took'),testnum=Count('user__userid')).order_by('-totalscore','totaltook')
|
||||
total = objs.count()
|
||||
objslist = list(objs)
|
||||
for i in objslist:
|
||||
i['rate'] = objslist.index(i) + 1
|
||||
with open('ratedata.dat','wb') as f:
|
||||
pickle.dump({'total':total,'rows':list(objs),'updatetime':datetime.now().strftime('%Y-%m-%d %H:%M')},f)
|
||||
pickle.dump({'total':total,'rows':objslist,'updatetime':datetime.now().strftime('%Y-%m-%d %H:%M')},f)
|
||||
return JsonResponse({"code": 1})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue