kaoshi xiufu
This commit is contained in:
parent
399a8bd32c
commit
b512e3f548
|
@ -0,0 +1,27 @@
|
|||
# Generated by Django 2.2.8 on 2020-03-01 18:35
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0318_auto_20200214_1427'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AlterField(
|
||||
model_name='examtestdetail',
|
||||
name='tms',
|
||||
field=models.CharField(default=',', max_length=10000),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='examtestdetail',
|
||||
name='wrongs',
|
||||
field=models.CharField(default=',', max_length=10000),
|
||||
),
|
||||
]
|
|
@ -773,8 +773,8 @@ class ExamTestDetail(models.Model): # 考试详情表
|
|||
passcode = models.IntegerField(default=0) # 是否通过
|
||||
testdetail = JSONField(null=True, blank=True)
|
||||
score = models.FloatField(default=0) # 得分
|
||||
tms = models.CharField(max_length=600, default=',')
|
||||
wrongs = models.CharField(max_length=600, default=',')
|
||||
tms = models.CharField(max_length=10000, default=',')
|
||||
wrongs = models.CharField(max_length=10000, default=',')
|
||||
|
||||
|
||||
class Train(models.Model): # 培训表
|
||||
|
|
|
@ -4821,125 +4821,70 @@ def apitool(req):
|
|||
i.took = (i.endtime-i.starttime).total_seconds()
|
||||
i.save()
|
||||
return JsonResponse({"code":1})
|
||||
elif a == 'correct_testtime':
|
||||
users = User.objects.filter(usecomp__partid=2681)
|
||||
objs = ExamTestDetail.objects.filter(testnum__gt=1,user__in=users)
|
||||
print(objs.count())
|
||||
for i in objs:
|
||||
testaddend = ExamTestDetail.objects.filter(user=i.user).exclude(id=i.id)
|
||||
if testaddend.count() == 2 : # 如果等于两场
|
||||
if testaddend[0].took < i.took and testaddend[1].took <i.took:#如果都比这个小
|
||||
newtook = round((testaddend[0].took + testaddend[1].took)/2)
|
||||
i.took = newtook
|
||||
i.endtime = i.starttime + timedelta(seconds=newtook)
|
||||
i.testnum = 1
|
||||
i.save()
|
||||
print('矫正了'+i.user.name + i.examtest.name + str(newtook))
|
||||
elif testaddend.count() == 1: # 如果参加了一场
|
||||
if testaddend[0].took < i.took:
|
||||
newtook = round((testaddend[0].took)*0.8)
|
||||
i.took = newtook
|
||||
i.endtime = i.starttime + timedelta(seconds=newtook)
|
||||
i.testnum = 1
|
||||
i.save()
|
||||
print('矫正了'+i.user.name + i.examtest.name + str(newtook))
|
||||
elif a == 'correct_testtime2':
|
||||
users = User.objects.filter(usecomp__partid=2681)
|
||||
for i in users:
|
||||
attends = ExamTestDetail.objects.filter(user=i)
|
||||
if attends.count() == 3:
|
||||
obj1 = attends.filter(examtest__id=516)[0]
|
||||
obj2 = attends.filter(examtest__id=517)[0]
|
||||
obj3 = attends.filter(examtest__id=526)[0]
|
||||
if obj1.took<obj2.took and obj1.took<obj3.took and obj2.took>1790 and obj3.took>1790:
|
||||
newtook2 = round((obj1.took)*0.9)
|
||||
newtook3 = round((obj1.took)*0.8)
|
||||
obj2.took = newtook2
|
||||
obj2.endtime = obj2.starttime + timedelta(seconds=newtook2)
|
||||
obj2.testnum = 1
|
||||
obj2.save()
|
||||
print('矫正了'+ obj2.user.name + obj2.examtest.name + str(newtook2))
|
||||
obj3.took = newtook3
|
||||
obj3.endtime = obj3.starttime + timedelta(seconds=newtook3)
|
||||
obj3.testnum = 1
|
||||
obj3.save()
|
||||
print('矫正了'+ obj3.user.name + obj3.examtest.name + str(newtook3))
|
||||
elif obj3.took >= 1798 and obj2.took < 1798 and obj1.took < 1798:
|
||||
newtook = round((obj2.took + obj1.took)/2)
|
||||
obj3.took = newtook
|
||||
obj3.endtime = obj3.starttime + timedelta(seconds=newtook)
|
||||
obj3.testnum = 1
|
||||
obj3.save()
|
||||
print('矫正了'+ obj3.user.name + obj3.examtest.name + str(newtook))
|
||||
elif obj2.took >= 1798 and obj1.took < 1798 and obj3.took < 1798:
|
||||
newtook = round((obj3.took + obj1.took)/2)
|
||||
obj2.took = newtook
|
||||
obj2.endtime = obj2.starttime + timedelta(seconds=newtook)
|
||||
obj2.testnum = 1
|
||||
obj2.save()
|
||||
print('矫正了'+ obj2.user.name + obj2.examtest.name + str(newtook))
|
||||
elif obj1.took >= 1798 and obj2.took < 1798 and obj3.took < 1798:
|
||||
newtook = round((obj3.took + obj1.took)/2)
|
||||
obj2.took = newtook
|
||||
obj2.endtime = obj2.starttime + timedelta(seconds=newtook)
|
||||
obj2.testnum = 1
|
||||
obj2.save()
|
||||
print('矫正了'+ obj2.user.name + obj2.examtest.name + str(newtook))
|
||||
elif attends.count() == 1:
|
||||
obj = attends[0]
|
||||
if obj.took > 1798:
|
||||
obj.took = 1801
|
||||
obj.endtime = obj.starttime + timedelta(seconds=1798)
|
||||
obj.testnum=1
|
||||
obj.save()
|
||||
print('矫正了'+ obj.user.name + obj.examtest.name)
|
||||
elif attends.count() == 2:
|
||||
obj1 = attends[0]
|
||||
obj2 = attends[1]
|
||||
if obj1.took < 1795 < obj2.took:
|
||||
newtook = round((obj1.took)*0.8)
|
||||
obj2.took = newtook
|
||||
obj2.endtime = obj2.starttime + timedelta(seconds=newtook)
|
||||
obj2.testnum=1
|
||||
obj2.save()
|
||||
print('矫正了'+ obj2.user.name + obj2.examtest.name)
|
||||
elif obj2.took < 1795 < obj1.took:
|
||||
newtook = round((obj2.took)*0.8)
|
||||
obj1.took = newtook
|
||||
obj1.endtime = obj1.starttime + timedelta(seconds=newtook)
|
||||
obj1.testnum=1
|
||||
obj1.save()
|
||||
print('矫正了'+ obj1.user.name + obj1.examtest.name)
|
||||
|
||||
elif a == 'correct_testtime3':
|
||||
objs = ExamTestDetail.objects.filter(user__usecomp=2681,testnum__gt=1)
|
||||
for i in objs:
|
||||
if i.took < 1798:
|
||||
i.testnum=1
|
||||
i.save()
|
||||
else:
|
||||
i.took = 1799
|
||||
i.endtime = i.starttime + timedelta(seconds=1799)
|
||||
i.testnum = 1
|
||||
i.save()
|
||||
elif a == 'correct_testtime4':
|
||||
objs = ExamTestDetail.objects.filter(user__usecomp=2681,testnum__gt=1)
|
||||
for i in objs:
|
||||
if i.took < 1798:
|
||||
i.testnum=1
|
||||
i.save()
|
||||
else:
|
||||
i.took = 1799
|
||||
i.endtime = i.starttime + timedelta(seconds=1799)
|
||||
i.testnum = 1
|
||||
i.save()
|
||||
elif a == 'correct_testtime5':
|
||||
objs = ExamTestDetail.objects.filter(user__usecomp=2681,took__gt=1800)
|
||||
for i in objs:
|
||||
i.took = 1801
|
||||
i.endtime = i.starttime + timedelta(seconds=1801)
|
||||
i.testnum = 1
|
||||
i.save()
|
||||
elif a == 'panjuan':
|
||||
test = ExamTest.objects.get(id=req.GET.get('test'))
|
||||
answers = ExamPaperDetail.objects.filter(exampaper=test.exampaper).values('id', 'question__right')
|
||||
answersdict = {}
|
||||
for i in answers:
|
||||
answersdict['paperdetail' + str(i['id'])] = i['question__right']
|
||||
panjuanlist = ExamTestDetail.objects.filter(examtest=test)
|
||||
num = 0
|
||||
for obj in panjuanlist:
|
||||
tms = []
|
||||
wrongs = []
|
||||
rights = 0
|
||||
testdetail = obj.testdetail
|
||||
if testdetail:
|
||||
score = 0
|
||||
for i in testdetail: # 判卷
|
||||
iscore = 0
|
||||
i['question__right'] = answersdict['paperdetail'+str(i['id'])]
|
||||
if i['question__type'] == 2:
|
||||
if 'userchecked' in i:
|
||||
if i['userchecked']:
|
||||
if set(i['userchecked']) == set(i['question__right']):
|
||||
iscore = i['score']
|
||||
rights = rights + 1
|
||||
else:
|
||||
miniscore = i['score']/len(i['question__right'])
|
||||
wrongs.append(str(i['question__id']))
|
||||
for x in i['userchecked']:
|
||||
if x in i['question__right']:
|
||||
iscore = iscore + miniscore
|
||||
else:
|
||||
iscore = 0
|
||||
break
|
||||
else:
|
||||
if 'userchecked' in i:
|
||||
if i['userchecked']:
|
||||
if i['userchecked'] == i['question__right']:
|
||||
iscore = i['score']
|
||||
rights = rights + 1
|
||||
else:
|
||||
wrongs.append(str(i['question__id']))
|
||||
i['iscore'] = iscore
|
||||
score = score + iscore
|
||||
tms.append(str(i['question__id']))
|
||||
obj.testdetail = testdetail
|
||||
obj.rights = rights
|
||||
score = round(score,1)
|
||||
obj.score = score
|
||||
obj.ison = 1
|
||||
totalscore = test.totalscore
|
||||
passscore = test.passscore
|
||||
if score >= passscore:
|
||||
passcode = 1
|
||||
else:
|
||||
passcode = 0
|
||||
obj.passcode = passcode
|
||||
if tms:
|
||||
obj.tms = ','+','.join(tms)+','
|
||||
if wrongs:
|
||||
obj.wrongs = ','+','.join(wrongs)+','
|
||||
obj.save()
|
||||
num = num + 1
|
||||
print(str(num) + obj.user.name + '得分' + str(score))
|
||||
return JsonResponse({"code":1})
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue