EditPaper.vue 50 KB

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