examStart.vue 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842
  1. <template>
  2. <uni-row>
  3. <uni-col :span="5" style="margin-top: 1vh">
  4. <uni-card style="height: 92vh;">
  5. <l-divider color="#00a60d">
  6. <view style="font-size: 2vh;">题库名称</view>
  7. </l-divider>
  8. <view
  9. style="font-family: '微软雅黑' , serif;font-size: 2vh;color: #8c8c8c;height: 30px;text-align: center;padding:5px;">
  10. {{title}}
  11. </view>
  12. <l-divider color="#00a60d">
  13. <view style="font-size: 2vh;">题型</view>
  14. </l-divider>
  15. <radio-group>
  16. <label v-for="(item, index) in repositoryType" :key="item">
  17. <view>
  18. <view v-if=" item.type!==6" class="paperCss"
  19. :style="'border: #757575 solid 1px;background-color: '+(item.type === subjectType?'#b5aa09 ;':'#f9f9f9 ;')"
  20. @click="subjectTypeClick(item)">
  21. <view style="color: #000000; ">
  22. <uni-row>
  23. <uni-col :span="12">
  24. <strong style="font-size: 2vh;">{{subjectTypes[item.type-1]}}</strong>
  25. </uni-col>
  26. <uni-col :span="12">
  27. <view style="font-size: 2vh;">数量:{{item.num}}</view>
  28. </uni-col>
  29. </uni-row>
  30. </view>
  31. </view>
  32. </view>
  33. </label>
  34. </radio-group>
  35. <l-divider color="#b3b3b3">
  36. </l-divider>
  37. <button type="primary" style="margin-top: 2%;width: 92%;" @click="backPage"><view style="font-size: 2vh;">返回</view></button>
  38. </uni-card>
  39. </uni-col>
  40. <uni-col :span="15" style="margin-top: 1vh">
  41. <uni-card style="height: 92vh;">
  42. <scroll-view scroll-y="true" scroll-x="true" class="scroll-Y">
  43. <uni-section :title="subjectTypes[subjectType-1]+'、'+(subjectNum+(pageNo-1)*pageSize)" type="line"
  44. padding>
  45. <view id="scantronNodes">
  46. </view>
  47. <template v-if="scantron.type===1||scantron.type===3">
  48. <view>
  49. <l-divider color="#aaaa7f">
  50. </l-divider>
  51. </view>
  52. <view>
  53. <radio-group>
  54. <label v-for="(item, index) in scantron.answerList" :key="item">
  55. <view>
  56. <button @click="radioAdd(item,index,scantron)"
  57. :style="'margin-top: 1%;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
  58. style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
  59. </view>
  60. </label>
  61. </radio-group>
  62. </view>
  63. </template>
  64. <template v-if="scantron.type===2">
  65. <view>
  66. <l-divider color="#aaaa7f">
  67. </l-divider>
  68. </view>
  69. <view>
  70. <radio-group>
  71. <label v-for="(item, index) in scantron.answerList" :key="item.value">
  72. <view>
  73. <button @click="item.right=!item.right;radioAdd(item,index,scantron);"
  74. :style="'margin-top: 15px;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
  75. style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
  76. </view>
  77. </label>
  78. </radio-group>
  79. </view>
  80. </template>
  81. <template v-if="scantron.type===4">
  82. <view>
  83. <l-divider color="#aaaa7f">
  84. </l-divider>
  85. </view>
  86. <view>
  87. <view>
  88. <view class="uni-textarea"
  89. style="border: #8c8c8c solid 2px;border-radius: 5px;height: 20vh;">
  90. <textarea @blur="radioAdd(null,null,scantron)"
  91. v-model="scantron.subjectiveAnswer" placeholder-style="color:#c7c7c7"
  92. placeholder="请输入答案" />
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. <template v-if="scantron.type===5">
  98. <view>
  99. <l-divider color="#aaaa7f">
  100. </l-divider>
  101. </view>
  102. <view>
  103. <label v-for="(item, index) in scantron.answerList" :key="item.value">
  104. <view class="allceter"
  105. style="background-color: #e7f4ff; text-align: left;padding: 10px;margin-bottom: 10px;border: #2a7eeb solid 1px;border-radius: 5px;">
  106. <view style="display: inline-block;padding-left: 10px;">
  107. <strong style="font-size: 20px;color: #0072eb;">{{item.tag}}</strong>
  108. </view>
  109. <input @blur="radioAdd(item.blankcontent,item.tag,scantron)" class="uni-input"
  110. style="display: inline-block;background-color: white;" type="text"
  111. v-model="item.blankcontent" :placeholder="item.tag" />
  112. </view>
  113. </label>
  114. </view>
  115. </template>
  116. <template v-if="scantron.type===6">
  117. <view>
  118. <l-divider color="#aaaa7f">
  119. </l-divider>
  120. </view>
  121. <view class="" v-for="(combinationItem,index) in scantron.subQuestionList">
  122. <uni-card>
  123. <strong>{{subjectNum+'.'+combinationItem.questionIndex+'、'+combinationItem.typeName}}</strong>
  124. <view :id="'combinationItemNodes'+index" style="height: 45vh;">
  125. <!-- <rich-text :nodes="combinationItem.content"></rich-text> -->
  126. </view>
  127. <template v-if="combinationItem.type===1||combinationItem.type===3">
  128. <view>
  129. <l-divider color="#aaaa7f">
  130. </l-divider>
  131. </view>
  132. <view>
  133. <radio-group>
  134. <label v-for="(item, index0) in combinationItem.answerList" :key="item">
  135. <view>
  136. <button @click="radioAdd(item,index0,scantron,combinationItem)"
  137. :style="'margin-top: 15px;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
  138. style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
  139. </view>
  140. </label>
  141. </radio-group>
  142. </view>
  143. </template>
  144. <template v-if="combinationItem.type===2">
  145. <view>
  146. <l-divider color="#aaaa7f">
  147. </l-divider>
  148. </view>
  149. <view>
  150. <radio-group>
  151. <label v-for="(item, index) in combinationItem.answerList"
  152. :key="item.value">
  153. <view>
  154. <button
  155. @click="item.right=!item.right;radioAdd(item,index0,scantron,combinationItem);"
  156. :style="'margin-top: 15px;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
  157. style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
  158. </view>
  159. </label>
  160. </radio-group>
  161. </view>
  162. </template>
  163. <template v-if="combinationItem.type===4">
  164. <view>
  165. <l-divider color="#aaaa7f">
  166. </l-divider>
  167. </view>
  168. <view>
  169. <view>
  170. <view class="uni-textarea"
  171. style="border: #8c8c8c solid 2px;border-radius: 5px;height: 20vh;">
  172. <textarea v-model="combinationItem.subjectiveAnswer"
  173. placeholder-style="color:#c7c7c7" placeholder="请输入答案" />
  174. </view>
  175. </view>
  176. </view>
  177. </template>
  178. <template v-if="combinationItem.type===5">
  179. <view>
  180. <l-divider color="#aaaa7f">
  181. </l-divider>
  182. </view>
  183. <view>
  184. <label v-for="(item, index) in combinationItem.answerList"
  185. :key="item.value">
  186. <view class="allceter"
  187. style="background-color: #e7f4ff; text-align: left;padding: 10px;margin-bottom: 10px;border: #2a7eeb solid 1px;border-radius: 5px;">
  188. <view style="display: inline-block;padding-left: 10px;">
  189. <strong
  190. style="font-size: 20px;color: #0072eb;">{{item.tag}}</strong>
  191. </view>
  192. <input
  193. @blur="radioAdd(item.blankcontent,item.tag,scantron,combinationItem)"
  194. class="uni-input"
  195. style="display: inline-block;background-color: white;"
  196. type="text" v-model="item.blankcontent"
  197. :placeholder="item.tag" />
  198. </view>
  199. </label>
  200. </view>
  201. </template>
  202. <template v-if="combinationItem.type===7">
  203. <view style="height: 5vh;">
  204. <rich-text :nodes="combinationItem.content"></rich-text>
  205. </view>
  206. <view>
  207. <l-divider color="#aaaa7f">
  208. </l-divider>
  209. </view>
  210. <view style=" height: 500px;width: 700px;background-color: #ff3807;">
  211. <movable-area style="height: 500px;width: 700px;background-color: #8c8c8c;">
  212. <movable-view style="width: 50px;height: 50px;border:solid 1px black;"
  213. :x="x" :y="y">
  214. </movable-view>
  215. <movable-view
  216. style="width: 40px;height: 40px;background-color: #f90005;"
  217. direction="all" :x="x" :y="y" @change="onChange">
  218. text
  219. </movable-view>
  220. </movable-area>
  221. </view>
  222. </template>
  223. <template v-if="combinationItem.type===8">
  224. <view style="height: 5vh;">
  225. <rich-text :nodes="combinationItem.content"></rich-text>
  226. </view>
  227. <view>
  228. <l-divider color="#aaaa7f">
  229. </l-divider>
  230. </view>
  231. <view>
  232. <view style="height: 600px;width: 800;background-color: #8c8c8c;">
  233. <movable-area
  234. style="height: 100%;width: 100%;background-color: #8c8c8c;">
  235. <movable-view
  236. style="width: 50px;height: 50px;border:solid 1px black;" :x="95"
  237. :y="95">
  238. </movable-view>
  239. <movable-view
  240. style="width: 40px;height: 40px;background-color: #f90005;"
  241. direction="all" :x="x" :y="y" @change="onChange">
  242. text
  243. </movable-view>
  244. </movable-area>
  245. </view>
  246. </view>
  247. </template>
  248. </uni-card>
  249. </view>
  250. </template>
  251. <template v-if="scantron.type===7">
  252. <button @click="restart">重置</button>
  253. <view>
  254. <l-divider color="#aaaa7f">
  255. </l-divider>
  256. </view>
  257. <view style="height: 600px;width: 800;background-color: #ffffff;">
  258. <movable-area
  259. :style="`height: 500px;width: 700px;background-color: #8c8c8c;margin: auto;background-image: url('${drag[subjectNum].background.url}');background-size:${drag[subjectNum].background.width}px ${drag[subjectNum].background.height}px;background-repeat: no-repeat;`">
  260. <!-- <rich-text :nodes="scantron.content"></rich-text> -->
  261. <!-- <img v-if="drag.background.url!==''" :style="`width:${drag.background.width} px;height:${drag.background.height} px;`" :src="drag.background.url"/> -->
  262. <template v-for="item in drag[subjectNum].answer">
  263. <view
  264. :style="`position: absolute;width: ${item.width}px;height: ${item.height}px;border:solid 1px black;left:${item.x}px;top:${item.y}px;`">
  265. {{Number(item.id.replace('answer',''))+1}}
  266. </view>
  267. </template>
  268. <template v-for="item in drag[subjectNum].option">
  269. <movable-view v-if="mbvShow" :id="item.id" :disabled="!disabledDrag"
  270. :style="'width: '+item.width+'px;height: '+item.height+'px;background-color: '+item.backgroundColor+';'"
  271. direction="all" :x="item.x" :y="item.y" @mousedown="onMousedown(item)"
  272. @change="onChange">
  273. </movable-view>
  274. <movable-view v-if="!mbvShow" :id="item.id" :disabled="!disabledDrag"
  275. :style="'width: '+item.width+'px;height: '+item.height+'px;background-color: '+item.backgroundColor+';'"
  276. direction="all" :x="item.x" :y="item.y" @mousedown="onMousedown(item)"
  277. @change="onChange">
  278. </movable-view>
  279. </template>
  280. </movable-area>
  281. </view>
  282. </template>
  283. <template v-if="scantron.type===8">
  284. <view style="height: 5vh;">
  285. </view>
  286. <view>
  287. <l-divider color="#aaaa7f">
  288. </l-divider>
  289. </view>
  290. <view>
  291. <view
  292. style="height: 600px;width: 800px;background-color: #8c8c8c;margin: auto;padding-top: 50px;">
  293. <movable-area
  294. style="height: 550px;width: 700px;background-color: #f6f6f6;margin: auto;">
  295. <canvas canvas-id="lineCanvas" style="width: 700px; height: 500px;">
  296. <template v-for="(item,index) in connectionHtml">
  297. <view
  298. style="display: inline-block;margin-top: 30px;margin-left: 30px;margin-right: 70px;">
  299. <!-- <rich-text :nodes="item.innerHTML"></rich-text> -->
  300. <view v-for="(item0,index0) in item.children" :key="index">
  301. <view :id="'option'+index+'-'+(index0+1)"
  302. style="width: 90px;height: 100px;padding: 10px;padding-bottom:0 ;margin-bottom: 10px;border-radius: 5px;border: #007aff solid 1px;background-color: #e0eef9;overflow: hidden;">
  303. </view>
  304. </view>
  305. </view>
  306. </template>
  307. </canvas>
  308. </movable-area>
  309. </view>
  310. </view>
  311. </template>
  312. </uni-section>
  313. <view v-if="examObject.records[subjectNum-1].disable"
  314. style="position: absolute;top: 0;background-color:rgb(255, 255, 255,0) ;width: 100%;height: 140%;">
  315. </view>
  316. </scroll-view>
  317. <view style="height: 8vh;">
  318. <button :disabled="!disabledDrag" v-if="scantron.type!==1&&scantron.type!==3" type="primary"
  319. style="width: 10vh;display: inline-block;margin-right: 1%;" @click="answerConfirm"><view style="font-size: 2vh;">答案确认</view>
  320. </button>
  321. <button type="primary" style="width: 10vh;display: inline-block;"
  322. @click="answerInspect(3)"> <view style="font-size: 2vh;">答案解析</view>
  323. </button>
  324. </view>
  325. <scroll-view scroll-y="true" style="height: 22vh;border: #a7a7a7 solid 1px;border-radius: 10px;">
  326. <view style="padding: 1%;">
  327. <view style="height:20px;">
  328. <view v-if="answerAnalysis.youAnswerState===0" style="font-size: 20px;color: #00ff00;">
  329. <strong>恭喜你,做对了!</strong>
  330. </view>
  331. <view v-if="answerAnalysis.youAnswerState===1" style="font-size: 20px;color: #c10003;">
  332. <strong>很遗憾,做错了!</strong>
  333. </view>
  334. </view>
  335. <view style="font-family: '黑体';font-size: 20px;padding-top: 10px;">
  336. <strong>答案:</strong>
  337. </view>
  338. <view style="font-family: '楷体';font-size: 20px;padding-top: 10px;">
  339. {{"  "+answerAnalysis.answer}}
  340. </view>
  341. <view style="font-family: '黑体';font-size: 20px;padding-top: 10px;">
  342. <strong>解析:</strong>
  343. </view>
  344. <view v-if="answerAnalysis.analysis!==null"
  345. style="font-family: '楷体';font-size: 20px;padding-top: 10px;">
  346. {{"  "+answerAnalysis.analysis}}
  347. </view>
  348. </view>
  349. </scroll-view>
  350. <view style="height: 5vh;">
  351. <button type="primary" style="margin-top: 10px;width: 48%;display: inline-block;font-size: 100%;"
  352. @click="previousQuestion">上一题</button>
  353. <button type="primary" style="margin-left: 1%;margin-top: 10px;width: 48%;display: inline-block;font-size:100%;"
  354. @click="nextQuestion">下一题</button>
  355. </view>
  356. </uni-card>
  357. </uni-col>
  358. <uni-col :span="4" style="margin-top: 1vh">
  359. <uni-card style="height: 92vh;">
  360. <l-divider color="#8f960c" style="margin-top: 5%;">
  361. <view style="font-size: 2vh;">当前题型数量</view>
  362. </l-divider>
  363. <view
  364. style="font-family: '微软雅黑', serif;font-size: 1%;color: #000000;height: 30px;text-align: center;padding:1vh;font-size: 3vh;">
  365. <strong>共{{this.repository.num}}题</strong>
  366. </view>
  367. <l-divider color="#251e75">
  368. <view style="font-size: 2vh;">答题卡</view>
  369. </l-divider>
  370. <view>
  371. <scroll-view scroll-y="true" style="height: 50vh;">
  372. <label v-for="(item, index) in examObject.records" :key="item">
  373. <view style="display: inline-block;margin-left: 5px;" @mousedown="radioScantron(index+1)">
  374. <view>
  375. <button type="radio"
  376. :style="'width: 30px;height: 30px;padding:0px;color:#FFFFFF;font-size: 12px;text-align: center;background-color: '+(index+1 === subjectNum?'#b5aa09;':(this.examObject.records[index].isAnswer?'#18da59':'#007aff'))">{{index+1+(pageNo-1)*pageSize}}</button>
  377. </view>
  378. <view>
  379. {{item.level_dictText}}
  380. </view>
  381. </view>
  382. </label>
  383. </scroll-view>
  384. </view>
  385. <view >
  386. <view style="text-align: left;;align-items: center;font-size: 15px;width: 200px;display: flex;">
  387. 当前<input
  388. style="display: inline-block;width: 40px;border: #c1c1c1 solid 1px;border-radius: 3px;font-size: 2vh;padding-top: 3px;"
  389. v-model="writePageNo" type="number" min='1' max="100" @input='inspect'
  390. @blur=" pageReplace(writePageNo,pageSize,0)" />页
  391. </view>
  392. <view style="text-align: left;align-items: center;font-size: 15px;width: 200px;display: flex;">
  393. 每页
  394. <input
  395. style="display: inline-block;width: 40px;border: #c1c1c1 solid 1px;border-radius: 3px;font-size: 2vh;padding-top: 3px;"
  396. v-model="pageSize" type="number" @blur="writePageNo=1;pageReplace(1,pageSize,0)" />条
  397. </view>
  398. </view>
  399. <l-divider color="#251e75" />
  400. <view style="height: 12vh;">
  401. <button type="primary" style="margin-top: 1%;height: 5vh;" @click="previousPage" ><view style="font-size: 2vh;">上一页</view></button>
  402. <button type="primary" style="margin-top: 5%;height: 5vh;" @click="nextPage"><view style="font-size: 2vh;">下一页</view></button>
  403. </view>
  404. </uni-card>
  405. </uni-col>
  406. </uni-row>
  407. <uni-popup ref="message" type="message">
  408. <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
  409. </uni-popup>
  410. <uni-popup ref="inputDialog" type="dialog">
  411. <uni-popup-dialog ref="inputClose" title="提交试卷" @confirm="dialogInputConfirm">
  412. <view>
  413. <view>1、提交当前试卷后不可再次作答</view>
  414. <view>2、本试卷剩余时间不计入下一套</view>
  415. <view>3、最终试卷提交将结束考试</view>
  416. <view style="text-align: center;">确认提交?</view>
  417. </view>
  418. </uni-popup-dialog>
  419. </uni-popup>
  420. <uni-popup ref="cheat" type="dialog">
  421. <uni-popup-dialog style="width: 50vh;" ref="inputClose" title="作弊提醒">
  422. <view style="color: red;">
  423. <view>1、鼠标请勿点击窗口之外的地方</view>
  424. <view>2、如果不小心退出全屏,请按F11恢复到全屏</view>
  425. <view>3、鼠标多次点击窗口之外的地方将按作弊处理</view>
  426. </view>
  427. </uni-popup-dialog>
  428. </uni-popup>
  429. </template>
  430. <script>
  431. import {
  432. exit,
  433. request,
  434. getExamDetail,
  435. getCacheAnswer,
  436. submitExamPaper,
  437. getExamQueryById,
  438. getRepositoryById,
  439. getListQuestionByMode
  440. } from '../../examJs/examRequest';
  441. import screenfull from "screenfull";
  442. import {
  443. redirectTo,
  444. toExamInfo,
  445. toLogin
  446. } from '../../examJs/examRoute';
  447. export default {
  448. name: "examStart",
  449. data() {
  450. return {
  451. // 所有方块============拖拽
  452. drag: [],
  453. // 拖拽元素刷新
  454. mbvShow: true,
  455. // 拖拽的方块信息
  456. dragItem: {},
  457. // 拖拽位置记录
  458. subDrag: [],
  459. // 拖拽后动作未完成禁用
  460. disabledDrag: true,
  461. // ==================================
  462. // 连线===============================
  463. // 连线题内容页面展示
  464. connectionHtml: [],
  465. // 连线题中间存储
  466. connectionInfo: [],
  467. // 连线题连线内容保存
  468. connectionContentALL: [],
  469. // 连线绘制
  470. ctx: null,
  471. // 点击过程颜色
  472. clickColor: '0px 0px 5px 2px rgba(80, 85, 83, 0.7)',
  473. // 点击结束颜色
  474. connectionColor: ['#ffaa00', '#00ff7f', '#6ca7ff', '#1d00ff', '#aa00ff', '#ffff00', '#550000', '#ff0000'],
  475. // ==============================
  476. // 所有试卷和试题
  477. examObject: {},
  478. // ==========================================
  479. // 当前题库所有类型
  480. repositoryType: [],
  481. repository: '',
  482. subjectTypes: ['单选题', '多选题', '判断题', '简答题', '填空题', '组合题', '拖拽题', '连线题'],
  483. subjectType: 1,
  484. subjectNum: 1,
  485. pageNo: 1,
  486. pageSize: 5,
  487. writePageNo: 1,
  488. writePageSize: 5,
  489. title: '',
  490. answerAnalysis: {
  491. analysis: '这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析',
  492. answer: 'ABCD',
  493. youAnswerState: 0
  494. },
  495. // ===========================================
  496. // 当前题目
  497. examTopic: {},
  498. // 答题卡
  499. scantron: '',
  500. //选项
  501. answer: {},
  502. typeThree: '',
  503. userExamAnswers: [],
  504. user: {},
  505. // 拖动监听测试
  506. b: true,
  507. count: 0,
  508. canvasWidth: 300,
  509. canvasHeight: 300,
  510. // 用户当前考试
  511. userExamPaper: {},
  512. // 消息弹窗记录=================
  513. msgType: 'success',
  514. messageText: '这是一条成功提示',
  515. };
  516. },
  517. methods: {
  518. // 消息提示
  519. messageToggle(type, message) {
  520. this.msgType = type
  521. this.messageText = message
  522. this.$refs.message.open()
  523. },
  524. // 输入检查
  525. inspect() {
  526. this.pageNo = Number(this.pageNo)
  527. if (this.pageNo < 1) {
  528. this.pageNo = 1
  529. }
  530. },
  531. // 重置
  532. restart() {
  533. this.disabledDrag = true
  534. this.drag[this.subjectNum].answer = []
  535. this.drag[this.subjectNum].option = []
  536. let content = this.stringToHTML(this.scantron.content)
  537. console.log(content);
  538. for (var i = 0; i < content.children.length; i++) {
  539. let thisTop = content.children[i].style.top.toString().replace("px", "")
  540. let thisLeft = content.children[i].style.left.toString().replace("px", "")
  541. let thisWidth = content.children[i].style.width.toString().replace("px", "")
  542. let thisHeight = content.children[i].style.height.toString().replace("px", "")
  543. let thisBackgroundColor = content.children[i].style.backgroundColor
  544. let thisInnerHTML = content.children[i].innerHTML
  545. if (content.children[i].id.includes("option")) {
  546. this.drag[this.subjectNum].option.push({
  547. id: content.children[i].id,
  548. x: Number(thisLeft),
  549. y: Number(thisTop),
  550. old: {
  551. x: 0,
  552. y: 0,
  553. ax: Number(thisLeft),
  554. by: Number(thisTop)
  555. },
  556. // 只添加一次拖拽监听
  557. b: true,
  558. width: thisWidth,
  559. height: thisHeight,
  560. backgroundColor: thisBackgroundColor,
  561. innerHTML: thisInnerHTML
  562. })
  563. }
  564. if (content.children[i].id.includes("answer")) {
  565. this.drag[this.subjectNum].answer.push({
  566. id: content.children[i].id,
  567. x: Number(thisLeft),
  568. y: Number(thisTop),
  569. old: {
  570. x: 0,
  571. y: 0
  572. },
  573. width: thisWidth,
  574. height: thisHeight,
  575. backgroundColor: thisBackgroundColor
  576. })
  577. }
  578. }
  579. },
  580. // 上一题目
  581. previousQuestion() {
  582. if (this.subjectNum > 1) {
  583. this.radioScantron(--this.subjectNum)
  584. }
  585. },
  586. // 下一题目
  587. nextQuestion() {
  588. if (this.subjectNum < this.examObject.records.length) {
  589. // this.scantron = this.examObject.records[this.subjectNum]
  590. this.radioScantron(++this.subjectNum)
  591. }
  592. }, // 上一题目
  593. // 下一页
  594. previousPage() {
  595. if (this.pageNo > 1) {
  596. this.pageReplace(this.pageNo, this.pageSize, -1)
  597. } else {
  598. this.messageToggle('warn', "当前在第一页")
  599. }
  600. },
  601. // 下一页
  602. nextPage() {
  603. this.pageReplace(this.pageNo, this.pageSize, 1)
  604. },
  605. pageReplace(thisPageNo, thisPageSize, num) {
  606. this.drag = []
  607. thisPageNo = Number(thisPageNo) + Number(num)
  608. thisPageSize = Number(thisPageSize)
  609. num =
  610. getListQuestionByMode({
  611. mode: 3,
  612. pageNo: thisPageNo,
  613. pageSize: thisPageSize,
  614. questionType: this.subjectType,
  615. repositoryId: sessionStorage.getItem('repositoryId')
  616. }).then(data => {
  617. if (0 === data.data.result.records.length) {
  618. this.messageToggle('warn', "新页没有数据")
  619. return
  620. }
  621. this.pageNo = thisPageNo
  622. this.writePageNo = thisPageNo
  623. console.log(data);
  624. this.examObject = data.data.result
  625. this.scantron = this.examObject.records[0]
  626. this.radioScantron(1)
  627. })
  628. },
  629. // 答题卡单击题目
  630. radioScantron(value) {
  631. this.analysisBlank()
  632. document.getElementById('scantronNodes').innerHTML = ''
  633. this.subjectNum = value
  634. this.scantron = this.examObject.records[value - 1]
  635. console.log(this.scantron);
  636. if (this.scantron.type !== 7 && this.scantron.type !== 8) {
  637. document.getElementById('scantronNodes').innerHTML = this.scantron.content
  638. } else {
  639. console.log(this.scantron.content.split('%||||||||%')[0]);
  640. document.getElementById('scantronNodes').innerHTML = this.scantron.content.split('%||||||||%')[0]
  641. }
  642. let combination = setInterval(() => {
  643. if (this.scantron.type === 6) {
  644. for (var i = 0; i < this.scantron.subQuestionList.length; i++) {
  645. if (document.getElementById('combinationItemNodes' + i) === null) {
  646. console.log("加载中");
  647. break;
  648. }
  649. document.getElementById('combinationItemNodes' + i).innerHTML = this.scantron
  650. .subQuestionList[i].content
  651. }
  652. clearInterval(combination);
  653. }
  654. }, 10)
  655. // 拖拽加载
  656. if (this.scantron.type == 7) {
  657. this.mbvShow = !this.mbvShow
  658. this.disabledDrag = true
  659. console.log(this.drag[this.subjectNum]);
  660. if (this.drag[this.subjectNum] !== undefined) {
  661. setTimeout(() => {
  662. for (var i = 0; i < this.drag[this.subjectNum].option.length; i++) {
  663. let drags = this.drag[this.subjectNum].option[i]
  664. console.log(document.getElementById(drags.id));
  665. console.log(drags);
  666. document.getElementById(drags.id).innerHTML = drags.innerHTML
  667. }
  668. }, 10)
  669. return
  670. }
  671. this.drag[this.subjectNum] = {}
  672. this.drag[this.subjectNum].answer = []
  673. this.drag[this.subjectNum].option = []
  674. this.drag[this.subjectNum].background = {}
  675. let content = this.stringToHTML(this.scantron.content)
  676. for (var i = 0; i < content.children.length; i++) {
  677. console.log(content.children[i]);
  678. let thisTop = content.children[i].style.top.toString().replace("px", "")
  679. let thisLeft = content.children[i].style.left.toString().replace("px", "")
  680. let thisWidth = content.children[i].style.width.toString().replace("px", "")
  681. let thisHeight = content.children[i].style.height.toString().replace("px", "")
  682. let thisBackgroundColor = content.children[i].style.backgroundColor
  683. let thisInnerHTML = content.children[i].innerHTML
  684. if (content.children[i].id.includes("option")) {
  685. this.drag[this.subjectNum].option.push({
  686. id: content.children[i].id,
  687. x: Number(thisLeft),
  688. y: Number(thisTop),
  689. old: {
  690. x: 0,
  691. y: 0,
  692. ax: Number(thisLeft),
  693. by: Number(thisTop)
  694. },
  695. // 只添加一次拖拽监听
  696. b: true,
  697. width: thisWidth,
  698. height: thisHeight,
  699. backgroundColor: thisBackgroundColor,
  700. innerHTML: thisInnerHTML
  701. })
  702. }
  703. if (content.children[i].id.includes("answer")) {
  704. this.drag[this.subjectNum].answer.push({
  705. id: content.children[i].id,
  706. x: Number(thisLeft),
  707. y: Number(thisTop),
  708. old: {
  709. x: 0,
  710. y: 0
  711. },
  712. width: thisWidth,
  713. height: thisHeight,
  714. backgroundColor: thisBackgroundColor
  715. })
  716. }
  717. if (content.children[i].tagName === 'IMG') {
  718. this.drag[this.subjectNum].background.url = content.children[i].src
  719. this.drag[this.subjectNum].background.width = content.children[i].style.width.toString()
  720. .replace("px", "")
  721. this.drag[this.subjectNum].background.height = content.children[i].style.height.toString()
  722. .replace("px", "")
  723. }
  724. }
  725. console.log(this.drag[this.subjectNum].option.length);
  726. setTimeout(() => {
  727. for (var i = 0; i < this.drag[this.subjectNum].option.length; i++) {
  728. let drags = this.drag[this.subjectNum].option[i]
  729. console.log(document.getElementById(drags.id));
  730. document.getElementById(drags.id).innerHTML = drags.innerHTML
  731. }
  732. }, 10)
  733. }
  734. // 连线题添加监听
  735. if (this.scantron.type == 8) {
  736. this.connectionHtml = []
  737. let content = this.stringToHTML(this.scantron.content)
  738. for (var i = 0; i < content.children.length; i++) {
  739. let child = content.children[i]
  740. for (var j = 0; j < child.children.length; j++) {
  741. if (child.children[j].id !== undefined && child.children[j].id.includes("option")) {
  742. this.connectionHtml.push(child.children[j])
  743. }
  744. }
  745. }
  746. if (this.connectionContentALL[value] === undefined) {
  747. this.connectionContentALL[value] = []
  748. }
  749. this.connectionInfo = []
  750. setTimeout(() => {
  751. // 画内容
  752. this.drawLineWriteContent()
  753. // 画缓存线
  754. this.drawLineWrite(value)
  755. }, 100)
  756. for (var i = 0; i < this.connectionHtml.length; i++) {
  757. let option = this.connectionHtml[i]
  758. for (var j = 0; j < option.children.length; j++) {
  759. let ids = "option" + i + "-" + (j + 1)
  760. if (document.getElementById(ids) === null) {
  761. setTimeout(() => {
  762. let optionCol = document.getElementById(ids)
  763. optionCol.addEventListener("mousedown", (event) => {
  764. console.log(event);
  765. let id = event.currentTarget.id
  766. console.log(id);
  767. let colId = Number(id.replace('option', '').split('-')[0])
  768. let rowId = Number(id.replace('option', '').split('-')[1])
  769. let left = event.target.offsetLeft
  770. let right = Number(event.target.offsetLeft + event.target
  771. .offsetWidth)
  772. let top = Number(event.target.offsetTop + event.target
  773. .offsetHeight / 2)
  774. if (this.connectionInfo.length === this.connectionHtml.length &&
  775. colId === 0) {
  776. this.connectionContentALL[this.subjectNum].push(this
  777. .connectionInfo)
  778. this.radioAdd(this.connectionInfo, this
  779. .connectionInfo[0].id.replace('option', '').split('-')[
  780. 1], this.scantron)
  781. this.connectionInfo = []
  782. }
  783. let arr = []
  784. for (var i = 0; i < this.connectionContentALL[this.subjectNum]
  785. .length; i++) {
  786. let all = this.connectionContentALL[this.subjectNum][i]
  787. if (all[0].id !== id) {
  788. arr.push(this.connectionContentALL[this.subjectNum][i])
  789. }
  790. }
  791. this.connectionContentALL[this.subjectNum] = arr
  792. let infoLength = this.connectionInfo.length
  793. if (infoLength <= this.connectionHtml.length) {
  794. if (infoLength !== 0) {
  795. if (!this.isLine(id, this.subjectNum)) {
  796. this.messageToggle('error', "这个已经连过了")
  797. this.drawLineWrite(this.subjectNum)
  798. return
  799. }
  800. let last = this.connectionInfo[infoLength -
  801. 1]
  802. let lastId = Number(last.id.replace('option', '').split(
  803. '-')[0])
  804. if (lastId + 1 === colId) {
  805. this.connectionInfo.push({
  806. 'id': id,
  807. 'left': left,
  808. 'right': right,
  809. 'top': top
  810. })
  811. }
  812. if (lastId === colId && colId !== this.connectionHtml
  813. .length - 1) {
  814. this.connectionInfo[infoLength - 1] = {
  815. 'id': id,
  816. 'left': left,
  817. 'right': right,
  818. 'top': top
  819. }
  820. document.getElementById(ids).style.boxShadow = this
  821. .clickColor
  822. if (Number(last.id.replace('option', '').split(
  823. '-')[1]) === rowId &&
  824. this.connectionInfo.length === this.connectionHtml
  825. .length) {
  826. this.connectionContentALL[this.subjectNum].push(
  827. this.connectionInfo)
  828. console.log(this.connectionContentALL[this.scantron
  829. .sort]);
  830. this.radioAdd(this.connectionInfo, this
  831. .connectionInfo[0].id.replace('option', '')
  832. .split('-')[1], this.scantron)
  833. this.connectionInfo = []
  834. }
  835. } else if (colId === this.connectionHtml.length - 1) {
  836. this.connectionContentALL[this.subjectNum].push(
  837. this.connectionInfo)
  838. console.log(this.connectionContentALL[this.scantron
  839. .sort]);
  840. this.radioAdd(this.connectionInfo, this
  841. .connectionInfo[0].id.replace('option', '')
  842. .split('-')[1], this.scantron)
  843. this.connectionInfo = []
  844. }
  845. } else if (infoLength === 0) {
  846. if (colId === 0) {
  847. this.connectionInfo.push({
  848. 'id': id,
  849. 'left': left,
  850. 'right': right,
  851. 'top': top
  852. })
  853. console.log(document.getElementById(id + ''));
  854. document.getElementById(id + '').style.boxShadow = this
  855. .clickColor
  856. console.log(document.getElementById(id));
  857. }
  858. }
  859. }
  860. this.shadowClean()
  861. this.drawLineWrite(this.subjectNum)
  862. })
  863. }, 10)
  864. } else {
  865. setTimeout(() => {
  866. this.shadowClean()
  867. }, 10)
  868. }
  869. }
  870. }
  871. }
  872. },
  873. // 连线绘制
  874. drawLine(x1, y1, x2, y2, index) {
  875. this.ctx = uni.createCanvasContext('lineCanvas');
  876. this.ctx.beginPath();
  877. let color = this.connectionColor[index]
  878. if (index === -1) {
  879. color = '#000000'
  880. this.ctx.shadowColor = 'red';
  881. // 设置阴影的模糊级别
  882. this.ctx.setshadowBlur = 100;
  883. // 设置阴影的水平偏移
  884. this.ctx.shadowOffsetX = 1;
  885. // 设置阴影的垂直偏移
  886. this.ctx.shadowOffsetY = 1;
  887. } else {
  888. this.ctx.shadowColor = '#000000';
  889. this.ctx.setshadowBlur = 0;
  890. this.ctx.shadowOffsetX = 0;
  891. this.ctx.shadowOffsetY = 0;
  892. }
  893. this.ctx.setStrokeStyle(color)
  894. this.ctx.lineWidth = 3
  895. this.ctx.moveTo(x1, y1); // 开始点
  896. this.ctx.lineTo(x2, y2); // 结束点
  897. this.ctx.stroke(); // 绘制线条
  898. this.ctx.draw(true);
  899. },
  900. // 连线清理
  901. clearRect() {
  902. const canvas = uni.createCanvasContext('lineCanvas');
  903. // 使用clearRect方法清空整个画布
  904. canvas.clearRect(0, 0, 700, 500); // 这里的300x300是画布的宽高,应该与你的实际画布尺寸相匹配
  905. canvas.draw(true); // 调用draw方法将清空操作应用到画布上
  906. },
  907. // 阴影清理
  908. shadowClean() {
  909. for (var i = 0; i < this.connectionHtml.length; i++) {
  910. let option = this.connectionHtml[i]
  911. for (var j = 0; j < option.children.length; j++) {
  912. let ids = "option" + i + "-" + (j + 1)
  913. document.getElementById(ids).style.boxShadow = ''
  914. }
  915. }
  916. },
  917. isLine(id, value) {
  918. for (var i = 0; i < this.connectionContentALL[value].length; i++) {
  919. let option = this.connectionContentALL[value][i]
  920. for (var j = 0; j < option.length; j++) {
  921. let oldId = option[j].id
  922. if (oldId === id) {
  923. return false
  924. }
  925. }
  926. }
  927. return true
  928. },
  929. // 连线题画内容
  930. drawLineWriteContent() {
  931. for (var i = 0; i < this.connectionHtml.length; i++) {
  932. let option = this.connectionHtml[i]
  933. for (var j = 0; j < option.children.length; j++) {
  934. let ids = "option" + i + "-" + (j + 1)
  935. document.getElementById(ids).innerHTML = option.children[j].innerHTML
  936. }
  937. }
  938. }, // 连线画线
  939. drawLineWrite(value) {
  940. this.clearRect()
  941. if (this.connectionInfo.length >= 2) {
  942. for (var i = 0; i < this.connectionInfo.length - 1; i++) {
  943. let one = this.connectionInfo[i]
  944. let two = this.connectionInfo[i + 1]
  945. // box-shadow: ;
  946. document.getElementById(one.id).style.boxShadow = this.clickColor
  947. document.getElementById(two.id).style.boxShadow = this.clickColor
  948. this.drawLine(one.right, one.top, two.left, two.top, -1)
  949. }
  950. } else if (this.connectionInfo.length === 1) {
  951. document.getElementById(this.connectionInfo[0].id).style.boxShadow = this.clickColor
  952. }
  953. for (var i = 0; i < this.connectionContentALL[value].length; i++) {
  954. let option = this.connectionContentALL[value][i]
  955. for (var j = 0; j < option.length - 1; j++) {
  956. let one = option[j]
  957. let two = option[j + 1]
  958. document.getElementById(one.id).style.boxShadow = '0px 0px 5px 2px ' + this.connectionColor[i]
  959. document.getElementById(two.id).style.boxShadow = '0px 0px 5px 2px ' + this.connectionColor[i]
  960. this.drawLine(one.right, one.top, two.left, two.top, i)
  961. }
  962. }
  963. },
  964. // 字符转换html对象
  965. stringToHTML(str) {
  966. var dom = document.createElement('div');
  967. dom.innerHTML = str;
  968. return dom;
  969. },
  970. // 拖动位置固定
  971. tap(index, subX, subY) {
  972. let x = subX
  973. let y = subY
  974. this.drag[this.subjectNum].option[index].x = this.drag[this.subjectNum].option[index].old.x
  975. this.drag[this.subjectNum].option[index].y = this.drag[this.subjectNum].option[index].old.y
  976. this.$nextTick(function() {
  977. this.drag[this.subjectNum].option[index].x = x
  978. this.drag[this.subjectNum].option[index].y = y
  979. })
  980. },
  981. // 鼠标按下
  982. onMousedown(item) {
  983. console.log(this.drag[this.subjectNum].option.length);
  984. this.dragItem = item;
  985. this.count = 0
  986. },
  987. // 拖动监听
  988. onChange: function(e) {
  989. if (!this.disabledDrag) {
  990. return
  991. }
  992. let index = -1
  993. for (var j = 0; j < this.drag[this.subjectNum].option.length; j++) {
  994. let option = this.drag[this.subjectNum].option[j]
  995. if (option.id === this.dragItem.id) {
  996. index = j
  997. break;
  998. }
  999. }
  1000. this.drag[this.subjectNum].option[index].old.x = e.detail.x
  1001. this.drag[this.subjectNum].option[index].old.y = e.detail.y
  1002. let asda = (event) => {
  1003. document.removeEventListener('mouseup', asda)
  1004. this.disabledDrag = false
  1005. let bxs = true
  1006. let dragOne;
  1007. // 处理鼠标抬起事件
  1008. for (var i = 0; i < this.drag[this.subjectNum].answer.length; i++) {
  1009. let drag = this.drag[this.subjectNum].answer[i]
  1010. let x = drag.x
  1011. let y = drag.y
  1012. if (
  1013. (Number(this.drag[this.subjectNum].option[index].old.x) <= (Number(drag.x) + Number(
  1014. drag
  1015. .width))) &&
  1016. (Number(this.drag[this.subjectNum].option[index].old.x) + Number(this.drag[this
  1017. .subjectNum].option[index]
  1018. .width)) >= drag.x &&
  1019. (Number(this.drag[this.subjectNum].option[index].old.y) <= (Number(drag.y) + Number(
  1020. drag
  1021. .height))) &&
  1022. (Number(this.drag[this.subjectNum].option[index].old.y) + Number(this.drag[this
  1023. .subjectNum].option[index]
  1024. .height)) >= drag.y
  1025. ) {
  1026. for (var p = 0; p < this.drag[this.subjectNum].answer.length; p++) {
  1027. if (this.drag[this.subjectNum].answer[p].op !== undefined && this.drag[this
  1028. .subjectNum].answer[p].op === index) {
  1029. this.drag[this.subjectNum].answer[p].op = undefined
  1030. }
  1031. }
  1032. if (this.drag[this.subjectNum].answer[i].op !== undefined) {
  1033. this.tap(this.drag[this.subjectNum].answer[i].op, this.drag[this.subjectNum]
  1034. .option[this.drag[this.subjectNum].answer[i].op].old.ax, this.drag[this
  1035. .subjectNum]
  1036. .option[this.drag[this.subjectNum].answer[i].op].old.by);
  1037. this.drag[this.subjectNum].answer[i].op = index
  1038. } else {
  1039. this.drag[this.subjectNum].answer[i].op = index
  1040. }
  1041. this.tap(index, x, y);
  1042. dragOne = drag
  1043. bxs = false
  1044. break;
  1045. }
  1046. }
  1047. // console.log(this.drag[this.subjectNum].option[index]);
  1048. if (bxs) {
  1049. this.tap(index, this.drag[this.subjectNum].option[index].old.ax, this.drag[this.subjectNum]
  1050. .option[index].old.by);
  1051. }
  1052. setTimeout(() => {
  1053. // for (var i = 0; i < this.drag[this.subjectNum].option.length; i++) {
  1054. // let op = this.drag[this.subjectNum].option[i]
  1055. // for (var j = 0; j < this.drag[this.subjectNum].answer.length; j++) {
  1056. // let an = this.drag[this.subjectNum].answer[j]
  1057. // }
  1058. // }
  1059. if (dragOne !== undefined) {
  1060. this.radioAdd(this.dragItem, dragOne.id.replace("answer", ""), this.scantron)
  1061. }
  1062. this.disabledDrag = true
  1063. }, 700)
  1064. }
  1065. // if (this.drag[this.subjectNum].option[index].b) {
  1066. // this.drag[this.subjectNum].option[index].b = false
  1067. document.addEventListener('mouseup', asda);
  1068. // }
  1069. },
  1070. // 题目做答
  1071. radioAdd(value, index, scantron, combinationItem) {
  1072. index = index + ''
  1073. let qIndex = this.subjectNum + ""
  1074. let arr = []
  1075. this.examObject.records[this.subjectNum - 1].isAnswer = true
  1076. if (this.scantron.type === 1 || this.scantron.type === 3) {
  1077. for (var i = 0; i < scantron.answerList.length; i++) {
  1078. scantron.answerList[i].right = false
  1079. }
  1080. scantron.answerList[index].right = true
  1081. this.answerInspect()
  1082. for (var i = 0; i < this.userExamAnswers.length; i++) {
  1083. if (this.userExamAnswers[i].index !== qIndex) {
  1084. arr.push(this.userExamAnswers[i])
  1085. }
  1086. }
  1087. arr.push({
  1088. answerIndex: [index],
  1089. answers: [value.id],
  1090. index: qIndex,
  1091. questionType: this.scantronType
  1092. })
  1093. } else if (this.scantron.type === 2) {
  1094. let b = true
  1095. for (var i = 0; i < this.userExamAnswers.length; i++) {
  1096. if (this.userExamAnswers[i].index !== qIndex) {
  1097. arr.push(this.userExamAnswers[i])
  1098. } else {
  1099. b = false
  1100. let bc = true
  1101. let arrAnswer = []
  1102. let arrAnswerId = []
  1103. let num = this.userExamAnswers[i].answers.length;
  1104. for (var j = 0; j < num; j++) {
  1105. if (this.userExamAnswers[i].answerIndex[j] !== index) {
  1106. arrAnswer.push(this.userExamAnswers[i].answerIndex[j])
  1107. arrAnswerId.push(this.userExamAnswers[i].answers[j])
  1108. } else {
  1109. if (!value.right) {
  1110. bc = false
  1111. }
  1112. }
  1113. }
  1114. if (bc) {
  1115. arrAnswer.push(index)
  1116. arrAnswerId.push(value.id)
  1117. }
  1118. if (arrAnswer.length !== 0) {
  1119. arr.push({
  1120. answerIndex: arrAnswer,
  1121. answers: arrAnswerId,
  1122. index: qIndex,
  1123. questionType: this.scantron.type
  1124. })
  1125. } else {
  1126. this.examObject.records[this.subjectNum - 1].isAnswer = false
  1127. }
  1128. }
  1129. }
  1130. if (b) {
  1131. arr.push({
  1132. answerIndex: [index],
  1133. answers: [value.id],
  1134. index: qIndex,
  1135. questionType: this.scantronType
  1136. })
  1137. }
  1138. } else if (this.scantron.type === 4) {
  1139. for (var i = 0; i < this.userExamAnswers.length; i++) {
  1140. if (this.userExamAnswers[i].index !== qIndex) {
  1141. arr.push(this.userExamAnswers[i])
  1142. }
  1143. }
  1144. if (scantron.subjectiveAnswer === null || scantron.subjectiveAnswer === "") {
  1145. this.examObject.records[this.subjectNum - 1].isAnswer = false
  1146. }
  1147. arr.push({
  1148. subjectiveAnswer: scantron.subjectiveAnswer,
  1149. index: qIndex,
  1150. questionType: this.scantronType
  1151. })
  1152. } else if (this.scantron.type === 5) {
  1153. if (value === undefined) {
  1154. return
  1155. }
  1156. let b = true
  1157. for (var i = 0; i < this.userExamAnswers.length; i++) {
  1158. if (this.userExamAnswers[i].index !== qIndex) {
  1159. arr.push(this.userExamAnswers[i])
  1160. } else {
  1161. b = false
  1162. let bc = true
  1163. let arrAnswer = []
  1164. let blankAnswer = JSON.parse(this.userExamAnswers[i].blankAnswer)
  1165. let num = blankAnswer.length;
  1166. for (var j = 0; j < num; j++) {
  1167. if (blankAnswer[j].tag !== index) {
  1168. arrAnswer.push({
  1169. tag: blankAnswer[j].tag,
  1170. content: blankAnswer[j].content
  1171. })
  1172. } else {
  1173. bc = false
  1174. }
  1175. }
  1176. if (bc) {
  1177. arrAnswer.push({
  1178. tag: index,
  1179. content: value
  1180. })
  1181. }
  1182. if (arrAnswer.length !== 0) {
  1183. arr.push({
  1184. blankAnswer: JSON.stringify(arrAnswer),
  1185. index: qIndex,
  1186. questionType: this.scantronType
  1187. })
  1188. } else {
  1189. this.examObject.records[this.subjectNum - 1].isAnswer = false
  1190. }
  1191. }
  1192. }
  1193. if (b) {
  1194. if (value === null || value === "") {
  1195. this.examObject.records[this.subjectNum - 1].isAnswer = false
  1196. }
  1197. arr.push({
  1198. blankAnswer: JSON.stringify([{
  1199. tag: index,
  1200. content: value
  1201. }]),
  1202. index: qIndex,
  1203. questionType: this.scantronType
  1204. })
  1205. }
  1206. } else if (this.scantron.type === 6) {
  1207. qIndex = qIndex + "." + combinationItem.sort
  1208. if (combinationItem.questionType === 1 || combinationItem.questionType ===
  1209. 3) {
  1210. for (var j = 0; j < combinationItem.answerList.length; j++) {
  1211. combinationItem.answerList[j].right = false
  1212. }
  1213. combinationItem.answerList[index].right = true
  1214. for (var j = 0; j < this.userExamAnswers.length; j++) {
  1215. if (this.userExamAnswers[j].index !== qIndex) {
  1216. arr.push(this.userExamAnswers[j])
  1217. }
  1218. }
  1219. arr.push({
  1220. answerIndex: [index],
  1221. answers: [value.id],
  1222. index: qIndex,
  1223. questionType: combinationItem.questionType
  1224. })
  1225. } else if (combinationItem.questionType === 2) {
  1226. let b = true
  1227. for (var j = 0; j < this.userExamAnswers.length; j++) {
  1228. if (this.userExamAnswers[j].index !== qIndex) {
  1229. arr.push(this.userExamAnswers[j])
  1230. } else {
  1231. b = false
  1232. let bca = true
  1233. let arrAnswer = []
  1234. let arrAnswerId = []
  1235. let num = this.userExamAnswers[j].answers.length;
  1236. for (var k = 0; k < num; k++) {
  1237. if (this.userExamAnswers[j].answerIndex[k] !== index) {
  1238. arrAnswer.push(this.userExamAnswers[j].answerIndex[k])
  1239. arrAnswerId.push(this.userExamAnswers[j].answers[k])
  1240. } else {
  1241. if (!value.right) {
  1242. bca = false
  1243. }
  1244. }
  1245. }
  1246. if (bca) {
  1247. arrAnswer.push(index)
  1248. arrAnswerId.push(value.id)
  1249. }
  1250. if (arrAnswer.length !== 0) {
  1251. arr.push({
  1252. answerIndex: arrAnswer,
  1253. answers: arrAnswerId,
  1254. index: qIndex,
  1255. questionType: combinationItem.questionType
  1256. })
  1257. } else {
  1258. this.examObject.records[this.subjectNum - 1].question
  1259. .isAnswer =
  1260. false
  1261. }
  1262. }
  1263. }
  1264. if (b) {
  1265. arr.push({
  1266. answerIndex: [index],
  1267. answers: [value.id],
  1268. index: qIndex,
  1269. questionType: combinationItem.questionType
  1270. })
  1271. }
  1272. } else if (combinationItem.questionType === 4) {
  1273. for (var j = 0; j < this.userExamAnswers.length; j++) {
  1274. if (this.userExamAnswers[j].index !== qIndex) {
  1275. arr.push(this.userExamAnswers[j])
  1276. }
  1277. }
  1278. if (combinationItem.subjectiveAnswer === null || scantron.subQuestionList[
  1279. i].subjectiveAnswer === "") {
  1280. this.examObject.records[this.subjectNum - 1].isAnswer = false
  1281. }
  1282. arr.push({
  1283. subjectiveAnswer: combinationItem.subjectiveAnswer,
  1284. index: qIndex,
  1285. questionType: combinationItem.questionType
  1286. })
  1287. } else if (combinationItem.questionType === 5) {
  1288. if (value === undefined) {
  1289. return
  1290. }
  1291. let b = true
  1292. for (var j = 0; j < this.userExamAnswers.length; j++) {
  1293. if (this.userExamAnswers[j].index !== qIndex) {
  1294. arr.push(this.userExamAnswers[j])
  1295. } else {
  1296. b = false
  1297. let bc = true
  1298. let arrAnswer = []
  1299. let blankAnswer = JSON.parse(this.userExamAnswers[j].blankAnswer)
  1300. let num = blankAnswer.length;
  1301. for (var q = 0; q < num; q++) {
  1302. if (blankAnswer[q].tag !== index) {
  1303. arrAnswer.push({
  1304. tag: blankAnswer[q].tag,
  1305. content: blankAnswer[q].content
  1306. })
  1307. } else {
  1308. bc = false
  1309. }
  1310. }
  1311. if (bc) {
  1312. arrAnswer.push({
  1313. tag: index,
  1314. content: value
  1315. })
  1316. }
  1317. if (arrAnswer.length !== 0) {
  1318. arr.push({
  1319. blankAnswer: JSON.stringify(arrAnswer),
  1320. index: qIndex,
  1321. questionType: scantron.subQuestionList[i].questionType
  1322. })
  1323. } else {
  1324. this.examObject.records[this.subjectNum - 1].question
  1325. .isAnswer = false
  1326. }
  1327. }
  1328. }
  1329. if (b) {
  1330. if (value === null || value === "") {
  1331. this.examObject.records[this.subjectNum - 1].isAnswer = false
  1332. }
  1333. arr.push({
  1334. blankAnswer: JSON.stringify([{
  1335. tag: index,
  1336. content: value
  1337. }]),
  1338. index: qIndex,
  1339. questionType: scantron.subQuestionList[i].questionType
  1340. })
  1341. }
  1342. }
  1343. } else if (this.scantron.type === 7) {
  1344. if (value === undefined || this.count > 0) {
  1345. return
  1346. }
  1347. console.log(this.drag);
  1348. this.count++
  1349. index = (Number(index) + 1) + ""
  1350. let b = true
  1351. for (var i = 0; i < this.userExamAnswers.length; i++) {
  1352. if (this.userExamAnswers[i].index !== qIndex) {
  1353. arr.push(this.userExamAnswers[i])
  1354. } else {
  1355. b = false
  1356. let bc = true
  1357. let arrAnswer = []
  1358. let blankAnswer = JSON.parse(this.userExamAnswers[i].blankAnswer)
  1359. let num = blankAnswer.length;
  1360. for (var j = 0; j < num; j++) {
  1361. if (blankAnswer[j].tag !== index) {
  1362. arrAnswer.push({
  1363. tag: blankAnswer[j].tag,
  1364. content: blankAnswer[j].content
  1365. })
  1366. } else {
  1367. arrAnswer.push({
  1368. tag: index,
  1369. content: value.id
  1370. })
  1371. this.scantron.answerList[Number(index) - 1].blankcontent = value.id
  1372. bc = false
  1373. }
  1374. }
  1375. console.log(arrAnswer);
  1376. if (bc) {
  1377. arrAnswer.push({
  1378. tag: index,
  1379. content: value.id
  1380. })
  1381. this.scantron.answerList[Number(index) - 1].blankcontent = value.id
  1382. }
  1383. if (arrAnswer.length !== 0) {
  1384. arr.push({
  1385. blankAnswer: JSON.stringify(arrAnswer),
  1386. coordinates: JSON.stringify(this.drag[qIndex]),
  1387. index: qIndex,
  1388. questionType: this.scantronType
  1389. })
  1390. this.scantron.answerList[Number(index) - 1].blankcontent = value.id
  1391. } else {
  1392. this.examObject.records[this.subjectNum - 1].isAnswer = false
  1393. }
  1394. }
  1395. }
  1396. if (b) {
  1397. if (value === null || value === "") {
  1398. this.examObject.records[this.subjectNum - 1].isAnswer = false
  1399. }
  1400. arr.push({
  1401. blankAnswer: JSON.stringify([{
  1402. tag: index,
  1403. content: value.id
  1404. }]),
  1405. coordinates: JSON.stringify(this.drag[qIndex]),
  1406. index: qIndex,
  1407. questionType: this.scantronType
  1408. })
  1409. this.scantron.answerList[Number(index) - 1].blankcontent = value.id
  1410. }
  1411. } else if (this.scantron.type === 8) {
  1412. console.log(this.connectionContentALL[qIndex]);
  1413. let info = value
  1414. value = ""
  1415. for (var i = 0; i < info.length; i++) {
  1416. console.log(info);
  1417. value += info[i].id.replace('option', '').split('-')[1]
  1418. }
  1419. // connectingCoordinates
  1420. if (value === undefined) {
  1421. return
  1422. }
  1423. let b = true
  1424. console.log(this.userExamAnswers.length);
  1425. this.scantron.answerList[Number(index) - 1].blankcontent = value
  1426. for (var j = 0; j < this.userExamAnswers.length; j++) {
  1427. if (this.userExamAnswers[j].index !== qIndex) {
  1428. arr.push(this.userExamAnswers[j])
  1429. } else {
  1430. b = false
  1431. let bc = true
  1432. let arrAnswer = []
  1433. let blankAnswer = JSON.parse(this.userExamAnswers[j].blankAnswer)
  1434. let num = blankAnswer.length;
  1435. for (var q = 0; q < num; q++) {
  1436. if (blankAnswer[q].tag !== index) {
  1437. arrAnswer.push({
  1438. tag: blankAnswer[q].tag,
  1439. content: blankAnswer[q].content
  1440. })
  1441. } else {
  1442. console.log(value);
  1443. bc = false
  1444. }
  1445. }
  1446. if (bc) {
  1447. console.log(value);
  1448. arrAnswer.push({
  1449. tag: index,
  1450. content: value
  1451. })
  1452. }
  1453. if (arrAnswer.length !== 0) {
  1454. arr.push({
  1455. blankAnswer: JSON.stringify(arrAnswer),
  1456. index: qIndex,
  1457. coordinates: JSON.stringify(this.connectionContentALL[qIndex]),
  1458. questionType: this.scantronType
  1459. })
  1460. } else {
  1461. this.examObject.records[this.subjectNum - 1].isAnswer =
  1462. false
  1463. }
  1464. }
  1465. }
  1466. if (b) {
  1467. if (value === null || value === "") {
  1468. this.examObject.records[this.subjectNum - 1].isAnswer =
  1469. false
  1470. }
  1471. this.scantron.answerList[Number(index) - 1].blankcontent = value
  1472. arr.push({
  1473. blankAnswer: JSON.stringify([{
  1474. tag: index,
  1475. content: value
  1476. }]),
  1477. coordinates: JSON.stringify(this.connectionContentALL[qIndex]),
  1478. index: qIndex,
  1479. questionType: this.scantronType
  1480. })
  1481. }
  1482. }
  1483. this.userExamAnswers = arr
  1484. console.log(this.scantron.answerList[Number(index) - 1]);
  1485. console.log(this.userExamAnswers);
  1486. },
  1487. // 类型点击
  1488. subjectTypeClick(item) {
  1489. this.repository = item
  1490. this.pageNo = 1
  1491. setTimeout(() => {
  1492. this.drag = []
  1493. this.shadowClean()
  1494. this.clearRect()
  1495. this.connectionContentALL = []
  1496. }, 100)
  1497. getListQuestionByMode({
  1498. mode: 3,
  1499. pageNo: 1,
  1500. pageSize: this.pageSize,
  1501. questionType: item.type,
  1502. repositoryId: sessionStorage.getItem('repositoryId')
  1503. }).then(data => {
  1504. if (0 === data.data.result.total) {
  1505. this.messageToggle('warn', "该题型数量为空")
  1506. return
  1507. }
  1508. for (var i = 0; i < data.data.result.records.length; i++) {
  1509. data.data.result.records[i].disable = false
  1510. }
  1511. this.subjectType = item.type
  1512. this.examObject = data.data.result
  1513. console.log(this.examObject);
  1514. console.log(this.subjectNum);
  1515. this.scantron = this.examObject.records[0]
  1516. this.radioScantron(1)
  1517. })
  1518. },
  1519. // 答案确认
  1520. answerConfirm() {
  1521. this.answerInspect()
  1522. }, // 答案检查
  1523. answerInspect(state) {
  1524. console.log(this.examObject.records[this.subjectNum - 1]);
  1525. if (this.examObject.records[this.subjectNum - 1].disable) {
  1526. console.log("0");
  1527. return
  1528. }
  1529. this.analysisBlank()
  1530. this.answerAnalysis.youAnswerState = 1
  1531. if (this.scantron.type === 1 || this.scantron.type === 3) {
  1532. for (var i = 0; i < this.scantron.answerList.length; i++) {
  1533. if (this.scantron.answerList[i].isRight && this.scantron.answerList[i].right) {
  1534. this.answerAnalysis.youAnswerState = 0
  1535. }
  1536. if (this.scantron.answerList[i].isRight && !this.scantron.answerList[i].right) {
  1537. this.answerAnalysis.youAnswerState = 1
  1538. }
  1539. if (this.scantron.answerList[i].isRight) {
  1540. this.answerAnalysis.answer += this.scantron.answerList[i].tag
  1541. }
  1542. }
  1543. } else if (this.scantron.type === 5) {
  1544. if (!this.examObject.records[this.subjectNum - 1].answerOrder) {
  1545. console.log(this.scantron.answerList);
  1546. for (var i = 0; i < this.scantron.answerList.length; i++) {
  1547. this.answerAnalysis.youAnswerState = 1
  1548. for (var j = 0; j < this.scantron.answerList.length; j++) {
  1549. if (this.scantron.answerList[i].isRight) {
  1550. let arrAwn = this.scantron.answerList[i].content.split("||")
  1551. for (var a = 0; a < arrAwn.length; a++) {
  1552. if (arrAwn[a] === this.scantron.answerList[j].blankcontent) {
  1553. this.answerAnalysis.youAnswerState = 0
  1554. break
  1555. }
  1556. }
  1557. }
  1558. }
  1559. if (this.answerAnalysis.youAnswerState === 1) {
  1560. break
  1561. }
  1562. }
  1563. for (var i = 0; i < this.scantron.answerList.length; i++) {
  1564. if (this.scantron.answerList[i].isRight) {
  1565. this.answerAnalysis.answer += (i + 1) + "、" + this.scantron.answerList[i].content + ";"
  1566. }
  1567. }
  1568. } else {
  1569. for (var i = 0; i < this.scantron.answerList.length; i++) {
  1570. if (this.scantron.answerList[i].isRight) {
  1571. let arrAwn = this.scantron.answerList[i].content.split("||")
  1572. for (var a = 0; a < arrAwn.length; a++) {
  1573. if (arrAwn[a] === this.scantron.answerList[i].blankcontent) {
  1574. this.answerAnalysis.youAnswerState = 0
  1575. break
  1576. }
  1577. }
  1578. }
  1579. if (this.answerAnalysis.youAnswerState === 1) {
  1580. break
  1581. }
  1582. }
  1583. for (var i = 0; i < this.scantron.answerList.length; i++) {
  1584. if (this.scantron.answerList[i].isRight) {
  1585. this.answerAnalysis.answer += (i + 1) + "、" + this.scantron.answerList[i].content + ";"
  1586. }
  1587. }
  1588. }
  1589. } else if (this.scantron.type === 7 || this.scantron.type === 8) {
  1590. let a = 1
  1591. this.answerAnalysis.youAnswerState = 0
  1592. console.log(this.scantron.answerList);
  1593. for (var i = 0; i < this.scantron.answerList.length; i++) {
  1594. let a = 1
  1595. for (var j = 0; j < this.scantron.answerList.length; j++) {
  1596. if (this.scantron.answerList[i].isRight) {
  1597. if (this.scantron.answerList[i].content === this.scantron.answerList[j].blankcontent) {
  1598. a = 0
  1599. }
  1600. }
  1601. }
  1602. console.log(this.scantron.answerList);
  1603. if (this.scantron.answerList[i].isRight) {
  1604. this.answerAnalysis.answer += (i + 1) + "、" + this.scantron.answerList[i].content + ";"
  1605. }
  1606. if (a === 1) {
  1607. this.answerAnalysis.youAnswerState = 1
  1608. }
  1609. }
  1610. }
  1611. if (state === 3) {
  1612. this.answerAnalysis.youAnswerState = state
  1613. }
  1614. this.answerAnalysis.analysis = this.scantron.analysis
  1615. this.examObject.records[this.subjectNum - 1].disable = true
  1616. },
  1617. // 解析置空
  1618. analysisBlank() {
  1619. this.answerAnalysis.analysis = ''
  1620. this.answerAnalysis.answer = ''
  1621. this.answerAnalysis.youAnswerState = -1
  1622. },
  1623. // 返回
  1624. backPage() {
  1625. toExamInfo()
  1626. }
  1627. },
  1628. mounted() {
  1629. this.user = JSON.parse(sessionStorage.getItem("user"))
  1630. let examId = sessionStorage.getItem('repositoryId')
  1631. getRepositoryById({
  1632. 'id': examId,
  1633. 't': new Date().toString()
  1634. }).then(data => {
  1635. if (data.data.code !== 200) {
  1636. sessionStorage.removeItem('examId')
  1637. toLogin()
  1638. }
  1639. this.repositoryType = data.data.result.questionDTOList
  1640. this.subjectTypeClick(this.repositoryType[0])
  1641. console.log(this.repositoryType);
  1642. this.title = data.data.result.title
  1643. })
  1644. }
  1645. }
  1646. </script>
  1647. <style scoped>
  1648. .svg-container {
  1649. width: 100%;
  1650. height: 100%;
  1651. overflow: hidden;
  1652. position: runiative;
  1653. }
  1654. svg {
  1655. display: block;
  1656. width: 100%;
  1657. height: 100%;
  1658. }
  1659. .scroll-Y {
  1660. height: 50vh;
  1661. }
  1662. .allceter {
  1663. display: flex;
  1664. align-items: center;
  1665. height: 50px;
  1666. }
  1667. .scroll-view_H {
  1668. white-space: nowrap;
  1669. width: 100%;
  1670. }
  1671. .scroll-view-item {
  1672. height: 300rpx;
  1673. line-height: 300rpx;
  1674. text-align: center;
  1675. font-size: 36rpx;
  1676. }
  1677. .scroll-view-item_H {
  1678. display: inline-block;
  1679. width: 100%;
  1680. height: 300rpx;
  1681. line-height: 300rpx;
  1682. text-align: center;
  1683. font-size: 36rpx;
  1684. }
  1685. div {
  1686. margin: 0;
  1687. padding: 0;
  1688. }
  1689. /* CSS 预设*/
  1690. * {
  1691. margin: 0;
  1692. padding: 0;
  1693. }
  1694. a {
  1695. text-decoration: none;
  1696. outline: none;
  1697. }
  1698. body a {
  1699. outline: none;
  1700. blr: expression(this.onFocus=this.blur());
  1701. }
  1702. .uni-input {
  1703. padding-left: 20px;
  1704. border: 1rpx solid #5bb4ee;
  1705. height: 50px;
  1706. margin-left: 10px;
  1707. color: #000000;
  1708. width: 90%;
  1709. display: flex;
  1710. justify-content: center;
  1711. align-items: center;
  1712. }
  1713. img {
  1714. border: none;
  1715. }
  1716. .dialog-text {
  1717. font-size: 14px;
  1718. color: #333;
  1719. }
  1720. .paperCss {
  1721. width: 85%;
  1722. border-radius: 5px;
  1723. padding: 1vh;
  1724. margin-top: 1vh;
  1725. font-size: 15px;
  1726. text-align: left;
  1727. }
  1728. </style>