EditPaper.vue 53 KB

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