detail.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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.createtime_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">
  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">{{index+1}}.<span v-html="question.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">
  69. <div v-if="question.kind !== 'FILL'">
  70. <div v-for="(option, indexOption) in question.options_json" :key="indexOption" class="option-item">
  71. {{option.key}}:{{option.value}}
  72. </div>
  73. </div>
  74. </td>
  75. </tr>
  76. </tbody>
  77. <tbody>
  78. <tr class="el-descriptions-row">
  79. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width">题型</th>
  80. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content th-fix-width">
  81. <el-tag size="small" effect="plain" v-if="question.kind == 'JUDGE'">判断题</el-tag>
  82. <el-tag size="small" effect="plain" v-else-if="question.kind == 'SINGLE'" type="success">单选题</el-tag>
  83. <el-tag size="small" effect="plain" v-else-if="question.kind == 'MULTI'" type="info">多选题</el-tag>
  84. <el-tag size="small" effect="plain" v-else-if="question.kind == 'FILL'" type="warning">填空题</el-tag>
  85. <el-tag size="small" effect="plain" v-else-if="question.kind == 'SHORT'" type="warning">简答题</el-tag>
  86. </td>
  87. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width">难度</th>
  88. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content th-fix-width">
  89. <el-tag size="small" effect="dark" v-if="question.difficulty == 'EASY'" type="success">简单</el-tag>
  90. <el-tag size="small" effect="dark" v-else-if="question.difficulty == 'GENERAL'" type="warning">普通</el-tag>
  91. <el-tag size="small" effect="dark" v-else-if="question.difficulty == 'HARD'" type="danger">困难</el-tag>
  92. </td>
  93. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width">正确答案</th>
  94. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content">
  95. <div v-if="question.kind == 'JUDGE' || question.kind == 'SINGLE' || question.kind == 'MULTI'">{{question.answer}}</div>
  96. <div v-else-if="question.kind == 'FILL'" v-html="getRightFillAnswer(question)"></div>
  97. <div v-else-if="question.kind == 'SHORT'" v-html="getRightShortAnswer(question)"></div>
  98. </td>
  99. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width">用户答案</th>
  100. <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']">
  101. <div>{{getUserAnswer(index) || '未答'}}</div>
  102. </td>
  103. <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']">
  104. <div>{{getUserFillAnswer(index) || '未答'}}</div>
  105. {{row.user_answers[index].answer.is_right}}
  106. </td>
  107. <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']">
  108. <div v-html="getUserShortAnswer(index) || '未答'"></div>
  109. {{row.user_answers[index].answer.is_right}}
  110. </td>
  111. <th colspan="1" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label th-fix-width">得分</th>
  112. <td colspan="1" class="el-descriptions-item__cell el-descriptions-item__content th-fix-width"><b>{{getSingleScore(question, index)}}</b>分</td>
  113. </tr>
  114. </tbody>
  115. </table>
  116. </div>
  117. </div>
  118. </div>
  119. </el-card>
  120. </div>
  121. <script>
  122. var row = {:html_entity_decode(str_replace('&quot;', "'", json_encode($row)))};
  123. var app = new Vue({
  124. el: '#app',
  125. data: {
  126. row: row,
  127. },
  128. computed: {
  129. /**
  130. * 获取填空题正确答案
  131. * @returns {(function(*): (string|string))|*}
  132. */
  133. getRightFillAnswer() {
  134. return function (question) {
  135. if (question && question.answer) {
  136. let html = '';
  137. question.answer.forEach(function (item, index) {
  138. html += '<span class="fill-answer-item">填空位' + (index + 1) + '答案:<b>' + item.answers.join(',') + '</b></span>';
  139. });
  140. return html;
  141. }
  142. return '';
  143. }
  144. },
  145. /**
  146. * 获取简答题正确答案
  147. * @returns {(function(*): (string|string))|*}
  148. */
  149. getRightShortAnswer() {
  150. return function (question) {
  151. if (question && question.answer) {
  152. let html = '正确答案:<b>' + question.answer.answer + '</b></br>';
  153. question.answer.config.forEach(function (item, index) {
  154. html += '<p class="fill-answer-item">关键词' + (index + 1) + ':<b>' + item.answer + '(' + item.score + '分)' + '</b></p>';
  155. });
  156. return html;
  157. }
  158. return '';
  159. }
  160. },
  161. /**
  162. * 获取用户答案
  163. * @returns {function(*): string|*}
  164. */
  165. getUserAnswer() {
  166. return function (questionIndex) {
  167. return this.row.user_answers && this.row.user_answers[questionIndex] ? this.row.user_answers[questionIndex].answer : '';
  168. }
  169. },
  170. /**
  171. * 获取用户填空题答案
  172. * @returns {(function(*): (string|string))|*}
  173. */
  174. getUserFillAnswer() {
  175. return function (questionIndex) {
  176. if (this.row.user_answers && this.row.user_answers[questionIndex]) {
  177. return this.row.user_answers[questionIndex].answer.join(',');
  178. }
  179. return '';
  180. }
  181. },
  182. /**
  183. * 获取用户简答题答案
  184. * @returns {(function(*): (string|string))|*}
  185. */
  186. getUserShortAnswer() {
  187. return function (questionIndex) {
  188. if (this.row.user_answers && this.row.user_answers[questionIndex]) {
  189. let html = '';
  190. if (this.row.user_answers[questionIndex].answer_score) {
  191. for (let i = 0; i < this.row.user_answers[questionIndex].answer_score.length; i++) {
  192. let short_user_answer = this.row.user_answers[questionIndex].answer_score[i];
  193. html += '<p class="fill-answer-item">' + short_user_answer.answer + '</p>';
  194. }
  195. }
  196. return html
  197. // return this.row.user_answers[questionIndex].answer.join(',');
  198. }
  199. return '';
  200. }
  201. },
  202. /**
  203. * 获取用户简答题得分
  204. * @returns {(function(*): (string|string))|*}
  205. */
  206. // getUserShortAnswerScore() {
  207. // return function (questionIndex) {
  208. // let score = 0;
  209. // if (this.row.user_answers && this.row.user_answers[questionIndex]) {
  210. // if (this.row.user_answers[questionIndex].answer_score) {
  211. // for (let i = 0; i < this.row.user_answers[questionIndex].answer_score.length; i++) {
  212. // let short_user_answer = this.row.user_answers[questionIndex].answer_score[i];
  213. // score += short_user_answer.score;
  214. // }
  215. // }
  216. // // return this.row.user_answers[questionIndex].answer.join(',');
  217. // }
  218. // return score;
  219. // }
  220. // },
  221. /**
  222. * 获取单个题目得分数
  223. * @returns {function(*): string|*}
  224. */
  225. getSingleScore() {
  226. return function (question, questionIndex) {
  227. var score = 0;
  228. if (this.row.mode == 'FIX') {
  229. score = question.score;
  230. } else {
  231. score = this.getConfigsScore(question.kind, question.difficulty);
  232. }
  233. if (this.row.user_answers && this.row.user_answers[questionIndex]) {
  234. if (question.kind === 'FILL') {
  235. if (this.row.user_answers[questionIndex].is_right) {
  236. return score;
  237. }
  238. } else if (question.kind === 'SHORT') {
  239. let score = 0;
  240. if (this.row.user_answers && this.row.user_answers[questionIndex]) {
  241. if (this.row.user_answers[questionIndex].answer_score) {
  242. for (let i = 0; i < this.row.user_answers[questionIndex].answer_score.length; i++) {
  243. let short_user_answer = this.row.user_answers[questionIndex].answer_score[i];
  244. score += parseInt(short_user_answer.score);
  245. }
  246. }
  247. // return this.row.user_answers[questionIndex].answer.join(',');
  248. }
  249. return score;
  250. } else {
  251. if (this.row.user_answers[questionIndex].answer === question.answer) {
  252. return score;
  253. }
  254. }
  255. }
  256. return 0;
  257. }
  258. },
  259. },
  260. created() {
  261. },
  262. methods: {
  263. /**
  264. * 获取单个题目得分数
  265. * @returns {function(*): string|*}
  266. */
  267. getConfigsScore(kind, difficulty) {
  268. const configs = this.row.configs[kind.toLowerCase()];
  269. if (configs && configs['use_difficulty']) {
  270. return configs['difficulty'][difficulty.toLowerCase()]['score'];
  271. }
  272. return configs['score'];
  273. },
  274. /**
  275. * 格式化秒数
  276. * @param second
  277. * @returns {string}
  278. */
  279. formatSecond: function (second) {
  280. if (second == 0) return '不限时'
  281. let result = parseInt(second)
  282. let h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
  283. let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
  284. let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
  285. let res = '';
  286. if (h !== '00') res += `${h}时`;
  287. if (m !== '00') res += `${m}分`;
  288. res += `${s}秒`;
  289. return res;
  290. }
  291. }
  292. })
  293. </script>
  294. <style>
  295. .answer-right {
  296. background: #E1F3D8;
  297. }
  298. .answer-fail {
  299. background: #FDE2E2;
  300. }
  301. .question-item {
  302. padding: 15px;
  303. }
  304. .option-item {
  305. margin-left: 10px;
  306. }
  307. .th-fix-width {
  308. width: 100px;
  309. text-align: center !important;
  310. }
  311. .fill-answer-item {
  312. margin-right: 20px;
  313. }
  314. </style>