errorRankingForm.jsp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <%@ include file="/webpage/include/taglib.jsp"%>
  3. <html>
  4. <head>
  5. <title>试题管理</title>
  6. <meta name="decorator" content="ani"/>
  7. <script type="text/javascript">
  8. $(document).ready(function() {
  9. });
  10. function save() {
  11. //遍历复选框 为data-value属性赋值
  12. var isValidate = jp.validateForm('#inputForm');//校验表单
  13. if(!isValidate){
  14. return false;
  15. }else{
  16. jp.loading();
  17. console.log($('#inputForm').serializeArray());
  18. jp.post("${ctx}/exam/eduQuestion/save",$('#inputForm').serialize(),function(data){
  19. if(data.success){
  20. jp.getParent().refresh();
  21. var dialogIndex = parent.layer.getFrameIndex(window.name); // 获取窗口索引
  22. parent.layer.close(dialogIndex);
  23. jp.success(data.msg)
  24. }else{
  25. jp.error(data.msg);
  26. }
  27. })
  28. }
  29. }
  30. function addRow(list, idx, tpl, row){
  31. $(list).append(Mustache.render(tpl, {
  32. idx: idx, delBtn: true, row: row
  33. }));
  34. $(list+idx).find("select").each(function(){
  35. $(this).val($(this).attr("data-value"));
  36. });
  37. $(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
  38. var ss = $(this).attr("data-value").split(',');
  39. for (var i=0; i<ss.length; i++){
  40. if($(this).val() == ss[i]){
  41. $(this).attr("checked","checked");
  42. }
  43. }
  44. });
  45. $(list+idx).find(".form_datetime").each(function(){
  46. $(this).datetimepicker({
  47. format: "YYYY-MM-DD HH:mm:ss"
  48. });
  49. });
  50. }
  51. function delRow(obj, prefix){
  52. var id = $(prefix+"_id");
  53. var delFlag = $(prefix+"_delFlag");
  54. if (id.val() == ""){
  55. $(obj).parent().parent().remove();
  56. }else if(delFlag.val() == "0"){
  57. delFlag.val("1");
  58. $(obj).html("&divide;").attr("title", "撤销删除");
  59. $(obj).parent().parent().addClass("error");
  60. }else if(delFlag.val() == "1"){
  61. delFlag.val("0");
  62. $(obj).html("&times;").attr("title", "删除");
  63. $(obj).parent().parent().removeClass("error");
  64. }
  65. }
  66. function typeChange() {
  67. var type = $("#types").val();
  68. if(type == "1" || type == "2"){
  69. $(".judgment-container").css("display","none");
  70. $(".tabs-container").css("display","block");
  71. }else if(type == "3") {
  72. $(".tabs-container").css("display","none");
  73. $(".judgment-container").css("display","block");
  74. }
  75. }
  76. function radioClick(clickId) {
  77. //debugger;
  78. var $radio = $(clickId+"_isAnswer");
  79. var $not = $(clickId+"_notAnswer");
  80. if ($radio.data('checked')){
  81. $radio.prop('checked', false);
  82. $radio.data('checked', false);
  83. $not.prop('checked', true);
  84. $not.data('checked', true);
  85. } else {
  86. $radio.prop('checked', true);
  87. $radio.data('checked', true);
  88. $not.prop('checked', false);
  89. $not.data('checked', false);
  90. }
  91. }
  92. </script>
  93. </head>
  94. <body class="bg-white">
  95. <form:form id="inputForm" modelAttribute="eduQuestion" action="${ctx}/exam/eduQuestion/save" method="post" class="form-horizontal">
  96. <form:hidden path="id"/>
  97. <table class="table table-bordered">
  98. <tbody>
  99. <tr>
  100. <td class="width-15 active"><label class="pull-right"><font color="red">*</font>题干:</label></td>
  101. <td class="width-35" colspan="3">
  102. <form:input path="title" htmlEscape="false" class="form-control required"/>
  103. </td>
  104. </tr>
  105. <tr>
  106. <td class="width-15 active"><label class="pull-right">分值:</label></td>
  107. <td class="width-35">
  108. <form:input path="points" htmlEscape="false" class="form-control isFloatGtZero" readonly="true"/>
  109. </td>
  110. <td class="width-15 active"><label class="pull-right"><font color="red">*</font>题型:</label></td>
  111. <td class="width-35">
  112. <form:select path="types" onchange="typeChange()" class="form-control m-b">
  113. <form:option value="1" label="单选"/>
  114. <form:option value="2" label="多选"/>
  115. <form:option value="3" label="判断"/>
  116. </form:select>
  117. </td>
  118. </tr>
  119. <tr>
  120. <td class="width-15 active"><label class="pull-right"><font color="red">*</font>固定试题:</label></td>
  121. <td class="width-35">
  122. <form:radiobuttons path="isFix" items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required i-checks "/>
  123. </td>
  124. <td class="width-15 active"><label class="pull-right"><font color="red">*</font>批次号:</label></td>
  125. <td class="width-35">
  126. <form:select path="pici" class="form-control required">
  127. <form:option value="" label=""/>
  128. <form:options items="${fns:getDictList('edu_question_pici')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
  129. </form:select>
  130. </td>
  131. </tbody>
  132. </table>
  133. <div class = "judgment-container" style="display: none;">
  134. <table class="table table-bordered">
  135. <tbody>
  136. <tr>
  137. <td class="width-15 active"><label class="pull-right"><font color="red">*</font>答案:</label></td>
  138. <td>
  139. <div style="margin-left: 50px;">
  140. <form:radiobutton path="judgment" label="对&nbsp;&nbsp;&nbsp;&nbsp;" value="1" htmlEscape="false" class="i-checks" />
  141. <form:radiobutton path="judgment" label="错" value="0" htmlEscape="false" class="i-checks" />
  142. </div>
  143. </td>
  144. </tr>
  145. </tbody>
  146. </table>
  147. </div>
  148. <div class="tabs-container">
  149. <ul class="nav nav-tabs">
  150. <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">试题选项:</a>
  151. </li>
  152. </ul>
  153. <div class="tab-content">
  154. <div id="tab-1" class="tab-pane fade in active">
  155. <a class="btn btn-white btn-sm" onclick="addRow('#eduQuestionOptionList', eduQuestionOptionRowIdx, eduQuestionOptionTpl);eduQuestionOptionRowIdx = eduQuestionOptionRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
  156. <table class="table table-striped table-bordered table-condensed">
  157. <thead>
  158. <tr>
  159. <th class="hide"></th>
  160. <th width="650" ><font color="red">*</font>选项内容</th>
  161. <th><font color="red">*</font>正确答案</th>
  162. <th width="10">&nbsp;</th>
  163. </tr>
  164. </thead>
  165. <tbody id="eduQuestionOptionList">
  166. </tbody>
  167. </table>
  168. <script type="text/template" id="eduQuestionOptionTpl">//<!--
  169. <tr id="eduQuestionOptionList{{idx}}">
  170. <td class="hide">
  171. <input id="eduQuestionOptionList{{idx}}_id" name="eduQuestionOptionList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
  172. <input id="eduQuestionOptionList{{idx}}_delFlag" name="eduQuestionOptionList[{{idx}}].delFlag" type="hidden" value="0"/>
  173. </td>
  174. <td>
  175. <input id="eduQuestionOptionList{{idx}}_title" name="eduQuestionOptionList[{{idx}}].title" type="text" value="{{row.title}}" class="form-control required"/>
  176. </td>
  177. <td>
  178. <input type="radio" id="eduQuestionOptionList{{idx}}_isAnswer" name="eduQuestionOptionList[{{idx}}].isAnswer"
  179. value="1" class="i-checks" style="width: 20px; height: 20px; margin: 5px 30px;" data-value="{{row.isAnswer}}" onclick="radioClick('#eduQuestionOptionList{{idx}}')" />
  180. <input type="radio" id="eduQuestionOptionList{{idx}}_notAnswer" name="eduQuestionOptionList[{{idx}}].isAnswer"
  181. value="0" class="i-checks" checked="true" style="display: none;" data-value="{{row.isAnswer}}" />
  182. </td>
  183. <td class="text-center" width="10">
  184. {{#delBtn}}<span class="close" onclick="delRow(this, '#eduQuestionOptionList{{idx}}')" title="删除">&times;</span>{{/delBtn}}
  185. </td>
  186. </tr>//-->
  187. </script>
  188. <script type="text/javascript">
  189. var eduQuestionOptionRowIdx = 0, eduQuestionOptionTpl = $("#eduQuestionOptionTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
  190. $(document).ready(function() {
  191. //debugger;
  192. var type = $("#types").val();
  193. if(type != '3'){
  194. var data = ${fns:toJson(eduQuestion.eduQuestionOptionList)};
  195. for (var i=0; i<data.length; i++){
  196. addRow('#eduQuestionOptionList', eduQuestionOptionRowIdx, eduQuestionOptionTpl, data[i]);
  197. eduQuestionOptionRowIdx = eduQuestionOptionRowIdx + 1;
  198. }
  199. }else {
  200. $(".tabs-container").css("display","none");
  201. $(".judgment-container").css("display","block");
  202. }
  203. });
  204. </script>
  205. </div>
  206. </div>
  207. </div>
  208. </form:form>
  209. </body>
  210. </html>