detail.html 18 KB

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