examPaperDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. </div>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </template>
  139. <script>
  140. export default {
  141. data() {
  142. return {
  143. courseId: "",
  144. examRecordDataId: "",
  145. examRecordData: {},
  146. examRecord: {},
  147. courseInfo: {},
  148. paperStruct: {},
  149. examQuestionList: [],
  150. };
  151. },
  152. created() {
  153. this.courseId = this.$route.params.courseId;
  154. this.examRecordDataId = this.$route.params.examRecordDataId;
  155. this.getExamRecordData();
  156. this.getCourseInfo();
  157. this.getPaperData();
  158. },
  159. methods: {
  160. getExamRecordData() {
  161. this.$http
  162. .get("/api/ecs_oe_admin/exam/record/data/findExamRecordDataEntity", {
  163. params: { examRecordDataId: this.examRecordDataId },
  164. })
  165. .then((response) => {
  166. this.examRecordData = response.data;
  167. this.examRecord = response.data.examRecord;
  168. });
  169. },
  170. getCourseInfo() {
  171. this.$http
  172. .get("/api/ecs_core/course/" + this.courseId)
  173. .then((response) => {
  174. this.courseInfo = response.data;
  175. });
  176. },
  177. getPaperData() {
  178. this.$http
  179. .get(
  180. "/api/ecs_oe_admin/examRecordPaperStruct/getExamRecordPaperStruct",
  181. { params: { examRecordDataId: this.examRecordDataId } }
  182. )
  183. .then((response) => {
  184. this.paperStruct = response.data.defaultPaper;
  185. var questionGroupList = this.paperStruct.questionGroupList; //大题集合
  186. this.$http
  187. .get(
  188. "/api/ecs_oe_admin/examRecordQuestions/getExamRecordQuestions",
  189. { params: { examRecordDataId: this.examRecordDataId } }
  190. )
  191. .then((response) => {
  192. this.examQuestionList = response.data.examQuestionEntities;
  193. var order = 0;
  194. for (var i = 0; i < questionGroupList.length; i++) {
  195. var questionGroup = questionGroupList[i]; //大题
  196. var questionWrapperList = questionGroup.questionWrapperList; //大题下小题集合
  197. for (var j = 0; j < questionWrapperList.length; j++) {
  198. var questionWrapper = questionWrapperList[j];
  199. order += questionWrapper.questionUnitWrapperList.length;
  200. this.getQuestionContent(
  201. questionWrapper.questionId,
  202. questionWrapper,
  203. order
  204. );
  205. }
  206. }
  207. });
  208. });
  209. },
  210. getQuestionContent(questionId, questionWrapper, order) {
  211. var params = {
  212. examId: this.examRecordData.examRecord.examId,
  213. courseCode: this.courseInfo.code,
  214. groupCode: this.examRecordData.examRecord.paperType,
  215. questionId: questionId,
  216. };
  217. this.$http
  218. .post("/api/ecs_ques/default_question/question", params)
  219. .then((response) => {
  220. var question = response.data.masterVersion;
  221. var questionUnitList = question.questionUnitList;
  222. var num = questionUnitList.length;
  223. for (var i = 0; i < questionUnitList.length; i++) {
  224. this.reOrderOptions(questionUnitList[i], order - num + 1);
  225. num--;
  226. }
  227. var questionList = questionWrapper.questionList;
  228. if (!questionList) {
  229. questionList = [];
  230. questionList.push(question);
  231. } else {
  232. questionList.push(question);
  233. }
  234. questionWrapper.questionList = questionList;
  235. });
  236. },
  237. reOrderOptions(question, order) {
  238. question.order = order; //设置序号
  239. var questionScore = this.examQuestionList[order - 1].questionScore;
  240. var studentAnswer = this.examQuestionList[order - 1].studentAnswer;
  241. var correctAnswer = question.rightAnswer; //从题中获取正确答案
  242. var optionList = question.questionOptionList;
  243. //单选,多选
  244. if (optionList && optionList.length > 0) {
  245. var correctAnswerInExamQuestion =
  246. this.examQuestionList[order - 1].correctAnswer;
  247. //如果是字母,说明是旧数据
  248. var reg = /^[a-zA-Z]+$/; //匹配任意字母
  249. if (
  250. correctAnswerInExamQuestion &&
  251. reg.test(correctAnswerInExamQuestion)
  252. ) {
  253. question.studentAnswer = studentAnswer;
  254. question.correctAnswer = correctAnswerInExamQuestion;
  255. for (var i1 = 0; i1 < optionList.length; i1++) {
  256. var letter1 = String.fromCharCode(i1 + 65);
  257. optionList[i1].letter = letter1;
  258. }
  259. question.quesOptions = optionList; //选项
  260. } else {
  261. var optionPermutation =
  262. this.examQuestionList[order - 1].optionPermutation;
  263. for (var i2 = 0; i2 < optionList.length; i2++) {
  264. optionList[i2].optionId = i2;
  265. }
  266. //按照optionPermutation排序
  267. var newOptionList = [];
  268. for (var i3 = 0; i3 < optionPermutation.length; i3++) {
  269. var optionId = optionPermutation[i3];
  270. for (var i4 = 0; i4 < optionList.length; i4++) {
  271. if (optionList[i4].optionId == optionId) {
  272. newOptionList.push(optionList[i4]);
  273. break;
  274. }
  275. }
  276. }
  277. var newCorrectAnswer = []; //正确答案
  278. var newStudentAnswer = []; //考生作答
  279. for (var i5 = 0; i5 < newOptionList.length; i5++) {
  280. var letter = String.fromCharCode(i5 + 65);
  281. newOptionList[i5].letter = letter;
  282. if (correctAnswer) {
  283. //如果是单选题,直接判等
  284. if (
  285. question.questionType == "SINGLE_CHOICE" &&
  286. correctAnswer == newOptionList[i5].optionId.toString()
  287. ) {
  288. newCorrectAnswer.push(letter);
  289. } else if (
  290. question.questionType != "SINGLE_CHOICE" &&
  291. correctAnswer.indexOf(newOptionList[i5].optionId.toString()) >
  292. -1
  293. ) {
  294. newCorrectAnswer.push(letter);
  295. }
  296. }
  297. if (studentAnswer) {
  298. if (
  299. question.questionType == "SINGLE_CHOICE" &&
  300. studentAnswer == newOptionList[i5].optionId.toString()
  301. ) {
  302. newStudentAnswer.push(letter);
  303. } else if (
  304. question.questionType != "SINGLE_CHOICE" &&
  305. studentAnswer.indexOf(newOptionList[i5].optionId.toString()) >
  306. -1
  307. ) {
  308. newStudentAnswer.push(letter);
  309. }
  310. }
  311. }
  312. question.quesOptions = newOptionList; //选项
  313. question.correctAnswer = newCorrectAnswer;
  314. question.studentAnswer = newStudentAnswer;
  315. }
  316. } else {
  317. question.studentAnswer = studentAnswer;
  318. question.correctAnswer = correctAnswer;
  319. if (question.questionType == "TRUE_OR_FALSE") {
  320. if (studentAnswer == "true") {
  321. question.studentAnswer = "正确";
  322. } else if (studentAnswer == "false") {
  323. question.studentAnswer = "错误";
  324. }
  325. if (correctAnswer == "true") {
  326. question.correctAnswer = "正确";
  327. } else if (correctAnswer == "false") {
  328. question.correctAnswer = "错误";
  329. }
  330. }
  331. }
  332. question.questionScore = questionScore;
  333. if (question.studentAnswer) {
  334. question.studentAnswer = question.studentAnswer.toString();
  335. }
  336. if (question.correctAnswer) {
  337. question.correctAnswer = question.correctAnswer.toString();
  338. }
  339. if (
  340. question.questionType == "SINGLE_CHOICE" ||
  341. question.questionType == "MULTIPLE_CHOICE" ||
  342. question.questionType == "TRUE_OR_FALSE"
  343. ) {
  344. question.isObjectiveQuestion = true;
  345. }
  346. if (
  347. question.studentAnswer &&
  348. question.correctAnswer &&
  349. question.studentAnswer == question.correctAnswer
  350. ) {
  351. question.isRight = true;
  352. } else {
  353. question.isRight = false;
  354. }
  355. this.$forceUpdate(); //刷新视图
  356. },
  357. toChineseNumber(num) {
  358. return num.toLocaleString("zh-u-nu-hanidec");
  359. },
  360. restoreAudio(str) {
  361. return (str || "")
  362. .replace(/<a/g, "<audio controls ")
  363. .replace(/url=/g, "src=")
  364. .replace(/a>/g, "audio>");
  365. },
  366. },
  367. };
  368. </script>
  369. <style scoped>
  370. #paperView {
  371. background-color: white;
  372. }
  373. #paperName {
  374. text-align: center;
  375. font-size: 32px;
  376. font-weight: bold;
  377. }
  378. #studentInfoDiv {
  379. text-align: center;
  380. margin: 20px 60px;
  381. }
  382. #studentInfoTable {
  383. width: 100%;
  384. height: 70px;
  385. border-collapse: collapse;
  386. }
  387. .mainQuestionDiv {
  388. font-size: 14px;
  389. margin: 20px 60px;
  390. border-bottom: 1px dashed black;
  391. }
  392. .el-icon-check {
  393. color: green;
  394. font-size: 16px;
  395. font-weight: bold;
  396. }
  397. .el-icon-close {
  398. color: red;
  399. font-size: 16px;
  400. font-weight: bold;
  401. }
  402. </style>
  403. <style>
  404. .photo-answers-block {
  405. width: 660px;
  406. height: 300px;
  407. }
  408. .photo-answer {
  409. width: 200px;
  410. height: 150px;
  411. padding: 5px;
  412. }
  413. </style>