EditPaper.vue 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882
  1. <template>
  2. <div
  3. class="paper"
  4. v-loading="loading"
  5. element-loading-text="拼命加载中。。。"
  6. id="editPaperApp"
  7. >
  8. <!-- <ckeditor v-model="examRemark"></ckeditor> -->
  9. <div class="edit-paper-top">
  10. <div class="edit-paper-top-inline">
  11. <div class="paper-top-div">
  12. <span class="paper-top-title">课程代码:</span>
  13. <span class="paper-top-value">{{ paper.course.code }}</span>
  14. </div>
  15. <div class="paper-top-div">
  16. <span class="paper-top-title">课程名称:</span>
  17. <span class="paper-top-value">{{ paper.course.name }}</span>
  18. </div>
  19. <div class="paper-top-div">
  20. <span class="paper-top-title">试卷名称:</span>
  21. <el-tooltip class="item" effect="dark" placement="top-start">
  22. <div slot="content">{{ paper.name }}</div>
  23. <input
  24. class="paperName-input font_length"
  25. placeholder="试卷名称"
  26. v-model="paper.name"
  27. />
  28. </el-tooltip>
  29. </div>
  30. <div class="paper-top-div">
  31. <span class="paper-top-title">试卷难度:</span>
  32. <span class="paper-top-value">{{ paper.difficultyDegree }}</span>
  33. </div>
  34. <div>
  35. <el-button type="primary" @click="savePaper" size="small">
  36. 保存
  37. </el-button>
  38. <el-button type="danger" @click="deletePaper(paper.id)" size="small">
  39. <i class="el-icon-delete"></i> 删除
  40. </el-button>
  41. <el-dropdown class="button_left">
  42. <el-button type="primary" size="small">
  43. 更多 <i class="el-icon-arrow-down el-icon--right"></i>
  44. </el-button>
  45. <el-dropdown-menu slot="dropdown">
  46. <el-dropdown-item>
  47. <el-button
  48. type="primary"
  49. :loading="duplicateLoading"
  50. @click="getreduplicateQuestions"
  51. size="small"
  52. ><i class="el-icon-zoom-in"></i> 查重
  53. </el-button>
  54. </el-dropdown-item>
  55. <el-dropdown-item>
  56. <el-button
  57. v-show="parentView == 'import_paper'"
  58. type="primary"
  59. @click="openDialog"
  60. size="small"
  61. ><i class="el-icon-upload2"></i> 上传音频
  62. </el-button>
  63. </el-dropdown-item>
  64. <el-dropdown-item>
  65. <el-button
  66. size="small"
  67. type="primary"
  68. @click="exportPaperAnswer()"
  69. ><i class="el-icon-download"></i>导出答案</el-button
  70. >
  71. </el-dropdown-item>
  72. <el-dropdown-item>
  73. <el-button
  74. v-show="parentView == 'import_paper'"
  75. type="primary"
  76. @click="openAnswerDialog"
  77. size="small"
  78. ><i class="el-icon-upload2"></i> 导入答案
  79. </el-button>
  80. </el-dropdown-item>
  81. </el-dropdown-menu>
  82. </el-dropdown>
  83. <el-button
  84. @click="back"
  85. size="small"
  86. type="primary"
  87. style="margin-left: 20px;"
  88. ><i class="el-icon-arrow-left"></i> 返回</el-button
  89. >
  90. </div>
  91. </div>
  92. </div>
  93. <div class="paperName">
  94. <div>
  95. <br />
  96. <h3 class="text-center">{{ paper.course.name }}&nbsp;试卷</h3>
  97. <h5 class="text-center">
  98. <span v-show="paper.hasAudio">(含音频试卷)</span>
  99. </h5>
  100. <br />
  101. <h4 class="text-center">(课程代码&nbsp;{{ paper.course.code }})</h4>
  102. <br />
  103. </div>
  104. <div class="text-left">
  105. <el-table :data="paper.paperDetails" border style="width: 100%;">
  106. <el-table-column header-align="center" label="大题名称">
  107. <template slot-scope="scope">
  108. <span>{{ scope.row.name }}</span>
  109. </template>
  110. </el-table-column>
  111. <el-table-column header-align="center" label="大题总分">
  112. <template slot-scope="scope">
  113. <span>{{ scope.row.score }}</span>
  114. </template>
  115. </el-table-column>
  116. <el-table-column header-align="center" label="小题数量">
  117. <template slot-scope="scope">
  118. <span>{{ scope.row.unitCount }}</span>
  119. </template>
  120. </el-table-column>
  121. <el-table-column header-align="center" label="公开数量">
  122. <template slot-scope="scope">
  123. <span>{{ scope.row.pubCount }}</span>
  124. </template>
  125. </el-table-column>
  126. <el-table-column header-align="center" label="非公开数量">
  127. <template slot-scope="scope">
  128. <span>{{ scope.row.noPubCount }}</span>
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. <div class="mainQues" style="margin-top: 20px; margin-left: 0px;">
  133. <div class="mainQuesTitle">
  134. <span>考试说明:</span>
  135. <span>
  136. <el-button size="small" @click="openEditExamPaperRemark"
  137. >编辑</el-button
  138. >
  139. </span>
  140. <div style="width: 550px; margin-left: 20px; margin-top: 20px;">
  141. <span v-html="paper.examRemark"></span>
  142. </div>
  143. </div>
  144. </div>
  145. <!-- end by wwh -->
  146. <div>
  147. <h1>本试卷满分{{ paper.totalScore }}分。</h1>
  148. </div>
  149. <br />
  150. </div>
  151. </div>
  152. <div>
  153. <!-- 循环大题 -->
  154. <div
  155. class="mainQues"
  156. v-show="paperDetailShow(paperDetail)"
  157. v-for="(paperDetail, detailIndex) in paper.paperDetails"
  158. :key="detailIndex"
  159. >
  160. <div
  161. class="mainQuesTitle"
  162. @mouseover="quesMouseOver(paperDetail.id)"
  163. @mouseout="quesMouseOut(paperDetail.id)"
  164. >
  165. <span>{{ paperDetail.cnNum }}</span> <span>.</span>
  166. <span>{{ paperDetail.name }}</span>
  167. <span>
  168. ({{ !paperDetail.title ? "本大题" : paperDetail.title + "," }}共{{
  169. paperDetail.unitCount
  170. }}小题,满分{{ paperDetail.score }}分)
  171. </span>
  172. <span class="btnDiv" :id="paperDetail.id">
  173. <el-button
  174. v-show="parentView == 'gen_paper'"
  175. size="small"
  176. @click="selectQues(paperDetail.id)"
  177. >选题
  178. </el-button>
  179. <el-button size="small" @click="openEditPaperDetail(paperDetail)"
  180. >编辑
  181. </el-button>
  182. <el-button
  183. size="small"
  184. type="danger"
  185. @click="deletePaperDetail(paperDetail.id)"
  186. >删除
  187. </el-button>
  188. <el-button
  189. size="small"
  190. icon="el-icon-arrow-up"
  191. @click.stop="hideContent(detailIndex)"
  192. v-show="showButtons[detailIndex].up"
  193. ></el-button>
  194. <el-button
  195. size="small"
  196. icon="el-icon-arrow-down"
  197. @click.stop="showContent(detailIndex)"
  198. v-show="!showButtons[detailIndex].up"
  199. ></el-button>
  200. </span>
  201. </div>
  202. <!-- 循环小题 -->
  203. <div v-show="showQuestions[detailIndex].is_show">
  204. <div
  205. class="ques"
  206. v-show="quesShow(paperDetailUnit.id)"
  207. v-for="(paperDetailUnit, unitIndex) in paperDetail.paperDetailUnits"
  208. :key="unitIndex"
  209. >
  210. <reduplicate_mark
  211. :id="paperDetailUnit.id"
  212. :show="reduplicateMarkShow(paperDetailUnit.id)"
  213. :fillColor="reduplicateMarkColor(paperDetailUnit.id)"
  214. :checked="reduplicateMarkCheck(paperDetailUnit.id)"
  215. @reduplicate_mark_check="reduplicate_mark_check"
  216. >
  217. </reduplicate_mark>
  218. <div
  219. class="quesSelect"
  220. @mouseover="quesMouseOver(paperDetailUnit.id)"
  221. @mouseout="quesMouseOut(paperDetailUnit.id)"
  222. >
  223. <div class="btnDiv" :id="paperDetailUnit.id">
  224. <el-button
  225. size="small"
  226. @click="editQues(paperDetailUnit, paperDetailUnit.question)"
  227. >编辑
  228. </el-button>
  229. <el-button
  230. type="danger"
  231. size="small"
  232. @click="deleteQues(paperDetailUnit)"
  233. >删除
  234. </el-button>
  235. </div>
  236. <div class="quesBody">
  237. <span class="ques-title">{{ paperDetailUnit.number }}.</span>
  238. <span
  239. class="ques-body"
  240. v-question-audio
  241. :hasAudio="paperDetailUnit.question.hasAudio"
  242. :questionId="paperDetailUnit.question.id"
  243. v-html="paperDetailUnit.question.quesBody"
  244. ></span>
  245. <span class="score-span">
  246. ({{ paperDetailUnit.score }}分)
  247. </span>
  248. </div>
  249. <div
  250. class="quesOption"
  251. v-for="(quesOption, optionIndex) in paperDetailUnit.question
  252. .quesOptions"
  253. :key="optionIndex"
  254. >
  255. <span class="ques-title"
  256. >{{ optionIndex | optionOrderWordFilter }}.
  257. </span>
  258. <span
  259. class="ques-body"
  260. v-question-audio
  261. :hasAudio="paperDetailUnit.question.hasAudio"
  262. :questionId="paperDetailUnit.question.id"
  263. v-html="quesOption.optionBody"
  264. ></span>
  265. </div>
  266. </div>
  267. <br />
  268. <div
  269. class="subQues"
  270. v-show="quesShow(subQuestion.id)"
  271. v-for="(subQuestion, subIndex) in paperDetailUnit.question
  272. .subQuestions"
  273. :key="subIndex"
  274. >
  275. <reduplicate_mark
  276. :show="reduplicateMarkShow(subQuestion.id)"
  277. ></reduplicate_mark>
  278. <div
  279. class="quesSelect"
  280. @mouseover="
  281. quesMouseOver(getSubQuesEditId(paperDetailUnit, subQuestion))
  282. "
  283. @mouseout="
  284. quesMouseOut(getSubQuesEditId(paperDetailUnit, subQuestion))
  285. "
  286. >
  287. <div
  288. class="btnDiv"
  289. :id="getSubQuesEditId(paperDetailUnit, subQuestion)"
  290. >
  291. <el-button
  292. size="small"
  293. @click="editQues(paperDetailUnit, subQuestion)"
  294. >编辑
  295. </el-button>
  296. </div>
  297. <div class="quesBody">
  298. <span class="ques-title"
  299. >{{ subQuestion.quesParams.number }}.
  300. </span>
  301. <span v-html="subQuestion.quesBody"></span>
  302. <span
  303. >({{ paperDetailUnit.subScoreList[subIndex] }}分)</span
  304. >
  305. </div>
  306. <div
  307. class="quesOption"
  308. v-for="(subQuesOption,
  309. subOptIndex) in subQuestion.quesOptions"
  310. :key="subOptIndex"
  311. >
  312. <span class="ques-title"
  313. >{{ subOptIndex | optionOrderWordFilter }}.
  314. </span>
  315. <span v-html="subQuesOption.optionBody"></span>
  316. </div>
  317. <br />
  318. </div>
  319. </div>
  320. </div>
  321. <br />
  322. </div>
  323. </div>
  324. </div>
  325. <div class="text-left">
  326. <!-- 编辑大题弹框 -->
  327. <el-dialog
  328. width="360px"
  329. @close="closeQuesDialog"
  330. title="大题名称编辑"
  331. v-loading.body="detailLoading"
  332. element-loading-text="保存中。。。"
  333. :visible.sync="paperDatailDialog"
  334. >
  335. <el-form
  336. :model="editpaperDetail"
  337. label-position="right"
  338. label-width="80px"
  339. >
  340. <el-row :gutter="10">
  341. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  342. <el-form-item label="大题名称" placeholder="大题名称">
  343. <el-input
  344. class="dialog_input_width"
  345. v-model="editpaperDetail.name"
  346. />
  347. </el-form-item>
  348. </el-col>
  349. </el-row>
  350. <el-row>
  351. <el-form-item>
  352. <el-button
  353. type="primary"
  354. @click="savePaperDatail(editpaperDetail)"
  355. >保存</el-button
  356. >
  357. <el-button @click="closePaperDatailDialog()">取消</el-button>
  358. </el-form-item>
  359. </el-row>
  360. </el-form>
  361. </el-dialog>
  362. <!-- 编辑试题弹框 -->
  363. <el-dialog
  364. @close="closeQuesDialog"
  365. title="试题编辑"
  366. v-loading.body="dialogLoading"
  367. element-loading-text="保存中。。。"
  368. :visible.sync="quesDialog"
  369. >
  370. <el-form :model="quesModel" label-position="right" label-width="80px">
  371. <el-row :gutter="10">
  372. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  373. <el-form-item label="题型">
  374. <el-select
  375. :disabled="true"
  376. v-model="quesModel.questionType"
  377. placeholder="请输入题型"
  378. >
  379. <el-option
  380. v-for="item in questionTypes"
  381. :label="item.label"
  382. :value="item.value"
  383. :key="item.value"
  384. >
  385. </el-option>
  386. </el-select>
  387. </el-form-item>
  388. </el-col>
  389. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  390. <el-form-item label="分值">
  391. <el-input
  392. placeholder="分值"
  393. :disabled="quesModel.questionType == 'NESTED_ANSWER_QUESTION'"
  394. v-model="quesModel.score"
  395. ></el-input>
  396. </el-form-item>
  397. </el-col>
  398. </el-row>
  399. <!-- create by weiwenhai 添加难度,公开度,试题属性 -->
  400. <el-row :gutter="10">
  401. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  402. <el-form-item label="难度">
  403. <el-select
  404. v-model="quesModel.difficultyDegree"
  405. placeholder="请输入难度"
  406. :disabled="
  407. quesModel.questionType == 'NESTED_ANSWER_QUESTION'
  408. ? true
  409. : updatePorperty
  410. "
  411. >
  412. <el-option
  413. v-for="item in difficultyDegreeList"
  414. :label="item.label"
  415. :value="item.value"
  416. :key="item.value"
  417. >
  418. </el-option>
  419. </el-select>
  420. </el-form-item>
  421. </el-col>
  422. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  423. <el-form-item label="公开度">
  424. <el-select
  425. v-model="quesModel.publicity"
  426. placeholder="请输入公开度"
  427. :disabled="updatePorperty"
  428. >
  429. <el-option
  430. v-for="item in publicityList"
  431. :label="item.label"
  432. :value="item.value"
  433. :key="item.value"
  434. >
  435. </el-option>
  436. </el-select>
  437. </el-form-item>
  438. </el-col>
  439. <el-col
  440. :xs="10"
  441. :sm="10"
  442. :md="10"
  443. :lg="10"
  444. v-if="quesModel.questionType == 'TEXT_ANSWER_QUESTION'"
  445. >
  446. <el-form-item label="作答类型">
  447. <el-select
  448. v-model="quesModel.answerType"
  449. :disabled="updatePorperty"
  450. >
  451. <el-option
  452. v-for="item in answerTypes"
  453. :label="item.label"
  454. :value="item.value"
  455. :key="item.value"
  456. >
  457. </el-option>
  458. </el-select>
  459. </el-form-item>
  460. </el-col>
  461. </el-row>
  462. <el-row :gutter="10">
  463. <el-col :xs="20" :sm="20" :md="20" :lg="20">
  464. <el-form-item label="属性列表">
  465. <el-tooltip
  466. placement="top"
  467. v-for="(content, propIndex) in quesModel.quesProperties"
  468. :key="propIndex"
  469. >
  470. <div slot="content">
  471. <span v-if="content.firstProperty != null"
  472. >一级属性:{{ content.firstProperty.name }}</span
  473. ><br />
  474. <span v-if="content.secondProperty != null"
  475. >二级属性:{{ content.secondProperty.name }}</span
  476. >
  477. </div>
  478. <span>
  479. <el-tag
  480. style="margin-right: 5px;"
  481. :key="content.id"
  482. :closable="!updatePorperty"
  483. type="primary"
  484. @close="handleClose(content)"
  485. >
  486. {{ content.coursePropertyName }}
  487. </el-tag>
  488. </span>
  489. </el-tooltip>
  490. </el-form-item>
  491. </el-col>
  492. </el-row>
  493. <el-row>
  494. <el-col :span="6">
  495. <el-form-item label="属性名" label-width="60px">
  496. <el-select
  497. v-model="coursePropertyName"
  498. placeholder="属性名"
  499. @change="searchFirst"
  500. class="property_with"
  501. :disabled="updatePorperty"
  502. >
  503. <el-option label="请选择" value=""></el-option>
  504. <el-option
  505. v-for="item in coursePropertyList"
  506. :label="item.name"
  507. :value="item.name"
  508. :key="item.name"
  509. >
  510. </el-option>
  511. </el-select>
  512. </el-form-item>
  513. </el-col>
  514. <el-col :span="6">
  515. <el-form-item label="一级" label-width="48px">
  516. <el-select
  517. v-model="firstPropertyId"
  518. placeholder="一级"
  519. @change="searchSecond"
  520. class="property_with"
  521. :disabled="updatePorperty"
  522. >
  523. <el-option label="请选择" value=""></el-option>
  524. <el-option
  525. v-for="item in firstPropertyList"
  526. :label="item.name"
  527. :value="item.id"
  528. :key="item.id"
  529. >
  530. </el-option>
  531. </el-select>
  532. </el-form-item>
  533. </el-col>
  534. <el-col :span="6">
  535. <el-form-item label="二级" label-width="48px">
  536. <el-select
  537. v-model="secondPropertyId"
  538. placeholder="二级"
  539. class="property_with"
  540. :disabled="updatePorperty"
  541. >
  542. <el-option label="请选择" value=""></el-option>
  543. <el-option
  544. v-for="item in secondPropertyList"
  545. :label="item.name"
  546. :value="item.id"
  547. :key="item.id"
  548. >
  549. </el-option>
  550. </el-select>
  551. </el-form-item>
  552. </el-col>
  553. <el-col :span="6">
  554. <el-form-item>
  555. <el-button
  556. type="primary"
  557. @click="insertProperty"
  558. style="margin-left: -50px;"
  559. :disabled="updatePorperty"
  560. ><i class="el-icon-plus"></i>新增属性
  561. </el-button>
  562. </el-form-item>
  563. </el-col>
  564. </el-row>
  565. <!-- end by weiwenhai -->
  566. <div v-if="paper.paperType == 'IMPORT'">
  567. <el-row>
  568. <el-col>
  569. <el-form-item label="题目">
  570. <ckeditor v-model="quesModel.quesBody"></ckeditor>
  571. </el-form-item>
  572. </el-col>
  573. </el-row>
  574. <el-form-item
  575. v-for="(quesOption, optIndex) in quesModel.quesOptions"
  576. :key="optIndex"
  577. >
  578. <el-col :span="2">
  579. <el-radio
  580. v-model="singleRightAnswer"
  581. :label="optIndex | optionOrderWordFilter"
  582. v-if="quesModel.questionType === 'SINGLE_ANSWER_QUESTION'"
  583. ></el-radio>
  584. <el-checkbox
  585. v-model="multipleRightAnswer"
  586. :label="optIndex | optionOrderWordFilter"
  587. v-if="quesModel.questionType === 'MULTIPLE_ANSWER_QUESTION'"
  588. ></el-checkbox>
  589. </el-col>
  590. <el-col :span="20">
  591. <ckeditor v-model="quesOption.optionBody"></ckeditor>
  592. </el-col>
  593. <el-col :span="2">
  594. <i
  595. class="el-icon-delete"
  596. @click.prevent="removeQuesOption(quesOption)"
  597. title="删除"
  598. ></i>
  599. </el-col>
  600. </el-form-item>
  601. <div
  602. v-if="
  603. quesModel.questionType != 'NESTED_ANSWER_QUESTION' &&
  604. quesModel.questionType != 'SINGLE_ANSWER_QUESTION' &&
  605. quesModel.questionType != 'MULTIPLE_ANSWER_QUESTION' &&
  606. quesModel.questionType != 'BOOL_ANSWER_QUESTION'
  607. "
  608. >
  609. <el-form-item label="答案">
  610. <ckeditor v-model="quesModel.quesAnswer"></ckeditor>
  611. </el-form-item>
  612. </div>
  613. <!-- 单选或多选 -->
  614. <div
  615. v-if="
  616. quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  617. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'
  618. "
  619. >
  620. <el-form-item label="答案">
  621. <span v-html="answer"></span>
  622. </el-form-item>
  623. </div>
  624. <div v-if="quesModel.questionType == 'BOOL_ANSWER_QUESTION'">
  625. <el-row>
  626. <el-col>
  627. <el-form-item label="答案" prop="quesAnswer">
  628. <el-select
  629. v-model="quesModel.quesAnswer"
  630. placeholder="请选择"
  631. >
  632. <el-option
  633. v-for="op in options"
  634. :label="op"
  635. :value="op"
  636. :key="op"
  637. >
  638. </el-option>
  639. </el-select>
  640. </el-form-item>
  641. </el-col>
  642. </el-row>
  643. </div>
  644. </div>
  645. <div
  646. :class="{
  647. margin_left_30:
  648. paper.paperType == 'IMPORT' &&
  649. (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  650. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'),
  651. margin_left_40: !(
  652. paper.paperType == 'IMPORT' &&
  653. (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  654. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION')
  655. ),
  656. }"
  657. >
  658. <el-button
  659. type="primary"
  660. @click="addQuesOption"
  661. v-if="
  662. paper.paperType == 'IMPORT' &&
  663. (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  664. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION')
  665. "
  666. ><i class="el-icon-plus"></i> 新增选项
  667. </el-button>
  668. <el-button type="primary" @click="savePaperDetailUnit()"
  669. >保存</el-button
  670. >
  671. <el-button @click="closeQuesDialog">取消</el-button>
  672. </div>
  673. </el-form>
  674. </el-dialog>
  675. <!-- 考试说明弹框 -->
  676. <el-dialog title="考试说明编辑" :visible.sync="paperRemarkDialog">
  677. <el-form label-position="right" label-width="80px">
  678. <el-row :gutter="10">
  679. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  680. <el-form-item label="考试说明">
  681. <div style="width: 550px;">
  682. <ckeditor
  683. :display="display"
  684. :width="wValue"
  685. :height="hValue"
  686. v-model="examRemark"
  687. ></ckeditor>
  688. </div>
  689. </el-form-item>
  690. </el-col>
  691. </el-row>
  692. <div style="margin-top: 20px; margin-left: 40%;">
  693. <el-button type="primary" @click="savePaperRemark">保存</el-button>
  694. <el-button @click="closPaperRemark">取消</el-button>
  695. </div>
  696. </el-form>
  697. </el-dialog>
  698. <!-- 上传音频弹框 -->
  699. <el-dialog
  700. title="上传音频文件"
  701. :visible.sync="dialogRadioFile"
  702. :before-close="closeAudioDialog"
  703. >
  704. <form
  705. id="radioForm"
  706. method="post"
  707. action=""
  708. enctype="multipart/form-data"
  709. >
  710. <input
  711. id="radioFile"
  712. name="files"
  713. type="file"
  714. value="上传音频文件"
  715. webkitdirectory
  716. />
  717. <el-button @click="checkFile" type="warning">检查文件名</el-button>
  718. <el-button
  719. @click="uploadAudioFile"
  720. type="info"
  721. :loading="uploadAudioLoading"
  722. :disabled="isUpload || uploadAudioLoading"
  723. >
  724. <span v-show="!uploadAudioLoading">开始上传</span>
  725. <span v-show="uploadAudioLoading">正在上传中...</span>
  726. </el-button>
  727. </form>
  728. <div style="margin-top: 20px;" v-if="checkResult">
  729. <span>检查结果:</span><br /><br />
  730. <span style="color: #13ce66;" v-show="message == 'OK!'">OK!</span>
  731. <span style="color: #ff4949;" v-show="message != 'OK!'">{{
  732. message
  733. }}</span>
  734. </div>
  735. </el-dialog>
  736. <el-dialog
  737. title="上传答案文件"
  738. :visible.sync="dialogAnswerFile"
  739. :before-close="closeAnswerDialog"
  740. >
  741. <form
  742. id="answerForm"
  743. method="post"
  744. action=""
  745. enctype="multipart/form-data"
  746. >
  747. <input
  748. id="answerFile"
  749. name="answerFiles"
  750. type="file"
  751. value="上传答案文件"
  752. accept=".xlsx"
  753. webkitdirectory
  754. />
  755. <el-button
  756. @click="uploadAnswerFile"
  757. type="info"
  758. :loading="uploadAnswerLoading"
  759. :disabled="uploadAnswerLoading"
  760. >
  761. <span v-show="!uploadAnswerLoading">开始上传</span>
  762. <span v-show="uploadAnswerLoading">正在上传中...</span>
  763. </el-button>
  764. </form>
  765. <div style="margin-top: 20px;">
  766. <span style="color: #ff4949;" v-show="answerMessage != ''">{{
  767. answerMessage
  768. }}</span>
  769. </div>
  770. </el-dialog>
  771. </div>
  772. </div>
  773. </template>
  774. <script>
  775. import { QUESTION_API } from "@/constants/constants";
  776. import { isEmptyStr, QUESTION_TYPES } from "../constants/constants";
  777. import { mapState } from "vuex";
  778. import reduplicate_mark from "../component/reduplicate_mark.vue";
  779. import randomColor from "randomcolor";
  780. import ckeditor from "../component/ckeditor.vue";
  781. export default {
  782. name: "editPaperApp",
  783. components: {
  784. reduplicate_mark,
  785. ckeditor,
  786. },
  787. data() {
  788. return {
  789. hValue: "100px",
  790. wValue: "500px",
  791. display: "block",
  792. uploadAction: "",
  793. fileList: [],
  794. answerFileList: [],
  795. paperId: "",
  796. paperDetailId: "",
  797. editPaperDetailUnit: "",
  798. quesDialog: false,
  799. paperDatailDialog: false,
  800. paperRemarkDialog: false,
  801. parentView: "",
  802. paper: {
  803. course: {
  804. code: "",
  805. name: "",
  806. },
  807. examRemark: "",
  808. },
  809. loading: false,
  810. dialogLoading: false,
  811. detailLoading: false,
  812. uploadAudioLoading: false,
  813. uploadAnswerLoading: false,
  814. questionTypes: QUESTION_TYPES,
  815. questionType: "",
  816. quesModel: { quesProperties: [] },
  817. editpaperDetail: {},
  818. reduplicateQuestions: [],
  819. reduplicateGroup: [],
  820. reduplicateQuesColor: [],
  821. singleRightAnswer: "", //接收单选答案
  822. multipleRightAnswer: [], //接收多选答案
  823. options: ["正确", "错误"],
  824. duplicateLoading: false,
  825. dialogRadioFile: false,
  826. dialogAnswerFile: false,
  827. isUpload: true,
  828. isUploadAnswer: true,
  829. message: "",
  830. answerMessage: "",
  831. checkResult: false,
  832. checkResultAnswer: false,
  833. fileNameList: [],
  834. defaultColor: [
  835. "Red",
  836. "Blue",
  837. "LimeGreen",
  838. "GoldenRod",
  839. "Black",
  840. "BlueViolet",
  841. "Chocolate",
  842. "DarkCyan",
  843. "HotPink",
  844. "Orange",
  845. "IndianRed",
  846. "Indigo",
  847. "Green",
  848. "Aqua",
  849. "CadetBlue",
  850. "SkyBlue",
  851. "SlateBlue",
  852. "SlateGray",
  853. "Tomato",
  854. "VioletRed",
  855. ],
  856. difficultyDegreeList: [
  857. { label: 0.1, value: 0.1 },
  858. { label: 0.2, value: 0.2 },
  859. { label: 0.3, value: 0.3 },
  860. { label: 0.4, value: 0.4 },
  861. { label: 0.5, value: 0.5 },
  862. { label: 0.6, value: 0.6 },
  863. { label: 0.7, value: 0.7 },
  864. { label: 0.8, value: 0.8 },
  865. { label: 0.9, value: 0.9 },
  866. { label: 1.0, value: 1.0 },
  867. ],
  868. publicityList: [
  869. { label: "公开", value: true },
  870. { label: "非公开", value: false },
  871. ],
  872. answerTypes: [
  873. { label: "文本", value: "DIVERSIFIED_TEXT" },
  874. { label: "音频", value: "SINGLE_AUDIO" },
  875. ],
  876. coursePropertyList: [],
  877. coursePropertyName: "", //课程属性名
  878. firstPropertyList: [], //一级属性集合
  879. firstPropertyId: "", //一级属性id
  880. secondPropertyList: [], //二级属性集合
  881. secondPropertyId: "", //二级属性id
  882. examRemark: "",
  883. showQuestions: [],
  884. showButtons: [],
  885. };
  886. },
  887. methods: {
  888. openAnswerDialog() {
  889. this.checkResultAnswer = false;
  890. this.isUploadAnswer = true;
  891. if (document.getElementById("answerFile")) {
  892. document.getElementById("answerFile").value = "";
  893. }
  894. this.dialogAnswerFile = true;
  895. this.answerFileList = [];
  896. },
  897. closeAnswerDialog() {
  898. this.dialogAnswerFile = this.uploadAnswerLoading;
  899. },
  900. uploadAnswerFile() {
  901. var fileList = document.getElementById("answerFile").files;
  902. if (fileList.length == 0) {
  903. this.answerMessage = "请选择文件!";
  904. return;
  905. }
  906. let param = new FormData();
  907. //循环添加到formData中
  908. for (var i = 0; i < fileList.length; i++) {
  909. var file = fileList[i];
  910. param.append("files", file, file.name);
  911. }
  912. let config = {
  913. headers: { "Content-Type": "multipart/form-data" },
  914. };
  915. this.$http
  916. .post(
  917. QUESTION_API + "/paper/answer/import/" + this.paperId,
  918. param,
  919. config
  920. )
  921. .then(() => {
  922. this.dialogAnswerFile = false;
  923. this.uploadAnswerLoading = false;
  924. this.checkResultAnswer = false;
  925. this.isUploadAnswer = true;
  926. document.getElementById("answerFile").value = "";
  927. this.initPaper();
  928. })
  929. .catch((error) => {
  930. this.answerMessage = error.response.data.desc;
  931. this.uploadAnswerLoading = false;
  932. });
  933. },
  934. //隐藏大题下的所有小题
  935. hideContent(index) {
  936. console.log("up");
  937. this.showQuestions[index].is_show = false;
  938. this.showButtons[index].up = false;
  939. },
  940. //展开大题下所有小题
  941. showContent(index) {
  942. console.log("down");
  943. this.showQuestions[index].is_show = true;
  944. this.showButtons[index].up = true;
  945. },
  946. quesMouseOver(index) {
  947. document.getElementById(index).style.visibility = "visible";
  948. },
  949. quesMouseOut(index) {
  950. document.getElementById(index).style.visibility = "hidden";
  951. },
  952. selectQues(id) {
  953. this.paperDetailId = id;
  954. var courseCode = this.paper.course.code;
  955. var courseName = this.paper.course.name;
  956. this.$router.push({
  957. path:
  958. "/select_question/" +
  959. this.paper.id +
  960. "/" +
  961. courseCode +
  962. "/" +
  963. encodeURIComponent(courseName) +
  964. "/" +
  965. this.paperDetailId +
  966. "/" +
  967. this.parentView,
  968. });
  969. },
  970. //打开编辑大题题目弹窗
  971. openEditPaperDetail(paperDetail) {
  972. this.paperDatailDialog = true;
  973. this.editpaperDetail = Object.assign({}, paperDetail); //浅拷贝
  974. },
  975. //关闭编辑大题题目弹窗
  976. closePaperDatailDialog() {
  977. this.paperDatailDialog = false;
  978. this.editpaperDetail = {};
  979. },
  980. //保存大题题目信息
  981. savePaperDatail(editpaperDetail) {
  982. this.detailLoading = true;
  983. var paperId = this.paper.id;
  984. this.$http
  985. .post(QUESTION_API + "/updatePaperDetail/" + paperId, editpaperDetail)
  986. .then(() => {
  987. this.$notify({
  988. message: "保存成功",
  989. type: "success",
  990. });
  991. this.detailLoading = false;
  992. this.closePaperDatailDialog();
  993. this.initPaper();
  994. });
  995. },
  996. //初始化试卷
  997. initPaper() {
  998. const scrollPosition =
  999. document.documentElement.scrollTop || document.body.scrollTop;
  1000. this.loading = true;
  1001. this.paper = {
  1002. course: {
  1003. code: "",
  1004. name: "",
  1005. },
  1006. };
  1007. this.$http
  1008. .get(QUESTION_API + "/paper/" + this.paperId)
  1009. .then((response) => {
  1010. this.paper = response.data;
  1011. //查询所有课程属性名
  1012. this.initCourseProperty(this.paper.course.code);
  1013. //将所有小题分为公开和非公开
  1014. if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
  1015. for (let paperDetil of this.paper.paperDetails) {
  1016. this.showQuestions.push({ is_show: true });
  1017. this.showButtons.push({ up: true });
  1018. paperDetil.pubCount = 0;
  1019. paperDetil.noPubCount = 0;
  1020. if (
  1021. paperDetil.paperDetailUnits &&
  1022. paperDetil.paperDetailUnits.length > 0
  1023. ) {
  1024. for (let paperDetilUt of paperDetil.paperDetailUnits) {
  1025. if (
  1026. paperDetilUt.question.questionType !=
  1027. "NESTED_ANSWER_QUESTION"
  1028. ) {
  1029. //非套题
  1030. if (paperDetilUt.question.publicity) {
  1031. paperDetil.pubCount = paperDetil.pubCount + 1;
  1032. } else {
  1033. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  1034. }
  1035. } else {
  1036. //循环所有子题
  1037. for (let ques of paperDetilUt.question.subQuestions) {
  1038. if (ques.publicity) {
  1039. paperDetil.pubCount = paperDetil.pubCount + 1;
  1040. } else {
  1041. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  1042. }
  1043. }
  1044. }
  1045. }
  1046. }
  1047. }
  1048. }
  1049. setTimeout(() => {
  1050. document.documentElement.scrollTop = document.body.scrollTop = scrollPosition;
  1051. console.log(scrollPosition);
  1052. }, 1000);
  1053. this.loading = false;
  1054. });
  1055. },
  1056. //查询所有课程属性名
  1057. initCourseProperty(courseCode) {
  1058. this.$http
  1059. .get(QUESTION_API + "/courseProperty/enable/" + courseCode)
  1060. .then((response) => {
  1061. this.coursePropertyList = response.data;
  1062. });
  1063. },
  1064. //删除大题
  1065. deletePaperDetail(paperDetailsId) {
  1066. //先判断大题下面是否还有小题
  1067. var count = 0;
  1068. for (var i = 0, imax = this.paper.paperDetails.length; i < imax; i++) {
  1069. if (paperDetailsId == this.paper.paperDetails[i].id) {
  1070. if (this.paper.paperDetails[i].paperDetailUnits) {
  1071. count += this.paper.paperDetails[i].paperDetailUnits.length;
  1072. break;
  1073. }
  1074. }
  1075. }
  1076. if (count == 0) {
  1077. this.$alert("您确定删除吗?", "提示", {
  1078. confirmButtonText: "确定",
  1079. callback: (action) => {
  1080. if (action == "confirm") {
  1081. this.loading = true;
  1082. this.$http
  1083. .delete(QUESTION_API + "/paperDetail/" + paperDetailsId)
  1084. .then(() => {
  1085. this.initPaper();
  1086. this.loading = true;
  1087. this.$notify({
  1088. message: "删除成功",
  1089. type: "success",
  1090. });
  1091. this.loading = false;
  1092. });
  1093. }
  1094. },
  1095. });
  1096. } else {
  1097. this.$alert("大题下还有小题,不可删除!", "提示", {
  1098. confirmButtonText: "确定",
  1099. callback: () => {},
  1100. });
  1101. }
  1102. },
  1103. quesShow(id) {
  1104. if (this.reduplicateGroup.length < 1) {
  1105. return true;
  1106. }
  1107. for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
  1108. if (id == this.reduplicateGroup[i]) {
  1109. return true;
  1110. }
  1111. }
  1112. return false;
  1113. },
  1114. reduplicateMarkShow(id) {
  1115. var found = false;
  1116. for (var i = 0, imax = this.reduplicateQuestions.length; i < imax; i++) {
  1117. for (
  1118. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1119. j < jmax;
  1120. j++
  1121. ) {
  1122. if (this.reduplicateQuestions[i][j] == id) {
  1123. found = true;
  1124. break;
  1125. }
  1126. }
  1127. if (found) {
  1128. break;
  1129. }
  1130. }
  1131. return found;
  1132. },
  1133. reduplicateMarkColor(id) {
  1134. for (var i = 0, imax = this.reduplicateQuestions.length; i < imax; i++) {
  1135. for (
  1136. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1137. j < jmax;
  1138. j++
  1139. ) {
  1140. if (this.reduplicateQuestions[i][j] == id) {
  1141. return this.reduplicateQuesColor[i];
  1142. }
  1143. }
  1144. }
  1145. },
  1146. reduplicateMarkCheck(id) {
  1147. for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
  1148. if (id == this.reduplicateGroup[i]) {
  1149. return true;
  1150. }
  1151. }
  1152. return false;
  1153. },
  1154. reduplicate_mark_check(id, checked) {
  1155. console.log(checked);
  1156. console.log(this.reduplicateQuestions);
  1157. console.log(id);
  1158. if (!checked) {
  1159. for (
  1160. var i = 0, imax = this.reduplicateQuestions.length;
  1161. i < imax;
  1162. i++
  1163. ) {
  1164. for (
  1165. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1166. j < jmax;
  1167. j++
  1168. ) {
  1169. if (this.reduplicateQuestions[i][j] == id) {
  1170. this.reduplicateGroup = [];
  1171. for (
  1172. var k = 0, kmax = this.reduplicateQuestions[i].length;
  1173. k < kmax;
  1174. k++
  1175. ) {
  1176. this.reduplicateGroup.push(this.reduplicateQuestions[i][k]);
  1177. }
  1178. return;
  1179. }
  1180. }
  1181. }
  1182. } else {
  1183. this.reduplicateGroup = [];
  1184. }
  1185. },
  1186. //编辑题目
  1187. editQues(paperDetailUnit, question) {
  1188. console.log("question:", question);
  1189. this.coursePropertyName = "";
  1190. this.firstPropertyId = "";
  1191. this.secondPropertyId = "";
  1192. this.editPaperDetailUnit = paperDetailUnit;
  1193. this.quesModel = JSON.parse(JSON.stringify(question)); //深拷贝
  1194. this.quesModel.score = paperDetailUnit.score;
  1195. //如果是套题下面的小题编辑 ( paperDetailUnit的类型是套题,question的类型不是套题)
  1196. if (
  1197. paperDetailUnit.questionType == "NESTED_ANSWER_QUESTION" &&
  1198. question.questionType != "NESTED_ANSWER_QUESTION"
  1199. ) {
  1200. for (var i = 0; i < paperDetailUnit.question.subQuestions.length; i++) {
  1201. if (
  1202. paperDetailUnit.question.subQuestions[i].id == this.quesModel.id
  1203. ) {
  1204. this.quesModel.score = paperDetailUnit.subScoreList[i];
  1205. break;
  1206. }
  1207. }
  1208. }
  1209. if (isEmptyStr(this.quesModel.answerType)) {
  1210. this.quesModel.answerType = "DIVERSIFIED_TEXT";
  1211. }
  1212. if (this.quesModel.questionType == "FILL_BLANK_QUESTION") {
  1213. this.quesModel.quesBody = this.quesModel.quesBody.replace(
  1214. /______/g,
  1215. "###"
  1216. );
  1217. }
  1218. this.assignAnswers(); //给singleRightAnswer或multipleRightAnswer赋值
  1219. this.openQuesDialog();
  1220. },
  1221. //给singleRightAnswer和multipleRightAnswer赋值
  1222. assignAnswers() {
  1223. if (this.quesModel.quesOptions && this.quesModel.quesOptions.length > 0) {
  1224. this.singleRightAnswer = "";
  1225. this.multipleRightAnswer = [];
  1226. for (let i = 0; i < this.quesModel.quesOptions.length; i++) {
  1227. let option = this.quesModel.quesOptions[i];
  1228. if (
  1229. this.quesModel.questionType == "SINGLE_ANSWER_QUESTION" &&
  1230. option.isCorrect == 1
  1231. ) {
  1232. this.singleRightAnswer = String.fromCharCode(65 + i);
  1233. }
  1234. if (
  1235. this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION" &&
  1236. option.isCorrect == 1
  1237. ) {
  1238. this.multipleRightAnswer.push(String.fromCharCode(65 + i));
  1239. }
  1240. }
  1241. }
  1242. },
  1243. //打开修改试题编辑框
  1244. openQuesDialog() {
  1245. this.quesDialog = true;
  1246. },
  1247. //关闭试题编辑框
  1248. closeQuesDialog() {
  1249. this.quesDialog = false;
  1250. this.quesModel = {};
  1251. },
  1252. //删除属性
  1253. handleClose(tag) {
  1254. this.quesModel.quesProperties.splice(
  1255. this.quesModel.quesProperties.indexOf(tag),
  1256. 1
  1257. );
  1258. },
  1259. //查询一级属性
  1260. searchFirst() {
  1261. this.firstPropertyId = "";
  1262. this.secondPropertyId = "";
  1263. this.secondPropertyList = [];
  1264. if (this.coursePropertyName) {
  1265. for (let courseProperty of this.coursePropertyList) {
  1266. if (courseProperty.name == this.coursePropertyName) {
  1267. this.$http
  1268. .get(QUESTION_API + "/property/first/" + courseProperty.id)
  1269. .then((response) => {
  1270. this.firstPropertyList = response.data;
  1271. });
  1272. }
  1273. }
  1274. }
  1275. },
  1276. //查询二级属性
  1277. searchSecond() {
  1278. this.secondPropertyId = "";
  1279. if (this.firstPropertyId) {
  1280. this.$http
  1281. .get(QUESTION_API + "/property/second/" + this.firstPropertyId)
  1282. .then((response) => {
  1283. this.secondPropertyList = response.data;
  1284. });
  1285. }
  1286. },
  1287. //新增属性
  1288. insertProperty() {
  1289. if (!this.checkInsertPro()) {
  1290. return false;
  1291. }
  1292. var quesProperty = {
  1293. id: "",
  1294. coursePropertyName: "",
  1295. firstProperty: {},
  1296. secondProperty: {},
  1297. };
  1298. if (
  1299. this.quesModel.quesProperties == null ||
  1300. this.quesModel.quesProperties.length == 0
  1301. ) {
  1302. this.quesModel.quesProperties = [];
  1303. }
  1304. if (this.secondPropertyId) {
  1305. quesProperty.id =
  1306. this.coursePropertyName +
  1307. "-" +
  1308. this.firstPropertyId +
  1309. "-" +
  1310. this.secondPropertyId;
  1311. } else {
  1312. quesProperty.id = this.coursePropertyName + "-" + this.firstPropertyId;
  1313. }
  1314. for (let quesPro of this.quesModel.quesProperties) {
  1315. if (quesPro.id == quesProperty.id) {
  1316. this.$notify({
  1317. message: "该属性已存在,请重新选择",
  1318. type: "error",
  1319. });
  1320. return false;
  1321. }
  1322. }
  1323. quesProperty.coursePropertyName = this.coursePropertyName;
  1324. //取到一级属性对象
  1325. for (let property of this.firstPropertyList) {
  1326. if (property.id == this.firstPropertyId) {
  1327. quesProperty.firstProperty = property;
  1328. }
  1329. }
  1330. //判断是否有二级属性
  1331. if (
  1332. this.secondPropertyList != undefined &&
  1333. this.secondPropertyList.length > 0
  1334. ) {
  1335. if (!this.secondPropertyId) {
  1336. this.$notify({
  1337. message: "请选择二级属性",
  1338. type: "error",
  1339. });
  1340. return false;
  1341. }
  1342. }
  1343. //取到二级属性对象
  1344. for (let property of this.secondPropertyList) {
  1345. if (property.id == this.secondPropertyId) {
  1346. quesProperty.secondProperty = property;
  1347. }
  1348. }
  1349. this.quesModel.quesProperties.push(quesProperty);
  1350. this.quesModel = Object.assign({}, this.quesModel);
  1351. //清空下拉框
  1352. this.coursePropertyName = "";
  1353. this.firstPropertyId = "";
  1354. this.secondPropertyId = "";
  1355. this.firstPropertyList = [];
  1356. this.secondPropertyList = [];
  1357. },
  1358. //新增属性验证
  1359. checkInsertPro() {
  1360. if (!this.coursePropertyName) {
  1361. this.$notify({
  1362. message: "请选择属性",
  1363. type: "error",
  1364. });
  1365. return false;
  1366. }
  1367. if (!this.firstPropertyId) {
  1368. this.$notify({
  1369. message: "请选择一级属性",
  1370. type: "error",
  1371. });
  1372. return false;
  1373. }
  1374. return true;
  1375. },
  1376. //删除选项
  1377. removeQuesOption(option) {
  1378. this.singleRightAnswer = "";
  1379. this.multipleRightAnswer = [];
  1380. let index = this.quesModel.quesOptions.indexOf(option);
  1381. if (index !== -1) {
  1382. this.quesModel.quesOptions.splice(index, 1);
  1383. }
  1384. if (this.quesModel.quesOptions.length > 0) {
  1385. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1386. var quesOption = this.quesModel.quesOptions[i];
  1387. quesOption["number"] = i + 1;
  1388. if (quesOption.isCorrect == 1) {
  1389. var answerOrderNum = String.fromCharCode(65 + i);
  1390. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1391. this.singleRightAnswer = answerOrderNum;
  1392. }
  1393. if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1394. this.multipleRightAnswer.push(answerOrderNum);
  1395. }
  1396. }
  1397. }
  1398. }
  1399. },
  1400. //新增选项
  1401. addQuesOption() {
  1402. this.quesModel.quesOptions.push({
  1403. number: "",
  1404. optionBody: "",
  1405. isCorrect: "",
  1406. });
  1407. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1408. this.quesModel.quesOptions[i]["number"] = i + 1;
  1409. }
  1410. },
  1411. savePaperDetailUnit() {
  1412. //跟新难度值
  1413. if (this.quesModel.difficultyDegree < 0.4) {
  1414. this.quesModel.difficulty = "难";
  1415. } else if (
  1416. this.quesModel.difficultyDegree > 0.3 &&
  1417. this.quesModel.difficultyDegree < 0.8
  1418. ) {
  1419. this.quesModel.difficulty = "中";
  1420. } else {
  1421. this.quesModel.difficulty = "易";
  1422. }
  1423. this.setRightAnswer();
  1424. if (/^\d+(?=\.{0,1}\d+$|$)/.test(this.quesModel.score)) {
  1425. console.log("正确");
  1426. } else {
  1427. this.$notify({
  1428. message: "分数只能为正数",
  1429. type: "error",
  1430. });
  1431. return;
  1432. }
  1433. let paperDetailUnitExp = {
  1434. id: this.editPaperDetailUnit.id,
  1435. question: this.quesModel,
  1436. score: this.quesModel.score,
  1437. };
  1438. if (
  1439. this.quesModel.quesOptions &&
  1440. this.quesModel.quesOptions.length == 0
  1441. ) {
  1442. this.$confirm("无选项将删除该试题, 是否继续?", "提示", {
  1443. confirmButtonText: "确定",
  1444. cancelButtonText: "取消",
  1445. type: "warning",
  1446. }).then(() => {
  1447. this.dialogLoading = true;
  1448. this.$http
  1449. .delete(QUESTION_API + "/paper/deleteQuestion/" + this.quesModel.id)
  1450. .then((response) => {
  1451. if (response.data.length > 0) {
  1452. var deleteInfo =
  1453. "该试题被试卷:" +
  1454. response.data.join(" , ") +
  1455. "使用,不能删除";
  1456. this.$notify({
  1457. message: deleteInfo,
  1458. type: "error",
  1459. });
  1460. } else {
  1461. this.$notify({
  1462. message: "保存成功",
  1463. type: "success",
  1464. });
  1465. }
  1466. this.dialogLoading = false;
  1467. });
  1468. });
  1469. } else {
  1470. this.dialogLoading = true;
  1471. this.$http
  1472. .put(QUESTION_API + "/paperDetailUnit", paperDetailUnitExp)
  1473. .then(() => {
  1474. this.$notify({
  1475. message: "保存成功",
  1476. type: "success",
  1477. });
  1478. this.dialogLoading = false;
  1479. this.closeQuesDialog();
  1480. this.initPaper();
  1481. })
  1482. .catch((err) => {
  1483. this.dialogLoading = false;
  1484. this.$notify({
  1485. type: "error",
  1486. message: err.response.data.desc,
  1487. });
  1488. });
  1489. }
  1490. },
  1491. //在正确的option上设置isCorrect=1
  1492. setRightAnswer() {
  1493. if (
  1494. !this.quesModel.quesOptions ||
  1495. this.quesModel.quesOptions.length == 0
  1496. ) {
  1497. return false;
  1498. }
  1499. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1500. var option = this.quesModel.quesOptions[i];
  1501. var answerOrderNum = String.fromCharCode(65 + i);
  1502. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1503. option["isCorrect"] =
  1504. answerOrderNum == this.singleRightAnswer ? 1 : 0;
  1505. }
  1506. if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1507. option["isCorrect"] =
  1508. this.multipleRightAnswer.indexOf(answerOrderNum) > -1 ? 1 : 0;
  1509. }
  1510. }
  1511. },
  1512. //删除试题
  1513. deleteQues(paperDetailUnit) {
  1514. let paperDetailUnitId = paperDetailUnit.id;
  1515. if (this.paper.paperType == "GENERATE") {
  1516. this.deleteQues01(paperDetailUnitId);
  1517. } else {
  1518. let questionId = paperDetailUnit.question.id;
  1519. this.deleteQues02(questionId);
  1520. }
  1521. },
  1522. deleteQues01(paperDetailUnitId) {
  1523. this.$alert("您确定删除吗?", "提示", {
  1524. confirmButtonText: "确定",
  1525. callback: (action) => {
  1526. if (action == "confirm") {
  1527. this.loading = true;
  1528. this.$http
  1529. .delete(QUESTION_API + "/paperDetailUnit/" + paperDetailUnitId)
  1530. .then(() => {
  1531. this.initPaper();
  1532. this.getreduplicateQuestions();
  1533. this.reduplicateGroup = [];
  1534. this.loading = true;
  1535. this.$notify({
  1536. message: "删除成功",
  1537. type: "success",
  1538. });
  1539. this.loading = false;
  1540. });
  1541. }
  1542. },
  1543. });
  1544. },
  1545. deleteQues02(questionId) {
  1546. this.$alert("您确定删除吗?", "提示", {
  1547. confirmButtonText: "确定",
  1548. callback: (action) => {
  1549. if (action == "confirm") {
  1550. this.loading = true;
  1551. this.$http
  1552. .delete(QUESTION_API + "/paper/deleteQuestion/" + questionId)
  1553. .then((response) => {
  1554. if (response.data.length > 0) {
  1555. var deleteInfo =
  1556. "该试题被试卷:" +
  1557. response.data.join(" , ") +
  1558. "使用,不能删除";
  1559. this.$notify({
  1560. message: deleteInfo,
  1561. type: "error",
  1562. });
  1563. } else {
  1564. this.initPaper();
  1565. this.getreduplicateQuestions();
  1566. this.reduplicateGroup = [];
  1567. this.loading = true;
  1568. this.$notify({
  1569. message: "保存成功",
  1570. type: "success",
  1571. });
  1572. }
  1573. this.loading = false;
  1574. });
  1575. }
  1576. },
  1577. });
  1578. },
  1579. //获取重复试题
  1580. getreduplicateQuestions() {
  1581. this.duplicateLoading = true;
  1582. this.$http
  1583. .get(QUESTION_API + "/paper/" + this.paperId + "/reduplicate-questions")
  1584. .then((response) => {
  1585. this.reduplicateQuestions = response.data;
  1586. this.duplicateLoading = false;
  1587. this.initReduplicateQuesColor();
  1588. // var ques = document.getElementsByClassName("ques")[0];
  1589. // ques.style.display = "inline";
  1590. });
  1591. },
  1592. exportPaperAnswer() {
  1593. var key = this.user.key;
  1594. var token = this.user.token;
  1595. window.open(
  1596. QUESTION_API +
  1597. "/paper/answer/export/" +
  1598. this.paperId +
  1599. "?$key=" +
  1600. key +
  1601. "&$token=" +
  1602. token
  1603. );
  1604. },
  1605. initReduplicateQuesColor() {
  1606. var colorCount = this.reduplicateQuestions.length;
  1607. if (colorCount > 20) {
  1608. this.reduplicateQuesColor = randomColor({
  1609. luminosity: "bright",
  1610. count: colorCount,
  1611. });
  1612. } else {
  1613. this.reduplicateQuesColor = this.defaultColor;
  1614. }
  1615. },
  1616. getSubQuesEditId(paperDetailUnit, subQuestion) {
  1617. return paperDetailUnit.question.id + "_" + subQuestion.quesParams.number;
  1618. },
  1619. //打开考试说明编辑框
  1620. openEditExamPaperRemark() {
  1621. if (this.paper.examRemark) {
  1622. this.examRemark = this.paper.examRemark;
  1623. } else {
  1624. this.examRemark = "";
  1625. }
  1626. this.paperRemarkDialog = true;
  1627. },
  1628. //保存考试说明
  1629. savePaperRemark() {
  1630. this.paper.examRemark = this.examRemark;
  1631. this.savePaper();
  1632. this.paperRemarkDialog = false;
  1633. },
  1634. //关闭考试说明编辑框
  1635. closPaperRemark() {
  1636. this.examRemark = "";
  1637. this.paperRemarkDialog = false;
  1638. },
  1639. //保存试卷
  1640. savePaper() {
  1641. this.loading = true;
  1642. this.$http
  1643. .put(QUESTION_API + "/paper", this.paper)
  1644. .then(() => {
  1645. this.$notify({
  1646. message: "保存成功",
  1647. type: "success",
  1648. });
  1649. this.loading = false;
  1650. this.initPaper();
  1651. })
  1652. .catch((error) => {
  1653. this.loading = false;
  1654. this.$notify({
  1655. type: "error",
  1656. message: error.response.data.desc,
  1657. });
  1658. });
  1659. },
  1660. //删除试卷
  1661. deletePaper(id) {
  1662. this.$confirm("确认删除试卷吗?", "提示", {
  1663. type: "warning",
  1664. }).then(() => {
  1665. this.loading = true;
  1666. this.$http.delete(QUESTION_API + "/paper/" + id).then(
  1667. () => {
  1668. this.$notify({
  1669. message: "删除成功",
  1670. type: "success",
  1671. });
  1672. this.back();
  1673. },
  1674. (error) => {
  1675. this.$notify({
  1676. message: error.response.data.desc,
  1677. type: "error",
  1678. title: "错误",
  1679. });
  1680. this.loading = false;
  1681. }
  1682. );
  1683. });
  1684. },
  1685. //打开上传音频弹框
  1686. openDialog() {
  1687. this.checkResult = false;
  1688. this.isUpload = true;
  1689. if (document.getElementById("radioFile")) {
  1690. document.getElementById("radioFile").value = "";
  1691. }
  1692. this.dialogRadioFile = true;
  1693. this.fileList = [];
  1694. },
  1695. //关闭音频弹框
  1696. closeAudioDialog() {
  1697. this.dialogRadioFile = this.uploadAudioLoading;
  1698. },
  1699. //返回
  1700. back() {
  1701. if (sessionStorage.getItem("question_back") == "true") {
  1702. this.$router.push({
  1703. path: "/questions/" + this.parentView + "/0",
  1704. });
  1705. } else {
  1706. this.$router.push({
  1707. path: "/questions/" + this.parentView + "/1",
  1708. });
  1709. }
  1710. },
  1711. paperDetailShow(paperDetail) {
  1712. if (this.reduplicateGroup.length == 0) {
  1713. return true;
  1714. }
  1715. let paperDetailUnits = paperDetail.paperDetailUnits;
  1716. for (let i = 0, imax = paperDetailUnits.length; i < imax; i++) {
  1717. for (var j = 0, jmax = this.reduplicateGroup.length; j < jmax; j++) {
  1718. if (paperDetailUnits[i].id == this.reduplicateGroup[j]) {
  1719. return true;
  1720. }
  1721. }
  1722. }
  1723. return false;
  1724. },
  1725. //上传文件检查
  1726. checkFile() {
  1727. this.fileNameList = [];
  1728. //读取选取的文件夹里面的文件
  1729. this.checkResult = true;
  1730. var files = document.getElementById("radioFile").files;
  1731. if (files.length == 0) {
  1732. this.message = "请选择音频文件夹!";
  1733. return;
  1734. }
  1735. var size = 0;
  1736. var isGo = false;
  1737. //取到所有文件的文件名
  1738. for (var i = 0; i < files.length; i++) {
  1739. this.fileNameList.push(files[i].name);
  1740. if (files[i].size > 5 * 1024 * 1024) {
  1741. isGo = true;
  1742. break;
  1743. }
  1744. size = files[i].size + size;
  1745. }
  1746. if (isGo) {
  1747. this.message = "上传单个文件不能超过5M";
  1748. this.isUpload = true;
  1749. }
  1750. if (size > 50 * 1024 * 1024) {
  1751. this.message = "上传文件总和不能超过50M";
  1752. this.isUpload = true;
  1753. return;
  1754. }
  1755. this.$http
  1756. .post(
  1757. QUESTION_API + "/checkRadioFile/" + this.paperId,
  1758. this.fileNameList
  1759. )
  1760. .then((response) => {
  1761. console.log("response:", response);
  1762. this.message = response.data.errorMsg;
  1763. if (this.message == "OK") {
  1764. this.message = "OK!";
  1765. this.isUpload = false;
  1766. } else {
  1767. this.isUpload = true;
  1768. }
  1769. })
  1770. .catch((error) => {
  1771. console.log(error);
  1772. });
  1773. },
  1774. //读取文件
  1775. uploadAudioFile() {
  1776. let param = new FormData();
  1777. var fileList = document.getElementById("radioFile").files;
  1778. //循环添加到formData中
  1779. for (var i = 0; i < fileList.length; i++) {
  1780. var file = fileList[i];
  1781. param.append("files", file, file.name);
  1782. }
  1783. let config = {
  1784. headers: { "Content-Type": "multipart/form-data" },
  1785. };
  1786. this.$http
  1787. .post(QUESTION_API + "/uploadRadio/" + this.paperId, param, config)
  1788. .then(() => {
  1789. this.dialogRadioFile = false;
  1790. this.uploadAudioLoading = false;
  1791. this.checkResult = false;
  1792. this.isUpload = true;
  1793. document.getElementById("radioFile").value = "";
  1794. this.initPaper();
  1795. })
  1796. .catch((error) => {
  1797. this.message = error.response.data.desc;
  1798. this.uploadAudioLoading = false;
  1799. });
  1800. },
  1801. },
  1802. computed: {
  1803. ...mapState({
  1804. user: (state) => state.user,
  1805. }),
  1806. updatePorperty() {
  1807. if (this.parentView === "gen_paper") {
  1808. return true;
  1809. }
  1810. return false;
  1811. },
  1812. answer() {
  1813. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1814. return this.singleRightAnswer;
  1815. } else if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1816. var obj = this.multipleRightAnswer;
  1817. return obj.sort().toString();
  1818. }
  1819. return this.quesModel.quesAnswer;
  1820. },
  1821. },
  1822. watch: {},
  1823. created() {
  1824. // $("body").attr("style", "");
  1825. document.getElementsByTagName("body")[0].style = "";
  1826. this.paperId = this.$route.params.id;
  1827. this.parentView = this.$route.params.parentView;
  1828. this.initPaper();
  1829. this.getreduplicateQuestions();
  1830. this.uploadAction = QUESTION_API + "/uploadRadio/" + this.paperId;
  1831. this.uploadHeaders = {
  1832. key: this.user.key,
  1833. token: this.user.token,
  1834. };
  1835. },
  1836. mounted() {},
  1837. };
  1838. </script>
  1839. <style scoped src="../styles/EditPaper.css">
  1840. .property_with {
  1841. width: 100px;
  1842. }
  1843. .ck-toolbar {
  1844. z-index: 9999;
  1845. }
  1846. #app {
  1847. background-color: white !important;
  1848. }
  1849. </style>
  1850. <style scoped src="../styles/Common.css"></style>