ViewPaper.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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.difficulty }}</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. <rich-text :text-json="paper.examRemark"></rich-text>
  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.difficulty"
  242. placeholder="请输入难度"
  243. :disabled="true"
  244. >
  245. <el-option
  246. v-for="item in difficultyList"
  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. import QuestionAnswer from "../../question/components/QuestionAnswer.vue";
  407. export default {
  408. name: "EditPaperApp",
  409. components: { QuestionAnswer },
  410. data() {
  411. return {
  412. hValue: "100px",
  413. wValue: "500px",
  414. display: "block",
  415. uploadAction: "",
  416. fileList: [],
  417. answerFileList: [],
  418. paperId: "",
  419. paperDetailId: "",
  420. editPaperDetailUnit: "",
  421. quesDialog: false,
  422. paperDatailDialog: false,
  423. paperRemarkDialog: false,
  424. parentView: "",
  425. paper: {
  426. course: {
  427. code: "",
  428. name: "",
  429. },
  430. examRemark: "",
  431. },
  432. loading: false,
  433. dialogLoading: false,
  434. detailLoading: false,
  435. uploadAudioLoading: false,
  436. uploadAnswerLoading: false,
  437. questionTypes: QUESTION_TYPES,
  438. questionType: "",
  439. quesModel: { quesProperties: [] },
  440. editpaperDetail: {},
  441. reduplicateQuestions: [],
  442. reduplicateGroup: [],
  443. reduplicateQuesColor: [],
  444. singleRightAnswer: "", //接收单选答案
  445. multipleRightAnswer: [], //接收多选答案
  446. options: ["正确", "错误"],
  447. duplicateLoading: false,
  448. dialogRadioFile: false,
  449. dialogAnswerFile: false,
  450. isUpload: true,
  451. isUploadAnswer: true,
  452. message: "",
  453. answerMessage: "",
  454. checkResult: false,
  455. checkResultAnswer: false,
  456. fileNameList: [],
  457. defaultColor: [
  458. "Red",
  459. "Blue",
  460. "LimeGreen",
  461. "GoldenRod",
  462. "Black",
  463. "BlueViolet",
  464. "Chocolate",
  465. "DarkCyan",
  466. "HotPink",
  467. "Orange",
  468. "IndianRed",
  469. "Indigo",
  470. "Green",
  471. "Aqua",
  472. "CadetBlue",
  473. "SkyBlue",
  474. "SlateBlue",
  475. "SlateGray",
  476. "Tomato",
  477. "VioletRed",
  478. ],
  479. difficultyList: [
  480. { label: "难", value: "难" },
  481. { label: "中", value: "中" },
  482. { label: "易", value: "易" },
  483. ],
  484. publicityList: [
  485. { label: "公开", value: true },
  486. { label: "非公开", value: false },
  487. ],
  488. answerTypes: [
  489. { label: "文本", value: "DIVERSIFIED_TEXT" },
  490. { label: "音频", value: "SINGLE_AUDIO" },
  491. ],
  492. matchingTypes: [
  493. { label: "填词", value: 1 },
  494. { label: "段落", value: 2 },
  495. ],
  496. matchingModes: [
  497. { label: "单用", value: 1 },
  498. { label: "复用", value: 2 },
  499. ],
  500. coursePropertyList: [],
  501. coursePropertyName: "", //课程属性名
  502. firstPropertyList: [], //一级属性集合
  503. firstPropertyId: "", //一级属性id
  504. secondPropertyList: [], //二级属性集合
  505. secondPropertyId: "", //二级属性id
  506. examRemark: "",
  507. showQuestions: [],
  508. showButtons: [],
  509. };
  510. },
  511. computed: {
  512. ...mapState({
  513. user: (state) => state.user,
  514. }),
  515. updatePorperty() {
  516. return false;
  517. },
  518. answer() {
  519. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  520. return this.singleRightAnswer;
  521. } else if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  522. var obj = this.multipleRightAnswer;
  523. return obj.sort().toString();
  524. }
  525. return this.quesModel.quesAnswer;
  526. },
  527. },
  528. created() {
  529. // $("body").attr("style", "");
  530. document.getElementsByTagName("body")[0].style = "";
  531. this.paperId = this.$route.params.id;
  532. this.parentView = this.$route.params.parentView;
  533. this.initPaper();
  534. this.uploadAction = QUESTION_API + "/uploadRadio/" + this.paperId;
  535. this.uploadHeaders = {
  536. key: this.user.key,
  537. token: this.user.token,
  538. };
  539. },
  540. methods: {
  541. isNested(questionType) {
  542. if (
  543. questionType == "NESTED_ANSWER_QUESTION" ||
  544. questionType == "LISTENING_QUESTION" ||
  545. questionType == "MATCHING_QUESTION"
  546. ) {
  547. return true;
  548. } else {
  549. return false;
  550. }
  551. },
  552. releasePaper(paperid) {
  553. this.$confirm("确认释放试卷吗?", "提示", {
  554. type: "warning",
  555. }).then(() => {
  556. this.loading = true;
  557. this.$http.put(QUESTION_API + "/paper_storage/release/" + paperid).then(
  558. () => {
  559. this.loading = false;
  560. this.$notify({
  561. message: "操作成功",
  562. type: "success",
  563. });
  564. this.back();
  565. },
  566. (response) => {
  567. this.loading = false;
  568. this.$notify({
  569. message: response.response.data.desc,
  570. type: "error",
  571. });
  572. }
  573. );
  574. });
  575. },
  576. //隐藏大题下的所有小题
  577. hideContent(index) {
  578. console.log("up");
  579. this.showQuestions[index].is_show = false;
  580. this.showButtons[index].up = false;
  581. },
  582. //展开大题下所有小题
  583. showContent(index) {
  584. console.log("down");
  585. this.showQuestions[index].is_show = true;
  586. this.showButtons[index].up = true;
  587. },
  588. quesMouseOver(index) {
  589. document.getElementById(index).style.visibility = "visible";
  590. },
  591. quesMouseOut(index) {
  592. document.getElementById(index).style.visibility = "hidden";
  593. },
  594. //初始化试卷
  595. initPaper() {
  596. const scrollPosition =
  597. document.documentElement.scrollTop || document.body.scrollTop;
  598. this.loading = true;
  599. this.paper = {
  600. course: {
  601. code: "",
  602. name: "",
  603. },
  604. };
  605. this.$http
  606. .get(QUESTION_API + "/paper/" + this.paperId)
  607. .then((response) => {
  608. this.paper = response.data;
  609. //将所有小题分为公开和非公开
  610. if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
  611. for (let paperDetil of this.paper.paperDetails) {
  612. this.showQuestions.push({ is_show: true });
  613. this.showButtons.push({ up: true });
  614. paperDetil.pubCount = 0;
  615. paperDetil.noPubCount = 0;
  616. if (
  617. paperDetil.paperDetailUnits &&
  618. paperDetil.paperDetailUnits.length > 0
  619. ) {
  620. for (let paperDetilUt of paperDetil.paperDetailUnits) {
  621. if (!this.isNested(paperDetilUt.question.questionType)) {
  622. //非套题
  623. if (paperDetilUt.question.publicity) {
  624. paperDetil.pubCount = paperDetil.pubCount + 1;
  625. } else {
  626. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  627. }
  628. } else {
  629. //循环所有子题
  630. for (let ques of paperDetilUt.question.subQuestions) {
  631. if (ques.publicity) {
  632. paperDetil.pubCount = paperDetil.pubCount + 1;
  633. } else {
  634. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  635. }
  636. }
  637. }
  638. }
  639. }
  640. }
  641. }
  642. setTimeout(() => {
  643. document.documentElement.scrollTop = document.body.scrollTop =
  644. scrollPosition;
  645. console.log(scrollPosition);
  646. }, 1000);
  647. this.loading = false;
  648. });
  649. },
  650. quesShow(id) {
  651. if (this.reduplicateGroup.length < 1) {
  652. return true;
  653. }
  654. for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
  655. if (id == this.reduplicateGroup[i]) {
  656. return true;
  657. }
  658. }
  659. return false;
  660. },
  661. //编辑题目
  662. editQues(paperDetailUnit, question) {
  663. console.log("question:", question);
  664. this.coursePropertyName = "";
  665. this.firstPropertyId = "";
  666. this.secondPropertyId = "";
  667. this.editPaperDetailUnit = paperDetailUnit;
  668. this.quesModel = JSON.parse(JSON.stringify(question)); //深拷贝
  669. this.quesModel.score = paperDetailUnit.score;
  670. //如果是套题下面的小题编辑 ( paperDetailUnit的类型是套题,question的类型不是套题)
  671. if (
  672. (paperDetailUnit.questionType == "NESTED_ANSWER_QUESTION" &&
  673. question.questionType != "NESTED_ANSWER_QUESTION") ||
  674. (paperDetailUnit.questionType == "LISTENING_QUESTION" &&
  675. question.questionType != "LISTENING_QUESTION") ||
  676. (paperDetailUnit.questionType == "MATCHING_QUESTION" &&
  677. question.questionType != "MATCHING_QUESTION")
  678. ) {
  679. for (var i = 0; i < paperDetailUnit.question.subQuestions.length; i++) {
  680. if (
  681. paperDetailUnit.question.subQuestions[i].id == this.quesModel.id
  682. ) {
  683. this.quesModel.score = paperDetailUnit.subScoreList[i];
  684. this.quesModel.parentType = paperDetailUnit.questionType;
  685. this.quesModel.optionsSelected = paperDetailUnit.optionsSelected;
  686. this.quesModel.parentQuesParam = paperDetailUnit.question.quesParam;
  687. break;
  688. }
  689. }
  690. }
  691. if (isEmptyStr(this.quesModel.answerType)) {
  692. this.quesModel.answerType = "DIVERSIFIED_TEXT";
  693. }
  694. this.assignAnswers(); //给singleRightAnswer或multipleRightAnswer赋值
  695. this.openQuesDialog();
  696. },
  697. //给singleRightAnswer和multipleRightAnswer赋值
  698. assignAnswers() {
  699. if (this.quesModel.quesOptions && this.quesModel.quesOptions.length > 0) {
  700. this.singleRightAnswer = "";
  701. this.multipleRightAnswer = [];
  702. for (let i = 0; i < this.quesModel.quesOptions.length; i++) {
  703. let option = this.quesModel.quesOptions[i];
  704. if (
  705. this.quesModel.questionType == "SINGLE_ANSWER_QUESTION" &&
  706. option.isCorrect == 1
  707. ) {
  708. this.singleRightAnswer = String.fromCharCode(65 + i);
  709. }
  710. if (
  711. this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION" &&
  712. option.isCorrect == 1
  713. ) {
  714. this.multipleRightAnswer.push(String.fromCharCode(65 + i));
  715. }
  716. }
  717. }
  718. },
  719. //打开修改试题编辑框
  720. openQuesDialog() {
  721. this.quesDialog = true;
  722. },
  723. //关闭试题编辑框
  724. closeQuesDialog() {
  725. this.quesDialog = false;
  726. this.quesModel = {};
  727. },
  728. //新增属性
  729. //在正确的option上设置isCorrect=1
  730. setRightAnswer() {
  731. if (
  732. !this.quesModel.quesOptions ||
  733. this.quesModel.quesOptions.length == 0
  734. ) {
  735. return false;
  736. }
  737. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  738. var option = this.quesModel.quesOptions[i];
  739. var answerOrderNum = String.fromCharCode(65 + i);
  740. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  741. option["isCorrect"] =
  742. answerOrderNum == this.singleRightAnswer ? 1 : 0;
  743. }
  744. if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  745. option["isCorrect"] =
  746. this.multipleRightAnswer.indexOf(answerOrderNum) > -1 ? 1 : 0;
  747. }
  748. }
  749. },
  750. getSubQuesEditId(paperDetailUnit, subQuestion) {
  751. return paperDetailUnit.question.id + "_" + subQuestion.subNumber;
  752. },
  753. //返回
  754. back() {
  755. window.history.go(-1);
  756. // if (sessionStorage.getItem("question_back") == "true") {
  757. // this.$router.push({
  758. // path: "/questions/paper_storage/0",
  759. // });
  760. // } else {
  761. // this.$router.push({
  762. // path: "/questions/paper_storage/1",
  763. // });
  764. // }
  765. },
  766. paperDetailShow(paperDetail) {
  767. if (this.reduplicateGroup.length == 0) {
  768. return true;
  769. }
  770. let paperDetailUnits = paperDetail.paperDetailUnits;
  771. for (let i = 0, imax = paperDetailUnits.length; i < imax; i++) {
  772. for (var j = 0, jmax = this.reduplicateGroup.length; j < jmax; j++) {
  773. if (paperDetailUnits[i].id == this.reduplicateGroup[j]) {
  774. return true;
  775. }
  776. }
  777. }
  778. return false;
  779. },
  780. },
  781. };
  782. </script>