题目导出
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)
|
modifytime = models.DateTimeField(auto_now=True)
|
||||||
usecomp = models.ForeignKey(
|
usecomp = models.ForeignKey(
|
||||||
Partment, on_delete=models.CASCADE, null=True, blank=True)
|
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,
|
id: row.id,
|
||||||
text: row.name,
|
text: row.name,
|
||||||
state: x,
|
state: x,
|
||||||
pic: row.pic
|
pic: row.pic,
|
||||||
|
isopen: row.isopen
|
||||||
}
|
}
|
||||||
if(row.name=='默认分类'){
|
if(row.name=='默认分类'){
|
||||||
node = {
|
node = {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
text: row.name,
|
text: row.name,
|
||||||
state: 'closed',
|
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++) {
|
for (var i = 0; i < rows.length; i++) {
|
||||||
var row = rows[i];
|
var row = rows[i];
|
||||||
if (row.parentId == node.id) {
|
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) {
|
if (node.children) {
|
||||||
node.children.push(child);
|
node.children.push(child);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a id="fztms" onclick="javascript:$('#fztmdg').dialog('open').window('center');" class="easyui-linkbutton"
|
<a id="fztms" onclick="javascript:$('#fztmdg').dialog('open').window('center');" class="easyui-linkbutton"
|
||||||
data-options="iconCls:'fa-clone',plain:true">复制题目至自建分类</a>
|
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>
|
<div>
|
||||||
<form id='searchtmff'>
|
<form id='searchtmff'>
|
||||||
<select name='type' style="width:100px" class="easyui-combobox" data-options="prompt:'题型'">
|
<select name='type' style="width:100px" class="easyui-combobox" data-options="prompt:'题型'">
|
||||||
|
|
@ -140,9 +141,13 @@
|
||||||
},
|
},
|
||||||
formatter: function (node) {
|
formatter: function (node) {
|
||||||
var s = node.text;
|
var s = node.text;
|
||||||
|
|
||||||
if (node.children) {
|
if (node.children) {
|
||||||
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
||||||
}
|
}
|
||||||
|
if(node.isopen==1){
|
||||||
|
s +='<span style=\'color:red\'>(已共享)</span>'
|
||||||
|
}
|
||||||
return s;
|
return s;
|
||||||
},
|
},
|
||||||
onSelect: function (row) {
|
onSelect: function (row) {
|
||||||
|
|
@ -158,6 +163,7 @@
|
||||||
},
|
},
|
||||||
formatter: function (node) {
|
formatter: function (node) {
|
||||||
var s = node.text;
|
var s = node.text;
|
||||||
|
|
||||||
if (node.children) {
|
if (node.children) {
|
||||||
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
||||||
}
|
}
|
||||||
|
|
@ -426,4 +432,50 @@
|
||||||
}; //请求完成
|
}; //请求完成
|
||||||
xhr.onerror = function (evt) { $.messager.alert('提示', '失败!文件内容有误'); document.getElementById('drfile').value = ''; }; //请求失败
|
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>
|
</script>
|
||||||
|
|
@ -16,6 +16,10 @@
|
||||||
editable="false">
|
editable="false">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="margin-bottom:10px">
|
||||||
|
<label>是否共享</label>
|
||||||
|
<input type="checkbox" id="isopen" name="isopen" value="1">
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@
|
||||||
editable="false">
|
editable="false">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="margin-bottom:10px">
|
||||||
|
<label>是否共享</label>
|
||||||
|
<input type="checkbox" id="isopen" name="isopen" value="1">
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -30,6 +34,9 @@
|
||||||
$('#name').textbox('setValue',res.name)
|
$('#name').textbox('setValue',res.name)
|
||||||
$('#tmflid').val(res.id)
|
$('#tmflid').val(res.id)
|
||||||
$('#parent').combotree('setValue',res.parent__id)
|
$('#parent').combotree('setValue',res.parent__id)
|
||||||
|
if(res.isopen == 1){
|
||||||
|
$('#isopen').attr("checked", 'checked');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
function submitform() {
|
function submitform() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
@ -52,6 +59,7 @@
|
||||||
$("#mrfltree").tree('reload');
|
$("#mrfltree").tree('reload');
|
||||||
$("#zjfltree").tree('reload');
|
$("#zjfltree").tree('reload');
|
||||||
$("#dd").dialog("close");
|
$("#dd").dialog("close");
|
||||||
|
$('#gxfltree').tree("reload")
|
||||||
} else { $.messager.alert('提示', '失败,该选项不可编辑!'); }
|
} else { $.messager.alert('提示', '失败,该选项不可编辑!'); }
|
||||||
$('#submitb').linkbutton('enable');
|
$('#submitb').linkbutton('enable');
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
|
|
||||||
<script></script>
|
<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>
|
<a onclick="usersearch()" class='easyui-linkbutton' iconCls='fa-search' plain=true>查询</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2755,7 +2755,7 @@ def getuser(req):
|
||||||
companyid = getcompany(userid)
|
companyid = getcompany(userid)
|
||||||
parts = Partment.objects.filter(
|
parts = Partment.objects.filter(
|
||||||
partlink__contains=','+companyid+',') | Partment.objects.filter(partid=companyid)
|
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')
|
'userid').values('userid', 'empid', 'name', 'ubelongpart__partname', 'ubelongpart__partid', 'username', 'openid')
|
||||||
total = a.count()
|
total = a.count()
|
||||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||||
|
|
@ -6666,11 +6666,11 @@ def apiquestioncat(req):
|
||||||
companyid = getcompany(userid)
|
companyid = getcompany(userid)
|
||||||
if a == 'tree1':
|
if a == 'tree1':
|
||||||
list_items = (Questioncat.objects.filter(usecomp__partid=1, deletemark=1)).annotate(
|
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")
|
return HttpResponse(json.dumps(list(list_items)), content_type="application/json")
|
||||||
elif a == 'tree2':
|
elif a == 'tree2':
|
||||||
list_items = (Questioncat.objects.filter(usecomp__partid=companyid, deletemark=1)).annotate(
|
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")
|
return HttpResponse(json.dumps(list(list_items)), content_type="application/json")
|
||||||
elif a == 'tree3':
|
elif a == 'tree3':
|
||||||
groups = g_models.Groupmember.objects.filter(member__partid=companyid).values_list('group__id', flat=True)
|
groups = g_models.Groupmember.objects.filter(member__partid=companyid).values_list('group__id', flat=True)
|
||||||
|
|
@ -6679,19 +6679,21 @@ def apiquestioncat(req):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
companys = Partment.objects.filter(partid=companyid).values_list('partid', flat=True)
|
companys = Partment.objects.filter(partid=companyid).values_list('partid', flat=True)
|
||||||
list_items = (Questioncat.objects.filter(usecomp__in=companys, deletemark=1)| Questioncat.objects.filter(
|
list_items = (Questioncat.objects.filter(usecomp__in=companys, deletemark=1, isopen=1)| Questioncat.objects.filter(
|
||||||
usecomp__partid=1, deletemark=1)).annotate(
|
usecomp__partid=1, deletemark=1, isopen=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")
|
return HttpResponse(json.dumps(list(list_items)), content_type="application/json")
|
||||||
elif a == 'tree':
|
elif a == 'tree':
|
||||||
list_items = (Questioncat.objects.filter(usecomp__partid=1, deletemark=1) | Questioncat.objects.filter(
|
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")
|
return HttpResponse(json.dumps(list(list_items)), content_type="application/json")
|
||||||
elif a == 'add':
|
elif a == 'add':
|
||||||
data = json.loads(req.body.decode('utf-8'))
|
data = json.loads(req.body.decode('utf-8'))
|
||||||
obj = Questioncat()
|
obj = Questioncat()
|
||||||
name = data['name']
|
name = data['name']
|
||||||
obj.name = name
|
obj.name = name
|
||||||
|
if 'isopen' in data:
|
||||||
|
obj.isopen = 1
|
||||||
if 'parent' in data:
|
if 'parent' in data:
|
||||||
if data['parent']:
|
if data['parent']:
|
||||||
parent = data['parent']
|
parent = data['parent']
|
||||||
|
|
@ -6710,17 +6712,19 @@ def apiquestioncat(req):
|
||||||
return JsonResponse({"code": 1})
|
return JsonResponse({"code": 1})
|
||||||
else:
|
else:
|
||||||
return JsonResponse({"code": 0})
|
return JsonResponse({"code": 0})
|
||||||
return JsonResponse({"code": 1})
|
|
||||||
elif a == 'detail':
|
elif a == 'detail':
|
||||||
id = req.GET.get('id')
|
id = req.GET.get('id')
|
||||||
a = Questioncat.objects.filter(id=id).values(
|
a = Questioncat.objects.filter(id=id).values(
|
||||||
'id', 'name', 'parent__id')[0]
|
'id', 'name', 'parent__id', 'isopen')[0]
|
||||||
return JsonResponse(a)
|
return JsonResponse(a)
|
||||||
elif a == 'edit':
|
elif a == 'edit':
|
||||||
data = json.loads(req.body.decode('utf-8'))
|
data = json.loads(req.body.decode('utf-8'))
|
||||||
id = data['id']
|
id = data['id']
|
||||||
a = Questioncat.objects.get(id=id)
|
a = Questioncat.objects.get(id=id)
|
||||||
a.name = data['name']
|
a.name = data['name']
|
||||||
|
a.isopen = 0
|
||||||
|
if 'isopen' in data:
|
||||||
|
a.isopen = 1
|
||||||
if 'parent' in data:
|
if 'parent' in data:
|
||||||
if data['parent']:
|
if data['parent']:
|
||||||
parent = Questioncat.objects.get(id=data['parent'])
|
parent = Questioncat.objects.get(id=data['parent'])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue