查看全部题目,复制题目到自己题库
This commit is contained in:
parent
6cf0bedfdc
commit
cf9d681843
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 2.2.8 on 2020-10-27 16:56
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0363_auto_20201015_2158'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AddField(
|
||||
model_name='question',
|
||||
name='parent',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='safesite.Question'),
|
||||
),
|
||||
]
|
|
@ -715,6 +715,8 @@ class Question(models.Model): # 题库
|
|||
User, blank=True, null=True, on_delete=models.CASCADE)
|
||||
creattime = models.DateTimeField(default=timezone.now)
|
||||
modifytime = models.DateTimeField(auto_now=True)
|
||||
parent = models.ForeignKey(
|
||||
'self', blank=True, null=True, on_delete=models.CASCADE)
|
||||
usecomps = models.TextField(default=',1,')
|
||||
nousecomps = models.TextField(default='')
|
||||
|
||||
|
|
|
@ -51,7 +51,8 @@
|
|||
<a id="drtms" onclick="javascript:$('#drtmdg').dialog('open').window('center');" class="easyui-linkbutton"
|
||||
data-options="iconCls:'fa-upload',plain:true">导入试题</a>
|
||||
{% endif %}
|
||||
|
||||
<a id="fztms" onclick="javascript:$('#fztmdg').dialog('open').window('center');" class="easyui-linkbutton"
|
||||
data-options="iconCls:'fa-clone',plain:true">复制题目至自建分类</a>
|
||||
<div>
|
||||
<form id='searchtmff'>
|
||||
<select name='type' style="width:100px" class="easyui-combobox" data-options="prompt:'题型'">
|
||||
|
@ -60,10 +61,13 @@
|
|||
<option value="2">多选</option>
|
||||
<option value="3">判断</option>
|
||||
</select>
|
||||
<input class="easyui-textbox" style="width:300px" name="name" data-options="prompt:'题干'"></input>
|
||||
<input class="easyui-textbox" style="width:300px" name="title" data-options="prompt:'题干/分类名'"></input>
|
||||
|
||||
<label>显示全部</label>
|
||||
<input type="checkbox" id="showAll">
|
||||
<a onclick="searchTm" class="easyui-linkbutton" data-options="iconCls:'fa-search',plain:true">查询</a>
|
||||
<input type="checkbox" id="showAll" name="all" value="1">
|
||||
<a onclick="searchTm()" class="easyui-linkbutton" data-options="iconCls:'fa-search',plain:true">查询</a>
|
||||
<a onclick="reset()" class="easyui-linkbutton"
|
||||
data-options="iconCls:'fa-undo',plain:true">重置</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -77,6 +81,29 @@
|
|||
<p style="margin-left: 10px">录入完成后点击下方按钮上传文件</p>
|
||||
<input type="file" id="drfile" name="" accept=".xls,.xlsx" style="margin-left: 10px" />
|
||||
</div>
|
||||
<div id="fztmdg" class="easyui-dialog" title="复制题目至" style="width:400px;height:200px;" data-options="iconCls:'fa-clone',resizable:true,modal:true,closed:true,border:false">
|
||||
<form id="fztmff">
|
||||
<p style="margin-left: 10px"><input class="easyui-combotree" name="questioncat" style="width:300px;margin-top:6px" data-options="
|
||||
label:'自建分类',
|
||||
url: 'api/questioncat?a=tree2',
|
||||
method: 'get',
|
||||
editable: false,
|
||||
loadFilter: function (rows) {
|
||||
return convert(rows);
|
||||
},
|
||||
formatter: function (node) {
|
||||
var s = node.text;
|
||||
if (node.children) {
|
||||
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
||||
}
|
||||
return s;
|
||||
},"
|
||||
required=true></p>
|
||||
<p style="margin-left: 10px">
|
||||
<a id="confirmfzb" onclick="confirmfz()" class="easyui-linkbutton" >确定</a></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$('#mrfl').panel()
|
||||
|
@ -123,6 +150,7 @@
|
|||
});
|
||||
$('#gwfl').datagrid({
|
||||
url: 'grouphandle?a=list',
|
||||
|
||||
rownumbers: true,
|
||||
singleSelect: true,
|
||||
striped: true,
|
||||
|
@ -141,9 +169,10 @@
|
|||
}
|
||||
});
|
||||
$('#tmtable').datagrid({
|
||||
url:'api/question?a=listall',
|
||||
url:'api/question',
|
||||
queryParams:{a:'listall'},
|
||||
rownumbers: true,
|
||||
singleSelect: true,
|
||||
singleSelect: false,
|
||||
striped: true,
|
||||
method: 'get',
|
||||
toolbar: '#tmbar',
|
||||
|
@ -151,6 +180,7 @@
|
|||
pageSize: 20,
|
||||
columns: [[
|
||||
{ field: 'id', title: 'ID', hidden: true },
|
||||
{ field: 'ck', checkbox: true , width: '5%'},
|
||||
{ field: 'title', title: '题目', width: '45%' },
|
||||
{ field: 'type', title: '题型', width: '10%', formatter: function (value, row, index) {
|
||||
if (value == 1) {
|
||||
|
@ -279,13 +309,60 @@
|
|||
$.messager.alert('提示', '请选择一道题目!');
|
||||
}
|
||||
}
|
||||
$("#showAll").click(function () {
|
||||
if ($(this).prop("checked")) {
|
||||
alert("选中");
|
||||
} else {
|
||||
alert("没有选中");
|
||||
function searchTm() {
|
||||
var querydata = $('#searchtmff').serializeJSON();
|
||||
querydata['a'] = 'listall'
|
||||
querydata['tmlx'] = ''
|
||||
$('#tmtable').datagrid('reload', querydata);
|
||||
}
|
||||
function confirmfz() {
|
||||
var rows = $('#tmtable').datagrid('getSelections');
|
||||
if(rows.length>0){
|
||||
var data = $('#fztmff').serializeJSON();
|
||||
var ids = []
|
||||
for(var i=0;i<rows.length;i++){
|
||||
ids.push(rows[i].id)
|
||||
}
|
||||
data['ids'] = ids
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'api/question?a=copy',
|
||||
data: JSON.stringify(data),
|
||||
datatype: "json",
|
||||
processData: false,
|
||||
contentType: "application/json;charset=utf-8",
|
||||
beforeSend: function () {
|
||||
var bo = $('#fztmff').form('validate')
|
||||
if (bo == false) {
|
||||
return bo
|
||||
} else {
|
||||
$('#confirmfzb').linkbutton('disable');
|
||||
}
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.code == 1) {
|
||||
$.messager.show({
|
||||
title:'复制成功',
|
||||
msg:'成功复制'+rows.length+'道题,'+'可在自建分类下查看',
|
||||
timeout:5000,
|
||||
showType:'slide'
|
||||
});
|
||||
$("#fztmdg").dialog("close");
|
||||
} else { $.messager.alert('提示', '失败!'); }
|
||||
$('#confirmfzb').linkbutton('enable');
|
||||
},
|
||||
complete:function(){
|
||||
$('#confirmfzb').linkbutton('enable');
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$.messager.alert('','未选择题目');
|
||||
}
|
||||
});
|
||||
}
|
||||
function reset() {
|
||||
$('#searchtmff').form('clear')
|
||||
$('#tmtable').datagrid('reload', {'tmlx':''})
|
||||
}
|
||||
document.getElementById('drfile').onchange = function () {
|
||||
var fileObj = this.files[0];
|
||||
var url = 'drapi?a=question'
|
||||
|
|
|
@ -11,7 +11,19 @@
|
|||
<div data-options="region:'center',title:'题目',split:true,border:false" style="height:100%;">
|
||||
|
||||
<div id="tmbar" style="padding:5px;height:auto">
|
||||
|
||||
<form id='searchtmff'>
|
||||
<select name='type' style="width:100px" class="easyui-combobox" data-options="prompt:'题型'">
|
||||
<option value=""></option>
|
||||
<option value="1">单选</option>
|
||||
<option value="2">多选</option>
|
||||
<option value="3">判断</option>
|
||||
</select>
|
||||
<input class="easyui-textbox" style="width:300px" name="title" data-options="prompt:'题干/分类名'"></input>
|
||||
|
||||
<label>显示全部</label>
|
||||
<input type="checkbox" id="showAll" name="all" value="1">
|
||||
<a onclick="searchTm()" class="easyui-linkbutton" data-options="iconCls:'fa-search',plain:true">查询</a>
|
||||
</form>
|
||||
</div>
|
||||
<table id="tmtable" style="height:100%;"></table>
|
||||
|
||||
|
@ -126,6 +138,11 @@
|
|||
|
||||
]],
|
||||
});
|
||||
function searchTm() {
|
||||
var querydata = $('#searchtmff').serializeJSON();
|
||||
querydata['a'] = 'listall'
|
||||
$('#tmtable').datagrid('load', querydata);
|
||||
}
|
||||
function tmxzsubmitForm(){
|
||||
var ss = [];
|
||||
var rows = $('#tmtable').datagrid('getSelections');
|
||||
|
|
|
@ -5752,20 +5752,27 @@ def apiquestion(req):
|
|||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
if a == 'listall':
|
||||
x = Question.objects.filter(deletemark=1)
|
||||
a = x.exclude(nousecomps__contains=','+companyid+',').filter(Q(usecomps__contains=',1,') | Q(usecomps__contains=','+companyid+','))
|
||||
if req.GET.get('tmlx'):
|
||||
objs = Question.objects.filter(deletemark=1)
|
||||
if not req.GET.get('all', None):
|
||||
objs = objs.exclude(nousecomps__contains=','+companyid+',').filter(Q(usecomps__contains=',1,') | Q(usecomps__contains=','+companyid+','))
|
||||
else:
|
||||
objs = objs.filter(parent__isnull=True)
|
||||
if req.GET.get('type', None):
|
||||
objs = objs.filter(type=req.GET.get('type'))
|
||||
if req.GET.get('title', None):
|
||||
objs = objs.filter(Q(title__contains=req.GET.get('title'))|Q(questioncat__name__contains=req.GET.get('title')))
|
||||
if req.GET.get('tmlx', None):
|
||||
tmlx = req.GET.get('tmlx')
|
||||
a = a.filter(Q(questioncat__link__contains=',' +
|
||||
objs = objs.filter(Q(questioncat__link__contains=',' +
|
||||
str(tmlx)+',') | Q(questioncat__id=tmlx))
|
||||
elif req.GET.get('gwlx'):
|
||||
if req.GET.get('gwlx', None):
|
||||
gwlx = req.GET.get('gwlx')
|
||||
a = a.filter(station=Group.objects.get(groupid=gwlx))
|
||||
total = a.count()
|
||||
objs = objs.filter(station=Group.objects.get(groupid=gwlx))
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
a = a.order_by('-id')[startnum:endnum].values('id', 'title', 'type', 'level', 'questioncat__id',
|
||||
objsdata = objs.order_by('-id')[startnum:endnum].values('id', 'title', 'type', 'level', 'questioncat__id',
|
||||
'questioncat__name', 'mark', 'createuser__name', 'answer', 'right', 'resolution','usecomps')
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
return HttpResponse(transjson(total, objsdata), content_type="application/json")
|
||||
elif a == 'search':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
tmfls = data['tmfls']
|
||||
|
@ -5857,6 +5864,20 @@ def apiquestion(req):
|
|||
a = a[:10].values('id', 'title', 'type', 'level', 'questioncat__id',
|
||||
'questioncat__name', 'mark', 'createuser__name', 'answer', 'right', 'resolution')
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
elif a == 'copy':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
ids = data['ids']
|
||||
questioncat = data['questioncat']
|
||||
for i in ids:
|
||||
question = Question.objects.get(pk=i)
|
||||
question.parent = Question.objects.get(pk=i)
|
||||
question.usecomps = ','+str(companyid)+','
|
||||
question.nousecomps = ''
|
||||
question.questioncat = Questioncat.objects.get(pk=questioncat)
|
||||
question.pk=None
|
||||
question.save()
|
||||
return JsonResponse({"code": 1})
|
||||
|
||||
|
||||
|
||||
def apiexampaper(req):
|
||||
|
|
Loading…
Reference in New Issue