examPaperDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div id="paperView">
  3. <div id="paperName">{{ paperStruct.name }}</div>
  4. <div id="studentInfoDiv">
  5. <table id="studentInfoTable" border>
  6. <thead>
  7. <tr>
  8. <th>考试ID</th>
  9. <th>学号</th>
  10. <th>姓名</th>
  11. <th>课程</th>
  12. </tr>
  13. </thead>
  14. <tbody>
  15. <tr>
  16. <td>{{ examRecordData.id }}</td>
  17. <td>{{ examRecord.studentCode }}</td>
  18. <td>{{ examRecord.studentName }}</td>
  19. <td>{{ courseInfo.name }}({{ courseInfo.code }})</td>
  20. </tr>
  21. </tbody>
  22. </table>
  23. </div>
  24. <!-- 遍历大题 -->
  25. <div
  26. v-for="(questionGroup, index) in paperStruct.questionGroupList"
  27. :key="index"
  28. class="mainQuestionDiv"
  29. >
  30. <div style="font-size: 16px; font-weight: bold">
  31. {{ toChineseNumber(index + 1) }}、{{ questionGroup.groupName }}({{
  32. questionGroup.groupScore
  33. }}分)
  34. </div>
  35. <div>{{ questionGroup.score }}</div>
  36. <!-- 遍历大题下的小题 -->
  37. <div
  38. v-for="(questionWrapper, index2) in questionGroup.questionWrapperList"
  39. :key="index2"
  40. >
  41. <div
  42. v-for="(question, index3) in questionWrapper.questionList"
  43. :key="index3"
  44. >
  45. <div style="display: flex; flex-direction: row">
  46. <div v-html="restoreAudio(question.body)"></div>
  47. </div>
  48. <div
  49. v-for="(questionUnit, index4) in question.questionUnitList"
  50. :key="index4"
  51. >
  52. <div style="display: flex; flex-direction: row">
  53. <div>{{ questionUnit.order }}、</div>
  54. <div v-html="restoreAudio(questionUnit.body)"></div>
  55. <span>({{ questionUnit.questionScore }}分)</span>
  56. </div>
  57. <div
  58. v-for="(option, index5) in questionUnit.quesOptions"
  59. :key="index5"
  60. >
  61. <div style="display: flex; flex-direction: row">
  62. <div>{{ option.letter }}.</div>
  63. <div v-html="restoreAudio(option.body)"></div>
  64. </div>
  65. </div>
  66. <div>
  67. <div
  68. style="
  69. display: flex;
  70. flex-direction: row;
  71. color: green;
  72. font-weight: bold;
  73. "
  74. >
  75. <div>标准答案:</div>
  76. <span v-html="questionUnit.correctAnswer"></span>
  77. </div>
  78. <div
  79. v-if="
  80. questionUnit.answerType !== 'SINGLE_AUDIO' ||
  81. (questionUnit.answerType === 'SINGLE_AUDIO' &&
  82. (questionUnit.studentAnswer == null ||
  83. questionUnit.studentAnswer == ''))
  84. "
  85. style="color: blue; font-weight: bold"
  86. >
  87. 学生答案:
  88. <span v-html="questionUnit.studentAnswer"></span>
  89. <i
  90. v-show="
  91. questionUnit.isObjectiveQuestion && questionUnit.isRight
  92. "
  93. class="el-icon-check"
  94. ></i>
  95. <i
  96. v-show="
  97. questionUnit.isObjectiveQuestion && !questionUnit.isRight
  98. "
  99. class="el-icon-close"
  100. ></i>
  101. </div>
  102. <div
  103. v-if="
  104. questionUnit.answerType === 'SINGLE_AUDIO' &&
  105. questionUnit.studentAnswer != null &&
  106. questionUnit.studentAnswer != ''
  107. "
  108. >
  109. <div
  110. style="
  111. float: left;
  112. color: blue;
  113. font-weight: bold;
  114. height: 54px;
  115. line-height: 54px;
  116. margin-right: 10px;
  117. "
  118. >
  119. 学生答案:
  120. </div>
  121. <audio
  122. v-if="
  123. questionUnit.answerType === 'SINGLE_AUDIO' &&
  124. questionUnit.studentAnswer != null &&
  125. questionUnit.studentAnswer != ''
  126. "
  127. style="height: 54px"
  128. :src="questionUnit.studentAnswer"
  129. controls
  130. ></audio>
  131. </div>
  132. <div
  133. style="
  134. display: flex;
  135. flex-direction: row;
  136. color: red;
  137. font-style: italic;
  138. "
  139. >
  140. <div>得分:</div>
  141. <span>{{ questionUnit.studentScore }}</span>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </template>
  150. <script>
  151. export default {
  152. data() {
  153. return {
  154. courseId: "",
  155. examRecordDataId: "",
  156. examRecordData: {},
  157. examRecord: {},
  158. courseInfo: {},
  159. paperStruct: {},
  160. examQuestionList: [],
  161. };
  162. },
  163. created() {
  164. this.courseId = this.$route.params.courseId;
  165. this.examRecordDataId = this.$route.params.examRecordDataId;
  166. this.getExamRecordData();
  167. this.getCourseInfo();
  168. this.getPaperData();
  169. },
  170. methods: {
  171. getExamRecordData() {
  172. this.$http
  173. .get("/api/ecs_oe_admin/exam/record/data/findExamRecordDataEntity", {
  174. params: { examRecordDataId: this.examRecordDataId },
  175. })
  176. .then((response) => {
  177. this.examRecordData = response.data;
  178. this.examRecord = response.data.examRecord;
  179. });
  180. },
  181. getCourseInfo() {
  182. this.$http
  183. .get("/api/ecs_core/course/" + this.courseId)
  184. .then((response) => {
  185. this.courseInfo = response.data;
  186. });
  187. },
  188. getPaperData() {
  189. this.$http
  190. .get(
  191. "/api/ecs_oe_admin/examRecordPaperStruct/getExamRecordPaperStruct",
  192. { params: { examRecordDataId: this.examRecordDataId } }
  193. )
  194. .then((response) => {
  195. this.paperStruct = response.data.defaultPaper;
  196. var questionGroupList = this.paperStruct.questionGroupList; //大题集合
  197. this.$http
  198. .get(
  199. "/api/ecs_oe_admin/examRecordQuestions/getExamRecordQuestions",
  200. {
  201. params: {
  202. examRecordDataId: this.examRecordDataId,
  203. withScore: true,
  204. },
  205. }
  206. )
  207. .then((response) => {
  208. this.examQuestionList = response.data.examQuestionEntities;
  209. var order = 0;
  210. for (var i = 0; i < questionGroupList.length; i++) {
  211. var questionGroup = questionGroupList[i]; //大题
  212. var questionWrapperList = questionGroup.questionWrapperList; //大题下小题集合
  213. for (var j = 0; j < questionWrapperList.length; j++) {
  214. var questionWrapper = questionWrapperList[j];
  215. order += questionWrapper.questionUnitWrapperList.length;
  216. this.getQuestionContent(
  217. questionWrapper.questionId,
  218. questionWrapper,
  219. order
  220. );
  221. }
  222. }
  223. });
  224. });
  225. },
  226. getQuestionContent(questionId, questionWrapper, order) {
  227. var params = {
  228. examId: this.examRecordData.examRecord.examId,
  229. courseCode: this.courseInfo.code,
  230. groupCode: this.examRecordData.examRecord.paperType,
  231. questionId: questionId,
  232. };
  233. this.$http
  234. .post("/api/ecs_ques/default_question/question", params)
  235. .then((response) => {
  236. var question = response.data.masterVersion;
  237. var questionUnitList = question.questionUnitList;
  238. var num = questionUnitList.length;
  239. for (var i = 0; i < questionUnitList.length; i++) {
  240. this.reOrderOptions(questionUnitList[i], order - num + 1);
  241. num--;
  242. }
  243. var questionList = questionWrapper.questionList;
  244. if (!questionList) {
  245. questionList = [];
  246. questionList.push(question);
  247. } else {
  248. questionList.push(question);
  249. }
  250. questionWrapper.questionList = questionList;
  251. });
  252. },
  253. reOrderOptions(question, order) {
  254. question.order = order; //设置序号
  255. var examQuestion = this.examQuestionList[order - 1];
  256. var questionScore = examQuestion.questionScore;
  257. var studentAnswer = examQuestion.studentAnswer;
  258. if (examQuestion.studentScore || examQuestion.studentScore === 0) {
  259. question.studentScore = examQuestion.studentScore + "分";
  260. } else {
  261. question.studentScore = "--分";
  262. }
  263. var correctAnswer = question.rightAnswer; //从题中获取正确答案
  264. var optionList = question.questionOptionList;
  265. //单选,多选
  266. if (optionList && optionList.length > 0) {
  267. var correctAnswerInExamQuestion =
  268. this.examQuestionList[order - 1].correctAnswer;
  269. //如果是字母,说明是旧数据
  270. var reg = /^[a-zA-Z]+$/; //匹配任意字母
  271. if (
  272. correctAnswerInExamQuestion &&
  273. reg.test(correctAnswerInExamQuestion)
  274. ) {
  275. question.studentAnswer = studentAnswer;
  276. question.correctAnswer = correctAnswerInExamQuestion;
  277. for (var i1 = 0; i1 < optionList.length; i1++) {
  278. var letter1 = String.fromCharCode(i1 + 65);
  279. optionList[i1].letter = letter1;
  280. }
  281. question.quesOptions = optionList; //选项
  282. } else {
  283. var optionPermutation =
  284. this.examQuestionList[order - 1].optionPermutation;
  285. for (var i2 = 0; i2 < optionList.length; i2++) {
  286. optionList[i2].optionId = i2;
  287. }
  288. //按照optionPermutation排序
  289. var newOptionList = [];
  290. for (var i3 = 0; i3 < optionPermutation.length; i3++) {
  291. var optionId = optionPermutation[i3];
  292. for (var i4 = 0; i4 < optionList.length; i4++) {
  293. if (optionList[i4].optionId == optionId) {
  294. newOptionList.push(optionList[i4]);
  295. break;
  296. }
  297. }
  298. }
  299. var newCorrectAnswer = []; //正确答案
  300. var newStudentAnswer = []; //考生作答
  301. for (var i5 = 0; i5 < newOptionList.length; i5++) {
  302. var letter = String.fromCharCode(i5 + 65);
  303. newOptionList[i5].letter = letter;
  304. if (correctAnswer) {
  305. //如果是单选题,直接判等
  306. if (
  307. question.questionType == "SINGLE_CHOICE" &&
  308. correctAnswer == newOptionList[i5].optionId.toString()
  309. ) {
  310. newCorrectAnswer.push(letter);
  311. } else if (
  312. question.questionType != "SINGLE_CHOICE" &&
  313. correctAnswer.indexOf(newOptionList[i5].optionId.toString()) >
  314. -1
  315. ) {
  316. newCorrectAnswer.push(letter);
  317. }
  318. }
  319. if (studentAnswer) {
  320. if (
  321. question.questionType == "SINGLE_CHOICE" &&
  322. studentAnswer == newOptionList[i5].optionId.toString()
  323. ) {
  324. newStudentAnswer.push(letter);
  325. } else if (
  326. question.questionType != "SINGLE_CHOICE" &&
  327. studentAnswer.indexOf(newOptionList[i5].optionId.toString()) >
  328. -1
  329. ) {
  330. newStudentAnswer.push(letter);
  331. }
  332. }
  333. }
  334. question.quesOptions = newOptionList; //选项
  335. question.correctAnswer = newCorrectAnswer;
  336. question.studentAnswer = newStudentAnswer;
  337. }
  338. } else {
  339. question.studentAnswer = studentAnswer;
  340. question.correctAnswer = correctAnswer;
  341. if (question.questionType == "TRUE_OR_FALSE") {
  342. if (studentAnswer == "true") {
  343. question.studentAnswer = "正确";
  344. } else if (studentAnswer == "false") {
  345. question.studentAnswer = "错误";
  346. }
  347. if (correctAnswer == "true") {
  348. question.correctAnswer = "正确";
  349. } else if (correctAnswer == "false") {
  350. question.correctAnswer = "错误";
  351. }
  352. }
  353. }
  354. question.questionScore = questionScore;
  355. if (question.studentAnswer) {
  356. question.studentAnswer = question.studentAnswer.toString();
  357. }
  358. if (question.correctAnswer) {
  359. question.correctAnswer = question.correctAnswer.toString();
  360. }
  361. if (
  362. question.questionType == "SINGLE_CHOICE" ||
  363. question.questionType == "MULTIPLE_CHOICE" ||
  364. question.questionType == "TRUE_OR_FALSE"
  365. ) {
  366. question.isObjectiveQuestion = true;
  367. }
  368. if (
  369. question.studentAnswer &&
  370. question.correctAnswer &&
  371. question.studentAnswer == question.correctAnswer
  372. ) {
  373. question.isRight = true;
  374. } else {
  375. question.isRight = false;
  376. }
  377. this.$forceUpdate(); //刷新视图
  378. },
  379. toChineseNumber(num) {
  380. return num.toLocaleString("zh-u-nu-hanidec");
  381. },
  382. restoreAudio(str) {
  383. return (str || "")
  384. .replace(/<a/g, "<audio controls ")
  385. .replace(/url=/g, "src=")
  386. .replace(/a>/g, "audio>");
  387. },
  388. },
  389. };
  390. </script>
  391. <style scoped>
  392. #paperView {
  393. background-color: white;
  394. }
  395. #paperName {
  396. text-align: center;
  397. font-size: 32px;
  398. font-weight: bold;
  399. }
  400. #studentInfoDiv {
  401. text-align: center;
  402. margin: 20px 60px;
  403. }
  404. #studentInfoTable {
  405. width: 100%;
  406. height: 70px;
  407. border-collapse: collapse;
  408. }
  409. .mainQuestionDiv {
  410. font-size: 14px;
  411. margin: 20px 60px;
  412. border-bottom: 1px dashed black;
  413. }
  414. .el-icon-check {
  415. color: green;
  416. font-size: 16px;
  417. font-weight: bold;
  418. }
  419. .el-icon-close {
  420. color: red;
  421. font-size: 16px;
  422. font-weight: bold;
  423. }
  424. </style>
  425. <style>
  426. .photo-answers-block {
  427. width: 660px;
  428. height: 300px;
  429. }
  430. .photo-answer {
  431. width: 200px;
  432. height: 150px;
  433. padding: 5px;
  434. }
  435. </style>