EditPaper.vue 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697
  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-col
  405. :xs="10"
  406. :sm="10"
  407. :md="10"
  408. :lg="10"
  409. v-if="quesModel.questionType == 'TEXT_ANSWER_QUESTION'"
  410. >
  411. <el-form-item label="作答类型">
  412. <el-select
  413. v-model="quesModel.answerType"
  414. :disabled="updatePorperty"
  415. >
  416. <el-option
  417. v-for="item in answerTypes"
  418. :label="item.label"
  419. :value="item.value"
  420. :key="item.value"
  421. >
  422. </el-option>
  423. </el-select>
  424. </el-form-item>
  425. </el-col>
  426. </el-row>
  427. <el-row :gutter="10">
  428. <el-col :xs="20" :sm="20" :md="20" :lg="20">
  429. <el-form-item label="属性列表">
  430. <el-tooltip
  431. placement="top"
  432. v-for="(content, index) in quesModel.quesProperties"
  433. :key="index"
  434. >
  435. <div slot="content">
  436. <span v-if="content.firstProperty != null"
  437. >一级属性:{{ content.firstProperty.name }}</span
  438. ><br />
  439. <span v-if="content.secondProperty != null"
  440. >二级属性:{{ content.secondProperty.name }}</span
  441. >
  442. </div>
  443. <span>
  444. <el-tag
  445. style="margin-right:5px;"
  446. :key="content.id"
  447. :closable="!updatePorperty"
  448. type="primary"
  449. @close="handleClose(content)"
  450. >
  451. {{ content.coursePropertyName }}
  452. </el-tag>
  453. </span>
  454. </el-tooltip>
  455. </el-form-item>
  456. </el-col>
  457. </el-row>
  458. <el-row>
  459. <el-col :span="6">
  460. <el-form-item label="属性名" label-width="60px">
  461. <el-select
  462. v-model="coursePropertyName"
  463. placeholder="属性名"
  464. @change="searchFirst"
  465. class="property_with"
  466. :disabled="updatePorperty"
  467. >
  468. <el-option label="请选择" value=""></el-option>
  469. <el-option
  470. v-for="item in coursePropertyList"
  471. :label="item.name"
  472. :value="item.name"
  473. :key="item.name"
  474. >
  475. </el-option>
  476. </el-select>
  477. </el-form-item>
  478. </el-col>
  479. <el-col :span="6">
  480. <el-form-item label="一级" label-width="48px">
  481. <el-select
  482. v-model="firstPropertyId"
  483. placeholder="一级"
  484. @change="searchSecond"
  485. class="property_with"
  486. :disabled="updatePorperty"
  487. >
  488. <el-option label="请选择" value=""></el-option>
  489. <el-option
  490. v-for="item in firstPropertyList"
  491. :label="item.name"
  492. :value="item.id"
  493. :key="item.id"
  494. >
  495. </el-option>
  496. </el-select>
  497. </el-form-item>
  498. </el-col>
  499. <el-col :span="6">
  500. <el-form-item label="二级" label-width="48px">
  501. <el-select
  502. v-model="secondPropertyId"
  503. placeholder="二级"
  504. class="property_with"
  505. :disabled="updatePorperty"
  506. >
  507. <el-option label="请选择" value=""></el-option>
  508. <el-option
  509. v-for="item in secondPropertyList"
  510. :label="item.name"
  511. :value="item.id"
  512. :key="item.id"
  513. >
  514. </el-option>
  515. </el-select>
  516. </el-form-item>
  517. </el-col>
  518. <el-col :span="6">
  519. <el-form-item>
  520. <el-button
  521. type="primary"
  522. @click="insertProperty"
  523. style="margin-left:-50px;"
  524. :disabled="updatePorperty"
  525. ><i class="el-icon-plus"></i>新增属性
  526. </el-button>
  527. </el-form-item>
  528. </el-col>
  529. </el-row>
  530. <!-- end by weiwenhai -->
  531. <div v-if="paper.paperType == 'IMPORT'">
  532. <el-row>
  533. <el-col>
  534. <el-form-item label="题目">
  535. <ckeditor v-model="quesModel.quesBody"></ckeditor>
  536. </el-form-item>
  537. </el-col>
  538. </el-row>
  539. <el-form-item
  540. v-for="(quesOption, index) in quesModel.quesOptions"
  541. :key="index"
  542. >
  543. <el-col :span="2">
  544. <el-radio
  545. v-model="singleRightAnswer"
  546. :label="index | optionOrderWordFilter"
  547. v-if="quesModel.questionType === 'SINGLE_ANSWER_QUESTION'"
  548. ></el-radio>
  549. <el-checkbox
  550. v-model="multipleRightAnswer"
  551. :label="index | optionOrderWordFilter"
  552. v-if="quesModel.questionType === 'MULTIPLE_ANSWER_QUESTION'"
  553. ></el-checkbox>
  554. </el-col>
  555. <el-col :span="20">
  556. <ckeditor v-model="quesOption.optionBody"></ckeditor>
  557. </el-col>
  558. <el-col :span="2">
  559. <i
  560. class="el-icon-delete"
  561. @click.prevent="removeQuesOption(quesOption)"
  562. title="删除"
  563. ></i>
  564. </el-col>
  565. </el-form-item>
  566. <div
  567. v-if="
  568. quesModel.questionType != 'NESTED_ANSWER_QUESTION' &&
  569. quesModel.questionType != 'SINGLE_ANSWER_QUESTION' &&
  570. quesModel.questionType != 'MULTIPLE_ANSWER_QUESTION' &&
  571. quesModel.questionType != 'BOOL_ANSWER_QUESTION'
  572. "
  573. >
  574. <el-form-item label="答案">
  575. <ckeditor v-model="quesModel.quesAnswer"></ckeditor>
  576. </el-form-item>
  577. </div>
  578. <!-- 单选或多选 -->
  579. <div
  580. v-if="
  581. quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  582. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'
  583. "
  584. >
  585. <el-form-item label="答案">
  586. <span v-html="answer"></span>
  587. </el-form-item>
  588. </div>
  589. <div v-if="quesModel.questionType == 'BOOL_ANSWER_QUESTION'">
  590. <el-row>
  591. <el-col>
  592. <el-form-item label="答案" prop="quesAnswer">
  593. <el-select
  594. v-model="quesModel.quesAnswer"
  595. placeholder="请选择"
  596. >
  597. <el-option
  598. v-for="op in options"
  599. :label="op"
  600. :value="op"
  601. :key="op"
  602. >
  603. </el-option>
  604. </el-select>
  605. </el-form-item>
  606. </el-col>
  607. </el-row>
  608. </div>
  609. </div>
  610. <div
  611. :class="{
  612. margin_left_30:
  613. paper.paperType == 'IMPORT' &&
  614. (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  615. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'),
  616. margin_left_40: !(
  617. paper.paperType == 'IMPORT' &&
  618. (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  619. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION')
  620. )
  621. }"
  622. >
  623. <el-button
  624. type="primary"
  625. @click="addQuesOption"
  626. v-if="
  627. paper.paperType == 'IMPORT' &&
  628. (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
  629. quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION')
  630. "
  631. ><i class="el-icon-plus"></i> 新增选项
  632. </el-button>
  633. <el-button type="primary" @click="savePaperDetailUnit()"
  634. >保存</el-button
  635. >
  636. <el-button @click="closeQuesDialog">取消</el-button>
  637. </div>
  638. </el-form>
  639. </el-dialog>
  640. <!-- 考试说明弹框 -->
  641. <el-dialog title="考试说明编辑" :visible.sync="paperRemarkDialog">
  642. <el-form label-position="right" label-width="80px">
  643. <el-row :gutter="10">
  644. <el-col :xs="10" :sm="10" :md="10" :lg="10">
  645. <el-form-item label="考试说明">
  646. <div style="width:550px;">
  647. <ckeditor
  648. :display="display"
  649. :width="wValue"
  650. :height="hValue"
  651. v-model="examRemark"
  652. ></ckeditor>
  653. </div>
  654. </el-form-item>
  655. </el-col>
  656. </el-row>
  657. <div style="margin-top:20px;margin-left:40%">
  658. <el-button type="primary" @click="savePaperRemark">保存</el-button>
  659. <el-button @click="closPaperRemark">取消</el-button>
  660. </div>
  661. </el-form>
  662. </el-dialog>
  663. <!-- 上传音频弹框 -->
  664. <el-dialog
  665. title="上传音频文件"
  666. :visible.sync="dialogRadioFile"
  667. :before-close="closeAudioDialog"
  668. >
  669. <form
  670. id="radioForm"
  671. method="post"
  672. action=""
  673. enctype="multipart/form-data"
  674. >
  675. <input
  676. id="radioFile"
  677. name="files"
  678. type="file"
  679. value="上传音频文件"
  680. webkitdirectory
  681. />
  682. <el-button @click="checkFile" type="warning">检查文件名</el-button>
  683. <el-button
  684. @click="uploadAudioFile"
  685. type="info"
  686. :loading="uploadAudioLoading"
  687. :disabled="isUpload || uploadAudioLoading"
  688. >
  689. <span v-show="!uploadAudioLoading">开始上传</span>
  690. <span v-show="uploadAudioLoading">正在上传中...</span>
  691. </el-button>
  692. </form>
  693. <div style="margin-top: 20px;" v-if="checkResult">
  694. <span>检查结果:</span><br /><br />
  695. <span style="color: #13CE66;" v-show="message == 'OK!'">OK!</span>
  696. <span style="color: #FF4949;" v-show="message != 'OK!'">{{
  697. message
  698. }}</span>
  699. </div>
  700. </el-dialog>
  701. </div>
  702. </div>
  703. </template>
  704. <script>
  705. import { QUESTION_API } from "@/constants/constants";
  706. import { isEmptyStr, QUESTION_TYPES } from "../constants/constants";
  707. import { mapState } from "vuex";
  708. import reduplicate_mark from "../component/reduplicate_mark.vue";
  709. import randomColor from "randomcolor";
  710. import ckeditor from "../component/ckeditor.vue";
  711. export default {
  712. name: "editPaperApp",
  713. components: {
  714. reduplicate_mark,
  715. ckeditor
  716. },
  717. data() {
  718. return {
  719. hValue: "100px",
  720. wValue: "500px",
  721. display: "block",
  722. uploadAction: "",
  723. fileList: [],
  724. paperId: "",
  725. paperDetailId: "",
  726. editPaperDetailUnit: "",
  727. quesDialog: false,
  728. paperDatailDialog: false,
  729. paperRemarkDialog: false,
  730. parentView: "",
  731. paper: {
  732. course: {
  733. code: "",
  734. name: ""
  735. },
  736. examRemark: ""
  737. },
  738. loading: false,
  739. dialogLoading: false,
  740. detailLoading: false,
  741. uploadAudioLoading: false,
  742. questionTypes: QUESTION_TYPES,
  743. questionType: "",
  744. quesModel: { quesProperties: [] },
  745. editpaperDetail: {},
  746. reduplicateQuestions: [],
  747. reduplicateGroup: [],
  748. reduplicateQuesColor: [],
  749. singleRightAnswer: "", //接收单选答案
  750. multipleRightAnswer: [], //接收多选答案
  751. options: ["正确", "错误"],
  752. duplicateLoading: false,
  753. dialogRadioFile: false,
  754. isUpload: true,
  755. message: "",
  756. checkResult: false,
  757. fileNameList: [],
  758. defaultColor: [
  759. "Red",
  760. "Blue",
  761. "LimeGreen",
  762. "GoldenRod",
  763. "Black",
  764. "BlueViolet",
  765. "Chocolate",
  766. "DarkCyan",
  767. "HotPink",
  768. "Orange",
  769. "IndianRed",
  770. "Indigo",
  771. "Green",
  772. "Aqua",
  773. "CadetBlue",
  774. "SkyBlue",
  775. "SlateBlue",
  776. "SlateGray",
  777. "Tomato",
  778. "VioletRed"
  779. ],
  780. difficultyDegreeList: [
  781. { label: 0.1, value: 0.1 },
  782. { label: 0.2, value: 0.2 },
  783. { label: 0.3, value: 0.3 },
  784. { label: 0.4, value: 0.4 },
  785. { label: 0.5, value: 0.5 },
  786. { label: 0.6, value: 0.6 },
  787. { label: 0.7, value: 0.7 },
  788. { label: 0.8, value: 0.8 },
  789. { label: 0.9, value: 0.9 },
  790. { label: 1.0, value: 1.0 }
  791. ],
  792. publicityList: [
  793. { label: "公开", value: true },
  794. { label: "非公开", value: false }
  795. ],
  796. answerTypes: [
  797. { label: "文本", value: "DIVERSIFIED_TEXT" },
  798. { label: "音频", value: "SINGLE_AUDIO" }
  799. ],
  800. coursePropertyList: [],
  801. coursePropertyName: "", //课程属性名
  802. firstPropertyList: [], //一级属性集合
  803. firstPropertyId: "", //一级属性id
  804. secondPropertyList: [], //二级属性集合
  805. secondPropertyId: "", //二级属性id
  806. examRemark: "",
  807. showQuestions: [],
  808. showButtons: []
  809. };
  810. },
  811. methods: {
  812. //隐藏大题下的所有小题
  813. hideContent(index) {
  814. console.log("up");
  815. this.showQuestions[index].is_show = false;
  816. this.showButtons[index].up = false;
  817. },
  818. //展开大题下所有小题
  819. showContent(index) {
  820. console.log("down");
  821. this.showQuestions[index].is_show = true;
  822. this.showButtons[index].up = true;
  823. },
  824. quesMouseOver(index) {
  825. document.getElementById(index).style.visibility = "visible";
  826. },
  827. quesMouseOut(index) {
  828. document.getElementById(index).style.visibility = "hidden";
  829. },
  830. selectQues(id) {
  831. this.paperDetailId = id;
  832. var courseCode = this.paper.course.code;
  833. var courseName = this.paper.course.name;
  834. this.$router.push({
  835. path:
  836. "/select_question/" +
  837. this.paper.id +
  838. "/" +
  839. courseCode +
  840. "/" +
  841. encodeURIComponent(courseName) +
  842. "/" +
  843. this.paperDetailId +
  844. "/" +
  845. this.parentView
  846. });
  847. },
  848. //打开编辑大题题目弹窗
  849. openEditPaperDetail(paperDetail) {
  850. this.paperDatailDialog = true;
  851. this.editpaperDetail = Object.assign({}, paperDetail); //浅拷贝
  852. },
  853. //关闭编辑大题题目弹窗
  854. closePaperDatailDialog() {
  855. this.paperDatailDialog = false;
  856. this.editpaperDetail = {};
  857. },
  858. //保存大题题目信息
  859. savePaperDatail(editpaperDetail) {
  860. this.detailLoading = true;
  861. var paperId = this.paper.id;
  862. this.$http
  863. .post(QUESTION_API + "/updatePaperDetail/" + paperId, editpaperDetail)
  864. .then(() => {
  865. this.$notify({
  866. message: "保存成功",
  867. type: "success"
  868. });
  869. this.detailLoading = false;
  870. this.closePaperDatailDialog();
  871. this.initPaper();
  872. });
  873. },
  874. //初始化试卷
  875. initPaper() {
  876. this.loading = true;
  877. this.paper = {
  878. course: {
  879. code: "",
  880. name: ""
  881. }
  882. };
  883. this.$http.get(QUESTION_API + "/paper/" + this.paperId).then(response => {
  884. this.paper = response.data;
  885. //查询所有课程属性名
  886. this.initCourseProperty(this.paper.course.code);
  887. //将所有小题分为公开和非公开
  888. if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
  889. for (let paperDetil of this.paper.paperDetails) {
  890. this.showQuestions.push({ is_show: true });
  891. this.showButtons.push({ up: true });
  892. paperDetil.pubCount = 0;
  893. paperDetil.noPubCount = 0;
  894. if (
  895. paperDetil.paperDetailUnits &&
  896. paperDetil.paperDetailUnits.length > 0
  897. ) {
  898. for (let paperDetilUt of paperDetil.paperDetailUnits) {
  899. if (
  900. paperDetilUt.question.questionType != "NESTED_ANSWER_QUESTION"
  901. ) {
  902. //非套题
  903. if (paperDetilUt.question.publicity) {
  904. paperDetil.pubCount = paperDetil.pubCount + 1;
  905. } else {
  906. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  907. }
  908. } else {
  909. //循环所有子题
  910. for (let ques of paperDetilUt.question.subQuestions) {
  911. if (ques.publicity) {
  912. paperDetil.pubCount = paperDetil.pubCount + 1;
  913. } else {
  914. paperDetil.noPubCount = paperDetil.noPubCount + 1;
  915. }
  916. }
  917. }
  918. }
  919. }
  920. }
  921. }
  922. this.loading = false;
  923. });
  924. },
  925. //查询所有课程属性名
  926. initCourseProperty(courseCode) {
  927. this.$http
  928. .get(QUESTION_API + "/courseProperty/enable/" + courseCode)
  929. .then(response => {
  930. this.coursePropertyList = response.data;
  931. });
  932. },
  933. //删除大题
  934. deletePaperDetail(paperDetailsId) {
  935. //先判断大题下面是否还有小题
  936. var count = 0;
  937. for (var i = 0, imax = this.paper.paperDetails.length; i < imax; i++) {
  938. if (paperDetailsId == this.paper.paperDetails[i].id) {
  939. if (this.paper.paperDetails[i].paperDetailUnits) {
  940. count += this.paper.paperDetails[i].paperDetailUnits.length;
  941. break;
  942. }
  943. }
  944. }
  945. if (count == 0) {
  946. this.$alert("您确定删除吗?", "提示", {
  947. confirmButtonText: "确定",
  948. callback: action => {
  949. if (action == "confirm") {
  950. this.loading = true;
  951. this.$http
  952. .delete(QUESTION_API + "/paperDetail/" + paperDetailsId)
  953. .then(() => {
  954. this.initPaper();
  955. this.loading = true;
  956. this.$notify({
  957. message: "删除成功",
  958. type: "success"
  959. });
  960. this.loading = false;
  961. });
  962. }
  963. }
  964. });
  965. } else {
  966. this.$alert("大题下还有小题,不可删除!", "提示", {
  967. confirmButtonText: "确定",
  968. callback: () => {}
  969. });
  970. }
  971. },
  972. quesShow(id) {
  973. if (this.reduplicateGroup.length < 1) {
  974. return true;
  975. }
  976. for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
  977. if (id == this.reduplicateGroup[i]) {
  978. return true;
  979. }
  980. }
  981. return false;
  982. },
  983. reduplicateMarkShow(id) {
  984. var found = false;
  985. for (var i = 0, imax = this.reduplicateQuestions.length; i < imax; i++) {
  986. for (
  987. var j = 0, jmax = this.reduplicateQuestions[i].length;
  988. j < jmax;
  989. j++
  990. ) {
  991. if (this.reduplicateQuestions[i][j] == id) {
  992. found = true;
  993. break;
  994. }
  995. }
  996. if (found) {
  997. break;
  998. }
  999. }
  1000. return found;
  1001. },
  1002. reduplicateMarkColor(id) {
  1003. for (var i = 0, imax = this.reduplicateQuestions.length; i < imax; i++) {
  1004. for (
  1005. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1006. j < jmax;
  1007. j++
  1008. ) {
  1009. if (this.reduplicateQuestions[i][j] == id) {
  1010. return this.reduplicateQuesColor[i];
  1011. }
  1012. }
  1013. }
  1014. },
  1015. reduplicateMarkCheck(id) {
  1016. for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
  1017. if (id == this.reduplicateGroup[i]) {
  1018. return true;
  1019. }
  1020. }
  1021. return false;
  1022. },
  1023. reduplicate_mark_check(id, checked) {
  1024. console.log(checked);
  1025. console.log(this.reduplicateQuestions);
  1026. console.log(id);
  1027. if (!checked) {
  1028. for (
  1029. var i = 0, imax = this.reduplicateQuestions.length;
  1030. i < imax;
  1031. i++
  1032. ) {
  1033. for (
  1034. var j = 0, jmax = this.reduplicateQuestions[i].length;
  1035. j < jmax;
  1036. j++
  1037. ) {
  1038. if (this.reduplicateQuestions[i][j] == id) {
  1039. this.reduplicateGroup = [];
  1040. for (
  1041. var k = 0, kmax = this.reduplicateQuestions[i].length;
  1042. k < kmax;
  1043. k++
  1044. ) {
  1045. this.reduplicateGroup.push(this.reduplicateQuestions[i][k]);
  1046. }
  1047. return;
  1048. }
  1049. }
  1050. }
  1051. } else {
  1052. this.reduplicateGroup = [];
  1053. }
  1054. },
  1055. //编辑题目
  1056. editQues(paperDetailUnit, question) {
  1057. console.log("question:", question);
  1058. this.coursePropertyName = "";
  1059. this.firstPropertyId = "";
  1060. this.secondPropertyId = "";
  1061. this.editPaperDetailUnit = paperDetailUnit;
  1062. this.quesModel = JSON.parse(JSON.stringify(question)); //深拷贝
  1063. this.quesModel.score = paperDetailUnit.score;
  1064. //如果是套题下面的小题编辑 ( paperDetailUnit的类型是套题,question的类型不是套题)
  1065. if (
  1066. paperDetailUnit.questionType == "NESTED_ANSWER_QUESTION" &&
  1067. question.questionType != "NESTED_ANSWER_QUESTION"
  1068. ) {
  1069. for (var i = 0; i < paperDetailUnit.question.subQuestions.length; i++) {
  1070. if (
  1071. paperDetailUnit.question.subQuestions[i].id == this.quesModel.id
  1072. ) {
  1073. this.quesModel.score = paperDetailUnit.subScoreList[i];
  1074. break;
  1075. }
  1076. }
  1077. }
  1078. if (isEmptyStr(this.quesModel.answerType)) {
  1079. this.quesModel.answerType = "DIVERSIFIED_TEXT";
  1080. }
  1081. this.assignAnswers(); //给singleRightAnswer或multipleRightAnswer赋值
  1082. this.openQuesDialog();
  1083. },
  1084. //给singleRightAnswer和multipleRightAnswer赋值
  1085. assignAnswers() {
  1086. if (this.quesModel.quesOptions && this.quesModel.quesOptions.length > 0) {
  1087. this.singleRightAnswer = "";
  1088. this.multipleRightAnswer = [];
  1089. for (let i = 0; i < this.quesModel.quesOptions.length; i++) {
  1090. let option = this.quesModel.quesOptions[i];
  1091. if (
  1092. this.quesModel.questionType == "SINGLE_ANSWER_QUESTION" &&
  1093. option.isCorrect == 1
  1094. ) {
  1095. this.singleRightAnswer = String.fromCharCode(65 + i);
  1096. }
  1097. if (
  1098. this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION" &&
  1099. option.isCorrect == 1
  1100. ) {
  1101. this.multipleRightAnswer.push(String.fromCharCode(65 + i));
  1102. }
  1103. }
  1104. }
  1105. },
  1106. //打开修改试题编辑框
  1107. openQuesDialog() {
  1108. this.quesDialog = true;
  1109. },
  1110. //关闭试题编辑框
  1111. closeQuesDialog() {
  1112. this.quesDialog = false;
  1113. this.quesModel = {};
  1114. },
  1115. //删除属性
  1116. handleClose(tag) {
  1117. this.quesModel.quesProperties.splice(
  1118. this.quesModel.quesProperties.indexOf(tag),
  1119. 1
  1120. );
  1121. },
  1122. //查询一级属性
  1123. searchFirst() {
  1124. this.firstPropertyId = "";
  1125. this.secondPropertyId = "";
  1126. this.secondPropertyList = [];
  1127. if (this.coursePropertyName) {
  1128. for (let courseProperty of this.coursePropertyList) {
  1129. if (courseProperty.name == this.coursePropertyName) {
  1130. this.$http
  1131. .get(QUESTION_API + "/property/first/" + courseProperty.id)
  1132. .then(response => {
  1133. this.firstPropertyList = response.data;
  1134. });
  1135. }
  1136. }
  1137. }
  1138. },
  1139. //查询二级属性
  1140. searchSecond() {
  1141. this.secondPropertyId = "";
  1142. if (this.firstPropertyId) {
  1143. this.$http
  1144. .get(QUESTION_API + "/property/second/" + this.firstPropertyId)
  1145. .then(response => {
  1146. this.secondPropertyList = response.data;
  1147. });
  1148. }
  1149. },
  1150. //新增属性
  1151. insertProperty() {
  1152. if (!this.checkInsertPro()) {
  1153. return false;
  1154. }
  1155. var quesProperty = {
  1156. id: "",
  1157. coursePropertyName: "",
  1158. firstProperty: {},
  1159. secondProperty: {}
  1160. };
  1161. if (
  1162. this.quesModel.quesProperties == null ||
  1163. this.quesModel.quesProperties.length == 0
  1164. ) {
  1165. this.quesModel.quesProperties = [];
  1166. }
  1167. if (this.secondPropertyId) {
  1168. quesProperty.id =
  1169. this.coursePropertyName +
  1170. "-" +
  1171. this.firstPropertyId +
  1172. "-" +
  1173. this.secondPropertyId;
  1174. } else {
  1175. quesProperty.id = this.coursePropertyName + "-" + this.firstPropertyId;
  1176. }
  1177. for (let quesPro of this.quesModel.quesProperties) {
  1178. if (quesPro.id == quesProperty.id) {
  1179. this.$notify({
  1180. message: "该属性已存在,请重新选择",
  1181. type: "error"
  1182. });
  1183. return false;
  1184. }
  1185. }
  1186. quesProperty.coursePropertyName = this.coursePropertyName;
  1187. //取到一级属性对象
  1188. for (let property of this.firstPropertyList) {
  1189. if (property.id == this.firstPropertyId) {
  1190. quesProperty.firstProperty = property;
  1191. }
  1192. }
  1193. //判断是否有二级属性
  1194. if (
  1195. this.secondPropertyList != undefined &&
  1196. this.secondPropertyList.length > 0
  1197. ) {
  1198. if (!this.secondPropertyId) {
  1199. this.$notify({
  1200. message: "请选择二级属性",
  1201. type: "error"
  1202. });
  1203. return false;
  1204. }
  1205. }
  1206. //取到二级属性对象
  1207. for (let property of this.secondPropertyList) {
  1208. if (property.id == this.secondPropertyId) {
  1209. quesProperty.secondProperty = property;
  1210. }
  1211. }
  1212. this.quesModel.quesProperties.push(quesProperty);
  1213. this.quesModel = Object.assign({}, this.quesModel);
  1214. //清空下拉框
  1215. this.coursePropertyName = "";
  1216. this.firstPropertyId = "";
  1217. this.secondPropertyId = "";
  1218. this.firstPropertyList = [];
  1219. this.secondPropertyList = [];
  1220. },
  1221. //新增属性验证
  1222. checkInsertPro() {
  1223. if (!this.coursePropertyName) {
  1224. this.$notify({
  1225. message: "请选择属性",
  1226. type: "error"
  1227. });
  1228. return false;
  1229. }
  1230. if (!this.firstPropertyId) {
  1231. this.$notify({
  1232. message: "请选择一级属性",
  1233. type: "error"
  1234. });
  1235. return false;
  1236. }
  1237. return true;
  1238. },
  1239. //删除选项
  1240. removeQuesOption(option) {
  1241. this.singleRightAnswer = "";
  1242. this.multipleRightAnswer = [];
  1243. let index = this.quesModel.quesOptions.indexOf(option);
  1244. if (index !== -1) {
  1245. this.quesModel.quesOptions.splice(index, 1);
  1246. }
  1247. if (this.quesModel.quesOptions.length > 0) {
  1248. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1249. var quesOption = this.quesModel.quesOptions[i];
  1250. quesOption["number"] = i + 1;
  1251. if (quesOption.isCorrect == 1) {
  1252. var answerOrderNum = String.fromCharCode(65 + i);
  1253. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1254. this.singleRightAnswer = answerOrderNum;
  1255. }
  1256. if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1257. this.multipleRightAnswer.push(answerOrderNum);
  1258. }
  1259. }
  1260. }
  1261. }
  1262. },
  1263. //新增选项
  1264. addQuesOption() {
  1265. this.quesModel.quesOptions.push({
  1266. number: "",
  1267. optionBody: "",
  1268. isCorrect: ""
  1269. });
  1270. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1271. this.quesModel.quesOptions[i]["number"] = i + 1;
  1272. }
  1273. },
  1274. savePaperDetailUnit() {
  1275. //跟新难度值
  1276. if (this.quesModel.difficultyDegree < 0.4) {
  1277. this.quesModel.difficulty = "难";
  1278. } else if (
  1279. this.quesModel.difficultyDegree > 0.3 &&
  1280. this.quesModel.difficultyDegree < 0.8
  1281. ) {
  1282. this.quesModel.difficulty = "中";
  1283. } else {
  1284. this.quesModel.difficulty = "易";
  1285. }
  1286. this.setRightAnswer();
  1287. if (/^\d+(?=\.{0,1}\d+$|$)/.test(this.quesModel.score)) {
  1288. console.log("正确");
  1289. } else {
  1290. this.$notify({
  1291. message: "分数只能为正数",
  1292. type: "error"
  1293. });
  1294. return;
  1295. }
  1296. let paperDetailUnitExp = {
  1297. id: this.editPaperDetailUnit.id,
  1298. question: this.quesModel,
  1299. score: this.quesModel.score
  1300. };
  1301. if (
  1302. this.quesModel.quesOptions &&
  1303. this.quesModel.quesOptions.length == 0
  1304. ) {
  1305. this.$confirm("无选项将删除该试题, 是否继续?", "提示", {
  1306. confirmButtonText: "确定",
  1307. cancelButtonText: "取消",
  1308. type: "warning"
  1309. }).then(() => {
  1310. this.dialogLoading = true;
  1311. this.$http
  1312. .delete(QUESTION_API + "/paper/deleteQuestion/" + this.quesModel.id)
  1313. .then(response => {
  1314. if (response.data.length > 0) {
  1315. var deleteInfo =
  1316. "该试题被试卷:" +
  1317. response.data.join(" , ") +
  1318. "使用,不能删除";
  1319. this.$notify({
  1320. message: deleteInfo,
  1321. type: "error"
  1322. });
  1323. } else {
  1324. this.$notify({
  1325. message: "保存成功",
  1326. type: "success"
  1327. });
  1328. }
  1329. this.dialogLoading = false;
  1330. });
  1331. });
  1332. } else {
  1333. this.dialogLoading = true;
  1334. this.$http
  1335. .put(QUESTION_API + "/paperDetailUnit", paperDetailUnitExp)
  1336. .then(() => {
  1337. this.$notify({
  1338. message: "保存成功",
  1339. type: "success"
  1340. });
  1341. this.dialogLoading = false;
  1342. this.closeQuesDialog();
  1343. this.initPaper();
  1344. });
  1345. }
  1346. },
  1347. //在正确的option上设置isCorrect=1
  1348. setRightAnswer() {
  1349. if (
  1350. !this.quesModel.quesOptions ||
  1351. this.quesModel.quesOptions.length == 0
  1352. ) {
  1353. return false;
  1354. }
  1355. for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
  1356. var option = this.quesModel.quesOptions[i];
  1357. var answerOrderNum = String.fromCharCode(65 + i);
  1358. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1359. option["isCorrect"] =
  1360. answerOrderNum == this.singleRightAnswer ? 1 : 0;
  1361. }
  1362. if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1363. option["isCorrect"] =
  1364. this.multipleRightAnswer.indexOf(answerOrderNum) > -1 ? 1 : 0;
  1365. }
  1366. }
  1367. },
  1368. //删除试题
  1369. deleteQues(paperDetailUnit) {
  1370. let paperDetailUnitId = paperDetailUnit.id;
  1371. if (this.paper.paperType == "GENERATE") {
  1372. this.deleteQues01(paperDetailUnitId);
  1373. } else {
  1374. let questionId = paperDetailUnit.question.id;
  1375. this.deleteQues02(questionId);
  1376. }
  1377. },
  1378. deleteQues01(paperDetailUnitId) {
  1379. this.$alert("您确定删除吗?", "提示", {
  1380. confirmButtonText: "确定",
  1381. callback: action => {
  1382. if (action == "confirm") {
  1383. this.loading = true;
  1384. this.$http
  1385. .delete(QUESTION_API + "/paperDetailUnit/" + paperDetailUnitId)
  1386. .then(() => {
  1387. this.initPaper();
  1388. this.getreduplicateQuestions();
  1389. this.reduplicateGroup = [];
  1390. this.loading = true;
  1391. this.$notify({
  1392. message: "删除成功",
  1393. type: "success"
  1394. });
  1395. this.loading = false;
  1396. });
  1397. }
  1398. }
  1399. });
  1400. },
  1401. deleteQues02(questionId) {
  1402. this.$alert("您确定删除吗?", "提示", {
  1403. confirmButtonText: "确定",
  1404. callback: action => {
  1405. if (action == "confirm") {
  1406. this.loading = true;
  1407. this.$http
  1408. .delete(QUESTION_API + "/paper/deleteQuestion/" + questionId)
  1409. .then(response => {
  1410. if (response.data.length > 0) {
  1411. var deleteInfo =
  1412. "该试题被试卷:" +
  1413. response.data.join(" , ") +
  1414. "使用,不能删除";
  1415. this.$notify({
  1416. message: deleteInfo,
  1417. type: "error"
  1418. });
  1419. } else {
  1420. this.initPaper();
  1421. this.getreduplicateQuestions();
  1422. this.reduplicateGroup = [];
  1423. this.loading = true;
  1424. this.$notify({
  1425. message: "保存成功",
  1426. type: "success"
  1427. });
  1428. }
  1429. this.loading = false;
  1430. });
  1431. }
  1432. }
  1433. });
  1434. },
  1435. //获取重复试题
  1436. getreduplicateQuestions() {
  1437. this.duplicateLoading = true;
  1438. this.$http
  1439. .get(QUESTION_API + "/paper/" + this.paperId + "/reduplicate-questions")
  1440. .then(response => {
  1441. this.reduplicateQuestions = response.data;
  1442. this.duplicateLoading = false;
  1443. this.initReduplicateQuesColor();
  1444. // var ques = document.getElementsByClassName("ques")[0];
  1445. // ques.style.display = "inline";
  1446. });
  1447. },
  1448. initReduplicateQuesColor() {
  1449. var colorCount = this.reduplicateQuestions.length;
  1450. if (colorCount > 20) {
  1451. this.reduplicateQuesColor = randomColor({
  1452. luminosity: "bright",
  1453. count: colorCount
  1454. });
  1455. } else {
  1456. this.reduplicateQuesColor = this.defaultColor;
  1457. }
  1458. },
  1459. getSubQuesEditId(paperDetailUnit, subQuestion) {
  1460. return paperDetailUnit.question.id + "_" + subQuestion.quesParams.number;
  1461. },
  1462. //打开考试说明编辑框
  1463. openEditExamPaperRemark() {
  1464. if (this.paper.examRemark) {
  1465. this.examRemark = this.paper.examRemark;
  1466. } else {
  1467. this.examRemark = "";
  1468. }
  1469. this.paperRemarkDialog = true;
  1470. },
  1471. //保存考试说明
  1472. savePaperRemark() {
  1473. this.paper.examRemark = this.examRemark;
  1474. this.savePaper();
  1475. this.paperRemarkDialog = false;
  1476. },
  1477. //关闭考试说明编辑框
  1478. closPaperRemark() {
  1479. this.examRemark = "";
  1480. this.paperRemarkDialog = false;
  1481. },
  1482. //保存试卷
  1483. savePaper() {
  1484. this.loading = true;
  1485. this.$http
  1486. .put(QUESTION_API + "/paper", this.paper)
  1487. .then(() => {
  1488. this.$notify({
  1489. message: "保存成功",
  1490. type: "success"
  1491. });
  1492. this.loading = false;
  1493. this.initPaper();
  1494. })
  1495. .catch(error => {
  1496. this.loading = false;
  1497. this.$notify({
  1498. type: "error",
  1499. message: error.body.msg
  1500. });
  1501. });
  1502. },
  1503. //删除试卷
  1504. deletePaper(id) {
  1505. this.$confirm("确认删除试卷吗?", "提示", {
  1506. type: "warning"
  1507. }).then(() => {
  1508. this.loading = true;
  1509. this.$http.delete(QUESTION_API + "/paper/" + id).then(
  1510. () => {
  1511. this.$notify({
  1512. message: "删除成功",
  1513. type: "success"
  1514. });
  1515. this.back();
  1516. },
  1517. error => {
  1518. this.$notify({
  1519. message: error.data.msg,
  1520. type: "error"
  1521. });
  1522. this.loading = false;
  1523. }
  1524. );
  1525. });
  1526. },
  1527. //打开上传音频弹框
  1528. openDialog() {
  1529. this.checkResult = false;
  1530. this.isUpload = true;
  1531. if (document.getElementById("radioFile")) {
  1532. document.getElementById("radioFile").value = "";
  1533. }
  1534. this.dialogRadioFile = true;
  1535. this.fileList = [];
  1536. },
  1537. //关闭音频弹框
  1538. closeAudioDialog() {
  1539. this.dialogRadioFile = this.uploadAudioLoading;
  1540. },
  1541. //返回
  1542. back() {
  1543. if (sessionStorage.getItem("question_back") == "true") {
  1544. this.$router.push({
  1545. path: "/questions/" + this.parentView + "/0"
  1546. });
  1547. } else {
  1548. this.$router.push({
  1549. path: "/questions/" + this.parentView + "/1"
  1550. });
  1551. }
  1552. },
  1553. paperDetailShow(paperDetail) {
  1554. if (this.reduplicateGroup.length == 0) {
  1555. return true;
  1556. }
  1557. let paperDetailUnits = paperDetail.paperDetailUnits;
  1558. for (let i = 0, imax = paperDetailUnits.length; i < imax; i++) {
  1559. for (var j = 0, jmax = this.reduplicateGroup.length; j < jmax; j++) {
  1560. if (paperDetailUnits[i].id == this.reduplicateGroup[j]) {
  1561. return true;
  1562. }
  1563. }
  1564. }
  1565. return false;
  1566. },
  1567. //上传文件检查
  1568. checkFile() {
  1569. this.fileNameList = [];
  1570. //读取选取的文件夹里面的文件
  1571. this.checkResult = true;
  1572. var files = document.getElementById("radioFile").files;
  1573. if (files.length == 0) {
  1574. this.message = "请选择音频文件夹!";
  1575. return;
  1576. }
  1577. var size = 0;
  1578. var isGo = false;
  1579. //取到所有文件的文件名
  1580. for (var i = 0; i < files.length; i++) {
  1581. this.fileNameList.push(files[i].name);
  1582. if (files[i].size > 5 * 1024 * 1024) {
  1583. isGo = true;
  1584. break;
  1585. }
  1586. size = files[i].size + size;
  1587. }
  1588. if (isGo) {
  1589. this.message = "上传单个文件不能超过5M";
  1590. this.isUpload = true;
  1591. }
  1592. if (size > 50 * 1024 * 1024) {
  1593. this.message = "上传文件总和不能超过50M";
  1594. this.isUpload = true;
  1595. return;
  1596. }
  1597. this.$http
  1598. .post(
  1599. QUESTION_API + "/checkRadioFile/" + this.paperId,
  1600. this.fileNameList
  1601. )
  1602. .then(response => {
  1603. console.log("response:", response);
  1604. this.message = response.data.errorMsg;
  1605. if (this.message == "OK") {
  1606. this.message = "OK!";
  1607. this.isUpload = false;
  1608. } else {
  1609. this.isUpload = true;
  1610. }
  1611. })
  1612. .catch(error => {
  1613. console.log(error);
  1614. });
  1615. },
  1616. //读取文件
  1617. uploadAudioFile() {
  1618. let param = new FormData();
  1619. var fileList = document.getElementById("radioFile").files;
  1620. //循环添加到formData中
  1621. for (var i = 0; i < fileList.length; i++) {
  1622. var file = fileList[i];
  1623. param.append("files", file, file.name);
  1624. }
  1625. let config = {
  1626. headers: { "Content-Type": "multipart/form-data" }
  1627. };
  1628. this.$http
  1629. .post(QUESTION_API + "/uploadRadio/" + this.paperId, param, config)
  1630. .then(() => {
  1631. this.dialogRadioFile = false;
  1632. this.uploadAudioLoading = false;
  1633. this.checkResult = false;
  1634. this.isUpload = true;
  1635. document.getElementById("radioFile").value = "";
  1636. this.initPaper();
  1637. })
  1638. .catch(error => {
  1639. this.message = error.response.responseText;
  1640. this.uploadAudioLoading = false;
  1641. });
  1642. }
  1643. },
  1644. computed: {
  1645. ...mapState({
  1646. user: state => state.user
  1647. }),
  1648. updatePorperty() {
  1649. if (this.parentView === "gen_paper") {
  1650. return true;
  1651. }
  1652. return false;
  1653. },
  1654. answer() {
  1655. if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
  1656. return this.singleRightAnswer;
  1657. } else if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
  1658. var obj = this.multipleRightAnswer;
  1659. return obj.sort().toString();
  1660. }
  1661. return this.quesModel.quesAnswer;
  1662. }
  1663. },
  1664. watch: {},
  1665. created() {
  1666. // $("body").attr("style", "");
  1667. document.getElementsByTagName("body")[0].style = "";
  1668. this.paperId = this.$route.params.id;
  1669. this.parentView = this.$route.params.parentView;
  1670. this.initPaper();
  1671. this.getreduplicateQuestions();
  1672. this.uploadAction = QUESTION_API + "/uploadRadio/" + this.paperId;
  1673. this.uploadHeaders = {
  1674. key: this.user.key,
  1675. token: this.user.token
  1676. };
  1677. },
  1678. mounted() {}
  1679. };
  1680. </script>
  1681. <style scoped src="../styles/EditPaper.css">
  1682. .property_with {
  1683. width: 100px;
  1684. }
  1685. .ck-toolbar {
  1686. z-index: 9999;
  1687. }
  1688. #app {
  1689. background-color: white !important;
  1690. }
  1691. </style>
  1692. <style scoped src="../styles/Common.css"></style>