questionBankExplain.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  1. <template>
  2. <view id="questionBank">
  3. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  4. <swiper-item v-for="(bank,bankIndex) in questionList" :key="bankIndex">
  5. <view class="pageContent">
  6. <view class="pad_8 titBox" >
  7. <view class="firstLetter">
  8. <view class="leftLetters">
  9. <view class="btnType">
  10. <text v-if="bank.type==1">单选</text>
  11. <text v-if="bank.type==2">多选</text>
  12. <text v-if="bank.type==3">判断</text>
  13. <text v-if="bank.type==4">案例题</text>
  14. <text v-if="bank.type==5">简答题</text>
  15. </view>
  16. <text>{{bankIndex+1}}/{{questionList.length}}</text>
  17. </view>
  18. <view style="color: #666;font-size: 28rpx;"></view>
  19. <view class="leftLetters"></view>
  20. </view>
  21. <view class="titles">
  22. <rich-text :nodes="bank.content"></rich-text>
  23. </view>
  24. </view>
  25. <view class="pad_8 titBox">
  26. <template v-if="bank.type == 1">
  27. <view v-if="!bank.ques">
  28. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect(item.optionsId,bankIndex)">
  29. <view class="activeTI">{{ ast[index] }}</view>
  30. <view class="flex_auto">{{ item.content }}</view>
  31. </view>
  32. </view>
  33. <view v-if="bank.ques">
  34. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  35. <text :class="{right:(item.optionsId == bank.ques) || (item.optionsId == bank.ans),wrong:(item.optionsId == bank.ques) && (bank.ques != bank.ans)}" class="activeTI">{{ ast[index] }}</text>
  36. <view class="flex_auto">{{ item.content }}</view>
  37. </view>
  38. </view>
  39. <view v-if="bank.ques">
  40. <view class="pad_8 answer">
  41. <view>正确答案:{{ast[bank.ans-1]}}</view>
  42. <view v-if="!explain">我的答案:{{ast[bank.ques-1]}}</view>
  43. </view>
  44. <view class="pad_8 answerInfos">
  45. <view class="answerTitle">答案解析</view>
  46. <view class="answerContent">
  47. <rich-text :nodes="bank.analysisContent"></rich-text>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <template v-if="bank.type == 2">
  53. <view v-if="!bank.ques">
  54. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect(item.optionsId,bankIndex,index)">
  55. <view :class="{checked:item.checked}" class="activeTI">{{ ast[index] }}</view>
  56. <view class="flex_auto">{{ item.content }}</view>
  57. </view>
  58. </view>
  59. <view v-if="!bank.ques" class="submit_checkbox" @click="checkboxSubmit(bankIndex)">
  60. 确认答案
  61. </view>
  62. <view v-if="bank.ques">
  63. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  64. <text :class="{right:(bank.ques.indexOf(item.optionsId) != -1 ) || (bank.ans.indexOf(item.optionsId) != -1),wrong:(bank.ques.indexOf(item.optionsId) != -1 ) && (bank.ans.indexOf(item.optionsId) == -1)}" class="activeTI">{{ ast[index] }}</text>
  65. <view class="flex_auto">{{ item.content }}</view>
  66. </view>
  67. </view>
  68. <view v-if="bank.ques">
  69. <view class="pad_8 answer">
  70. <view>正确答案:
  71. <text v-for="ansItem in bank.ans">{{ast[ansItem-1]}}</text>
  72. </view>
  73. <view v-if="!explain">我的答案:
  74. <text v-for="quesItem in bank.ques">{{ast[quesItem-1]}}</text>
  75. </view>
  76. </view>
  77. <view class="pad_8 answerInfos">
  78. <view class="answerTitle">答案解析</view>
  79. <view class="answerContent">
  80. <rich-text :nodes="bank.analysisContent"></rich-text>
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <template v-if="bank.type == 3">
  86. <view v-if="!bank.ques">
  87. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect(index,bankIndex)">
  88. <view class="activeTI">{{ ast[index] }}</view>
  89. {{ item }}
  90. </view>
  91. </view>
  92. <view v-if="bank.ques">
  93. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  94. <text :class="{right:(index == bank.ques) || (index == bank.ans),wrong:(index == bank.ques) && (bank.ques != bank.ans)}" class="activeTI">{{ ast[index] }}</text>
  95. {{ item }}
  96. </view>
  97. </view>
  98. <view v-if="bank.ques">
  99. <view class="pad_8 answer">
  100. <view>正确答案:{{ast[bank.ans]}}</view>
  101. <view v-if="!explain">我的答案:{{ast[bank.ques]}}</view>
  102. </view>
  103. <view class="pad_8 answerInfos">
  104. <view class="answerTitle">答案解析</view>
  105. <view class="answerContent">
  106. <rich-text :nodes="bank.analysisContent"></rich-text>
  107. </view>
  108. </view>
  109. </view>
  110. </template>
  111. <!-- 简答题 -->
  112. <template v-if="bank.type == 5">
  113. <view class="ans">
  114. <view class="ans_input" v-if="!bank.ques">
  115. <view class="top flex">
  116. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/08-10_032.jpg" mode=""></image>
  117. <view class="progress">0/4</view>
  118. <view class="submit" @click="submitAns(bankIndex)" >确认答案</view>
  119. </view>
  120. <view class="textarea">
  121. <textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea>
  122. </view>
  123. <view class="imgs">
  124. <view class="img" v-for="(img,imgIndex) in bank.ansText.imageList" >
  125. <text @click="deleteImg(imgIndex,bankIndex)">x</text>
  126. <image :src="$method.splitImgHost(img, true)"></image>
  127. </view>
  128. </view>
  129. </view>
  130. <view class="ans_submit answerInfos" v-if="bank.ques && !explain">
  131. <view class="answerTitle">答案我的</view>
  132. {{bank.ques.text}}
  133. <view class="imgs">
  134. <image class="img" v-for="ques in bank.ques.imageList" :src="$method.splitImgHost(ques,true)"></image>
  135. </view>
  136. </view>
  137. </view>
  138. <view v-if="bank.ques">
  139. <view class="pad_8 answerInfos">
  140. <view class="answerTitle">答案解析</view>
  141. <view class="answerContent">
  142. <rich-text :nodes="bank.analysisContent"></rich-text>
  143. </view>
  144. </view>
  145. </view>
  146. </template>
  147. <!-- 案例题 -->
  148. <template v-if="bank.type == 4">
  149. <view class="tabs">
  150. <view class="tab" :class="{current:tabIndex == bank.current}" :key="tabIndex" v-for="(tab,tabIndex) in bank.jsonStr" @click="tabSelect(tabIndex,bankIndex)">问题{{tabIndex}}</view>
  151. </view>
  152. <view v-for="(ansItem,ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  153. <view class="titles">
  154. <rich-text :nodes="ansItem.content"></rich-text>
  155. </view>
  156. <template v-if="ansItem.type == 1">
  157. <view v-if="!bank.ques[ansIndex]">
  158. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty" @click="radioSelectChild(option.optionsId,ansIndex,bankIndex)">
  159. <view class="activeTI">{{ ast[childIndex] }}</view>
  160. <rich-text class="textChild" :nodes="option.content"></rich-text>
  161. </view>
  162. </view>
  163. <view v-if="bank.ques[ansIndex]">
  164. <view v-for="(option, childIndex) in ansItem.optionsList" :key="index" class="lisSty">
  165. <text :class="{right:(option.optionsId == bank.ques[ansIndex]) || (option.optionsId == bank.ans[ansIndex]),wrong:(option.optionsId == bank.ques[ansIndex]) && (bank.ques[ansIndex] != bank.ans[ansIndex])}" class="activeTI">{{ ast[childIndex] }}</text>
  166. <rich-text :nodes="option.content"></rich-text>
  167. </view>
  168. </view>
  169. <view v-if="bank.ques[ansIndex]">
  170. <view class="pad_8 answer">
  171. <view>正确答案:{{ast[bank.ans[ansIndex]-1]}}</view>
  172. <view v-if="!explain">我的答案:{{ast[bank.ques[ansIndex]-1]}}</view>
  173. </view>
  174. <view class="pad_8 answerInfos">
  175. <view class="answerTitle">答案解析</view>
  176. <view class="answerContent">
  177. <rich-text :nodes="option.analysisContent"></rich-text>
  178. </view>
  179. </view>
  180. </view>
  181. </template>
  182. <template v-if="ansItem.type == 2">
  183. <view v-if="!bank.ques[ansIndex]">
  184. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty" @click="checkboxSelectChild(bankIndex,ansIndex,childindex)">
  185. <view :class="{checked:option.checked}" class="activeTI">{{ ast[childindex] }}</view>
  186. <rich-text :nodes="option.content"></rich-text>
  187. </view>
  188. </view>
  189. <view v-if="!bank.ques[ansIndex]" class="submit_checkbox" @click="checkboxSubmitChild(bankIndex,ansIndex)">
  190. 确认答案
  191. </view>
  192. <view v-if="bank.ques && bank.ques[ansIndex]">
  193. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  194. <text :class="{right:right(bankIndex,ansIndex,option),wrong:wrong(bankIndex,ansIndex,option)}" class="activeTI">{{ ast[childindex] }}</text>
  195. <rich-text :nodes="option.content"></rich-text>
  196. </view>
  197. </view>
  198. <view v-if="bank.ques[ansIndex]">
  199. <view class="pad_8 answer">
  200. <view>正确答案:
  201. <text v-for="ansItem1 in bank.ans[ansIndex]">{{ast[ansItem1-1]}}</text>
  202. </view>
  203. <view v-if="!explain">我的答案:
  204. <text v-for="quesItem in bank.ques[ansIndex]">{{ast[quesItem-1]}}</text>
  205. </view>
  206. </view>
  207. <view class="pad_8 answerInfos">
  208. <view class="answerTitle">答案解析</view>
  209. <view class="answerContent">
  210. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  211. </view>
  212. </view>
  213. </view>
  214. </template>
  215. <template v-if="ansItem.type == 3">
  216. <view v-if="!bank.ques[ansIndex]">
  217. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex,childindex,bankIndex)">
  218. <view class="activeTI">{{ ast[childindex] }}</view>
  219. {{ option }}
  220. </view>
  221. </view>
  222. <view v-if="bank.ques[ansIndex]">
  223. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  224. <text :class="{right:(childindex == bank.ques[ansIndex]) || (childindex == bank.ans[ansIndex]),wrong:(childindex == bank.ques[ansIndex]) && (bank.ques[ansIndex] != bank.ans[ansIndex])}" class="activeTI">{{ ast[childindex] }}</text>
  225. {{ option }}
  226. </view>
  227. </view>
  228. <view v-if="bank.ques[ansIndex]">
  229. <view class="pad_8 answer">
  230. <view>正确答案:{{ast[bank.ans[ansIndex]]}}</view>
  231. <view v-if="!explain">我的答案:{{ast[bank.ques[ansIndex]]}}</view>
  232. </view>
  233. <view class="pad_8 answerInfos">
  234. <view class="answerTitle">答案解析</view>
  235. <view class="answerContent">
  236. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  237. </view>
  238. </view>
  239. </view>
  240. </template>
  241. <!-- 简答题 -->
  242. <template v-if="ansItem.type == 5">
  243. <view class="ans">
  244. <view class="ans_input" v-if="!bank.ques[ansIndex]">
  245. <view class="top flex">
  246. <image class="icon" @click="chooseImgChild(bankIndex,ansIndex)" src="/static/08-10_032.jpg" mode=""></image>
  247. <view class="progress">0/4</view>
  248. <view class="submit" @click="submitAnsChild(bankIndex,ansIndex)">确认答案</view>
  249. </view>
  250. <view class="textarea">
  251. <textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea>
  252. </view>
  253. <view class="imgs">
  254. <view class="img" v-for="(img,imgIndex) in ansItem.ansText.imageList" >
  255. <text @click="deleteImgChild(imgIndex,bankIndex,ansIndex)">x</text>
  256. <image :src="$method.splitImgHost(img, true)"></image>
  257. </view>
  258. </view>
  259. </view>
  260. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex] && !explain">
  261. <view class="answerTitle">答案我的</view>
  262. {{bank.ques[ansIndex].text}}
  263. <view class="imgs">
  264. <image class="img" v-for="ques in bank.ques[ansIndex].imageList" :src="$method.splitImgHost(ques,true)"></image>
  265. </view>
  266. </view>
  267. </view>
  268. <view v-if="bank.ques[ansIndex]">
  269. <view class="pad_8 answerInfos">
  270. <view class="answerTitle">答案解析</view>
  271. <view class="answerContent">
  272. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  273. </view>
  274. </view>
  275. </view>
  276. </template>
  277. </view>
  278. </template>
  279. </view>
  280. <view class="footer_btn" v-if="isContinue || !isHistory">
  281. <view class="collect"></view>
  282. <view class="flex_center" @click="openFooterTab">
  283. <view class="up-icon">
  284. <image src="/static/up.png"></image>
  285. </view>
  286. 答题卡
  287. </view>
  288. <view class="collect show" @click="submit">
  289. <view>
  290. <image src="/static/jj.png" mode=""></image>
  291. <view>交卷</view>
  292. </view>
  293. </view>
  294. </view>
  295. </view>
  296. </swiper-item>
  297. </swiper>
  298. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  299. <view class="popupView">
  300. <view class="popupTops">
  301. <view class="topIcon"></view>
  302. 点击编号即可跳转至对应题目
  303. </view>
  304. <view class="popupContent">
  305. <scroll-view scroll-y="true" style="height: 506rpx;">
  306. <view class="boxSty">
  307. <view v-for="(item, index) in questionList" :key="index" @click="changeIndex(index)" :class="{isRight:isRight(item,index),isWrong:isWrong(item,index)}" class="liListSty">{{ index + 1 }}</view>
  308. </view>
  309. </scroll-view>
  310. </view>
  311. </view>
  312. </u-popup>
  313. <view class="dialog" v-if="showDialog">
  314. <view class="text">左右滑动切换上下题</view>
  315. <view class="btn" @click="hideDialog">我知道了</view>
  316. </view>
  317. </view>
  318. </template>
  319. <script>
  320. export default {
  321. data() {
  322. return {
  323. id:'',
  324. current:0,
  325. questionList:[],
  326. ast: ['A', 'B', 'C', 'D','E','F','G'],
  327. judge:['错误','正确'],
  328. show: false,
  329. showDialog:true,
  330. bankList: [],
  331. collectList:[],
  332. goodsId:'',
  333. explain:'', //是否显示答案
  334. isContinue:'', //是否继续做题
  335. chapterId:'',
  336. moduleId:'',
  337. isHistory:'', //是否显示历史答题记录
  338. isSubmit:false,
  339. };
  340. },
  341. onLoad(option){
  342. this.id = option.id;
  343. this.explain = option.explain;
  344. this.isContinue = option.continue;
  345. this.goodsId = option.goodsid;
  346. this.chapterId = option.chapterId;
  347. this.moduleId = option.moduleId;
  348. this.recordId = option.recordId;
  349. this.isHistory = option.isHistory;
  350. this.goodsQuestionList();
  351. },
  352. onUnload() {
  353. if(this.isSubmit || this.isHistory) {
  354. return
  355. }
  356. this.examRecordEdit();
  357. },
  358. methods: {
  359. goodsQuestionList() {
  360. //继续答题
  361. if(this.isContinue || this.isHistory) {
  362. console.log(this.isContinue,"历史做题")
  363. this.$api.examReport(this.recordId).then(res => {
  364. let json = JSON.parse(res.data.data.historyExamJson)
  365. this.questionList = json;
  366. })
  367. } else { //解析
  368. this.$api.goodsQuestionList({
  369. examId:this.id
  370. }).then(res => {
  371. res.data.data.forEach((item,index) => {
  372. if(typeof item.jsonStr == 'string') {
  373. item.jsonStr = JSON.parse(item.jsonStr)
  374. if(item.type == 2) { //多选
  375. item.jsonStr.forEach(str => {
  376. str.optionsId = ''+str.optionsId;
  377. })
  378. let arr = item.answerQuestion.split(',');
  379. arr.forEach((a,i) => {
  380. arr[i] = ''+a;
  381. })
  382. item.ans = arr;
  383. if(this.explain) {
  384. item.ques = item.ans;
  385. }
  386. return;
  387. } else if(item.type == 5) {
  388. item.ansText = {
  389. text: '',
  390. imageList: []
  391. }
  392. if(this.explain) {
  393. item.ques = {
  394. text:item.analysisContent
  395. }
  396. return;
  397. }
  398. } else if(item.type == 4) {
  399. console.log(item.jsonStr)
  400. item.ques = []
  401. item.current = 0;
  402. let ansArr = [];
  403. item.jsonStr.forEach((json,index) => {
  404. if(json.type == 1) {
  405. ansArr[index] = json.answerQuestion;
  406. } else if(json.type == 2) {
  407. json.optionsList.forEach(str => {
  408. str.optionsId = ''+str.optionsId;
  409. })
  410. let arr = json.answerQuestion.split(',');
  411. arr.forEach((a,i) => {
  412. arr[i] = ''+a;
  413. })
  414. ansArr[index] = arr
  415. } else if(json.type == 3) {
  416. ansArr[index] = json.answerQuestion;
  417. } else if(json.type == 5) {
  418. ansArr[index] = {
  419. text: '',
  420. imageList: []
  421. }
  422. json.ansText = {
  423. text: '',
  424. imageList: []
  425. }
  426. }
  427. })
  428. item.ans = ansArr
  429. if(this.explain) {
  430. item.ques = item.ans;
  431. }
  432. return;
  433. }
  434. item.ans = item.answerQuestion
  435. if(this.explain) {
  436. item.ques = item.ans;
  437. }
  438. } else {
  439. if(this.explain) {
  440. item.ques = item.ans;
  441. }
  442. }
  443. })
  444. this.questionList = res.data.data;
  445. console.log(this.questionList)
  446. })
  447. }
  448. },
  449. /**
  450. * @param {Object} e单选点击
  451. */
  452. radioSelect(optionsId,bindex) {
  453. if(this.questionList[bindex].ques) return;
  454. this.$set(this.questionList[bindex],'ques',optionsId)
  455. },
  456. examRecordEdit() {
  457. if(!this.isSubmit) {
  458. let number = 0;
  459. let score = 0;
  460. this.questionList.length && this.questionList.forEach((item,index) => {
  461. if(item.type == 1) {
  462. if(item.ques == item.ans) {
  463. score += item.score;
  464. number++
  465. }
  466. } else if(item.type == 2) {
  467. let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
  468. return item.ques[quesIndex] == item.ans[quesIndex]
  469. })
  470. if(isRight) {
  471. score += item.score;
  472. number++
  473. }
  474. } else if(item.type == 3) {
  475. if(item.ques == item.ans) {
  476. score += item.score;
  477. number++
  478. }
  479. }
  480. })
  481. this.$api.examRecordEdit({
  482. examId:this.id,
  483. goodsId:this.goodsId,
  484. recordId: this.recordId,
  485. rightQuestionNum:number,
  486. status:0,
  487. historyExamJson:JSON.stringify(this.questionList)
  488. }).then(res => {
  489. })
  490. }
  491. },
  492. /**
  493. * @param {Object} e单选点击
  494. */
  495. radioSelectChild(optionsId,ansIndex,bindex) {
  496. if(this.questionList[bindex].ques[ansIndex]) return;
  497. this.$set(this.questionList[bindex].ques,ansIndex,optionsId)
  498. },
  499. /**
  500. * @param {Object} 多选点击
  501. */
  502. checkboxSelect(optionsId,bindex,index) {
  503. this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
  504. },
  505. /**
  506. * @param {Object} 多选点击
  507. */
  508. checkboxSelectChild(bindex,ansIndex,childIndex) {
  509. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],'checked',!this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked)
  510. },
  511. /**
  512. * 提交数据
  513. */
  514. submit() {
  515. let score = 0; //计算总分
  516. let reportStatus = 0;
  517. let number = 0;
  518. let allScore = 0;
  519. let passScore = 0;
  520. this.questionList.forEach((item,index) => {
  521. passScore = item.passScore
  522. if(item.type == 1) {
  523. if(item.ques == item.ans) {
  524. score += item.score;
  525. number++
  526. }
  527. allScore += item.score
  528. } else if(item.type == 2) {
  529. let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
  530. return item.ques[quesIndex] == item.ans[quesIndex]
  531. })
  532. if(isRight) {
  533. score += item.score;
  534. number++
  535. }
  536. allScore += item.score
  537. } else if(item.type == 3) {
  538. if(item.ques == item.ans) {
  539. score += item.score;
  540. number++
  541. }
  542. allScore += item.score
  543. }
  544. })
  545. if(score >= passScore) {
  546. reportStatus = 1
  547. } else {
  548. reportStatus = 0
  549. }
  550. this.$api.examRecordEdit({
  551. examId:this.id,
  552. goodsId:this.goodsId,
  553. reportStatus:reportStatus,
  554. totalScore:allScore,
  555. recordId: this.recordId,
  556. rightQuestionNum:number,
  557. status:1,
  558. performance:score,
  559. historyExamJson:JSON.stringify(this.questionList)
  560. }).then(res => {
  561. this.isSubmit = true;
  562. if(res.data.code == 200) {
  563. uni.showToast({
  564. title: '交卷成功',
  565. duration: 2000,
  566. icon:'none'
  567. });
  568. setTimeout(() => {
  569. uni.redirectTo({
  570. url:'/pages2/bank/question_report?id='+this.recordId+'&examId='+this.id
  571. })
  572. },2000)
  573. }
  574. })
  575. },
  576. /**
  577. * @param {Object} 多选确认
  578. */
  579. checkboxSubmit(bindex) {
  580. if(this.questionList[bindex].ques) return;
  581. let arr = [];
  582. this.questionList[bindex].jsonStr.forEach(item => {
  583. if(item.checked) {
  584. arr.push(item.optionsId)
  585. }
  586. })
  587. this.$set(this.questionList[bindex],'ques',arr)
  588. },
  589. /**
  590. * @param {Object} 多选确认
  591. */
  592. checkboxSubmitChild(bindex,ansIndex) {
  593. if(this.questionList[bindex].ques[ansIndex]) return;
  594. let arr = [];
  595. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  596. if(item.checked) {
  597. arr.push(item.optionsId)
  598. }
  599. })
  600. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  601. },
  602. judgeSelect(index,bindex) {
  603. if(this.questionList[bindex].ques) return;
  604. this.$set(this.questionList[bindex],'ques',index+'')
  605. },
  606. judgeSelectChild(ansindex,childindex,bindex) {
  607. if(this.questionList[bindex].ques[ansindex]) return;
  608. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  609. },
  610. openFooterTab() {
  611. this.show = true;
  612. },
  613. hideDialog() {
  614. this.showDialog = false
  615. },
  616. changeIndex(index) {
  617. this.current = index
  618. },
  619. swiperChange(e) {
  620. this.current = e.detail.current;
  621. },
  622. deleteImg(imgIndex,bankIndex) {
  623. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  624. },
  625. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  626. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  627. },
  628. chooseImg(bankindex) {
  629. uni.chooseImage({
  630. count: 1, //默认9
  631. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  632. sourceType: ['album','camera'], //从相册选择
  633. success: (res) => {
  634. let self = this;
  635. // console.log(JSON.stringify(res.tempFilePaths));
  636. let img = res.tempFilePaths[0];
  637. uni.getImageInfo({
  638. src: img,
  639. success: async res => {
  640. let canvasWidth = res.width; //图片原始长宽
  641. let canvasHeight = res.height;
  642. if (canvasWidth > 1000 || canvasHeight > 1000) {
  643. uni.compressImage({
  644. src: img,
  645. quality: 75,
  646. width: '50%',
  647. height: '50%',
  648. success: async rest => {
  649. const dir = await self.uploadFile(rest.tempFilePath, 0);
  650. this.questionList[bankindex].ansText.imageList.push(dir)
  651. }
  652. });
  653. } else {
  654. const dir = await self.uploadFile(img, 0);
  655. this.questionList[bankindex].ansText.imageList.push(dir)
  656. }
  657. }
  658. });
  659. }
  660. })
  661. },
  662. chooseImgChild(bankindex,ansindex) {
  663. uni.chooseImage({
  664. count: 1, //默认9
  665. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  666. sourceType: ['album','camera'], //从相册选择
  667. success: (res) => {
  668. let self = this;
  669. // console.log(JSON.stringify(res.tempFilePaths));
  670. let img = res.tempFilePaths[0];
  671. uni.getImageInfo({
  672. src: img,
  673. success: async res => {
  674. let canvasWidth = res.width; //图片原始长宽
  675. let canvasHeight = res.height;
  676. if (canvasWidth > 1000 || canvasHeight > 1000) {
  677. uni.compressImage({
  678. src: img,
  679. quality: 75,
  680. width: '50%',
  681. height: '50%',
  682. success: async rest => {
  683. const dir = await self.uploadFile(rest.tempFilePath, 0);
  684. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  685. }
  686. });
  687. } else {
  688. const dir = await self.uploadFile(img, 0);
  689. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  690. }
  691. }
  692. });
  693. }
  694. })
  695. },
  696. uploadFile(options, int) {
  697. var self = this;
  698. return new Promise((resolve, reject) => {
  699. var data = {
  700. imageStatus: int
  701. };
  702. self.$api.aliyunpolicy(data).then(res => {
  703. console.log(res.data,6)
  704. if(res.data.code!=200){
  705. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  706. return
  707. }
  708. var ossToken = res.data.data.resultContent;
  709. if(ossToken.host==null||ossToken.host==undefined){
  710. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  711. return
  712. }
  713. uni.uploadFile({
  714. url: ossToken.host,
  715. name: 'file',
  716. filePath: options,
  717. fileType: 'image',
  718. header: {
  719. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  720. },
  721. formData: {
  722. key: ossToken.dir,
  723. OSSAccessKeyId: ossToken.accessid,
  724. policy: ossToken.policy,
  725. Signature: ossToken.signature,
  726. callback: ossToken.callback,
  727. success_action_status: 200
  728. },
  729. success: result => {
  730. if (result.statusCode === 200) {
  731. resolve(ossToken.dir);
  732. } else {
  733. uni.showToast({
  734. title: '上传失败',
  735. icon: 'none'
  736. });
  737. return;
  738. }
  739. },
  740. fail: error => {
  741. uni.showToast({
  742. title: '上传接口报错'+error,
  743. icon: 'none'
  744. });
  745. return;
  746. }
  747. });
  748. });
  749. });
  750. },
  751. submitAns(bankindex) {
  752. console.log(this.questionList[bankindex])
  753. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  754. uni.showToast({
  755. title: '请输入内容或上传图片',
  756. duration: 2000,
  757. icon:'none'
  758. });
  759. return
  760. }
  761. this.$set(this.questionList[bankindex],'ques',{
  762. imageList:this.questionList[bankindex].ansText.imageList,
  763. text:this.questionList[bankindex].ansText.text,
  764. })
  765. },
  766. submitAnsChild(bankindex,ansindex) {
  767. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  768. uni.showToast({
  769. title: '请输入内容或上传图片',
  770. duration: 2000,
  771. icon:'none'
  772. });
  773. return
  774. }
  775. this.$set(this.questionList[bankindex].ques,ansindex,{
  776. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  777. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  778. })
  779. },
  780. isRight(item,index) {
  781. //单选
  782. if(this.questionList[index].ques) {
  783. if(item.type == 1) {
  784. return this.questionList[index].ques == this.questionList[index].ans;
  785. //多选
  786. } else if(item.type == 2) {
  787. //每一项都相等
  788. return this.questionList[index].ques.every((item,i) => {
  789. console.log(item == this.questionList[index].ans[i])
  790. return item == this.questionList[index].ans[i];
  791. })
  792. //判断
  793. } else if(item.type == 3) {
  794. return this.questionList[index].ques == this.questionList[index].ans;
  795. } else {
  796. return false;
  797. }
  798. } else {
  799. return false;
  800. }
  801. },
  802. right(bankIndex,ansIndex,option) {
  803. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  804. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  805. return true
  806. } else {
  807. return false;
  808. }
  809. } else {
  810. return false;
  811. }
  812. },
  813. wrong(bankIndex,ansIndex,option) {
  814. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  815. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  816. return true;
  817. } else {
  818. return false;
  819. }
  820. } else {
  821. return false;
  822. }
  823. },
  824. isWrong(item,index) {
  825. if(this.questionList[index].ques) {
  826. //单选
  827. if(item.type == 1) {
  828. return this.questionList[index].ques != this.questionList[index].ans;
  829. //多选
  830. } else if(item.type == 2) {
  831. //每一项都相等
  832. return this.questionList[index].ques.some((item,i) => {
  833. return item != this.questionList[index].ans[i];
  834. })
  835. //判断
  836. } else if(item.type == 3) {
  837. return this.questionList[index].ques != this.questionList[index].ans;
  838. } else {
  839. return false;
  840. }
  841. } else {
  842. return false;
  843. }
  844. },
  845. tabSelect(index,bankindex) {
  846. this.$set(this.questionList[bankindex],'current',index)
  847. },
  848. }
  849. };
  850. </script>
  851. <style lang="scss" scoped>
  852. .swiper {
  853. width:100%;
  854. height:100vh;
  855. }
  856. .lisSty {
  857. margin-bottom: 16rpx;
  858. display: flex;
  859. .flex_auto {
  860. flex:1;
  861. }
  862. }
  863. .activeTI {
  864. vertical-align: middle;
  865. display: inline-block;
  866. border: 1rpx solid #eee;
  867. border-radius: 50rpx;
  868. height: 48rpx;
  869. line-height: 46rpx;
  870. text-align: center;
  871. width: 48rpx;
  872. margin-right: 15rpx;
  873. color: #666;
  874. font-size: 30rpx;
  875. &.right {
  876. color:#fff;
  877. background:green;
  878. }
  879. &.wrong {
  880. color:#fff;
  881. background:red;
  882. }
  883. &.checked {
  884. color:#fff;
  885. background:blue;
  886. }
  887. }
  888. .submit_checkbox {
  889. margin:20rpx auto;
  890. width: 526rpx;
  891. height: 80rpx;
  892. background: rgba(0, 122, 255, 1);
  893. color:#fff;
  894. text-align: center;
  895. line-height: 80rpx;
  896. font-size: 30rpx;
  897. border-radius: 40rpx;
  898. }
  899. .titles {
  900. overflow: hidden;
  901. margin-bottom: 24rpx;
  902. }
  903. .titBox {
  904. padding: 41rpx 25rpx 24rpx 25rpx;
  905. }
  906. .tabs {
  907. margin:10rpx;
  908. display: flex;
  909. .tab {
  910. margin:0 10rpx;
  911. width: 96rpx;
  912. height: 48rpx;
  913. line-height: 48rpx;
  914. text-align: center;
  915. color:#007AFF;
  916. font-size: 28rpx;
  917. border-radius: 16rpx;
  918. &.current {
  919. color:#fff;
  920. background: #007AFF;
  921. }
  922. }
  923. }
  924. .ans {
  925. margin:8rpx 8rpx 8rpx;
  926. .ans_input {
  927. border-radius: 16rpx;
  928. background:#fff;
  929. .top {
  930. border-bottom:1rpx solid #EEEEEE;
  931. padding: 16rpx;
  932. display: flex;
  933. align-items: center;
  934. .icon {
  935. margin-right:20rpx;
  936. width: 40rpx;
  937. height: 38rpx;
  938. }
  939. .progress {
  940. flex:1;
  941. }
  942. .submit {
  943. width: 168rpx;
  944. height: 48rpx;
  945. line-height: 48rpx;
  946. text-align: center;
  947. color:#fff;
  948. font-size: 30rpx;
  949. background: #007AFF;
  950. border-radius: 24rpx;
  951. }
  952. }
  953. .textarea {
  954. textarea {
  955. width:100%;
  956. height:287rpx;
  957. padding:10rpx;
  958. }
  959. }
  960. .imgs {
  961. overflow: hidden;
  962. display: flex;
  963. width:100%;
  964. .img {
  965. width: 104rpx;
  966. height: 104rpx;
  967. border-radius: 8rpx;
  968. position:relative;
  969. margin:20rpx;
  970. text {
  971. position:absolute;
  972. right:-15rpx;
  973. top:-15rpx;
  974. width:30rpx;
  975. height:30rpx;
  976. text-align: center;
  977. line-height: 30rpx;
  978. color:#fff;
  979. background:red;
  980. border-radius:50%;
  981. }
  982. image {
  983. width:100%;
  984. height:100%;
  985. }
  986. }
  987. }
  988. }
  989. .ans_submit {
  990. padding:16rpx;
  991. border-radius: 16rpx;
  992. background:#fff;
  993. .imgs {
  994. overflow: hidden;
  995. display: flex;
  996. width:100%;
  997. .img {
  998. width: 104rpx;
  999. height: 104rpx;
  1000. border-radius: 8rpx;
  1001. position:relative;
  1002. margin:20rpx;
  1003. image {
  1004. width:100%;
  1005. height:100%;
  1006. }
  1007. }
  1008. }
  1009. }
  1010. }
  1011. .firstLetter {
  1012. display: flex;
  1013. justify-content: space-between;
  1014. align-items: center;
  1015. margin-bottom: 30rpx;
  1016. .leftLetters {
  1017. display: flex;
  1018. align-items: center;
  1019. width: 220rpx;
  1020. .btnType {
  1021. padding: 5rpx 10rpx;
  1022. border: 1rpx solid #007aff;
  1023. border-radius: 10rpx;
  1024. background-color: rgba(0, 122, 255, 0.1);
  1025. font-size: 28rpx;
  1026. color: #007aff;
  1027. margin-right: 15rpx;
  1028. }
  1029. }
  1030. }
  1031. .popupView {
  1032. height: 100%;
  1033. padding-bottom: 100rpx;
  1034. .popupTops {
  1035. height: 77rpx;
  1036. border-bottom: 1rpx solid #eee;
  1037. text-align: center;
  1038. line-height: 77rpx;
  1039. font-size: 24rpx;
  1040. color: #999;
  1041. position: relative;
  1042. .topIcon {
  1043. position: absolute;
  1044. top: 10rpx;
  1045. left: 50%;
  1046. transform: translateX(-50%);
  1047. width: 80rpx;
  1048. height: 8rpx;
  1049. background-color: #999;
  1050. border-radius: 4rpx;
  1051. }
  1052. }
  1053. .popupContent {
  1054. }
  1055. }
  1056. .pageContent {
  1057. position:relative;
  1058. background-color: #eaeef1;
  1059. height: 100%;
  1060. overflow-y: scroll;
  1061. padding-top: 8rpx;
  1062. padding-bottom: 100rpx;
  1063. }
  1064. .pad_8 {
  1065. background-color: #fff;
  1066. margin: 0rpx 8rpx 8rpx;
  1067. border-radius: 16rpx;
  1068. }
  1069. .answer {
  1070. height: 80rpx;
  1071. line-height: 80rpx;
  1072. padding: 0rpx 24rpx;
  1073. display: flex;
  1074. align-items: center;
  1075. justify-content: space-between;
  1076. color: #666;
  1077. font-size: 30rpx;
  1078. }
  1079. .footer_btn {
  1080. background-color: #fff;
  1081. z-index: 10078;
  1082. position: fixed;
  1083. bottom: 0rpx;
  1084. display: flex;
  1085. align-items: center;
  1086. justify-content: space-between;
  1087. width: 100%;
  1088. height: 98rpx;
  1089. padding: 0rpx 38rpx;
  1090. border-top: 1rpx solid #eee;
  1091. .flex_center {
  1092. flex:1;
  1093. display: flex;
  1094. justify-content: center;
  1095. align-items: center;
  1096. flex-direction: column;
  1097. margin:0 200rpx;
  1098. font-size: 24rpx;
  1099. color: #999999;
  1100. .up-icon {
  1101. margin-bottom:18rpx;
  1102. width:100%;
  1103. display: flex;
  1104. justify-content: center;
  1105. image {
  1106. width:58rpx;
  1107. height:21rpx;
  1108. }
  1109. }
  1110. }
  1111. .collect {
  1112. visibility: hidden;
  1113. &.show {
  1114. visibility: visible;
  1115. }
  1116. >view {
  1117. display: flex;
  1118. flex-direction: column;
  1119. align-items: center;
  1120. justify-content: center;
  1121. image {
  1122. width:32rpx;
  1123. height:32rpx;
  1124. margin-bottom:6rpx;
  1125. }
  1126. view {
  1127. font-size: 24rpx;
  1128. color: #999999;
  1129. }
  1130. }
  1131. }
  1132. }
  1133. .boxSty {
  1134. padding: 44rpx 41rpx 0rpx;
  1135. }
  1136. .liListSty {
  1137. border:1rpx solid #EEEEEE;
  1138. width: 88rpx;
  1139. height: 88rpx;
  1140. border-radius: 32rpx;
  1141. text-align: center;
  1142. line-height: 88rpx;
  1143. color: #333;
  1144. font-size: 32rpx;
  1145. float: left;
  1146. margin: 20rpx 23rpx;
  1147. &.isRight {
  1148. border:1rpx solid #EEEEEE;
  1149. color:#fff;
  1150. background: green;
  1151. }
  1152. &.isWrong {
  1153. border:1rpx solid #EEEEEE;
  1154. color:#fff;
  1155. background: red;
  1156. }
  1157. }
  1158. .answerInfos {
  1159. padding: 25rpx 25rpx 25rpx 23rpx;
  1160. }
  1161. .answerTitle {
  1162. margin-bottom: 28rpx;
  1163. color: #666;
  1164. font-size: 30rpx;
  1165. }
  1166. .answerContent {
  1167. font-size: 30rpx;
  1168. color: #666;
  1169. }
  1170. .textChild {
  1171. display: inline-block;
  1172. vertical-align: middle;
  1173. }
  1174. .dialog {
  1175. position: fixed;
  1176. left:0;
  1177. top:0;
  1178. width:100%;
  1179. height:100%;
  1180. background-color: rgba(0,0,0,0.8);
  1181. display: flex;
  1182. flex-direction: column;
  1183. align-items: center;
  1184. justify-content: center;
  1185. z-index: 20000;
  1186. .text {
  1187. font-size: 32rpx;
  1188. color: #FFFFFF;
  1189. text-align: center;
  1190. }
  1191. .btn {
  1192. width: 242rpx;
  1193. height: 82rpx;
  1194. border: 2rpx solid #FFFFFF;
  1195. border-radius: 16rpx;
  1196. text-align: center;
  1197. line-height: 82rpx;
  1198. margin:41rpx auto;
  1199. color:#fff;
  1200. font-size: 32rpx;
  1201. }
  1202. }
  1203. </style>