EditPaper.vue 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885
  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: 10px;"
  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="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  753. />
  754. <el-button
  755. @click="uploadAnswerFile"
  756. type="info"
  757. :loading="uploadAnswerLoading"
  758. :disabled="uploadAnswerLoading"
  759. >
  760. <span v-show="!uploadAnswerLoading">开始上传</span>
  761. <span v-show="uploadAnswerLoading">正在上传中...</span>
  762. </el-button>
  763. </form>
  764. <div style="margin-top: 20px;">
  765. <span style="color: #ff4949;" v-show="answerMessage != ''">{{
  766. answerMessage
  767. }}</span>
  768. </div>
  769. </el-dialog>
  770. </div>
  771. </div>
  772. </template>
  773. <script>
  774. import { QUESTION_API } from "@/constants/constants";
  775. import { isEmptyStr, QUESTION_TYPES } from "../constants/constants";
  776. import { mapState } from "vuex";
  777. import reduplicate_mark from "../component/reduplicate_mark.vue";
  778. import randomColor from "randomcolor";
  779. import ckeditor from "../component/ckeditor.vue";
  780. export default {
  781. name: "editPaperApp",
  782. components: {
  783. reduplicate_mark,
  784. ckeditor,
  785. },
  786. data() {
  787. return {
  788. hValue: "100px",
  789. wValue: "500px",
  790. display: "block",
  791. uploadAction: "",
  792. fileList: [],
  793. answerFileList: [],
  794. paperId: "",
  795. paperDetailId: "",
  796. editPaperDetailUnit: "",
  797. quesDialog: false,
  798. paperDatailDialog: false,
  799. paperRemarkDialog: false,
  800. parentView: "",
  801. paper: {
  802. course: {
  803. code: "",
  804. name: "",
  805. },
  806. examRemark: "",
  807. },
  808. loading: false,
  809. dialogLoading: false,
  810. detailLoading: false,
  811. uploadAudioLoading: false,
  812. uploadAnswerLoading: false,
  813. questionTypes: QUESTION_TYPES,
  814. questionType: "",
  815. quesModel: { quesProperties: [] },
  816. editpaperDetail: {},
  817. reduplicateQuestions: [],
  818. reduplicateGroup: [],
  819. reduplicateQuesColor: [],
  820. singleRightAnswer: "", //接收单选答案
  821. multipleRightAnswer: [], //接收多选答案
  822. options: ["正确", "错误"],
  823. duplicateLoading: false,
  824. dialogRadioFile: false,
  825. dialogAnswerFile: false,
  826. isUpload: true,
  827. isUploadAnswer: true,
  828. message: "",
  829. answerMessage: "",
  830. checkResult: false,
  831. checkResultAnswer: false,
  832. fileNameList: [],
  833. defaultColor: [
  834. "Red",
  835. "Blue",
  836. "LimeGreen",
  837. "GoldenRod",
  838. "Black",
  839. "BlueViolet",
  840. "Chocolate",
  841. "DarkCyan",
  842. "HotPink",
  843. "Orange",
  844. "IndianRed",
  845. "Indigo",
  846. "Green",
  847. "Aqua",
  848. "CadetBlue",
  849. "SkyBlue",
  850. "SlateBlue",
  851. "SlateGray",
  852. "Tomato",
  853. "VioletRed",
  854. ],
  855. difficultyDegreeList: [
  856. { label: 0.1, value: 0.1 },
  857. { label: 0.2, value: 0.2 },
  858. { label: 0.3, value: 0.3 },
  859. { label: 0.4, value: 0.4 },
  860. { label: 0.5, value: 0.5 },
  861. { label: 0.6, value: 0.6 },
  862. { label: 0.7, value: 0.7 },
  863. { label: 0.8, value: 0.8 },
  864. { label: 0.9, value: 0.9 },
  865. { label: 1.0, value: 1.0 },
  866. ],
  867. publicityList: [
  868. { label: "公开", value: true },
  869. { label: "非公开", value: false },
  870. ],
  871. answerTypes: [
  872. { label: "文本", value: "DIVERSIFIED_TEXT" },
  873. { label: "音频", value: "SINGLE_AUDIO" },
  874. ],
  875. coursePropertyList: [],
  876. coursePropertyName: "", //课程属性名
  877. firstPropertyList: [], //一级属性集合
  878. firstPropertyId: "", //一级属性id
  879. secondPropertyList: [], //二级属性集合
  880. secondPropertyId: "", //二级属性id
  881. examRemark: "",
  882. showQuestions: [],
  883. showButtons: [],
  884. };
  885. },
  886. methods: {
  887. openAnswerDialog() {
  888. this.checkResultAnswer = false;
  889. this.isUploadAnswer = true;
  890. if (document.getElementById("answerFile")) {
  891. document.getElementById("answerFile").value = "";
  892. }
  893. this.dialogAnswerFile = true;
  894. this.answerFileList = [];
  895. },
  896. closeAnswerDialog() {
  897. this.answerMessage = "";
  898. this.dialogAnswerFile = this.uploadAnswerLoading;
  899. },
  900. uploadAnswerFile() {
  901. this.answerMessage = "";
  902. var fileList = document.getElementById("answerFile").files;
  903. if (fileList.length == 0) {
  904. this.answerMessage = "请选择文件!";
  905. return;
  906. }
  907. let param = new FormData();
  908. //循环添加到formData中
  909. for (var i = 0; i < fileList.length; i++) {
  910. var file = fileList[i];
  911. param.append("dataFile", file, file.name);
  912. }
  913. let config = {
  914. headers: { "Content-Type": "multipart/form-data" },
  915. };
  916. this.uploadAnswerLoading = true;
  917. this.$http
  918. .post(
  919. QUESTION_API + "/paper/answer/import/" + this.paperId,
  920. param,
  921. config
  922. )
  923. .then(() => {
  924. this.dialogAnswerFile = false;
  925. this.uploadAnswerLoading = false;
  926. this.checkResultAnswer = false;
  927. this.isUploadAnswer = true;
  928. document.getElementById("answerFile").value = "";
  929. this.initPaper();
  930. })
  931. .catch((error) => {
  932. this.answerMessage = error.response.data.desc;
  933. document.getElementById("answerFile").value = "";
  934. this.uploadAnswerLoading = false;
  935. });
  936. },
  937. //隐藏大题下的所有小题
  938. hideContent(index) {
  939. console.log("up");
  940. this.showQuestions[index].is_show = false;
  941. this.showButtons[index].up = false;
  942. },
  943. //展开大题下所有小题
  944. showContent(index) {
  945. console.log("down");
  946. this.showQuestions[index].is_show = true;
  947. this.showButtons[index].up = true;
  948. },
  949. quesMouseOver(index) {
  950. document.getElementById(index).style.visibility = "visible";
  951. },
  952. quesMouseOut(index) {
  953. document.getElementById(index).style.visibility = "hidden";
  954. },
  955. selectQues(id) {
  956. this.paperDetailId = id;
  957. var courseCode = this.paper.course.code;
  958. var courseName = this.paper.course.name;
  959. this.$router.push({
  960. path:
  961. "/select_question/" +
  962. this.paper.id +
  963. "/" +
  964. courseCode +
  965. "/" +
  966. encodeURIComponent(courseName) +
  967. "/" +
  968. this.paperDetailId +
  969. "/" +
  970. this.parentView,
  971. });
  972. },
  973. //打开编辑大题题目弹窗
  974. openEditPaperDetail(paperDetail) {
  975. this.paperDatailDialog = true;
  976. this.editpaperDetail = Object.assign({}, paperDetail); //浅拷贝
  977. },
  978. //关闭编辑大题题目弹窗
  979. closePaperDatailDialog() {
  980. this.paperDatailDialog = false;
  981. this.editpaperDetail = {};
  982. },
  983. //保存大题题目信息
  984. savePaperDatail(editpaperDetail) {
  985. this.detailLoading = true;
  986. var paperId = this.paper.id;
  987. this.$http
  988. .post(QUESTION_API + "/updatePaperDetail/" + paperId, editpaperDetail)
  989. .then(() => {
  990. this.$notify({
  991. message: "保存成功",
  992. type: "success",
  993. });
  994. this.detailLoading = false;
  995. this.closePaperDatailDialog();
  996. this.initPaper();
  997. });
  998. },
  999. //初始化试卷
  1000. initPaper() {
  1001. const scrollPosition =
  1002. document.documentElement.scrollTop || document.body.scrollTop;
  1003. this.loading = true;
  1004. this.paper = {
  1005. course: {
  1006. code: "",
  1007. name: "",
  1008. },
  1009. };
  1010. this.$http
  1011. .get(QUESTION_API + "/paper/" + this.paperId)
  1012. .then((response) => {
  1013. this.paper = response.data;
  1014. //查询所有课程属性名
  1015. this.initCourseProperty(this.paper.course.code);
  1016. //将所有小题分为公开和非公开
  1017. if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
  1018. for (let paperDetil of this.paper.paperDetails) {
  1019. this.showQuestions.push({ is_show: true });
  1020. this.showButtons.push({ up: true });
  1021. paperDetil.pubCount = 0;
  1022. paperDetil.noPubCount = 0;
  1023. if (
  1024. paperDetil.paperDetailUnits &&
  1025. paperDetil.paperDetailUnits.length > 0
  1026. ) {
  1027. for (let paperDetilUt of paperDetil.paperDetailUnits) {
  1028. if (
  1029. paperDetilUt.question.questionType !=
  1030. "NESTED_ANSWER_QUESTION"
  1031. ) {
  1032. //非套题
  1033. if (paperDetilUt.question.publicity) {
  1034. paperDetil.pubCount = paperDetil.pubCount + 1;
  1035. } else {
  1036. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  1037. }
  1038. } else {
  1039. //循环所有子题
  1040. for (let ques of paperDetilUt.question.subQuestions) {
  1041. if (ques.publicity) {
  1042. paperDetil.pubCount = paperDetil.pubCount + 1;
  1043. } else {
  1044. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  1045. }
  1046. }
  1047. }
  1048. }
  1049. }
  1050. }
  1051. }
  1052. setTimeout(() => {
  1053. document.documentElement.scrollTop = document.body.scrollTop = scrollPosition;
  1054. console.log(scrollPosition);
  1055. }, 1000);
  1056. this.loading = false;
  1057. });
  1058. },
  1059. //查询所有课程属性名
  1060. initCourseProperty(courseCode) {
  1061. this.$http
  1062. .get(QUESTION_API + "/courseProperty/enable/" + courseCode)
  1063. .then((response) => {
  1064. this.coursePropertyList = response.data;
  1065. });
  1066. },
  1067. //删除大题
  1068. deletePaperDetail(paperDetailsId) {
  1069. //先判断大题下面是否还有小题
  1070. var count = 0;
  1071. for (var i = 0, imax = this.paper.paperDetails.length; i < imax; i++) {
  1072. if (paperDetailsId == this.paper.paperDetails[i].id) {
  1073. if (this.paper.paperDetails[i].paperDetailUnits) {
  1074. count += this.paper.paperDetails[i].paperDetailUnits.length;
  1075. break;
  1076. }
  1077. }
  1078. }
  1079. if (count == 0) {
  1080. this.$alert("您确定删除吗?", "提示", {
  1081. confirmButtonText: "确定",
  1082. callback: (action) => {
  1083. if (action == "confirm") {
  1084. this.loading = true;
  1085. this.$http
  1086. .delete(QUESTION_API + "/paperDetail/" + paperDetailsId)
  1087. .then(() => {
  1088. this.initPaper();
  1089. this.loading = true;
  1090. this.$notify({
  1091. message: "删除成功",
  1092. type: "success",
  1093. });
  1094. this.loading = false;
  1095. });
  1096. }
  1097. },
  1098. });
  1099. } else {
  1100. this.$alert("大题下还有小题,不可删除!", "提示", {
  1101. confirmButtonText: "确定",
  1102. callback: () => {},
  1103. });
  1104. }
  1105. },
  1106. quesShow(id) {
  1107. if (this.reduplicateGroup.length < 1) {
  1108. return true;
  1109. }
  1110. for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
  1111. if (id == this.reduplicateGroup[i]) {
  1112. return true;
  1113. }
  1114. }
  1115. return false;
  1116. },
  1117. reduplicateMarkShow(id) {
  1118. var found = false;
  1119. for (var i = 0, imax = this.reduplicateQuestions.length; i < imax; i++) {
  1120. for (
  1121. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1122. j < jmax;
  1123. j++
  1124. ) {
  1125. if (this.reduplicateQuestions[i][j] == id) {
  1126. found = true;
  1127. break;
  1128. }
  1129. }
  1130. if (found) {
  1131. break;
  1132. }
  1133. }
  1134. return found;
  1135. },
  1136. reduplicateMarkColor(id) {
  1137. for (var i = 0, imax = this.reduplicateQuestions.length; i < imax; i++) {
  1138. for (
  1139. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1140. j < jmax;
  1141. j++
  1142. ) {
  1143. if (this.reduplicateQuestions[i][j] == id) {
  1144. return this.reduplicateQuesColor[i];
  1145. }
  1146. }
  1147. }
  1148. },
  1149. reduplicateMarkCheck(id) {
  1150. for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
  1151. if (id == this.reduplicateGroup[i]) {
  1152. return true;
  1153. }
  1154. }
  1155. return false;
  1156. },
  1157. reduplicate_mark_check(id, checked) {
  1158. console.log(checked);
  1159. console.log(this.reduplicateQuestions);
  1160. console.log(id);
  1161. if (!checked) {
  1162. for (
  1163. var i = 0, imax = this.reduplicateQuestions.length;
  1164. i < imax;
  1165. i++
  1166. ) {
  1167. for (
  1168. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1169. j < jmax;
  1170. j++
  1171. ) {
  1172. if (this.reduplicateQuestions[i][j] == id) {
  1173. this.reduplicateGroup = [];
  1174. for (
  1175. var k = 0, kmax = this.reduplicateQuestions[i].length;
  1176. k < kmax;
  1177. k++
  1178. ) {
  1179. this.reduplicateGroup.push(this.reduplicateQuestions[i][k]);
  1180. }
  1181. return;
  1182. }
  1183. }
  1184. }
  1185. } else {
  1186. this.reduplicateGroup = [];
  1187. }
  1188. },
  1189. //编辑题目
  1190. editQues(paperDetailUnit, question) {
  1191. console.log("question:", question);
  1192. this.coursePropertyName = "";
  1193. this.firstPropertyId = "";
  1194. this.secondPropertyId = "";
  1195. this.editPaperDetailUnit = paperDetailUnit;
  1196. this.quesModel = JSON.parse(JSON.stringify(question)); //深拷贝
  1197. this.quesModel.score = paperDetailUnit.score;
  1198. //如果是套题下面的小题编辑 ( paperDetailUnit的类型是套题,question的类型不是套题)
  1199. if (
  1200. paperDetailUnit.questionType == "NESTED_ANSWER_QUESTION" &&
  1201. question.questionType != "NESTED_ANSWER_QUESTION"
  1202. ) {
  1203. for (var i = 0; i < paperDetailUnit.question.subQuestions.length; i++) {
  1204. if (
  1205. paperDetailUnit.question.subQuestions[i].id == this.quesModel.id
  1206. ) {
  1207. this.quesModel.score = paperDetailUnit.subScoreList[i];
  1208. break;
  1209. }
  1210. }
  1211. }
  1212. if (isEmptyStr(this.quesModel.answerType)) {
  1213. this.quesModel.answerType = "DIVERSIFIED_TEXT";
  1214. }
  1215. if (this.quesModel.questionType == "FILL_BLANK_QUESTION") {
  1216. this.quesModel.quesBody = this.quesModel.quesBody.replace(
  1217. /______/g,
  1218. "###"
  1219. );
  1220. }
  1221. this.assignAnswers(); //给singleRightAnswer或multipleRightAnswer赋值
  1222. this.openQuesDialog();
  1223. },
  1224. //给singleRightAnswer和multipleRightAnswer赋值
  1225. assignAnswers() {
  1226. if (this.quesModel.quesOptions && this.quesModel.quesOptions.length > 0) {
  1227. this.singleRightAnswer = "";
  1228. this.multipleRightAnswer = [];
  1229. for (let i = 0; i < this.quesModel.quesOptions.length; i++) {
  1230. let option = this.quesModel.quesOptions[i];
  1231. if (
  1232. this.quesModel.questionType == "SINGLE_ANSWER_QUESTION" &&
  1233. option.isCorrect == 1
  1234. ) {
  1235. this.singleRightAnswer = String.fromCharCode(65 + i);
  1236. }
  1237. if (
  1238. this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION" &&
  1239. option.isCorrect == 1
  1240. ) {
  1241. this.multipleRightAnswer.push(String.fromCharCode(65 + i));
  1242. }
  1243. }
  1244. }
  1245. },
  1246. //打开修改试题编辑框
  1247. openQuesDialog() {
  1248. this.quesDialog = true;
  1249. },
  1250. //关闭试题编辑框
  1251. closeQuesDialog() {
  1252. this.quesDialog = false;
  1253. this.quesModel = {};
  1254. },
  1255. //删除属性
  1256. handleClose(tag) {
  1257. this.quesModel.quesProperties.splice(
  1258. this.quesModel.quesProperties.indexOf(tag),
  1259. 1
  1260. );
  1261. },
  1262. //查询一级属性
  1263. searchFirst() {
  1264. this.firstPropertyId = "";
  1265. this.secondPropertyId = "";
  1266. this.secondPropertyList = [];
  1267. if (this.coursePropertyName) {
  1268. for (let courseProperty of this.coursePropertyList) {
  1269. if (courseProperty.name == this.coursePropertyName) {
  1270. this.$http
  1271. .get(QUESTION_API + "/property/first/" + courseProperty.id)
  1272. .then((response) => {
  1273. this.firstPropertyList = response.data;
  1274. });
  1275. }
  1276. }
  1277. }
  1278. },
  1279. //查询二级属性
  1280. searchSecond() {
  1281. this.secondPropertyId = "";
  1282. if (this.firstPropertyId) {
  1283. this.$http
  1284. .get(QUESTION_API + "/property/second/" + this.firstPropertyId)
  1285. .then((response) => {
  1286. this.secondPropertyList = response.data;
  1287. });
  1288. }
  1289. },
  1290. //新增属性
  1291. insertProperty() {
  1292. if (!this.checkInsertPro()) {
  1293. return false;
  1294. }
  1295. var quesProperty = {
  1296. id: "",
  1297. coursePropertyName: "",
  1298. firstProperty: {},
  1299. secondProperty: {},
  1300. };
  1301. if (
  1302. this.quesModel.quesProperties == null ||
  1303. this.quesModel.quesProperties.length == 0
  1304. ) {
  1305. this.quesModel.quesProperties = [];
  1306. }
  1307. if (this.secondPropertyId) {
  1308. quesProperty.id =
  1309. this.coursePropertyName +
  1310. "-" +
  1311. this.firstPropertyId +
  1312. "-" +
  1313. this.secondPropertyId;
  1314. } else {
  1315. quesProperty.id = this.coursePropertyName + "-" + this.firstPropertyId;
  1316. }
  1317. for (let quesPro of this.quesModel.quesProperties) {
  1318. if (quesPro.id == quesProperty.id) {
  1319. this.$notify({
  1320. message: "该属性已存在,请重新选择",
  1321. type: "error",
  1322. });
  1323. return false;
  1324. }
  1325. }
  1326. quesProperty.coursePropertyName = this.coursePropertyName;
  1327. //取到一级属性对象
  1328. for (let property of this.firstPropertyList) {
  1329. if (property.id == this.firstPropertyId) {
  1330. quesProperty.firstProperty = property;
  1331. }
  1332. }
  1333. //判断是否有二级属性
  1334. if (
  1335. this.secondPropertyList != undefined &&
  1336. this.secondPropertyList.length > 0
  1337. ) {
  1338. if (!this.secondPropertyId) {
  1339. this.$notify({
  1340. message: "请选择二级属性",
  1341. type: "error",
  1342. });
  1343. return false;
  1344. }
  1345. }
  1346. //取到二级属性对象
  1347. for (let property of this.secondPropertyList) {
  1348. if (property.id == this.secondPropertyId) {
  1349. quesProperty.secondProperty = property;
  1350. }
  1351. }
  1352. this.quesModel.quesProperties.push(quesProperty);
  1353. this.quesModel = Object.assign({}, this.quesModel);
  1354. //清空下拉框
  1355. this.coursePropertyName = "";
  1356. this.firstPropertyId = "";
  1357. this.secondPropertyId = "";
  1358. this.firstPropertyList = [];
  1359. this.secondPropertyList = [];
  1360. },
  1361. //新增属性验证
  1362. checkInsertPro() {
  1363. if (!this.coursePropertyName) {
  1364. this.$notify({
  1365. message: "请选择属性",
  1366. type: "error",
  1367. });
  1368. return false;
  1369. }
  1370. if (!this.firstPropertyId) {
  1371. this.$notify({
  1372. message: "请选择一级属性",
  1373. type: "error",
  1374. });
  1375. return false;
  1376. }
  1377. return true;
  1378. },
  1379. //删除选项
  1380. removeQuesOption(option) {
  1381. this.singleRightAnswer = "";
  1382. this.multipleRightAnswer = [];
  1383. let index = this.quesModel.quesOptions.indexOf(option);
  1384. if (index !== -1) {
  1385. this.quesModel.quesOptions.splice(index, 1);
  1386. }
  1387. if (this.quesModel.quesOptions.length > 0) {
  1388. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1389. var quesOption = this.quesModel.quesOptions[i];
  1390. quesOption["number"] = i + 1;
  1391. if (quesOption.isCorrect == 1) {
  1392. var answerOrderNum = String.fromCharCode(65 + i);
  1393. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1394. this.singleRightAnswer = answerOrderNum;
  1395. }
  1396. if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1397. this.multipleRightAnswer.push(answerOrderNum);
  1398. }
  1399. }
  1400. }
  1401. }
  1402. },
  1403. //新增选项
  1404. addQuesOption() {
  1405. this.quesModel.quesOptions.push({
  1406. number: "",
  1407. optionBody: "",
  1408. isCorrect: "",
  1409. });
  1410. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1411. this.quesModel.quesOptions[i]["number"] = i + 1;
  1412. }
  1413. },
  1414. savePaperDetailUnit() {
  1415. //跟新难度值
  1416. if (this.quesModel.difficultyDegree < 0.4) {
  1417. this.quesModel.difficulty = "难";
  1418. } else if (
  1419. this.quesModel.difficultyDegree > 0.3 &&
  1420. this.quesModel.difficultyDegree < 0.8
  1421. ) {
  1422. this.quesModel.difficulty = "中";
  1423. } else {
  1424. this.quesModel.difficulty = "易";
  1425. }
  1426. this.setRightAnswer();
  1427. if (/^\d+(?=\.{0,1}\d+$|$)/.test(this.quesModel.score)) {
  1428. console.log("正确");
  1429. } else {
  1430. this.$notify({
  1431. message: "分数只能为正数",
  1432. type: "error",
  1433. });
  1434. return;
  1435. }
  1436. let paperDetailUnitExp = {
  1437. id: this.editPaperDetailUnit.id,
  1438. question: this.quesModel,
  1439. score: this.quesModel.score,
  1440. };
  1441. if (
  1442. this.quesModel.quesOptions &&
  1443. this.quesModel.quesOptions.length == 0
  1444. ) {
  1445. this.$confirm("无选项将删除该试题, 是否继续?", "提示", {
  1446. confirmButtonText: "确定",
  1447. cancelButtonText: "取消",
  1448. type: "warning",
  1449. }).then(() => {
  1450. this.dialogLoading = true;
  1451. this.$http
  1452. .delete(QUESTION_API + "/paper/deleteQuestion/" + this.quesModel.id)
  1453. .then((response) => {
  1454. if (response.data.length > 0) {
  1455. var deleteInfo =
  1456. "该试题被试卷:" +
  1457. response.data.join(" , ") +
  1458. "使用,不能删除";
  1459. this.$notify({
  1460. message: deleteInfo,
  1461. type: "error",
  1462. });
  1463. } else {
  1464. this.$notify({
  1465. message: "保存成功",
  1466. type: "success",
  1467. });
  1468. }
  1469. this.dialogLoading = false;
  1470. });
  1471. });
  1472. } else {
  1473. this.dialogLoading = true;
  1474. this.$http
  1475. .put(QUESTION_API + "/paperDetailUnit", paperDetailUnitExp)
  1476. .then(() => {
  1477. this.$notify({
  1478. message: "保存成功",
  1479. type: "success",
  1480. });
  1481. this.dialogLoading = false;
  1482. this.closeQuesDialog();
  1483. this.initPaper();
  1484. })
  1485. .catch((err) => {
  1486. this.dialogLoading = false;
  1487. this.$notify({
  1488. type: "error",
  1489. message: err.response.data.desc,
  1490. });
  1491. });
  1492. }
  1493. },
  1494. //在正确的option上设置isCorrect=1
  1495. setRightAnswer() {
  1496. if (
  1497. !this.quesModel.quesOptions ||
  1498. this.quesModel.quesOptions.length == 0
  1499. ) {
  1500. return false;
  1501. }
  1502. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1503. var option = this.quesModel.quesOptions[i];
  1504. var answerOrderNum = String.fromCharCode(65 + i);
  1505. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1506. option["isCorrect"] =
  1507. answerOrderNum == this.singleRightAnswer ? 1 : 0;
  1508. }
  1509. if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1510. option["isCorrect"] =
  1511. this.multipleRightAnswer.indexOf(answerOrderNum) > -1 ? 1 : 0;
  1512. }
  1513. }
  1514. },
  1515. //删除试题
  1516. deleteQues(paperDetailUnit) {
  1517. let paperDetailUnitId = paperDetailUnit.id;
  1518. if (this.paper.paperType == "GENERATE") {
  1519. this.deleteQues01(paperDetailUnitId);
  1520. } else {
  1521. let questionId = paperDetailUnit.question.id;
  1522. this.deleteQues02(questionId);
  1523. }
  1524. },
  1525. deleteQues01(paperDetailUnitId) {
  1526. this.$alert("您确定删除吗?", "提示", {
  1527. confirmButtonText: "确定",
  1528. callback: (action) => {
  1529. if (action == "confirm") {
  1530. this.loading = true;
  1531. this.$http
  1532. .delete(QUESTION_API + "/paperDetailUnit/" + paperDetailUnitId)
  1533. .then(() => {
  1534. this.initPaper();
  1535. this.getreduplicateQuestions();
  1536. this.reduplicateGroup = [];
  1537. this.loading = true;
  1538. this.$notify({
  1539. message: "删除成功",
  1540. type: "success",
  1541. });
  1542. this.loading = false;
  1543. });
  1544. }
  1545. },
  1546. });
  1547. },
  1548. deleteQues02(questionId) {
  1549. this.$alert("您确定删除吗?", "提示", {
  1550. confirmButtonText: "确定",
  1551. callback: (action) => {
  1552. if (action == "confirm") {
  1553. this.loading = true;
  1554. this.$http
  1555. .delete(QUESTION_API + "/paper/deleteQuestion/" + questionId)
  1556. .then((response) => {
  1557. if (response.data.length > 0) {
  1558. var deleteInfo =
  1559. "该试题被试卷:" +
  1560. response.data.join(" , ") +
  1561. "使用,不能删除";
  1562. this.$notify({
  1563. message: deleteInfo,
  1564. type: "error",
  1565. });
  1566. } else {
  1567. this.initPaper();
  1568. this.getreduplicateQuestions();
  1569. this.reduplicateGroup = [];
  1570. this.loading = true;
  1571. this.$notify({
  1572. message: "保存成功",
  1573. type: "success",
  1574. });
  1575. }
  1576. this.loading = false;
  1577. });
  1578. }
  1579. },
  1580. });
  1581. },
  1582. //获取重复试题
  1583. getreduplicateQuestions() {
  1584. this.duplicateLoading = true;
  1585. this.$http
  1586. .get(QUESTION_API + "/paper/" + this.paperId + "/reduplicate-questions")
  1587. .then((response) => {
  1588. this.reduplicateQuestions = response.data;
  1589. this.duplicateLoading = false;
  1590. this.initReduplicateQuesColor();
  1591. // var ques = document.getElementsByClassName("ques")[0];
  1592. // ques.style.display = "inline";
  1593. });
  1594. },
  1595. exportPaperAnswer() {
  1596. var key = this.user.key;
  1597. var token = this.user.token;
  1598. window.open(
  1599. QUESTION_API +
  1600. "/paper/answer/export/" +
  1601. this.paperId +
  1602. "?$key=" +
  1603. key +
  1604. "&$token=" +
  1605. token
  1606. );
  1607. },
  1608. initReduplicateQuesColor() {
  1609. var colorCount = this.reduplicateQuestions.length;
  1610. if (colorCount > 20) {
  1611. this.reduplicateQuesColor = randomColor({
  1612. luminosity: "bright",
  1613. count: colorCount,
  1614. });
  1615. } else {
  1616. this.reduplicateQuesColor = this.defaultColor;
  1617. }
  1618. },
  1619. getSubQuesEditId(paperDetailUnit, subQuestion) {
  1620. return paperDetailUnit.question.id + "_" + subQuestion.quesParams.number;
  1621. },
  1622. //打开考试说明编辑框
  1623. openEditExamPaperRemark() {
  1624. if (this.paper.examRemark) {
  1625. this.examRemark = this.paper.examRemark;
  1626. } else {
  1627. this.examRemark = "";
  1628. }
  1629. this.paperRemarkDialog = true;
  1630. },
  1631. //保存考试说明
  1632. savePaperRemark() {
  1633. this.paper.examRemark = this.examRemark;
  1634. this.savePaper();
  1635. this.paperRemarkDialog = false;
  1636. },
  1637. //关闭考试说明编辑框
  1638. closPaperRemark() {
  1639. this.examRemark = "";
  1640. this.paperRemarkDialog = false;
  1641. },
  1642. //保存试卷
  1643. savePaper() {
  1644. this.loading = true;
  1645. this.$http
  1646. .put(QUESTION_API + "/paper", this.paper)
  1647. .then(() => {
  1648. this.$notify({
  1649. message: "保存成功",
  1650. type: "success",
  1651. });
  1652. this.loading = false;
  1653. this.initPaper();
  1654. })
  1655. .catch((error) => {
  1656. this.loading = false;
  1657. this.$notify({
  1658. type: "error",
  1659. message: error.response.data.desc,
  1660. });
  1661. });
  1662. },
  1663. //删除试卷
  1664. deletePaper(id) {
  1665. this.$confirm("确认删除试卷吗?", "提示", {
  1666. type: "warning",
  1667. }).then(() => {
  1668. this.loading = true;
  1669. this.$http.delete(QUESTION_API + "/paper/" + id).then(
  1670. () => {
  1671. this.$notify({
  1672. message: "删除成功",
  1673. type: "success",
  1674. });
  1675. this.back();
  1676. },
  1677. (error) => {
  1678. this.$notify({
  1679. message: error.response.data.desc,
  1680. type: "error",
  1681. title: "错误",
  1682. });
  1683. this.loading = false;
  1684. }
  1685. );
  1686. });
  1687. },
  1688. //打开上传音频弹框
  1689. openDialog() {
  1690. this.checkResult = false;
  1691. this.isUpload = true;
  1692. if (document.getElementById("radioFile")) {
  1693. document.getElementById("radioFile").value = "";
  1694. }
  1695. this.dialogRadioFile = true;
  1696. this.fileList = [];
  1697. },
  1698. //关闭音频弹框
  1699. closeAudioDialog() {
  1700. this.dialogRadioFile = this.uploadAudioLoading;
  1701. },
  1702. //返回
  1703. back() {
  1704. if (sessionStorage.getItem("question_back") == "true") {
  1705. this.$router.push({
  1706. path: "/questions/" + this.parentView + "/0",
  1707. });
  1708. } else {
  1709. this.$router.push({
  1710. path: "/questions/" + this.parentView + "/1",
  1711. });
  1712. }
  1713. },
  1714. paperDetailShow(paperDetail) {
  1715. if (this.reduplicateGroup.length == 0) {
  1716. return true;
  1717. }
  1718. let paperDetailUnits = paperDetail.paperDetailUnits;
  1719. for (let i = 0, imax = paperDetailUnits.length; i < imax; i++) {
  1720. for (var j = 0, jmax = this.reduplicateGroup.length; j < jmax; j++) {
  1721. if (paperDetailUnits[i].id == this.reduplicateGroup[j]) {
  1722. return true;
  1723. }
  1724. }
  1725. }
  1726. return false;
  1727. },
  1728. //上传文件检查
  1729. checkFile() {
  1730. this.fileNameList = [];
  1731. //读取选取的文件夹里面的文件
  1732. this.checkResult = true;
  1733. var files = document.getElementById("radioFile").files;
  1734. if (files.length == 0) {
  1735. this.message = "请选择音频文件夹!";
  1736. return;
  1737. }
  1738. var size = 0;
  1739. var isGo = false;
  1740. //取到所有文件的文件名
  1741. for (var i = 0; i < files.length; i++) {
  1742. this.fileNameList.push(files[i].name);
  1743. if (files[i].size > 5 * 1024 * 1024) {
  1744. isGo = true;
  1745. break;
  1746. }
  1747. size = files[i].size + size;
  1748. }
  1749. if (isGo) {
  1750. this.message = "上传单个文件不能超过5M";
  1751. this.isUpload = true;
  1752. }
  1753. if (size > 50 * 1024 * 1024) {
  1754. this.message = "上传文件总和不能超过50M";
  1755. this.isUpload = true;
  1756. return;
  1757. }
  1758. this.$http
  1759. .post(
  1760. QUESTION_API + "/checkRadioFile/" + this.paperId,
  1761. this.fileNameList
  1762. )
  1763. .then((response) => {
  1764. console.log("response:", response);
  1765. this.message = response.data.errorMsg;
  1766. if (this.message == "OK") {
  1767. this.message = "OK!";
  1768. this.isUpload = false;
  1769. } else {
  1770. this.isUpload = true;
  1771. }
  1772. })
  1773. .catch((error) => {
  1774. console.log(error);
  1775. });
  1776. },
  1777. //读取文件
  1778. uploadAudioFile() {
  1779. let param = new FormData();
  1780. var fileList = document.getElementById("radioFile").files;
  1781. //循环添加到formData中
  1782. for (var i = 0; i < fileList.length; i++) {
  1783. var file = fileList[i];
  1784. param.append("files", file, file.name);
  1785. }
  1786. let config = {
  1787. headers: { "Content-Type": "multipart/form-data" },
  1788. };
  1789. this.$http
  1790. .post(QUESTION_API + "/uploadRadio/" + this.paperId, param, config)
  1791. .then(() => {
  1792. this.dialogRadioFile = false;
  1793. this.uploadAudioLoading = false;
  1794. this.checkResult = false;
  1795. this.isUpload = true;
  1796. document.getElementById("radioFile").value = "";
  1797. this.initPaper();
  1798. })
  1799. .catch((error) => {
  1800. this.message = error.response.data.desc;
  1801. this.uploadAudioLoading = false;
  1802. });
  1803. },
  1804. },
  1805. computed: {
  1806. ...mapState({
  1807. user: (state) => state.user,
  1808. }),
  1809. updatePorperty() {
  1810. if (this.parentView === "gen_paper") {
  1811. return true;
  1812. }
  1813. return false;
  1814. },
  1815. answer() {
  1816. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1817. return this.singleRightAnswer;
  1818. } else if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1819. var obj = this.multipleRightAnswer;
  1820. return obj.sort().toString();
  1821. }
  1822. return this.quesModel.quesAnswer;
  1823. },
  1824. },
  1825. watch: {},
  1826. created() {
  1827. // $("body").attr("style", "");
  1828. document.getElementsByTagName("body")[0].style = "";
  1829. this.paperId = this.$route.params.id;
  1830. this.parentView = this.$route.params.parentView;
  1831. this.initPaper();
  1832. this.getreduplicateQuestions();
  1833. this.uploadAction = QUESTION_API + "/uploadRadio/" + this.paperId;
  1834. this.uploadHeaders = {
  1835. key: this.user.key,
  1836. token: this.user.token,
  1837. };
  1838. },
  1839. mounted() {},
  1840. };
  1841. </script>
  1842. <style scoped src="../styles/EditPaper.css">
  1843. .property_with {
  1844. width: 100px;
  1845. }
  1846. .ck-toolbar {
  1847. z-index: 9999;
  1848. }
  1849. #app {
  1850. background-color: white !important;
  1851. }
  1852. </style>
  1853. <style scoped src="../styles/Common.css"></style>