ViewPaper.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. <template>
  2. <div
  3. id="editPaperApp"
  4. v-loading="loading"
  5. class="view-paper"
  6. element-loading-text="拼命加载中。。。"
  7. >
  8. <div class="view-header box-justify">
  9. <div class="header-info">
  10. <div class="header-info-item">
  11. <span>课程代码:</span>
  12. <span>{{ paper.course.code }}</span>
  13. </div>
  14. <div class="header-info-item">
  15. <span>课程名称:</span>
  16. <span>{{ paper.course.name }}</span>
  17. </div>
  18. <div class="header-info-item">
  19. <span>试卷名称:</span>
  20. <span>
  21. {{ paper.name }}
  22. </span>
  23. </div>
  24. <div class="header-info-item">
  25. <span>试卷难度:</span>
  26. <span>{{ paper.difficultyDegree }}</span>
  27. </div>
  28. </div>
  29. <div class="header-btns">
  30. <el-button
  31. type="primary"
  32. plain
  33. icon="icon icon-share"
  34. @click="releasePaper(paper.id)"
  35. >释放</el-button
  36. >
  37. <el-button type="danger" plain icon="icon icon-back" @click="back"
  38. >返回</el-button
  39. >
  40. </div>
  41. </div>
  42. <div class="view-body">
  43. <div class="view-title">
  44. <h1 class="paper-title">{{ paper.course.name }}&nbsp;试卷</h1>
  45. <p v-if="paper.hasAudio" class="paper-title-sub">(含音频试卷)</p>
  46. <p class="paper-title-sub">(课程代码&nbsp;{{ paper.course.code }})</p>
  47. </div>
  48. <div class="view-summary">
  49. <el-table :data="paper.paperDetails" border>
  50. <el-table-column prop="name" label="大题名称"> </el-table-column>
  51. <el-table-column prop="score" label="大题总分"> </el-table-column>
  52. <el-table-column prop="unitCount" label="小题数量"> </el-table-column>
  53. <el-table-column prop="pubCount" label="公开数量"> </el-table-column>
  54. <el-table-column prop="noPubCount" label="非公开数量">
  55. </el-table-column>
  56. </el-table>
  57. </div>
  58. <div class="view-seperator"></div>
  59. <!-- 考试说明 -->
  60. <div class="view-part">
  61. <div class="paper-question-title">考试说明</div>
  62. <div class="paper-question-body">
  63. <div v-html="paper.examRemark"></div>
  64. <div>本试卷满分{{ paper.totalScore }}分。</div>
  65. </div>
  66. </div>
  67. <!-- 循环大题 -->
  68. <div
  69. v-for="(paperDetail, detailIndex) in paper.paperDetails"
  70. v-show="paperDetailShow(paperDetail)"
  71. :key="detailIndex"
  72. class="view-part"
  73. @mouseover="quesMouseOver(paperDetail.id)"
  74. @mouseout="quesMouseOut(paperDetail.id)"
  75. >
  76. <div class="paper-question-title">
  77. <span>{{ paperDetail.cnNum }}</span> <span>.</span>
  78. <span>{{ paperDetail.name }}</span>
  79. <span>
  80. ({{ !paperDetail.title ? "本大题" : paperDetail.title + "," }}共{{
  81. paperDetail.unitCount
  82. }}小题,满分{{ paperDetail.score }}分)
  83. </span>
  84. </div>
  85. <rich-text
  86. class="paper-question-body"
  87. :text-json="paperDetail.description"
  88. ></rich-text>
  89. <div :id="paperDetail.id" class="view-part-action">
  90. <el-button
  91. v-show="showButtons[detailIndex].up"
  92. size="small"
  93. icon="el-icon-arrow-up"
  94. @click.stop="hideContent(detailIndex)"
  95. ></el-button>
  96. <el-button
  97. v-show="!showButtons[detailIndex].up"
  98. size="small"
  99. icon="el-icon-arrow-down"
  100. @click.stop="showContent(detailIndex)"
  101. ></el-button>
  102. </div>
  103. <!-- 循环小题 -->
  104. <div
  105. v-show="showQuestions[detailIndex].is_show"
  106. class="view-paper-questions"
  107. >
  108. <div
  109. v-for="(paperDetailUnit, unitIndex) in paperDetail.paperDetailUnits"
  110. v-show="quesShow(paperDetailUnit.id)"
  111. :key="unitIndex"
  112. class="view-quesiton"
  113. @mouseover="quesMouseOver(paperDetailUnit.id)"
  114. @mouseout="quesMouseOut(paperDetailUnit.id)"
  115. >
  116. <div class="paper-question-title">
  117. <span>{{ paperDetailUnit.number }}.</span>
  118. <rich-text
  119. :text-json="paperDetailUnit.question.quesBody"
  120. ></rich-text>
  121. <span> ({{ paperDetailUnit.score }}分) </span>
  122. </div>
  123. <div class="paper-question-body">
  124. <div
  125. v-for="(quesOption, optionIndex) in paperDetailUnit.question
  126. .quesOptions"
  127. :key="optionIndex"
  128. class="paper-question-option"
  129. >
  130. <span>{{ optionIndex | optionOrderWordFilter }}. </span>
  131. <rich-text :text-json="quesOption.optionBody"></rich-text>
  132. </div>
  133. </div>
  134. <div :id="paperDetailUnit.id" class="view-part-action">
  135. <el-button
  136. size="small"
  137. type="primary"
  138. plain
  139. @click="editQues(paperDetailUnit, paperDetailUnit.question)"
  140. >查看
  141. </el-button>
  142. </div>
  143. <!-- 子题循环 -->
  144. <div class="view-question-subs">
  145. <div
  146. v-for="(subQuestion, subIndex) in paperDetailUnit.question
  147. .subQuestions"
  148. v-show="quesShow(subQuestion.id)"
  149. :key="subIndex"
  150. class="view-part"
  151. @mouseover="
  152. quesMouseOver(getSubQuesEditId(paperDetailUnit, subQuestion))
  153. "
  154. @mouseout="
  155. quesMouseOut(getSubQuesEditId(paperDetailUnit, subQuestion))
  156. "
  157. >
  158. <div class="paper-question-title">
  159. <span>{{ subQuestion.subNumber }}. </span>
  160. <rich-text :text-json="subQuestion.quesBody"></rich-text>
  161. <span
  162. >({{ paperDetailUnit.subScoreList[subIndex] }}分)</span
  163. >
  164. </div>
  165. <div
  166. v-if="paperDetailUnit.questionType != 'MATCHING_QUESTION'"
  167. class="paper-question-body"
  168. >
  169. <div
  170. v-for="(
  171. subQuesOption, subOptIndex
  172. ) in subQuestion.quesOptions"
  173. :key="subOptIndex"
  174. class="paper-question-option"
  175. >
  176. <span>{{ subOptIndex | optionOrderWordFilter }}. </span>
  177. <rich-text
  178. :text-json="subQuesOption.optionBody"
  179. ></rich-text>
  180. </div>
  181. </div>
  182. <div
  183. :id="getSubQuesEditId(paperDetailUnit, subQuestion)"
  184. class="view-part-action"
  185. >
  186. <el-button
  187. size="small"
  188. type="primary"
  189. plain
  190. @click="editQues(paperDetailUnit, subQuestion)"
  191. >查看
  192. </el-button>
  193. </div>
  194. </div>
  195. </div>
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. <!-- 试题查看 -->
  201. <el-dialog
  202. v-loading.body="dialogLoading"
  203. title="试题查看"
  204. :visible.sync="quesDialog"
  205. :modal="false"
  206. append-to-body
  207. custom-class="side-dialog"
  208. @close="closeQuesDialog"
  209. >
  210. <el-form :model="quesModel" label-position="right" label-width="80px">
  211. <el-row :gutter="10">
  212. <el-col :span="12">
  213. <el-form-item label="题型">
  214. <el-select
  215. v-model="quesModel.questionType"
  216. :disabled="true"
  217. placeholder="请输入题型"
  218. >
  219. <el-option
  220. v-for="item in questionTypes"
  221. :key="item.value"
  222. :label="item.label"
  223. :value="item.value"
  224. >
  225. </el-option>
  226. </el-select>
  227. </el-form-item>
  228. </el-col>
  229. <el-col :span="12">
  230. <el-form-item label="分值">
  231. <el-input
  232. v-model="quesModel.score"
  233. :disabled="true"
  234. placeholder="分值"
  235. ></el-input>
  236. </el-form-item>
  237. </el-col>
  238. <el-col :span="12">
  239. <el-form-item label="难度">
  240. <el-select
  241. v-model="quesModel.difficultyDegree"
  242. placeholder="请输入难度"
  243. :disabled="true"
  244. >
  245. <el-option
  246. v-for="item in difficultyDegreeList"
  247. :key="item.value"
  248. :label="item.label"
  249. :value="item.value"
  250. >
  251. </el-option>
  252. </el-select>
  253. </el-form-item>
  254. </el-col>
  255. <el-col :span="12">
  256. <el-form-item label="公开度">
  257. <el-select
  258. v-model="quesModel.publicity"
  259. placeholder="请输入公开度"
  260. :disabled="true"
  261. >
  262. <el-option
  263. v-for="item in publicityList"
  264. :key="item.value"
  265. :label="item.label"
  266. :value="item.value"
  267. >
  268. </el-option>
  269. </el-select>
  270. </el-form-item>
  271. </el-col>
  272. <el-col
  273. v-if="quesModel.questionType == 'TEXT_ANSWER_QUESTION'"
  274. :span="12"
  275. >
  276. <el-form-item label="作答类型">
  277. <el-select v-model="quesModel.answerType" :disabled="true">
  278. <el-option
  279. v-for="item in answerTypes"
  280. :key="item.value"
  281. :label="item.label"
  282. :value="item.value"
  283. >
  284. </el-option>
  285. </el-select>
  286. </el-form-item>
  287. </el-col>
  288. <el-col
  289. v-if="quesModel.questionType && !isNested(quesModel.questionType)"
  290. :span="12"
  291. >
  292. <el-form-item label="时长">
  293. <el-input
  294. v-model="quesModel.control.maxAnswerTime"
  295. size="small"
  296. class="select_width"
  297. :disabled="true"
  298. ></el-input>
  299. </el-form-item>
  300. </el-col>
  301. <el-col
  302. v-if="quesModel.questionType == 'MATCHING_QUESTION'"
  303. :span="12"
  304. >
  305. <el-form-item label="配对类型">
  306. <el-select
  307. v-model="quesModel.quesParam.matchingType"
  308. :disabled="true"
  309. >
  310. <el-option
  311. v-for="item in matchingTypes"
  312. :key="item.value"
  313. :label="item.label"
  314. :value="item.value"
  315. >
  316. </el-option>
  317. </el-select>
  318. </el-form-item>
  319. </el-col>
  320. <el-col
  321. v-if="quesModel.questionType == 'MATCHING_QUESTION'"
  322. :span="12"
  323. >
  324. <el-form-item label="答题模式">
  325. <el-select
  326. v-model="quesModel.quesParam.matchingMode"
  327. :disabled="true"
  328. >
  329. <el-option
  330. v-for="item in matchingModes"
  331. :key="item.value"
  332. :label="item.label"
  333. :value="item.value"
  334. >
  335. </el-option>
  336. </el-select>
  337. </el-form-item>
  338. </el-col>
  339. </el-row>
  340. <el-form-item label="属性列表">
  341. <el-tooltip
  342. v-for="(content, propIndex) in quesModel.quesProperties"
  343. :key="propIndex"
  344. placement="top"
  345. >
  346. <div slot="content">
  347. <span v-if="content.firstProperty != null"
  348. >一级属性:{{ content.firstProperty.name }}</span
  349. ><br />
  350. <span v-if="content.secondProperty != null"
  351. >二级属性:{{ content.secondProperty.name }}</span
  352. >
  353. </div>
  354. <span>
  355. <el-tag
  356. :key="propIndex"
  357. style="margin-right: 5px"
  358. :closable="false"
  359. type="primary"
  360. effect="dark"
  361. >
  362. {{ content.courseProperty.name }}
  363. </el-tag>
  364. </span>
  365. </el-tooltip>
  366. </el-form-item>
  367. <el-form-item label="题目">
  368. <rich-text
  369. class="paper-question-title"
  370. style="font-weight: 400; padding-top: 7px"
  371. :text-json="quesModel.quesBody"
  372. ></rich-text>
  373. </el-form-item>
  374. <el-form-item
  375. v-if="
  376. !quesModel.parentType || quesModel.parentType != 'MATCHING_QUESTION'
  377. "
  378. >
  379. <div
  380. v-for="(quesOption, optIndex) in quesModel.quesOptions"
  381. :key="optIndex"
  382. class="paper-question-option"
  383. >
  384. <span>{{ optIndex | optionOrderWordFilter }}. </span>
  385. <rich-text :text-json="quesOption.optionBody"></rich-text>
  386. </div>
  387. </el-form-item>
  388. <el-form-item v-if="!isNested(quesModel.questionType)" label="答案">
  389. <question-answer
  390. class="paper-question-body"
  391. style="padding-top: 6px"
  392. :data="quesModel"
  393. ></question-answer>
  394. </el-form-item>
  395. </el-form>
  396. <div slot="footer">
  397. <el-button type="danger" plain @click="closeQuesDialog">关闭</el-button>
  398. </div>
  399. </el-dialog>
  400. </div>
  401. </template>
  402. <script>
  403. import { QUESTION_API } from "@/constants/constants";
  404. import { isEmptyStr, QUESTION_TYPES } from "../constants/constants";
  405. import { mapState } from "vuex";
  406. export default {
  407. name: "EditPaperApp",
  408. components: {},
  409. data() {
  410. return {
  411. hValue: "100px",
  412. wValue: "500px",
  413. display: "block",
  414. uploadAction: "",
  415. fileList: [],
  416. answerFileList: [],
  417. paperId: "",
  418. paperDetailId: "",
  419. editPaperDetailUnit: "",
  420. quesDialog: false,
  421. paperDatailDialog: false,
  422. paperRemarkDialog: false,
  423. parentView: "",
  424. paper: {
  425. course: {
  426. code: "",
  427. name: "",
  428. },
  429. examRemark: "",
  430. },
  431. loading: false,
  432. dialogLoading: false,
  433. detailLoading: false,
  434. uploadAudioLoading: false,
  435. uploadAnswerLoading: false,
  436. questionTypes: QUESTION_TYPES,
  437. questionType: "",
  438. quesModel: { quesProperties: [] },
  439. editpaperDetail: {},
  440. reduplicateQuestions: [],
  441. reduplicateGroup: [],
  442. reduplicateQuesColor: [],
  443. singleRightAnswer: "", //接收单选答案
  444. multipleRightAnswer: [], //接收多选答案
  445. options: ["正确", "错误"],
  446. duplicateLoading: false,
  447. dialogRadioFile: false,
  448. dialogAnswerFile: false,
  449. isUpload: true,
  450. isUploadAnswer: true,
  451. message: "",
  452. answerMessage: "",
  453. checkResult: false,
  454. checkResultAnswer: false,
  455. fileNameList: [],
  456. defaultColor: [
  457. "Red",
  458. "Blue",
  459. "LimeGreen",
  460. "GoldenRod",
  461. "Black",
  462. "BlueViolet",
  463. "Chocolate",
  464. "DarkCyan",
  465. "HotPink",
  466. "Orange",
  467. "IndianRed",
  468. "Indigo",
  469. "Green",
  470. "Aqua",
  471. "CadetBlue",
  472. "SkyBlue",
  473. "SlateBlue",
  474. "SlateGray",
  475. "Tomato",
  476. "VioletRed",
  477. ],
  478. difficultyDegreeList: [
  479. { label: 0.1, value: 0.1 },
  480. { label: 0.2, value: 0.2 },
  481. { label: 0.3, value: 0.3 },
  482. { label: 0.4, value: 0.4 },
  483. { label: 0.5, value: 0.5 },
  484. { label: 0.6, value: 0.6 },
  485. { label: 0.7, value: 0.7 },
  486. { label: 0.8, value: 0.8 },
  487. { label: 0.9, value: 0.9 },
  488. { label: 1.0, value: 1.0 },
  489. ],
  490. publicityList: [
  491. { label: "公开", value: true },
  492. { label: "非公开", value: false },
  493. ],
  494. answerTypes: [
  495. { label: "文本", value: "DIVERSIFIED_TEXT" },
  496. { label: "音频", value: "SINGLE_AUDIO" },
  497. ],
  498. matchingTypes: [
  499. { label: "填词", value: 1 },
  500. { label: "段落", value: 2 },
  501. ],
  502. matchingModes: [
  503. { label: "单用", value: 1 },
  504. { label: "复用", value: 2 },
  505. ],
  506. coursePropertyList: [],
  507. coursePropertyName: "", //课程属性名
  508. firstPropertyList: [], //一级属性集合
  509. firstPropertyId: "", //一级属性id
  510. secondPropertyList: [], //二级属性集合
  511. secondPropertyId: "", //二级属性id
  512. examRemark: "",
  513. showQuestions: [],
  514. showButtons: [],
  515. };
  516. },
  517. computed: {
  518. ...mapState({
  519. user: (state) => state.user,
  520. }),
  521. updatePorperty() {
  522. return false;
  523. },
  524. answer() {
  525. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  526. return this.singleRightAnswer;
  527. } else if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  528. var obj = this.multipleRightAnswer;
  529. return obj.sort().toString();
  530. }
  531. return this.quesModel.quesAnswer;
  532. },
  533. },
  534. created() {
  535. // $("body").attr("style", "");
  536. document.getElementsByTagName("body")[0].style = "";
  537. this.paperId = this.$route.params.id;
  538. this.parentView = this.$route.params.parentView;
  539. this.initPaper();
  540. this.uploadAction = QUESTION_API + "/uploadRadio/" + this.paperId;
  541. this.uploadHeaders = {
  542. key: this.user.key,
  543. token: this.user.token,
  544. };
  545. },
  546. methods: {
  547. isNested(questionType) {
  548. if (
  549. questionType == "NESTED_ANSWER_QUESTION" ||
  550. questionType == "LISTENING_QUESTION" ||
  551. questionType == "MATCHING_QUESTION"
  552. ) {
  553. return true;
  554. } else {
  555. return false;
  556. }
  557. },
  558. releasePaper(paperid) {
  559. this.$confirm("确认释放试卷吗?", "提示", {
  560. type: "warning",
  561. }).then(() => {
  562. this.loading = true;
  563. this.$http.put(QUESTION_API + "/paper_storage/release/" + paperid).then(
  564. () => {
  565. this.loading = false;
  566. this.$notify({
  567. message: "操作成功",
  568. type: "success",
  569. });
  570. this.back();
  571. },
  572. (response) => {
  573. this.loading = false;
  574. this.$notify({
  575. message: response.response.data.desc,
  576. type: "error",
  577. });
  578. }
  579. );
  580. });
  581. },
  582. //隐藏大题下的所有小题
  583. hideContent(index) {
  584. console.log("up");
  585. this.showQuestions[index].is_show = false;
  586. this.showButtons[index].up = false;
  587. },
  588. //展开大题下所有小题
  589. showContent(index) {
  590. console.log("down");
  591. this.showQuestions[index].is_show = true;
  592. this.showButtons[index].up = true;
  593. },
  594. quesMouseOver(index) {
  595. document.getElementById(index).style.visibility = "visible";
  596. },
  597. quesMouseOut(index) {
  598. document.getElementById(index).style.visibility = "hidden";
  599. },
  600. //初始化试卷
  601. initPaper() {
  602. const scrollPosition =
  603. document.documentElement.scrollTop || document.body.scrollTop;
  604. this.loading = true;
  605. this.paper = {
  606. course: {
  607. code: "",
  608. name: "",
  609. },
  610. };
  611. this.$http
  612. .get(QUESTION_API + "/paper/" + this.paperId)
  613. .then((response) => {
  614. this.paper = response.data;
  615. //查询所有课程属性名
  616. this.initCourseProperty(this.paper.course.id);
  617. //将所有小题分为公开和非公开
  618. if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
  619. for (let paperDetil of this.paper.paperDetails) {
  620. this.showQuestions.push({ is_show: true });
  621. this.showButtons.push({ up: true });
  622. paperDetil.pubCount = 0;
  623. paperDetil.noPubCount = 0;
  624. if (
  625. paperDetil.paperDetailUnits &&
  626. paperDetil.paperDetailUnits.length > 0
  627. ) {
  628. for (let paperDetilUt of paperDetil.paperDetailUnits) {
  629. if (!this.isNested(paperDetilUt.question.questionType)) {
  630. //非套题
  631. if (paperDetilUt.question.publicity) {
  632. paperDetil.pubCount = paperDetil.pubCount + 1;
  633. } else {
  634. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  635. }
  636. } else {
  637. //循环所有子题
  638. for (let ques of paperDetilUt.question.subQuestions) {
  639. if (ques.publicity) {
  640. paperDetil.pubCount = paperDetil.pubCount + 1;
  641. } else {
  642. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  643. }
  644. }
  645. }
  646. }
  647. }
  648. }
  649. }
  650. setTimeout(() => {
  651. document.documentElement.scrollTop = document.body.scrollTop =
  652. scrollPosition;
  653. console.log(scrollPosition);
  654. }, 1000);
  655. this.loading = false;
  656. });
  657. },
  658. //查询所有课程属性名
  659. initCourseProperty(courseId) {
  660. this.$http
  661. .get(QUESTION_API + "/courseProperty/enable?courseId=" + courseId)
  662. .then((response) => {
  663. this.coursePropertyList = response.data;
  664. });
  665. },
  666. quesShow(id) {
  667. if (this.reduplicateGroup.length < 1) {
  668. return true;
  669. }
  670. for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
  671. if (id == this.reduplicateGroup[i]) {
  672. return true;
  673. }
  674. }
  675. return false;
  676. },
  677. //编辑题目
  678. editQues(paperDetailUnit, question) {
  679. console.log("question:", question);
  680. this.coursePropertyName = "";
  681. this.firstPropertyId = "";
  682. this.secondPropertyId = "";
  683. this.editPaperDetailUnit = paperDetailUnit;
  684. this.quesModel = JSON.parse(JSON.stringify(question)); //深拷贝
  685. this.quesModel.score = paperDetailUnit.score;
  686. //如果是套题下面的小题编辑 ( paperDetailUnit的类型是套题,question的类型不是套题)
  687. if (
  688. (paperDetailUnit.questionType == "NESTED_ANSWER_QUESTION" &&
  689. question.questionType != "NESTED_ANSWER_QUESTION") ||
  690. (paperDetailUnit.questionType == "LISTENING_QUESTION" &&
  691. question.questionType != "LISTENING_QUESTION") ||
  692. (paperDetailUnit.questionType == "MATCHING_QUESTION" &&
  693. question.questionType != "MATCHING_QUESTION")
  694. ) {
  695. for (var i = 0; i < paperDetailUnit.question.subQuestions.length; i++) {
  696. if (
  697. paperDetailUnit.question.subQuestions[i].id == this.quesModel.id
  698. ) {
  699. this.quesModel.score = paperDetailUnit.subScoreList[i];
  700. this.quesModel.parentType = paperDetailUnit.questionType;
  701. this.quesModel.optionsSelected = paperDetailUnit.optionsSelected;
  702. this.quesModel.parentQuesParam = paperDetailUnit.question.quesParam;
  703. break;
  704. }
  705. }
  706. }
  707. if (isEmptyStr(this.quesModel.answerType)) {
  708. this.quesModel.answerType = "DIVERSIFIED_TEXT";
  709. }
  710. if (this.quesModel.questionType == "FILL_BLANK_QUESTION") {
  711. this.quesModel.quesBody = this.quesModel.quesBody.replace(
  712. /______/g,
  713. "###"
  714. );
  715. }
  716. this.assignAnswers(); //给singleRightAnswer或multipleRightAnswer赋值
  717. this.openQuesDialog();
  718. },
  719. //给singleRightAnswer和multipleRightAnswer赋值
  720. assignAnswers() {
  721. if (this.quesModel.quesOptions && this.quesModel.quesOptions.length > 0) {
  722. this.singleRightAnswer = "";
  723. this.multipleRightAnswer = [];
  724. for (let i = 0; i < this.quesModel.quesOptions.length; i++) {
  725. let option = this.quesModel.quesOptions[i];
  726. if (
  727. this.quesModel.questionType == "SINGLE_ANSWER_QUESTION" &&
  728. option.isCorrect == 1
  729. ) {
  730. this.singleRightAnswer = String.fromCharCode(65 + i);
  731. }
  732. if (
  733. this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION" &&
  734. option.isCorrect == 1
  735. ) {
  736. this.multipleRightAnswer.push(String.fromCharCode(65 + i));
  737. }
  738. }
  739. }
  740. },
  741. //打开修改试题编辑框
  742. openQuesDialog() {
  743. this.quesDialog = true;
  744. },
  745. //关闭试题编辑框
  746. closeQuesDialog() {
  747. this.quesDialog = false;
  748. this.quesModel = {};
  749. },
  750. //新增属性
  751. //在正确的option上设置isCorrect=1
  752. setRightAnswer() {
  753. if (
  754. !this.quesModel.quesOptions ||
  755. this.quesModel.quesOptions.length == 0
  756. ) {
  757. return false;
  758. }
  759. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  760. var option = this.quesModel.quesOptions[i];
  761. var answerOrderNum = String.fromCharCode(65 + i);
  762. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  763. option["isCorrect"] =
  764. answerOrderNum == this.singleRightAnswer ? 1 : 0;
  765. }
  766. if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  767. option["isCorrect"] =
  768. this.multipleRightAnswer.indexOf(answerOrderNum) > -1 ? 1 : 0;
  769. }
  770. }
  771. },
  772. getSubQuesEditId(paperDetailUnit, subQuestion) {
  773. return paperDetailUnit.question.id + "_" + subQuestion.subNumber;
  774. },
  775. //返回
  776. back() {
  777. if (sessionStorage.getItem("question_back") == "true") {
  778. this.$router.push({
  779. path: "/questions/paper_storage/0",
  780. });
  781. } else {
  782. this.$router.push({
  783. path: "/questions/paper_storage/1",
  784. });
  785. }
  786. },
  787. paperDetailShow(paperDetail) {
  788. if (this.reduplicateGroup.length == 0) {
  789. return true;
  790. }
  791. let paperDetailUnits = paperDetail.paperDetailUnits;
  792. for (let i = 0, imax = paperDetailUnits.length; i < imax; i++) {
  793. for (var j = 0, jmax = this.reduplicateGroup.length; j < jmax; j++) {
  794. if (paperDetailUnits[i].id == this.reduplicateGroup[j]) {
  795. return true;
  796. }
  797. }
  798. }
  799. return false;
  800. },
  801. },
  802. };
  803. </script>