detail.html 17 KB

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