ViewPaper.vue 32 KB

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