detailnew.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>123</title>
  5. {include file="common/meta" /}
  6. </head>
  7. <style>
  8. /* 默认情况下,屏幕上显示 */
  9. .hide-on-print {
  10. display: block;
  11. text-align: right;
  12. margin-bottom: 20px;
  13. padding-top: 20px;
  14. }
  15. .table-bordered {
  16. border: 1px solid #ddd;
  17. }
  18. .panel-heading {
  19. padding: 10px 0px;
  20. }
  21. .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
  22. border: 1px solid #ddd;
  23. }
  24. /* 打印时隐藏 */
  25. @media print {
  26. .hide-on-print {
  27. display: none;
  28. }
  29. }
  30. </style>
  31. <body style="width: 760px;margin: 0 auto">
  32. <div class="hide-on-print">
  33. <button type="button" onclick="printPage()" class="btn btn-primary dropdown-toggle">打印</button>
  34. </div>
  35. <script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
  36. <script src="__CDN__/assets/addons/exam/js/vue.js"></script>
  37. <link rel="stylesheet" type="text/css" href="__CDN__/assets/addons/exam/css/common.css"></link>
  38. <link rel="stylesheet" type="text/css" href="__CDN__/assets/addons/exam/js/element-ui/index.css"/>
  39. <script src="__CDN__/assets/addons/exam/js/element-ui/index.js"></script>
  40. <div id="app">
  41. <el-card class="box-card" style="margin-bottom: 20px;">
  42. <div slot="header" class="clearfix">
  43. <span>考试用户信息</span>
  44. </div>
  45. <el-descriptions title="" :column="2" border>
  46. <el-descriptions-item label="用户名">{{row.user.nickname}}</el-descriptions-item>
  47. <el-descriptions-item label="手机号">{{row.user.mobile}}</el-descriptions-item>
  48. </el-descriptions>
  49. </el-card>
  50. <el-card class="box-card" style="margin-bottom: 20px;">
  51. <div slot="header" class="clearfix">
  52. <span>考卷信息</span>
  53. </div>
  54. <el-descriptions title="" :column="3" border>
  55. <el-descriptions-item label="考卷分类">{{row.cate.name}}</el-descriptions-item>
  56. <el-descriptions-item label="考卷名称">{{row.paper.title}}</el-descriptions-item>
  57. <el-descriptions-item label="出题模式">
  58. <el-tag size="small" v-if="row.paper.mode == 'RANDOM'">随机模式</el-tag>
  59. <el-tag size="small" v-else-if="row.paper.mode == 'FIX'" type="success">固定模式</el-tag>
  60. </el-descriptions-item>
  61. <el-descriptions-item label="题目数量">{{row.paper.quantity}}题</el-descriptions-item>
  62. <el-descriptions-item label="试卷总分">{{row.paper.total_score}}分</el-descriptions-item>
  63. <el-descriptions-item label="及格线">
  64. <span style="font-weight: bold;">{{row.paper.pass_score}}</span>分
  65. </el-descriptions-item>
  66. <el-descriptions-item label="考试限时">{{formatSecond(row.paper.limit_time)}}分</el-descriptions-item>
  67. </el-descriptions>
  68. </el-card>
  69. <el-card class="box-card" style="margin-bottom: 20px;">
  70. <div slot="header" class="clearfix">
  71. <span>用户考试情况</span>
  72. <!--<el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button>-->
  73. </div>
  74. <el-descriptions title="" :column="3" border style="margin-bottom: 30px;">
  75. <el-descriptions-item label="考试分数">
  76. <span style="margin-right: 10px;">{{row.score}}分</span>
  77. <el-tag size="small" v-if="row.is_pass" type="success">及格</el-tag>
  78. <el-tag size="small" v-else type="danger">不及格</el-tag>
  79. </el-descriptions-item>
  80. <el-descriptions-item label="答对数" content-class-name="answer-right">{{row.right_count}}题</el-descriptions-item>
  81. <el-descriptions-item label="答错数" content-class-name="answer-fail">{{row.error_count}}题</el-descriptions-item>
  82. <el-descriptions-item label="交卷时间">{{row.finishtime_text}}</el-descriptions-item>
  83. <el-descriptions-item label="考试用时">{{formatSecond(row.grade_time)}}</el-descriptions-item>
  84. </el-descriptions>
  85. </el-card>
  86. <el-card class="box-card" style="margin-bottom: 20px;">
  87. <div slot="header" class="clearfix">
  88. <span>用户答题情况</span>
  89. <!--<el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button>-->
  90. </div>
  91. <div v-for="(question, index) in row.questions" :key="index" class="question-item">
  92. <div class="el-descriptions">
  93. <div class="el-descriptions__body">
  94. <table class="el-descriptions__table is-bordered">
  95. <tbody>
  96. <tr class="el-descriptions-row" v-if="question.material_title">
  97. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width ">材料题内容</th>
  98. <td colspan="9" class="el-descriptions-item__cell el-descriptions-item__content"><span v-html="question.material_title"></span></td>
  99. </tr>
  100. <tr class="el-descriptions-row">
  101. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width ">标题</th>
  102. <td colspan="9" class="el-descriptions-item__cell el-descriptions-item__content">{{index+1}}.<span v-html="question.title"></span></td>
  103. </tr>
  104. <tr class="el-descriptions-row">
  105. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width ">选项</th>
  106. <td colspan="9" class="el-descriptions-item__cell el-descriptions-item__content">
  107. <div v-if="question.kind !== 'FILL'">
  108. <div v-for="(option, indexOption) in question.options_json" :key="indexOption" class="option-item">
  109. {{option.key}}:{{option.value}}
  110. </div>
  111. </div>
  112. </td>
  113. </tr>
  114. </tbody>
  115. <tbody>
  116. <tr class="el-descriptions-row">
  117. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width">题型</th>
  118. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content th-fix-width">
  119. <el-tag size="small" effect="plain" v-if="question.kind == 'JUDGE'">判断题</el-tag>
  120. <el-tag size="small" effect="plain" v-else-if="question.kind == 'SINGLE'" type="success">单选题</el-tag>
  121. <el-tag size="small" effect="plain" v-else-if="question.kind == 'MULTI'" type="info">多选题</el-tag>
  122. <el-tag size="small" effect="plain" v-else-if="question.kind == 'FILL'" type="warning">填空题</el-tag>
  123. <el-tag size="small" effect="plain" v-else-if="question.kind == 'SHORT'" type="warning">简答题</el-tag>
  124. </td>
  125. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width">难度</th>
  126. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content th-fix-width">
  127. <el-tag size="small" effect="dark" v-if="question.difficulty == 'EASY'" type="success">简单</el-tag>
  128. <el-tag size="small" effect="dark" v-else-if="question.difficulty == 'GENERAL'" type="warning">普通</el-tag>
  129. <el-tag size="small" effect="dark" v-else-if="question.difficulty == 'HARD'" type="danger">困难</el-tag>
  130. </td>
  131. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width">正确答案</th>
  132. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content">
  133. <div v-if="question.kind == 'JUDGE' || question.kind == 'SINGLE' || question.kind == 'MULTI'">{{question.answer}}</div>
  134. <div v-else-if="question.kind == 'FILL'" v-html="getRightFillAnswer(question)"></div>
  135. <div v-else-if="question.kind == 'SHORT'" v-html="getRightShortAnswer(question)"></div>
  136. </td>
  137. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width">用户答案</th>
  138. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content" v-if="question.kind == 'JUDGE' || question.kind == 'SINGLE' || question.kind == 'MULTI'" :class="getUserAnswer(index) == question.answer ? ['answer-right'] : ['answer-fail']">
  139. <div>{{getUserAnswer(index) || '未答'}}</div>
  140. </td>
  141. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content" v-else-if="question.kind == 'FILL'" :class="row.user_answers[index].is_right ? ['answer-right'] : ['answer-fail']">
  142. <div>{{getUserFillAnswer(index) || '未答'}}</div>
  143. {{row.user_answers[index].answer.is_right}}
  144. </td>
  145. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content" v-else-if="question.kind == 'SHORT'" :class="row.user_answers[index].is_right ? ['answer-right'] : ['answer-fail']">
  146. <div v-html="getUserShortAnswer(index) || '未答'"></div>
  147. {{row.user_answers[index].answer.is_right}}
  148. </td>
  149. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width">得分</th>
  150. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content th-fix-width"><b>{{getSingleScore(question, index)}}</b>分</td>
  151. </tr>
  152. </tbody>
  153. </table>
  154. </div>
  155. </div>
  156. </div>
  157. </el-card>
  158. </div>
  159. <script>
  160. var row = {:html_entity_decode(str_replace('&quot;', "'", json_encode($row)))};
  161. var app = new Vue({
  162. el: '#app',
  163. data: {
  164. row: row,
  165. },
  166. computed: {
  167. /**
  168. * 获取填空题正确答案
  169. * @returns {(function(*): (string|string))|*}
  170. */
  171. getRightFillAnswer() {
  172. return function (question) {
  173. if (question && question.answer) {
  174. let html = '';
  175. question.answer.forEach(function (item, index) {
  176. html += '<span class="fill-answer-item">填空位' + (index + 1) + '答案:<b>' + item.answers.join(',') + '</b></span>';
  177. });
  178. return html;
  179. }
  180. return '';
  181. }
  182. },
  183. /**
  184. * 获取简答题正确答案
  185. * @returns {(function(*): (string|string))|*}
  186. */
  187. getRightShortAnswer() {
  188. return function (question) {
  189. if (question && question.answer) {
  190. let html = '正确答案:<b>' + question.answer.answer + '</b></br>';
  191. question.answer.config.forEach(function (item, index) {
  192. html += '<p class="fill-answer-item">关键词' + (index + 1) + ':<b>' + item.answer + '(' + item.score + '分)' + '</b></p>';
  193. });
  194. return html;
  195. }
  196. return '';
  197. }
  198. },
  199. /**
  200. * 获取用户答案
  201. * @returns {function(*): string|*}
  202. */
  203. getUserAnswer() {
  204. return function (questionIndex) {
  205. return this.row.user_answers && this.row.user_answers[questionIndex] ? this.row.user_answers[questionIndex].answer : '';
  206. }
  207. },
  208. /**
  209. * 获取用户填空题答案
  210. * @returns {(function(*): (string|string))|*}
  211. */
  212. getUserFillAnswer() {
  213. return function (questionIndex) {
  214. if (this.row.user_answers && this.row.user_answers[questionIndex]) {
  215. return this.row.user_answers[questionIndex].answer.join(',');
  216. }
  217. return '';
  218. }
  219. },
  220. /**
  221. * 获取用户简答题答案
  222. * @returns {(function(*): (string|string))|*}
  223. */
  224. getUserShortAnswer() {
  225. return function (questionIndex) {
  226. return this.row.user_answers && this.row.user_answers[questionIndex] ? this.row.user_answers[questionIndex].answer : '';
  227. if (this.row.user_answers && this.row.user_answers[questionIndex]) {
  228. let html = '';
  229. if (this.row.user_answers[questionIndex].answer_score.length) {
  230. for (let i = 0; i < this.row.user_answers[questionIndex].answer_score.length; i++) {
  231. let short_user_answer = this.row.user_answers[questionIndex].answer_score[i];
  232. html += '<p class="fill-answer-item">' + short_user_answer.answer + '</p>';
  233. }
  234. }else{
  235. html = this.row.user_answers[questionIndex].answer;
  236. }
  237. return html
  238. // return this.row.user_answers[questionIndex].answer.join(',');
  239. }
  240. return '';
  241. }
  242. },
  243. /**
  244. * 获取用户简答题得分
  245. * @returns {(function(*): (string|string))|*}
  246. */
  247. // getUserShortAnswerScore() {
  248. // return function (questionIndex) {
  249. // let score = 0;
  250. // if (this.row.user_answers && this.row.user_answers[questionIndex]) {
  251. // if (this.row.user_answers[questionIndex].answer_score) {
  252. // for (let i = 0; i < this.row.user_answers[questionIndex].answer_score.length; i++) {
  253. // let short_user_answer = this.row.user_answers[questionIndex].answer_score[i];
  254. // score += short_user_answer.score;
  255. // }
  256. // }
  257. // // return this.row.user_answers[questionIndex].answer.join(',');
  258. // }
  259. // return score;
  260. // }
  261. // },
  262. /**
  263. * 获取单个题目得分数
  264. * @returns {function(*): string|*}
  265. */
  266. getSingleScore() {
  267. return function (question, questionIndex) {
  268. var score = 0;
  269. if (this.row.mode == 'FIX') {
  270. score = question.score;
  271. } else {
  272. score = this.getConfigsScore(question.kind, question.difficulty);
  273. }
  274. if (this.row.user_answers && this.row.user_answers[questionIndex]) {
  275. if (question.kind === 'FILL') {
  276. if (this.row.user_answers[questionIndex].is_right) {
  277. return score;
  278. }
  279. } else if (question.kind === 'SHORT') {
  280. /*let score = 0;
  281. if (this.row.user_answers && this.row.user_answers[questionIndex]) {
  282. if (this.row.user_answers[questionIndex].answer_score) {
  283. for (let i = 0; i < this.row.user_answers[questionIndex].answer_score.length; i++) {
  284. let short_user_answer = this.row.user_answers[questionIndex].answer_score[i];
  285. score += parseInt(short_user_answer.score);
  286. }
  287. }
  288. // return this.row.user_answers[questionIndex].answer.join(',');
  289. }
  290. return score;*/
  291. if (this.row.user_answers[questionIndex].is_right) {
  292. return score;
  293. }
  294. } else {
  295. if (this.row.user_answers[questionIndex].answer === question.answer) {
  296. return score;
  297. }
  298. }
  299. }
  300. return 0;
  301. }
  302. },
  303. },
  304. created() {
  305. },
  306. methods: {
  307. /**
  308. * 获取单个题目得分数
  309. * @returns {function(*): string|*}
  310. */
  311. getConfigsScore(kind, difficulty) {
  312. const configs = this.row.configs[kind.toLowerCase()];
  313. if (configs && configs['use_difficulty']) {
  314. return configs['difficulty'][difficulty.toLowerCase()]['score'];
  315. }
  316. return configs['score'];
  317. },
  318. /**
  319. * 格式化秒数
  320. * @param second
  321. * @returns {string}
  322. */
  323. formatSecond: function (second) {
  324. if (second == 0) return '不限时'
  325. let result = parseInt(second)
  326. let h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
  327. let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
  328. let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
  329. let res = '';
  330. if (h !== '00') res += `${h}时`;
  331. if (m !== '00') res += `${m}分`;
  332. res += `${s}秒`;
  333. return res;
  334. }
  335. }
  336. })
  337. </script>
  338. <style>
  339. .answer-right {
  340. background: #E1F3D8;
  341. }
  342. .answer-fail {
  343. background: #FDE2E2;
  344. }
  345. .question-item {
  346. padding: 15px;
  347. }
  348. .option-item {
  349. margin-left: 10px;
  350. }
  351. .th-fix-width {
  352. width: 100px;
  353. text-align: center !important;
  354. }
  355. .fill-answer-item {
  356. margin-right: 20px;
  357. }
  358. </style>
  359. {include file="common/script" /}
  360. </body>
  361. </html>