题目导出
This commit is contained in:
parent
835b7116e6
commit
a1de212d69
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 2.2.8 on 2020-11-17 14:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0366_auto_20201117_1314'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AddField(
|
||||
model_name='questioncat',
|
||||
name='isopen',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
]
|
||||
|
|
@ -693,6 +693,7 @@ class Questioncat(models.Model): # 题目分类
|
|||
modifytime = models.DateTimeField(auto_now=True)
|
||||
usecomp = models.ForeignKey(
|
||||
Partment, on_delete=models.CASCADE, null=True, blank=True)
|
||||
isopen = models.IntegerField(default=0) #默认不共享
|
||||
# 题库数据表
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -213,14 +213,16 @@ function convert(rows, x) {
|
|||
id: row.id,
|
||||
text: row.name,
|
||||
state: x,
|
||||
pic: row.pic
|
||||
pic: row.pic,
|
||||
isopen: row.isopen
|
||||
}
|
||||
if(row.name=='默认分类'){
|
||||
node = {
|
||||
id: row.id,
|
||||
text: row.name,
|
||||
state: 'closed',
|
||||
pic: row.pic
|
||||
pic: row.pic,
|
||||
isopen: row.isopen
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +240,7 @@ function convert(rows, x) {
|
|||
for (var i = 0; i < rows.length; i++) {
|
||||
var row = rows[i];
|
||||
if (row.parentId == node.id) {
|
||||
var child = { id: row.id, text: row.name, pic: row.pic };
|
||||
var child = { id: row.id, text: row.name, pic: row.pic, isopen:row.isopen };
|
||||
if (node.children) {
|
||||
node.children.push(child);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
{% endif %}
|
||||
<a id="fztms" onclick="javascript:$('#fztmdg').dialog('open').window('center');" class="easyui-linkbutton"
|
||||
data-options="iconCls:'fa-clone',plain:true">复制题目至自建分类</a>
|
||||
<a id="exportquestionexcel" onclick="exportquestionexcel()" class="easyui-linkbutton" data-options="iconCls: 'fa-download',plain:true">导出Excel</a>
|
||||
<div>
|
||||
<form id='searchtmff'>
|
||||
<select name='type' style="width:100px" class="easyui-combobox" data-options="prompt:'题型'">
|
||||
|
|
@ -140,9 +141,13 @@
|
|||
},
|
||||
formatter: function (node) {
|
||||
var s = node.text;
|
||||
|
||||
if (node.children) {
|
||||
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
||||
}
|
||||
if(node.isopen==1){
|
||||
s +='<span style=\'color:red\'>(已共享)</span>'
|
||||
}
|
||||
return s;
|
||||
},
|
||||
onSelect: function (row) {
|
||||
|
|
@ -158,6 +163,7 @@
|
|||
},
|
||||
formatter: function (node) {
|
||||
var s = node.text;
|
||||
|
||||
if (node.children) {
|
||||
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
||||
}
|
||||
|
|
@ -426,4 +432,50 @@
|
|||
}; //请求完成
|
||||
xhr.onerror = function (evt) { $.messager.alert('提示', '失败!文件内容有误'); document.getElementById('drfile').value = ''; }; //请求失败
|
||||
}
|
||||
function exportquestionexcel(){
|
||||
var data = $('#tmtable').datagrid('getData');
|
||||
var datalist = data.rows;
|
||||
|
||||
var datalist_ = []
|
||||
for (var j = 0, len = datalist.length; j < len; j++) {
|
||||
var dic = datalist[j]
|
||||
var i = {}
|
||||
i["题目"] = dic.title
|
||||
i["分类"] = dic.questioncat__name
|
||||
i["题型"] = '单选'
|
||||
if(dic.type==2){
|
||||
i["题型"] = '多选'
|
||||
}
|
||||
else if(dic.type==3){
|
||||
i["题型"] = '判断'
|
||||
}
|
||||
i['选项A'] = ''
|
||||
i['选项B'] = ''
|
||||
i['选项C'] = ''
|
||||
i['选项D'] = ''
|
||||
i['选项E'] = ''
|
||||
i['选项F'] = ''
|
||||
if(dic.answer.A){
|
||||
i['选项A'] = dic.answer.A
|
||||
}
|
||||
if(dic.answer.B){
|
||||
i['选项B'] = dic.answer.B
|
||||
}
|
||||
if(dic.answer.C){
|
||||
i['选项C'] = dic.answer.C
|
||||
}
|
||||
if(dic.answer.D){
|
||||
i['选项D'] = dic.answer.D
|
||||
}
|
||||
if(dic.answer.E){
|
||||
i['选项E'] = dic.answer.E
|
||||
}
|
||||
if(dic.answer.F){
|
||||
i['选项F'] = dic.answer.F
|
||||
}
|
||||
i['正确答案'] = dic.right
|
||||
datalist_.push(i)
|
||||
}
|
||||
JSONToCSVConvertor(JSON.stringify(datalist_), "题目列表", true);
|
||||
}
|
||||
</script>
|
||||
|
|
@ -16,6 +16,10 @@
|
|||
editable="false">
|
||||
</select>
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<label>是否共享</label>
|
||||
<input type="checkbox" id="isopen" name="isopen" value="1">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@
|
|||
editable="false">
|
||||
</select>
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<label>是否共享</label>
|
||||
<input type="checkbox" id="isopen" name="isopen" value="1">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
|
|
@ -30,6 +34,9 @@
|
|||
$('#name').textbox('setValue',res.name)
|
||||
$('#tmflid').val(res.id)
|
||||
$('#parent').combotree('setValue',res.parent__id)
|
||||
if(res.isopen == 1){
|
||||
$('#isopen').attr("checked", 'checked');
|
||||
}
|
||||
})
|
||||
function submitform() {
|
||||
$.ajax({
|
||||
|
|
@ -52,6 +59,7 @@
|
|||
$("#mrfltree").tree('reload');
|
||||
$("#zjfltree").tree('reload');
|
||||
$("#dd").dialog("close");
|
||||
$('#gxfltree').tree("reload")
|
||||
} else { $.messager.alert('提示', '失败,该选项不可编辑!'); }
|
||||
$('#submitb').linkbutton('enable');
|
||||
},
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
|
||||
<script></script>
|
||||
<label>姓名</label><input id='sname' class='easyui-textbox' />
|
||||
<input id='sname' class='easyui-textbox' data-options="prompt:'姓名/账户'"/>
|
||||
<a onclick="usersearch()" class='easyui-linkbutton' iconCls='fa-search' plain=true>查询</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -2755,7 +2755,7 @@ def getuser(req):
|
|||
companyid = getcompany(userid)
|
||||
parts = Partment.objects.filter(
|
||||
partlink__contains=','+companyid+',') | Partment.objects.filter(partid=companyid)
|
||||
a = User.objects.filter(ubelongpart__in=parts, deletemark=1, name__contains=req.GET.get('name')).order_by(
|
||||
a = User.objects.filter(ubelongpart__in=parts, deletemark=1).filter(Q(name__contains=req.GET.get('name'))|Q(username__contains=req.GET.get('name'))).order_by(
|
||||
'userid').values('userid', 'empid', 'name', 'ubelongpart__partname', 'ubelongpart__partid', 'username', 'openid')
|
||||
total = a.count()
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
|
|
@ -6666,11 +6666,11 @@ def apiquestioncat(req):
|
|||
companyid = getcompany(userid)
|
||||
if a == 'tree1':
|
||||
list_items = (Questioncat.objects.filter(usecomp__partid=1, deletemark=1)).annotate(
|
||||
parentId=F('parent__id')).values('id', 'parentId', 'name')
|
||||
parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen')
|
||||
return HttpResponse(json.dumps(list(list_items)), content_type="application/json")
|
||||
elif a == 'tree2':
|
||||
list_items = (Questioncat.objects.filter(usecomp__partid=companyid, deletemark=1)).annotate(
|
||||
parentId=F('parent__id')).values('id', 'parentId', 'name')
|
||||
parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen')
|
||||
return HttpResponse(json.dumps(list(list_items)), content_type="application/json")
|
||||
elif a == 'tree3':
|
||||
groups = g_models.Groupmember.objects.filter(member__partid=companyid).values_list('group__id', flat=True)
|
||||
|
|
@ -6679,19 +6679,21 @@ def apiquestioncat(req):
|
|||
pass
|
||||
else:
|
||||
companys = Partment.objects.filter(partid=companyid).values_list('partid', flat=True)
|
||||
list_items = (Questioncat.objects.filter(usecomp__in=companys, deletemark=1)| Questioncat.objects.filter(
|
||||
usecomp__partid=1, deletemark=1)).annotate(
|
||||
parentId=F('parent__id')).values('id', 'parentId', 'name')
|
||||
list_items = (Questioncat.objects.filter(usecomp__in=companys, deletemark=1, isopen=1)| Questioncat.objects.filter(
|
||||
usecomp__partid=1, deletemark=1, isopen=1)).annotate(
|
||||
parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen')
|
||||
return HttpResponse(json.dumps(list(list_items)), content_type="application/json")
|
||||
elif a == 'tree':
|
||||
list_items = (Questioncat.objects.filter(usecomp__partid=1, deletemark=1) | Questioncat.objects.filter(
|
||||
usecomp__partid=companyid, deletemark=1)).annotate(parentId=F('parent__id')).values('id', 'parentId', 'name')
|
||||
usecomp__partid=companyid, deletemark=1)).annotate(parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen')
|
||||
return HttpResponse(json.dumps(list(list_items)), content_type="application/json")
|
||||
elif a == 'add':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
obj = Questioncat()
|
||||
name = data['name']
|
||||
obj.name = name
|
||||
if 'isopen' in data:
|
||||
obj.isopen = 1
|
||||
if 'parent' in data:
|
||||
if data['parent']:
|
||||
parent = data['parent']
|
||||
|
|
@ -6710,17 +6712,19 @@ def apiquestioncat(req):
|
|||
return JsonResponse({"code": 1})
|
||||
else:
|
||||
return JsonResponse({"code": 0})
|
||||
return JsonResponse({"code": 1})
|
||||
elif a == 'detail':
|
||||
id = req.GET.get('id')
|
||||
a = Questioncat.objects.filter(id=id).values(
|
||||
'id', 'name', 'parent__id')[0]
|
||||
'id', 'name', 'parent__id', 'isopen')[0]
|
||||
return JsonResponse(a)
|
||||
elif a == 'edit':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
id = data['id']
|
||||
a = Questioncat.objects.get(id=id)
|
||||
a.name = data['name']
|
||||
a.isopen = 0
|
||||
if 'isopen' in data:
|
||||
a.isopen = 1
|
||||
if 'parent' in data:
|
||||
if data['parent']:
|
||||
parent = Questioncat.objects.get(id=data['parent'])
|
||||
|
|
|
|||
Loading…
Reference in New Issue