自动抽屉生成的考试二维码bug
This commit is contained in:
parent
79a025904d
commit
bec5c2fbbf
|
@ -741,7 +741,7 @@ class ExamTest(models.Model): # 考试表
|
|||
id = models.AutoField(primary_key=True)
|
||||
num = models.CharField(max_length=200, default='') # 编号
|
||||
name = models.CharField(max_length=200, default='')
|
||||
type = models.IntegerField(default=1) # 正式考试/模拟考试/练习
|
||||
type = models.IntegerField(default=1) # 试卷库考试/自动抽题考试
|
||||
state = models.IntegerField(default=1) # 1进行中 0是已关闭
|
||||
exampaper = models.ForeignKey(ExamPaper, on_delete=models.CASCADE)
|
||||
user = models.ManyToManyField(User, through='ExamTestDetail') # 考试人员
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
<input id="name" name="name" class="easyui-textbox" style="width:90%" data-options="label:'考试名称'"
|
||||
required=true />
|
||||
</div>
|
||||
<div style="margin-bottom:5px;">
|
||||
<label>允许与其他自动抽题考试题目重复</label>
|
||||
<input id="repeatbutton" class="easyui-switchbutton" data-options="onText:'允许',offText:'不允许'" style="width: 80px;">
|
||||
<input id="repeat" name="repeat" val="yes" type="hidden"></input>
|
||||
</div>
|
||||
<div style="margin-bottom:5px;">
|
||||
<input id="tmfls" editable="false" name="tmfls" class="easyui-combotree" style="width:90%"
|
||||
data-options="label:'选择分类'" required=true />
|
||||
|
@ -46,6 +51,28 @@
|
|||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$('#repeatbutton').switchbutton({
|
||||
checked: true,
|
||||
onChange: function(checked){
|
||||
if (checked == true){
|
||||
$('#repeat').val('yes')
|
||||
}
|
||||
if (checked == false){
|
||||
$('#repeat').val('no')
|
||||
}
|
||||
var tmfls = $('#tmfls').combotree('getValues')
|
||||
if(tmfls.length>0){
|
||||
var repeat = $('#repeat').val()
|
||||
$.post('api/question?a=search',JSON.stringify({'tmfls':tmfls,'repeat':repeat}),function(res){
|
||||
$('#dxnumt').textbox('setValue',res.dxnum)
|
||||
$('#duoxnumt').textbox('setValue',res.duoxnum)
|
||||
$('#pdnumt').textbox('setValue',res.pdnum)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
$("#tmfls").combotree({
|
||||
url: 'api/questioncat?a=tree',
|
||||
method: 'get',
|
||||
|
@ -63,7 +90,8 @@
|
|||
editable: false,
|
||||
onCheck:function(node){
|
||||
var tmfls = $('#tmfls').combotree('getValues')
|
||||
$.post('api/question?a=search',JSON.stringify({'tmfls':tmfls}),function(res){
|
||||
var repeat = $('#repeat').val()
|
||||
$.post('api/question?a=search',JSON.stringify({'tmfls':tmfls,'repeat':repeat}),function(res){
|
||||
$('#dxnumt').textbox('setValue',res.dxnum)
|
||||
$('#duoxnumt').textbox('setValue',res.duoxnum)
|
||||
$('#pdnumt').textbox('setValue',res.pdnum)
|
||||
|
@ -95,6 +123,7 @@
|
|||
function kssubmitForm() {
|
||||
var ksdata = $('#ksff').serializeJSON();
|
||||
ksdata['tmfls'] = $('#tmfls').combotree('getValues')
|
||||
console.log(ksdata)
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'api/examtest?a=add2',
|
||||
|
|
|
@ -5581,6 +5581,10 @@ def apiquestion(req):
|
|||
data = json.loads(req.body.decode('utf-8'))
|
||||
tmfls = data['tmfls']
|
||||
a = Question.objects.filter(deletemark=1, questioncat__id__in=tmfls)
|
||||
if 'repeat' in data and data['repeat'] == 'no':
|
||||
excludequestions = ExamTest.objects.filter(usecomps__contains=','+companyid +
|
||||
',').exclude(nousecomps__contains=','+companyid+',').values_list('exampaper__question__id',flat=True).distinct()
|
||||
a = a.exclude(id__in=excludequestions)
|
||||
dxnum = a.filter(type=1).count()
|
||||
duoxnum = a.filter(type=2).count()
|
||||
pdnum = a.filter(type=3).count()
|
||||
|
@ -5904,6 +5908,10 @@ def apiexamtest(req):
|
|||
objpaper.save()
|
||||
questionobjs = Question.objects.filter(
|
||||
questioncat__id__in=data['tmfls'])
|
||||
if 'repeat' in data and data['repeat'] == 'no':
|
||||
excludequestions = ExamTest.objects.filter(usecomps__contains=','+companyid +
|
||||
',').exclude(nousecomps__contains=','+companyid+',').values_list('exampaper__question__id',flat=True).distinct()
|
||||
questionobjs = questionobjs.exclude(id__in=excludequestions)
|
||||
if dxnum > 0:
|
||||
qobjs = questionobjs.filter(type=1).order_by('?')[:dxnum]
|
||||
for i in qobjs:
|
||||
|
@ -5931,6 +5939,7 @@ def apiexamtest(req):
|
|||
obj.passscore = data['passscore']
|
||||
obj.duration = data['duration']
|
||||
obj.createuser = User.objects.get(userid=userid)
|
||||
obj.save()
|
||||
obj.qrcode = makeqr_examtest(
|
||||
'https://safeyun.ctcshe.com/miniprogram/examtest?id='+str(obj.id))
|
||||
obj.save()
|
||||
|
|
Loading…
Reference in New Issue