自动允许重考功能

This commit is contained in:
caoqianming 2020-12-07 22:53:09 +08:00
parent 6b3ccc9aae
commit 0b49ce1254
4 changed files with 23 additions and 12 deletions

View File

@ -479,7 +479,7 @@ def exam_rate(request):
# 员工数
user_count = s_models.User.objects.filter(usecomp=i, deletemark=1).count()
# 参加考试员工数/考次数
base = s_models.ExamTestDetail.objects.filter(user__usecomp=i, user__deletemark=1, ison=1).exclude(examtest__nousecomps__contains=','+str(i.partid)+',')
base = s_models.ExamTestDetail.objects.filter(user__usecomp=i, user__deletemark=1, testnum__gte=1).exclude(examtest__nousecomps__contains=','+str(i.partid)+',')
if start:
base = base.filter(examtest__starttime__gte=start)
if end:

View File

@ -764,6 +764,8 @@ class ExamTest(models.Model): # 考试表
createuser = models.ForeignKey(
User, blank=True, null=True, on_delete=models.CASCADE, related_name='kscjr')
qrcode = models.CharField(max_length=200, blank=True, null=True)
retest_count = models.IntegerField('允许重考次数', default=10)
class ExamTestDetail(models.Model): # 考试详情表
@ -776,7 +778,7 @@ class ExamTestDetail(models.Model): # 考试详情表
endtime = models.DateTimeField(null=True, blank=True)
took = models.IntegerField(default=0) # 耗时
rights = models.IntegerField(default=1) # 正确数
ison = models.IntegerField(default=0) # 参加0/已参加1/
ison = models.IntegerField(default=0) # 参加0/已参加1/
passcode = models.IntegerField(default=0) # 是否通过
testdetail = JSONField(null=True, blank=True)
score = models.FloatField(default=0) # 得分

View File

@ -83,7 +83,7 @@
参考时间
</th>
<th style="width:10%">
用时
用时(s)
</th>
<th style="width:15%">
答题详情
@ -100,7 +100,7 @@
<td>{{$value.user__name}}</td>
<td>{{$value.user__ubelongpart__partname}}</td>
{{if $value.ison==0}}
<td><font color="red">参加</font></td>
<td><font color="orange">参加</font></td>
{{else}}
<td><font color="green">已参加</font></td>
{{/if}}

View File

@ -6222,6 +6222,8 @@ def apiexamtest(req):
obj.passscore = data['passscore']
obj.duration = data['duration']
obj.createuser = User.objects.get(userid=userid)
if 'retest_count' in data and data['retest_count']:
obj.retest_count = data['retest_count']
obj.save()
obj.qrcode = makeqr_examtest(
'https://safeyun.ctcshe.com/miniprogram/examtest?id='+str(obj.id))
@ -6317,6 +6319,8 @@ def apiexamtest(req):
obj.ispublic = 1
else:
obj.ispublic = 0
if 'retest_count' in data and data['retest_count']:
obj.retest_count = data['retest_count']
obj.save()
obj.qrcode = makeqr_examtest(
'https://safeyun.ctcshe.com/miniprogram/examtest?id='+str(obj.id))
@ -6375,32 +6379,37 @@ def apiexamtest(req):
elif a == 'detail2':
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]
'passscore', 'exampaper__total', 'createtime', 'state', 'exampaper__name', 'createuser__name', 'type', 'qrcode', 'retest_count')[0]
a['notinTime'] = 0
if a['starttime'] > datetime.now():
a['notinTime'] = 1
if 'endtime' in a and a['endtime'] < datetime.now():
a['notinTime'] = 1
objs = ExamTestDetail.objects.filter(examtest__id=id).order_by('-score','-took').values(
'id', 'user__name', 'user__ubelongpart__partname', 'took', 'score', 'ison', 'passcode','starttime')
'id', 'user__name', 'user__ubelongpart__partname', 'took', 'score', 'ison', 'passcode','starttime', 'testnum')
a['cjrydetail'] = list(objs)
a['ison'] = 0
tests = ExamTestDetail.objects.filter(examtest__id=id,user__userid=userid)#考试记录
if tests.exists():
a['ison'] = tests[0].ison
a['testnum'] = 0
queryset = ExamTestDetail.objects.filter(examtest__id=id,user__userid=userid)
if queryset.exists():
a['ison'] = queryset[0].ison
a['testnum'] = queryset[0].testnum
return HttpResponse(json.dumps(a, cls=MyEncoder), content_type="application/json")
elif a == 'detail':
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]
'passscore', 'exampaper__total', 'createtime', 'state', 'exampaper__name', 'createuser__name', 'type', 'qrcode', 'retest_count')[0]
a['notinTime'] = 0
if a['starttime'] > datetime.now():
a['notinTime'] = 1
if 'endtime' in a and a['endtime'] < datetime.now():
a['notinTime'] = 1
a['ison'] = 0
if ExamTestDetail.objects.filter(examtest__id=id,user__userid=userid,ison=1).exists():
a['ison'] = 1
a['testnum'] = 0
queryset = ExamTestDetail.objects.filter(examtest__id=id,user__userid=userid)
if queryset.exists():
a['ison'] = queryset[0].ison
a['testnum'] = queryset[0].testnum
return HttpResponse(json.dumps(a, cls=MyEncoder), content_type="application/json")
elif a == 'detailtm':
id = req.GET.get('id')