ViewPaper.vue 33 KB

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