examPage.jsp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  2. <%@ include file="/webpage/include/taglibf.jsp"%>
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <meta charset="utf-8">
  7. <title>${fns:getConfig("productName")}</title>
  8. <link rel="stylesheet" href="${ctxStaticWeb}/css/base.css" />
  9. <link rel="stylesheet" href="${ctxStaticWeb}/css/second.css" />
  10. <link href="${ctx}/static/plugin/layui/dist/css/layui.css" rel="stylesheet" />
  11. <script src="${ctx}/static/web/js/jquery-2.1.4.js"></script>
  12. <script src="${ctx}/static/plugin/jquery-validation/1.14.0/jquery.validate.js" type="text/javascript"></script>
  13. <script src="${ctx}/static/plugin/jquery-validation/1.14.0/localization/messages_zh.min.js" type="text/javascript"></script>
  14. <script src="${ctxStatic}/plugin/layui/layer/layer.js"></script>
  15. <script src="${ctxStatic}/plugin/layui/laytpl/laytpl.js"></script>
  16. <script src="${ctxStatic}/plugin/vue/vue.js"></script>
  17. <link rel="stylesheet" type="text/css" href="${ctxStaticWeb}/css/dj.css" />
  18. <style>
  19. h2 div{
  20. display: inline;
  21. }
  22. label div{
  23. display: inline;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <%@ include file="/webpage/modules/web/top.jsp"%>
  29. <div id="app" class="contant c">
  30. <div class="dtk">
  31. <div class="time">剩余时间<p>{{count}}</p>
  32. </div>
  33. <div class="title">
  34. <div class="title_border"></div>
  35. <div class="title_content">答题卡</div>
  36. </div>
  37. <div class="card-content-title">{{testInfo.paperName}}(共{{sum}}题,合计{{testInfo.points}}分)</div>
  38. <div class="box-list clearfix">
  39. <div v-for="(question, i) in questionList">
  40. <a :herf="'#'+i" :class="questionList[i].userAnswer === '' ? '' : 'red'">{{i + 1}}</a>
  41. </div>
  42. </div>
  43. <div class="modal-footer">
  44. <span class="icon-box s2"></span>
  45. <span class="icon-label">已答</span>
  46. <span class="icon-box s1"></span>
  47. <span class="icon-label">未答</span>
  48. </div>
  49. </div>
  50. <div class="mian">
  51. <div class="tit">{{testInfo.paperName}}(共{{sum}}题,合计{{testInfo.points}}分)</div>
  52. <div class="qustion">
  53. <div v-for="(question, i) in questionList">
  54. <div v-if="question.types === '1'">
  55. <h2 :id="i"><strong>{{i+1}}</strong>.<div v-html="question.title">{{question.title}}</div>({{question.points}}分)</h2>
  56. <ul>
  57. <div v-for="(option,index) in question.eduQuestionOptionList">
  58. <li>
  59. <input class="radio_type" type="radio" :name="'question'+i" :value="index+''" v-model="questionList[i].userAnswer" @click="handleClick(i,question.types)"/>
  60. <label>
  61. <div v-html="option.title">{{option.title}}</div>
  62. </label>
  63. </li>
  64. </div>
  65. </ul>
  66. <div class="h"></div>
  67. </div>
  68. <div v-if="question.types === '2'">
  69. <h2 :id="i"><strong>{{i+1}}</strong>.<div v-html="question.title">{{question.title}}</div>({{question.points}}分)</h2>
  70. <ul>
  71. <div v-for="(option,index) in question.eduQuestionOptionList">
  72. <li>
  73. <input class="radio_type" type="checkbox" :name="'question'+i" :value="index+''" v-model="questionList[i].checkAnswer" @click="handleClick(i,question.types)" />
  74. <label>
  75. <div v-html="option.title">{{option.title}}</div>
  76. </label>
  77. </li>
  78. </div>
  79. </ul>
  80. <div class="h"></div>
  81. </div>
  82. <div v-if="question.types === '3'">
  83. <h2 :id="i"><strong>{{i+1}}</strong>.<div v-html="question.title">{{question.title}}</div>({{question.points}}分)</h2>
  84. <ul>
  85. <div v-for="(option,index) in question.eduQuestionOptionList">
  86. <li>
  87. <input class="radio_type" type="radio" :name="'question'+i" :value="index+''" v-model="questionList[i].userAnswer" @click="handleClick(i,question.types)"/>
  88. <label>
  89. <div v-html="option.title">{{option.title}}</div>
  90. </label>
  91. </li>
  92. </div>
  93. </ul>
  94. <div class="h"></div>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="btn" @click="handleCommit()">提交</div>
  99. </div>
  100. </div>
  101. <div class="hintl">
  102. <div class="hintl-in2">有试题未完成,是否交卷?</div>
  103. <div class="hintl-in3">取消</div>
  104. <div class="hintl-in4">确认</div>
  105. </div>
  106. <link rel="stylesheet" type="text/css" href="${ctxStaticWeb}/css/alert.css" />
  107. <script>
  108. new Vue({
  109. el: "#app",
  110. data: {
  111. num: 0,
  112. questionList: [],
  113. testInfo: {},
  114. count: '',
  115. endTime: 0,
  116. sum: 0
  117. },
  118. mounted: function () {
  119. const now = Date.parse(new Date())
  120. this._interval = setInterval(() => {
  121. this.handleCount();
  122. }, 1000)
  123. },
  124. destroyed () {
  125. this.commit()
  126. clearInterval(this._interval)
  127. },
  128. methods: {
  129. commit(){
  130. clearInterval(this._interval)
  131. var eduQuestionDtos = JSON.stringify(this.questionList);
  132. var inde = top.layer.msg('智能判卷中!', {
  133. icon: 16
  134. ,shade: 0.01,
  135. time:999999999//设置超长时间
  136. });
  137. $.ajax({
  138. type:"post",
  139. async: false,
  140. url:"${ctx}/a/exam/eduUserTests/commit",
  141. data:eduQuestionDtos,
  142. contentType : 'application/json',
  143. dataType : 'json',
  144. success:function(data){
  145. if(data.success){
  146. layer.close(inde)
  147. msg = '提交成功,考试结束!您的得分是'+data.totalPoint+'分!'
  148. layer.open({
  149. content: msg
  150. ,btn: ['确定']
  151. ,yes: function(index, layero){
  152. window.location.href = "${ctxF}/${goToPage}";
  153. }
  154. });
  155. }
  156. },
  157. error:function(){//失败的函数
  158. layer.close(inde)
  159. layer.confirm('提交失败', {icon: 3, title:'提示'}, function(index){
  160. layer.close(index);
  161. });
  162. }
  163. });
  164. },
  165. handleCommit() {
  166. var msg = "确认要提交吗?"
  167. var unAnswer = 0;
  168. for (let i = 0; i < this.questionList.length; i++) {
  169. const obj = this.questionList[i]
  170. if(obj.userAnswer === ''){
  171. unAnswer++
  172. }
  173. }
  174. if(unAnswer != 0){
  175. msg = '您有'+unAnswer+'道题未做,'+msg
  176. }
  177. var that = this;
  178. layer.confirm(msg, {icon: 3, title:'提示'}, function(index){
  179. that.commit();
  180. layer.close(index);
  181. });
  182. },
  183. handleClick(i,types) {
  184. var obj = this.questionList[i];
  185. if(types === '2') {
  186. //多选绑定数组
  187. setTimeout(function(){
  188. obj.userAnswer = obj.checkAnswer.toString();
  189. },10)
  190. }
  191. this.$set(this.questionList, i, obj);
  192. },
  193. handleCount(){
  194. const now = Date.parse(new Date())
  195. const msec = this.endTime - now
  196. if(msec <= 0){
  197. this.commit()
  198. }
  199. let hr = parseInt(msec / 1000 / 60 / 60 % 24)
  200. let min = parseInt(msec / 1000 / 60 % 60)
  201. let sec = parseInt(msec / 1000 % 60)
  202. hr = hr > 9 ? hr : '0' + hr
  203. min = min > 9 ? min : '0' + min
  204. sec = sec > 9 ? sec : '0' + sec,
  205. this.count = hr+':'+min+':'+sec
  206. }
  207. },
  208. beforeCreate(){
  209. const msg = "您已经开始考试,离开本页面即为提交!"
  210. layer.alert(msg, {icon: 0});
  211. },
  212. created() {
  213. this.testInfo = ${fns: toJson(testInfo)}
  214. this.endTime = Date.parse(new Date()) + this.testInfo.examTime * 60000;
  215. const dataList = ${fns: toJson(questionList)}
  216. for (var i = 0; i < dataList.length; i++) {
  217. var obj = dataList[i];
  218. //v-modle双向绑定时 复选框初始化为数组
  219. if (obj.types === '2') {
  220. obj.checkAnswer = [];
  221. }
  222. obj.userAnswer = '';
  223. obj.testId = this.testInfo.id;
  224. obj.questionId = obj.id;
  225. this.questionList[i] = obj;
  226. }
  227. this.sum = this.questionList.length;
  228. }
  229. })
  230. </script>
  231. </body>
  232. </html>