权限初始化bug
This commit is contained in:
parent
b512e3f548
commit
88a7ea4d9f
BIN
ratedata.dat
BIN
ratedata.dat
Binary file not shown.
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 2.2.8 on 2020-03-02 14:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0319_auto_20200301_1835'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AddField(
|
||||
model_name='examtest',
|
||||
name='ispublic',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 2.2.8 on 2020-03-02 14:03
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0320_auto_20200302_1402'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
]
|
|
@ -743,6 +743,7 @@ class ExamTest(models.Model): # 考试表
|
|||
name = models.CharField(max_length=200, default='')
|
||||
type = models.IntegerField(default=1) # 试卷库考试/自动抽题考试
|
||||
state = models.IntegerField(default=1) # 1进行中 0是已关闭
|
||||
ispublic = models.IntegerField(default=0) # 默认不公开
|
||||
exampaper = models.ForeignKey(ExamPaper, on_delete=models.CASCADE)
|
||||
user = models.ManyToManyField(User, through='ExamTestDetail') # 考试人员
|
||||
starttime = models.DateTimeField(null=True, blank=True) # 最早参加
|
||||
|
|
|
@ -35,8 +35,13 @@
|
|||
<input id="endtime" editable="false" name="endtime" class="easyui-datetimebox" style="width:90%"
|
||||
data-options="label:'最迟参加',currentText:'今天',closeText:'关闭',showSeconds: false,required:true" />
|
||||
</div>
|
||||
<div style="margin-bottom:5px">
|
||||
<input class="easyui-textbox" id="participantname" style="width:80%;height:120px" editable="false"
|
||||
<div style="margin-bottom:5px;">
|
||||
<label>是否公开</label>
|
||||
<input id="ispublicbutton" class="easyui-switchbutton" data-options="onText:'公开',offText:'不公开'" style="width: 80px;">
|
||||
<input id="ispublic" name="ispublic" val="yes" type="hidden"></input>
|
||||
</div>
|
||||
<div style="margin-bottom:5px" id="choosediv">
|
||||
<input class="easyui-textbox" id="participantname" style="width:500px;height:120px" editable="false"
|
||||
data-options="label:'通知人员',multiline:true,prompt:'请选择'" >
|
||||
<input type="hidden" id="participant" name="participant" />
|
||||
<a class='easyui-linkbutton' onclick="choseusers()" style="width:auto">选择</a>
|
||||
|
@ -45,6 +50,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$('#choosediv').hide()
|
||||
$.get('api/exampaper?a=listok', function (res) {
|
||||
$('#exampaper').combobox({
|
||||
valueField: 'id',
|
||||
|
@ -58,7 +64,24 @@
|
|||
}
|
||||
})
|
||||
})
|
||||
$('#ispublicbutton').switchbutton({
|
||||
checked: true,
|
||||
onChange: function(checked){
|
||||
if (checked == true){
|
||||
$('#ispublic').val('yes')
|
||||
$('#choosediv').hide()
|
||||
}
|
||||
if (checked == false){
|
||||
$('#ispublic').val('no')
|
||||
$('#choosediv').show()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
function kssubmitForm() {
|
||||
if($('#ispublic').val()=='yes'){
|
||||
$('#participant').val('')
|
||||
}
|
||||
var ksdata = $('#ksff').serializeJSON();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
required=true />
|
||||
</div>
|
||||
<div style="margin-bottom:5px;">
|
||||
<label>允许与其他自动抽题考试题目重复</label>
|
||||
<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>
|
||||
|
@ -41,8 +41,13 @@
|
|||
<input id="endtime" editable="false" name="endtime" class="easyui-datetimebox" style="width:90%"
|
||||
data-options="label:'考试结束',currentText:'今天',closeText:'关闭',showSeconds: false,required:true" />
|
||||
</div>
|
||||
<div style="margin-bottom:5px">
|
||||
<input class="easyui-textbox" id="participantname" style="width:90%;height:120px" editable="false"
|
||||
<div style="margin-bottom:5px;">
|
||||
<label>是否公开</label>
|
||||
<input id="ispublicbutton" class="easyui-switchbutton" data-options="onText:'公开',offText:'不公开'" style="width: 80px;">
|
||||
<input id="ispublic" name="ispublic" val="yes" type="hidden"></input>
|
||||
</div>
|
||||
<div style="margin-bottom:5px" id="choosediv">
|
||||
<input class="easyui-textbox" id="participantname" style="width:500px;height:120px" editable="false"
|
||||
data-options="label:'通知人员',multiline:true,prompt:'请选择'" >
|
||||
<input type="hidden" id="participant" name="participant" />
|
||||
<a class='easyui-linkbutton' onclick="choseusers()" style="width:auto">选择</a>
|
||||
|
@ -51,6 +56,21 @@
|
|||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$('#choosediv').hide()
|
||||
$('#ispublicbutton').switchbutton({
|
||||
checked: true,
|
||||
onChange: function(checked){
|
||||
if (checked == true){
|
||||
$('#ispublic').val('yes')
|
||||
$('#choosediv').hide()
|
||||
}
|
||||
if (checked == false){
|
||||
$('#ispublic').val('no')
|
||||
$('#choosediv').show()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
$('#repeatbutton').switchbutton({
|
||||
checked: true,
|
||||
onChange: function(checked){
|
||||
|
@ -121,6 +141,9 @@
|
|||
})
|
||||
})
|
||||
function kssubmitForm() {
|
||||
if($('#ispublic').val()=='yes'){
|
||||
$('#participant').val('')
|
||||
}
|
||||
var ksdata = $('#ksff').serializeJSON();
|
||||
ksdata['tmfls'] = $('#tmfls').combotree('getValues')
|
||||
console.log(ksdata)
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
}
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "api/examtest?a=detail",
|
||||
url: "api/examtest?a=detail2",
|
||||
data: { id: ksid },
|
||||
async: false, // ajax同步使用false
|
||||
success: function (data) {
|
||||
|
|
|
@ -851,6 +851,7 @@ def apirights(req):
|
|||
allrights = user.usecomp.role.permissions.all()
|
||||
menus = allrights.exclude(menuid__in=[11, 9]).order_by(
|
||||
'sortnum').values('menuid', 'menucode', 'parentid', 'url', 'menuname', 'icon').distinct()
|
||||
if haverights:
|
||||
for i in menus:
|
||||
if i['menuid'] in haverights:
|
||||
i['checked'] = True
|
||||
|
@ -4883,7 +4884,7 @@ def apitool(req):
|
|||
obj.wrongs = ','+','.join(wrongs)+','
|
||||
obj.save()
|
||||
num = num + 1
|
||||
print(str(num) + obj.user.name + '得分' + str(score))
|
||||
print(str(num) + obj.examtest.name + obj.user.name + '得分' + str(score))
|
||||
return JsonResponse({"code":1})
|
||||
|
||||
|
||||
|
@ -5894,10 +5895,14 @@ def apiexamtest(req):
|
|||
a = a.filter(usecomps__contains=','+companyid +
|
||||
',').exclude(nousecomps__contains=','+companyid+',')
|
||||
state = req.GET.get('state',None)
|
||||
owner = req.GET.get('owner',None)
|
||||
if state == 'open':
|
||||
a = a.filter(state=1)
|
||||
if state == 'close':
|
||||
a = a.filter(state=0)
|
||||
if owner == 'yes':
|
||||
ownerlist = ExamTestDetail.objects.filter(user__userid=userid, examtest__state=1,ison=0).values_list('examtest__id',flat=True)
|
||||
a = a.filter(Q(id__in=ownerlist)|Q(ispublic=1))
|
||||
a = a.order_by('-id')
|
||||
total = a.count()
|
||||
startnum, endnum = fenye(req)
|
||||
|
@ -5933,6 +5938,11 @@ def apiexamtest(req):
|
|||
if 'endtime' in data:
|
||||
if data['endtime']:
|
||||
obj.endtime = data['endtime']
|
||||
if 'ispublic' in data:
|
||||
if data['ispublic'] == 'yes':
|
||||
obj.ispublic = 1
|
||||
else:
|
||||
obj.ispublic = 0
|
||||
obj.totalscore = expaper.total['total']['score']
|
||||
obj.passscore = data['passscore']
|
||||
obj.duration = data['duration']
|
||||
|
@ -6028,6 +6038,11 @@ def apiexamtest(req):
|
|||
obj.passscore = data['passscore']
|
||||
obj.duration = data['duration']
|
||||
obj.createuser = User.objects.get(userid=userid)
|
||||
if 'ispublic' in data:
|
||||
if data['ispublic'] == 'yes':
|
||||
obj.ispublic = 1
|
||||
else:
|
||||
obj.ispublic = 0
|
||||
obj.save()
|
||||
obj.qrcode = makeqr_examtest(
|
||||
'https://safeyun.ctcshe.com/miniprogram/examtest?id='+str(obj.id))
|
||||
|
@ -6083,6 +6098,23 @@ def apiexamtest(req):
|
|||
return JsonResponse({"code": 1})
|
||||
else:
|
||||
return JsonResponse({"code": 0})
|
||||
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]
|
||||
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')
|
||||
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
|
||||
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',
|
||||
|
@ -6092,13 +6124,6 @@ def apiexamtest(req):
|
|||
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').values(
|
||||
'id', 'user__name', 'user__ubelongpart__partname', 'took', 'score', 'ison', 'passcode','starttime')
|
||||
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
|
||||
return HttpResponse(json.dumps(a, cls=MyEncoder), content_type="application/json")
|
||||
elif a == 'detailtm':
|
||||
id = req.GET.get('id')
|
||||
|
@ -6116,8 +6141,9 @@ def apiexamtest(req):
|
|||
a = ExamTest.objects
|
||||
a = a.filter(usecomps__contains=','+companyid + #未关闭的考试
|
||||
',').exclude(nousecomps__contains=','+companyid+',').filter(state=1,endtime__gte=datetime.now())
|
||||
hasAttend = ExamTestDetail.objects.filter(examtest__in=a,user__userid=req.session['userid'],ison=1) #在未关闭的考试中已经参加的
|
||||
return JsonResponse({"code":1, "dknum":a.count()-hasAttend.count()})
|
||||
ownerlist = ExamTestDetail.objects.filter(user__userid=userid, examtest__state=1,ison=0).values_list('examtest__id',flat=True)
|
||||
dknum = a.filter(Q(id__in=ownerlist)|Q(ispublic=1)).count()
|
||||
return JsonResponse({"code":1, "dknum":dknum})
|
||||
|
||||
|
||||
|
||||
|
@ -6290,7 +6316,7 @@ def apiexamtestrate(req):
|
|||
for i in objslist:
|
||||
i['rate'] = objslist.index(i) + 1
|
||||
i['avgscore'] = round(i['totalscore']/i['testnum'],1)
|
||||
orgsCal = allexamtestdetail.filter(score__gt=0).values('user__ubelongpart__partid','user__ubelongpart__partname').annotate(totaltest=Count('user__ubelongpart__partid'),avgscore=Avg('score')).order_by('-totaltest','-avgscore')
|
||||
orgsCal = allexamtestdetail.filter(score__gt=0,ison__gt=0).values('user__ubelongpart__partid','user__ubelongpart__partname').annotate(totaltest=Count('user__ubelongpart__partid'),avgscore=Avg('score')).order_by('-totaltest','-avgscore')
|
||||
allattenduser = allexamtestdetail.values_list('user__userid', flat=True)
|
||||
orgsCallist = list(orgsCal)
|
||||
for i in orgsCallist:
|
||||
|
@ -6300,9 +6326,42 @@ def apiexamtestrate(req):
|
|||
i['avgscore'] = round(i['avgscore'],1)
|
||||
with open('ratedata.dat','wb') as f:
|
||||
pickle.dump({'total':total,'rows':objslist,'rows2':orgsCallist,'updatetime':datetime.now().strftime('%Y-%m-%d %H:%M')},f)
|
||||
from openpyxl import Workbook, load_workbook
|
||||
wb = load_workbook('e:/个人总排名.xlsx')
|
||||
sheet = wb.active
|
||||
for i in objslist:
|
||||
num = str(objslist.index(i)+3)
|
||||
sheet['a'+num] = i['user__name']
|
||||
sheet['b'+num] = i['user__ubelongpart__partname']
|
||||
sheet['c'+num] = i['testnum']
|
||||
sheet['d'+num] = i['totalscore']
|
||||
sheet['e'+num] = convertseconds(i['totaltook'])
|
||||
nowtime = datetime.now().strftime('%Y%m%d')
|
||||
sheet['b1'] = nowtime
|
||||
filename = '个人总排名' + nowtime
|
||||
filepath = 'e:/' + filename +'.xlsx'
|
||||
wb.save(filepath)
|
||||
|
||||
wb2 = load_workbook('e:/机构总排名.xlsx')
|
||||
sheet = wb2.active
|
||||
for i in orgsCallist:
|
||||
num = str(orgsCallist.index(i)+3)
|
||||
sheet['a'+num] = i['user__ubelongpart__partname']
|
||||
sheet['b'+num] = i['totaluser']
|
||||
sheet['c'+num] = i['totaltest']
|
||||
sheet['d'+num] = i['avgscore']
|
||||
nowtime = datetime.now().strftime('%Y%m%d')
|
||||
sheet['b1'] = nowtime
|
||||
filename = '机构总排名' + nowtime
|
||||
filepath = 'e:/' + filename +'.xlsx'
|
||||
wb2.save(filepath)
|
||||
|
||||
return JsonResponse({"code": 1})
|
||||
|
||||
|
||||
def convertseconds(seconds):
|
||||
m, s = divmod(seconds, 60)
|
||||
h, m = divmod(m, 60)
|
||||
return ("%02d:%02d:%02d" % (h, m, s))
|
||||
|
||||
def apitrain(req):
|
||||
if req.GET.get('a') == 'listjoin':
|
||||
|
|
Loading…
Reference in New Issue