多选,单选,判断
This commit is contained in:
parent
3ead7cdeda
commit
3611278756
|
|
@ -46,6 +46,22 @@ public class ExamQuestionController extends BaseController
|
|||
mmap.put("type",1);
|
||||
return prefix + "/choiceadd";
|
||||
}
|
||||
|
||||
@GetMapping("/morechoiceadd/{id}")
|
||||
public String addMoreChoiceUrl(@PathVariable("id") String id, ModelMap mmap)
|
||||
{
|
||||
mmap.put("categoryId",id);
|
||||
mmap.put("type",2);
|
||||
return prefix + "/morechoiceadd";
|
||||
}
|
||||
|
||||
@GetMapping("/judgeadd/{id}")
|
||||
public String JudgeUrl(@PathVariable("id") String id, ModelMap mmap)
|
||||
{
|
||||
mmap.put("categoryId",id);
|
||||
mmap.put("type",3);
|
||||
return prefix + "/judgeadd";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询问题列表
|
||||
|
|
|
|||
|
|
@ -62,7 +62,13 @@
|
|||
|
||||
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
|
||||
<a class="btn btn-success" onclick="addChoiceQuestion()" shiro:hasPermission="exam:examQuestion:add">
|
||||
<i class="fa fa-plus"></i> 添加选择题
|
||||
<i class="fa fa-plus"></i> 添加单选题
|
||||
</a>
|
||||
<a class="btn btn-success" onclick="addMoreChoiceQuestion()" shiro:hasPermission="exam:examQuestion:add">
|
||||
<i class="fa fa-plus"></i> 添加多选题
|
||||
</a>
|
||||
<a class="btn btn-success" onclick="addJudgeQuestion()" shiro:hasPermission="exam:examQuestion:add">
|
||||
<i class="fa fa-plus"></i> 添加判断题
|
||||
</a>
|
||||
<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
|
||||
shiro:hasPermission="exam:examQuestion:edit">
|
||||
|
|
@ -219,7 +225,25 @@
|
|||
return;
|
||||
}
|
||||
var url = prefix + "/choiceadd/"+$("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加选择题",url);
|
||||
$.operate.jumpModeltoUrl("添加单选题",url);
|
||||
}
|
||||
|
||||
function addMoreChoiceQuestion(){
|
||||
if($("#categoryId").val() == null||$("#categoryId").val() == ''){
|
||||
alert("请选择题库!")
|
||||
return;
|
||||
}
|
||||
var url = prefix + "/morechoiceadd/"+$("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加多选题",url);
|
||||
}
|
||||
|
||||
function addJudgeQuestion(){
|
||||
if($("#categoryId").val() == null||$("#categoryId").val() == ''){
|
||||
alert("请选择题库!")
|
||||
return;
|
||||
}
|
||||
var url = prefix + "/judgeadd/"+$("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加多选题",url);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,148 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<meta charset="utf-8">
|
||||
<head th:include="include :: header"></head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-examQuestion-add">
|
||||
<div class="form-group">
|
||||
<input type="hidden" id="categoryId" name="categoryId" th:value="${categoryId}">
|
||||
<input type="hidden" id="type" name="type" th:value="${type}">
|
||||
<label class="col-sm-3 control-label">问题标题:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="title" name="title" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="form-group">-->
|
||||
<!--<label class="col-sm-3 control-label">问题答案:</label>-->
|
||||
<!--<div class="col-sm-8">-->
|
||||
<!--<input id="answer" name="answer" class="form-control" type="text">-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
|
||||
<div class="form-group" >
|
||||
<label class="col-sm-3 control-label">问题选项:</label>
|
||||
<div class="col-sm-1" style="padding-right: 0px;">
|
||||
<input class="form-control" name="answer" value="A" type="radio" style="margin: 0 0 0;">
|
||||
</div>
|
||||
<div class="col-sm-1" style="padding-right: 0px;padding-left: 0px">
|
||||
<input style="padding: 6px 10px;text-align: center" id="number1" name="number" class="form-control" type="text" value="A" readonly>
|
||||
</div>
|
||||
<div class="col-sm-6" style="padding-left: 0px">
|
||||
<input id="content1" name="content" class="form-control" type="text" value="正确" readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group" >
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-1" style="padding-right: 0px;">
|
||||
<input class="form-control" name="answer" value="B" type="radio" style="margin: 0 0 0;" >
|
||||
</div>
|
||||
<div class="col-sm-1" style="padding-right: 0px;padding-left: 0px">
|
||||
<input style="padding: 6px 10px;text-align: center" id="number2" name="number" class="form-control" type="text" value="B" readonly>
|
||||
</div>
|
||||
<div class="col-sm-6" style="padding-left: 0px">
|
||||
<input id="content2" name="content" class="form-control" type="text" value="错误" readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--</div>-->
|
||||
|
||||
<!--<div class="form-group">-->
|
||||
<!--<label class="col-sm-3 control-label">标签:</label>-->
|
||||
<!--<div class="col-sm-8">-->
|
||||
<!--<input id="label" name="label" class="form-control" type="text">-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">备注信息:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="remarks" name="remarks" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div th:include="include::footer"></div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
if ($.validator) {
|
||||
$.validator.prototype.elements = function () {
|
||||
var validator = this,
|
||||
rulesCache = {};
|
||||
return $([]).add(this.currentForm.elements)
|
||||
.filter(":input")
|
||||
.not(":submit, :reset, :image, [disabled]")
|
||||
.not(this.settings.ignore)
|
||||
.filter(function () {
|
||||
var elementIdentification = this.id || this.name;
|
||||
!elementIdentification && validator.settings.debug && window.console && console.error("%o has no id nor name assigned", this);
|
||||
if (elementIdentification in rulesCache || !validator.objectLength($(this).rules()))
|
||||
return false;
|
||||
rulesCache[elementIdentification] = true;
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var item = ["C","D","E","F","G","H","I","G","K","L","M","N"];
|
||||
var index = 0;
|
||||
var prefix = ctx + "exam/examQuestion"
|
||||
$("#form-examQuestion-add").validate({
|
||||
rules:{
|
||||
title:{
|
||||
required:true,
|
||||
},
|
||||
content:{
|
||||
required:true,
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/add", $('#form-examQuestion-add').serialize());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function addOption(){
|
||||
$("#addOption").before(' <div class="form-group update1" id="div'+item[index]+'"> <label class="col-sm-3 control-label"></label><div class="col-sm-1" style="padding-right: 0px;"> <input class="form-control update4" name="answer" value="'+item[index]+'" type="checkbox" style="margin: 0 0 0;">' +
|
||||
'</div><div class="col-sm-1" style="padding-right: 0px;padding-left: 0px"> ' +
|
||||
'<input style="padding: 6px 10px;text-align: center" id="number'+item[index]+'" name="number" class="form-control update2" type="text" value="'+item[index]+'" readonly> ' +
|
||||
'</div> <div class="col-sm-6" style="padding-left: 0px"> <input name="content" class="form-control" type="text"> </div> <div class="col-sm-1"> <a class="update3" style="text-align: center;color: #999;border: 1px #ccc dashed;display:block;height: 34px;line-height: 34px" href="javascript:deleteOption(\''+item[index++]+'\');">X</a> </div></div>')
|
||||
}
|
||||
|
||||
function deleteOption(id){
|
||||
debugger
|
||||
$("#div"+id).remove();
|
||||
index--;
|
||||
var index1 = 0;
|
||||
var index2 = 0;
|
||||
var index3 = 0;
|
||||
var index4 = 0
|
||||
$(".update1").each(function(){
|
||||
$(this).attr("id","div"+item[index1++])
|
||||
})
|
||||
$(".update2").each(function(){
|
||||
$(this).attr("value",item[index2++])
|
||||
})
|
||||
$(".update3").each(function(){
|
||||
$(this).attr("href",'javascript:deleteOption(\''+item[index3++]+'\');');
|
||||
})
|
||||
$(".update4").each(function(){
|
||||
$(this).attr("value",'javascript:deleteOption(\''+item[index4++]+'\');');
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<meta charset="utf-8">
|
||||
<head th:include="include :: header"></head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-examQuestion-add">
|
||||
<div class="form-group">
|
||||
<input type="hidden" id="categoryId" name="categoryId" th:value="${categoryId}">
|
||||
<input type="hidden" id="type" name="type" th:value="${type}">
|
||||
<label class="col-sm-3 control-label">问题标题:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="title" name="title" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="form-group">-->
|
||||
<!--<label class="col-sm-3 control-label">问题答案:</label>-->
|
||||
<!--<div class="col-sm-8">-->
|
||||
<!--<input id="answer" name="answer" class="form-control" type="text">-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
|
||||
<div class="form-group" >
|
||||
<label class="col-sm-3 control-label">问题选项:</label>
|
||||
<div class="col-sm-1" style="padding-right: 0px;">
|
||||
<input class="form-control" name="answer" value="A" type="checkbox" style="margin: 0 0 0;">
|
||||
</div>
|
||||
<div class="col-sm-1" style="padding-right: 0px;padding-left: 0px">
|
||||
<input style="padding: 6px 10px;text-align: center" id="number1" name="number" class="form-control" type="text" value="A" readonly>
|
||||
</div>
|
||||
<div class="col-sm-6" style="padding-left: 0px">
|
||||
<input id="content1" name="content" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" >
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-1" style="padding-right: 0px;">
|
||||
<input class="form-control" name="answer" value="B" type="checkbox" style="margin: 0 0 0;">
|
||||
</div>
|
||||
<div class="col-sm-1" style="padding-right: 0px;padding-left: 0px">
|
||||
<input style="padding: 6px 10px;text-align: center" id="number2" name="number" class="form-control" type="text" value="B" readonly>
|
||||
</div>
|
||||
<div class="col-sm-6" style="padding-left: 0px">
|
||||
<input id="content2" name="content" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="addOption">
|
||||
<label class="col-sm-4 control-label"></label>
|
||||
<div class="col-sm-7" style="padding-left: 0px">
|
||||
<a style="text-align: center;color: #999;border: 1px #ccc dashed;display:block;height: 34px
|
||||
;line-height: 34px" href="javascript:addOption();">添加选项</a>
|
||||
</div>
|
||||
</div>
|
||||
<!--</div>-->
|
||||
|
||||
<!--<div class="form-group">-->
|
||||
<!--<label class="col-sm-3 control-label">标签:</label>-->
|
||||
<!--<div class="col-sm-8">-->
|
||||
<!--<input id="label" name="label" class="form-control" type="text">-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">备注信息:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="remarks" name="remarks" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div th:include="include::footer"></div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
if ($.validator) {
|
||||
$.validator.prototype.elements = function () {
|
||||
var validator = this,
|
||||
rulesCache = {};
|
||||
return $([]).add(this.currentForm.elements)
|
||||
.filter(":input")
|
||||
.not(":submit, :reset, :image, [disabled]")
|
||||
.not(this.settings.ignore)
|
||||
.filter(function () {
|
||||
var elementIdentification = this.id || this.name;
|
||||
!elementIdentification && validator.settings.debug && window.console && console.error("%o has no id nor name assigned", this);
|
||||
if (elementIdentification in rulesCache || !validator.objectLength($(this).rules()))
|
||||
return false;
|
||||
rulesCache[elementIdentification] = true;
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var item = ["C","D","E","F","G","H","I","G","K","L","M","N"];
|
||||
var index = 0;
|
||||
var prefix = ctx + "exam/examQuestion"
|
||||
$("#form-examQuestion-add").validate({
|
||||
rules:{
|
||||
title:{
|
||||
required:true,
|
||||
},
|
||||
content:{
|
||||
required:true,
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/add", $('#form-examQuestion-add').serialize());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function addOption(){
|
||||
$("#addOption").before(' <div class="form-group update1" id="div'+item[index]+'"> <label class="col-sm-3 control-label"></label><div class="col-sm-1" style="padding-right: 0px;"> <input class="form-control update4" name="answer" value="'+item[index]+'" type="checkbox" style="margin: 0 0 0;">' +
|
||||
'</div><div class="col-sm-1" style="padding-right: 0px;padding-left: 0px"> ' +
|
||||
'<input style="padding: 6px 10px;text-align: center" id="number'+item[index]+'" name="number" class="form-control update2" type="text" value="'+item[index]+'" readonly> ' +
|
||||
'</div> <div class="col-sm-6" style="padding-left: 0px"> <input name="content" class="form-control" type="text"> </div> <div class="col-sm-1"> <a class="update3" style="text-align: center;color: #999;border: 1px #ccc dashed;display:block;height: 34px;line-height: 34px" href="javascript:deleteOption(\''+item[index++]+'\');">X</a> </div></div>')
|
||||
}
|
||||
|
||||
function deleteOption(id){
|
||||
debugger
|
||||
$("#div"+id).remove();
|
||||
index--;
|
||||
var index1 = 0;
|
||||
var index2 = 0;
|
||||
var index3 = 0;
|
||||
var index4 = 0
|
||||
$(".update1").each(function(){
|
||||
$(this).attr("id","div"+item[index1++])
|
||||
})
|
||||
$(".update2").each(function(){
|
||||
$(this).attr("value",item[index2++])
|
||||
})
|
||||
$(".update3").each(function(){
|
||||
$(this).attr("href",'javascript:deleteOption(\''+item[index3++]+'\');');
|
||||
})
|
||||
$(".update4").each(function(){
|
||||
$(this).attr("value",'javascript:deleteOption(\''+item[index4++]+'\');');
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue