防止提前答卷,统一时间

This commit is contained in:
caoqianming 2020-02-20 19:44:03 +08:00
parent e25d7e56f2
commit 5633ffec4d
1 changed files with 6 additions and 4 deletions

View File

@ -6014,6 +6014,9 @@ def apiexamtest(req):
id = req.GET.get('id')
a = ExamTest.objects.filter(id=id).values('id', 'num', 'name', 'starttime', 'endtime', 'duration', 'totalscore',
'passscore', 'exampaper__total', 'createtime', 'state', 'exampaper__name', 'createuser__name', 'type', 'qrcode')[0]
a['notinTime'] = 0
if a['starttime'] > datetime.now() or a['endtime'] < datetime.now():
a['notinTime'] = 1
objs = ExamTestDetail.objects.filter(examtest__id=id).order_by('-score').values(
'id', 'user__name', 'user__ubelongpart__partname', 'took', 'score', 'ison', 'passcode','starttime')
a['cjrydetail'] = list(objs)
@ -6028,7 +6031,7 @@ def apiexamtest(req):
objs = ExamPaperDetail.objects.filter(exampaper=test.exampaper).order_by('question__type','?').values(
'id', 'question__id', 'score', 'question__title', 'question__type', 'question__answer', 'question__right', 'question__resolution')
duration = test.duration
data = {'duration': duration, 'tms': list(objs)}
data = {'duration': duration, 'tms': list(objs), 'starttime':datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
return JsonResponse(data)
elif a == 'exportword':
data = json.loads(req.body.decode('utf-8'))
@ -6082,9 +6085,8 @@ def apiexamtestdetail(req):
data = json.loads(req.body.decode('utf-8'))
testid = data['testid']
starttime = data['starttime']
endtime = data['endtime']
took = (datetime.strptime(endtime, '%Y-%m-%d %H:%M:%S') -
datetime.strptime(starttime, '%Y-%m-%d %H:%M:%S')).total_seconds() #计算相差多少秒
endtime = datetime.now()
took = (endtime - datetime.strptime(starttime, '%Y-%m-%d %H:%M:%S')).total_seconds() #计算相差多少秒
testdetail = data['sheet']
score = 0
rights = 0