EditPaper.vue 64 KB

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