diff --git a/ratedata.dat b/ratedata.dat index 879447c0..af1baa98 100644 Binary files a/ratedata.dat and b/ratedata.dat differ diff --git a/safesite/views.py b/safesite/views.py index 0a968e87..d0645f4c 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -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})