123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- <%@ page contentType="text/html;charset=UTF-8" %>
- <%@ include file="/webpage/include/taglib.jsp"%>
- <html>
- <head>
- <title>试题管理</title>
- <meta name="decorator" content="ani"/>
- <script type="text/javascript">
- $(document).ready(function() {
- });
- function save() {
- //遍历复选框 为data-value属性赋值
- var isValidate = jp.validateForm('#inputForm');//校验表单
- if(!isValidate){
- return false;
- }else{
- jp.loading();
- console.log($('#inputForm').serializeArray());
- jp.post("${ctx}/exam/eduQuestion/save",$('#inputForm').serialize(),function(data){
- if(data.success){
- jp.getParent().refresh();
- var dialogIndex = parent.layer.getFrameIndex(window.name); // 获取窗口索引
- parent.layer.close(dialogIndex);
- jp.success(data.msg)
- }else{
- jp.error(data.msg);
- }
- })
- }
- }
- function addRow(list, idx, tpl, row){
- $(list).append(Mustache.render(tpl, {
- idx: idx, delBtn: true, row: row
- }));
- $(list+idx).find("select").each(function(){
- $(this).val($(this).attr("data-value"));
- });
- $(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
- var ss = $(this).attr("data-value").split(',');
- for (var i=0; i<ss.length; i++){
- if($(this).val() == ss[i]){
- $(this).attr("checked","checked");
- }
- }
- });
- $(list+idx).find(".form_datetime").each(function(){
- $(this).datetimepicker({
- format: "YYYY-MM-DD HH:mm:ss"
- });
- });
- }
- function delRow(obj, prefix){
- var id = $(prefix+"_id");
- var delFlag = $(prefix+"_delFlag");
- if (id.val() == ""){
- $(obj).parent().parent().remove();
- }else if(delFlag.val() == "0"){
- delFlag.val("1");
- $(obj).html("÷").attr("title", "撤销删除");
- $(obj).parent().parent().addClass("error");
- }else if(delFlag.val() == "1"){
- delFlag.val("0");
- $(obj).html("×").attr("title", "删除");
- $(obj).parent().parent().removeClass("error");
- }
- }
- function typeChange() {
- var type = $("#types").val();
- if(type == "1" || type == "2"){
- $(".judgment-container").css("display","none");
- $(".tabs-container").css("display","block");
- }else if(type == "3") {
- $(".tabs-container").css("display","none");
- $(".judgment-container").css("display","block");
- }
- }
-
- function radioClick(clickId) {
- //debugger;
- var $radio = $(clickId+"_isAnswer");
- var $not = $(clickId+"_notAnswer");
- if ($radio.data('checked')){
- $radio.prop('checked', false);
- $radio.data('checked', false);
- $not.prop('checked', true);
- $not.data('checked', true);
- } else {
- $radio.prop('checked', true);
- $radio.data('checked', true);
- $not.prop('checked', false);
- $not.data('checked', false);
- }
- }
- </script>
- </head>
- <body class="bg-white">
- <form:form id="inputForm" modelAttribute="eduQuestion" action="${ctx}/exam/eduQuestion/save" method="post" class="form-horizontal">
- <form:hidden path="id"/>
- <table class="table table-bordered">
- <tbody>
- <tr>
- <td class="width-15 active"><label class="pull-right"><font color="red">*</font>题干:</label></td>
- <td class="width-35" colspan="3">
- <form:input path="title" htmlEscape="false" class="form-control required"/>
- </td>
- </tr>
- <tr>
- <td class="width-15 active"><label class="pull-right">分值:</label></td>
- <td class="width-35">
- <form:input path="points" htmlEscape="false" class="form-control isFloatGtZero" readonly="true"/>
- </td>
- <td class="width-15 active"><label class="pull-right"><font color="red">*</font>题型:</label></td>
- <td class="width-35">
- <form:select path="types" onchange="typeChange()" class="form-control m-b">
- <form:option value="1" label="单选"/>
- <form:option value="2" label="多选"/>
- <form:option value="3" label="判断"/>
- </form:select>
- </td>
- </tr>
- <tr>
- <td class="width-15 active"><label class="pull-right"><font color="red">*</font>固定试题:</label></td>
- <td class="width-35">
- <form:radiobuttons path="isFix" items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required i-checks "/>
- </td>
- <td class="width-15 active"><label class="pull-right"><font color="red">*</font>批次号:</label></td>
- <td class="width-35">
- <form:select path="pici" class="form-control required">
- <form:option value="" label=""/>
- <form:options items="${fns:getDictList('edu_question_pici')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
- </form:select>
- </td>
- </tbody>
- </table>
- <div class = "judgment-container" style="display: none;">
- <table class="table table-bordered">
- <tbody>
- <tr>
- <td class="width-15 active"><label class="pull-right"><font color="red">*</font>答案:</label></td>
- <td>
- <div style="margin-left: 50px;">
- <form:radiobutton path="judgment" label="对 " value="1" htmlEscape="false" class="i-checks" />
- <form:radiobutton path="judgment" label="错" value="0" htmlEscape="false" class="i-checks" />
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <div class="tabs-container">
- <ul class="nav nav-tabs">
- <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">试题选项:</a>
- </li>
- </ul>
- <div class="tab-content">
- <div id="tab-1" class="tab-pane fade in active">
- <a class="btn btn-white btn-sm" onclick="addRow('#eduQuestionOptionList', eduQuestionOptionRowIdx, eduQuestionOptionTpl);eduQuestionOptionRowIdx = eduQuestionOptionRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
- <table class="table table-striped table-bordered table-condensed">
- <thead>
- <tr>
- <th class="hide"></th>
- <th width="650" ><font color="red">*</font>选项内容</th>
- <th><font color="red">*</font>正确答案</th>
- <th width="10"> </th>
- </tr>
- </thead>
- <tbody id="eduQuestionOptionList">
- </tbody>
- </table>
- <script type="text/template" id="eduQuestionOptionTpl">//<!--
- <tr id="eduQuestionOptionList{{idx}}">
- <td class="hide">
- <input id="eduQuestionOptionList{{idx}}_id" name="eduQuestionOptionList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
- <input id="eduQuestionOptionList{{idx}}_delFlag" name="eduQuestionOptionList[{{idx}}].delFlag" type="hidden" value="0"/>
- </td>
-
- <td>
- <input id="eduQuestionOptionList{{idx}}_title" name="eduQuestionOptionList[{{idx}}].title" type="text" value="{{row.title}}" class="form-control required"/>
- </td>
- <td>
- <input type="radio" id="eduQuestionOptionList{{idx}}_isAnswer" name="eduQuestionOptionList[{{idx}}].isAnswer"
- value="1" class="i-checks" style="width: 20px; height: 20px; margin: 5px 30px;" data-value="{{row.isAnswer}}" onclick="radioClick('#eduQuestionOptionList{{idx}}')" />
- <input type="radio" id="eduQuestionOptionList{{idx}}_notAnswer" name="eduQuestionOptionList[{{idx}}].isAnswer"
- value="0" class="i-checks" checked="true" style="display: none;" data-value="{{row.isAnswer}}" />
- </td>
- <td class="text-center" width="10">
- {{#delBtn}}<span class="close" onclick="delRow(this, '#eduQuestionOptionList{{idx}}')" title="删除">×</span>{{/delBtn}}
- </td>
- </tr>//-->
- </script>
- <script type="text/javascript">
- var eduQuestionOptionRowIdx = 0, eduQuestionOptionTpl = $("#eduQuestionOptionTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
- $(document).ready(function() {
- //debugger;
- var type = $("#types").val();
- if(type != '3'){
- var data = ${fns:toJson(eduQuestion.eduQuestionOptionList)};
- for (var i=0; i<data.length; i++){
- addRow('#eduQuestionOptionList', eduQuestionOptionRowIdx, eduQuestionOptionTpl, data[i]);
- eduQuestionOptionRowIdx = eduQuestionOptionRowIdx + 1;
- }
- }else {
- $(".tabs-container").css("display","none");
- $(".judgment-container").css("display","block");
- }
- });
- </script>
- </div>
- </div>
- </div>
- </form:form>
- </body>
- </html>
|