123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842 |
- <template>
- <uni-row>
- <uni-col :span="5" style="margin-top: 1vh">
- <uni-card style="height: 92vh;">
- <l-divider color="#00a60d">
- <view style="font-size: 2vh;">题库名称</view>
- </l-divider>
- <view
- style="font-family: '微软雅黑' , serif;font-size: 2vh;color: #8c8c8c;height: 30px;text-align: center;padding:5px;">
- {{title}}
- </view>
- <l-divider color="#00a60d">
- <view style="font-size: 2vh;">题型</view>
- </l-divider>
- <radio-group>
- <label v-for="(item, index) in repositoryType" :key="item">
- <view>
- <view v-if=" item.type!==6" class="paperCss"
- :style="'border: #757575 solid 1px;background-color: '+(item.type === subjectType?'#b5aa09 ;':'#f9f9f9 ;')"
- @click="subjectTypeClick(item)">
- <view style="color: #000000; ">
- <uni-row>
- <uni-col :span="12">
- <strong style="font-size: 2vh;">{{subjectTypes[item.type-1]}}</strong>
- </uni-col>
- <uni-col :span="12">
- <view style="font-size: 2vh;">数量:{{item.num}}</view>
- </uni-col>
- </uni-row>
- </view>
- </view>
- </view>
- </label>
- </radio-group>
- <l-divider color="#b3b3b3">
- </l-divider>
- <button type="primary" style="margin-top: 2%;width: 92%;" @click="backPage"><view style="font-size: 2vh;">返回</view></button>
- </uni-card>
- </uni-col>
- <uni-col :span="15" style="margin-top: 1vh">
- <uni-card style="height: 92vh;">
- <scroll-view scroll-y="true" scroll-x="true" class="scroll-Y">
- <uni-section :title="subjectTypes[subjectType-1]+'、'+(subjectNum+(pageNo-1)*pageSize)" type="line"
- padding>
- <view id="scantronNodes">
- </view>
- <template v-if="scantron.type===1||scantron.type===3">
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view>
- <radio-group>
- <label v-for="(item, index) in scantron.answerList" :key="item">
- <view>
- <button @click="radioAdd(item,index,scantron)"
- :style="'margin-top: 1%;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
- style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
- </view>
- </label>
- </radio-group>
- </view>
- </template>
- <template v-if="scantron.type===2">
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view>
- <radio-group>
- <label v-for="(item, index) in scantron.answerList" :key="item.value">
- <view>
- <button @click="item.right=!item.right;radioAdd(item,index,scantron);"
- :style="'margin-top: 15px;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
- style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
- </view>
- </label>
- </radio-group>
- </view>
- </template>
- <template v-if="scantron.type===4">
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view>
- <view>
- <view class="uni-textarea"
- style="border: #8c8c8c solid 2px;border-radius: 5px;height: 20vh;">
- <textarea @blur="radioAdd(null,null,scantron)"
- v-model="scantron.subjectiveAnswer" placeholder-style="color:#c7c7c7"
- placeholder="请输入答案" />
- </view>
- </view>
- </view>
- </template>
- <template v-if="scantron.type===5">
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view>
- <label v-for="(item, index) in scantron.answerList" :key="item.value">
- <view class="allceter"
- style="background-color: #e7f4ff; text-align: left;padding: 10px;margin-bottom: 10px;border: #2a7eeb solid 1px;border-radius: 5px;">
- <view style="display: inline-block;padding-left: 10px;">
- <strong style="font-size: 20px;color: #0072eb;">{{item.tag}}</strong>
- </view>
- <input @blur="radioAdd(item.blankcontent,item.tag,scantron)" class="uni-input"
- style="display: inline-block;background-color: white;" type="text"
- v-model="item.blankcontent" :placeholder="item.tag" />
- </view>
- </label>
- </view>
- </template>
- <template v-if="scantron.type===6">
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view class="" v-for="(combinationItem,index) in scantron.subQuestionList">
- <uni-card>
- <strong>{{subjectNum+'.'+combinationItem.questionIndex+'、'+combinationItem.typeName}}</strong>
- <view :id="'combinationItemNodes'+index" style="height: 45vh;">
- <!-- <rich-text :nodes="combinationItem.content"></rich-text> -->
- </view>
- <template v-if="combinationItem.type===1||combinationItem.type===3">
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view>
- <radio-group>
- <label v-for="(item, index0) in combinationItem.answerList" :key="item">
- <view>
- <button @click="radioAdd(item,index0,scantron,combinationItem)"
- :style="'margin-top: 15px;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
- style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
- </view>
- </label>
- </radio-group>
- </view>
- </template>
- <template v-if="combinationItem.type===2">
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view>
- <radio-group>
- <label v-for="(item, index) in combinationItem.answerList"
- :key="item.value">
- <view>
- <button
- @click="item.right=!item.right;radioAdd(item,index0,scantron,combinationItem);"
- :style="'margin-top: 15px;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
- style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
- </view>
- </label>
- </radio-group>
- </view>
- </template>
- <template v-if="combinationItem.type===4">
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view>
- <view>
- <view class="uni-textarea"
- style="border: #8c8c8c solid 2px;border-radius: 5px;height: 20vh;">
- <textarea v-model="combinationItem.subjectiveAnswer"
- placeholder-style="color:#c7c7c7" placeholder="请输入答案" />
- </view>
- </view>
- </view>
- </template>
- <template v-if="combinationItem.type===5">
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view>
- <label v-for="(item, index) in combinationItem.answerList"
- :key="item.value">
- <view class="allceter"
- style="background-color: #e7f4ff; text-align: left;padding: 10px;margin-bottom: 10px;border: #2a7eeb solid 1px;border-radius: 5px;">
- <view style="display: inline-block;padding-left: 10px;">
- <strong
- style="font-size: 20px;color: #0072eb;">{{item.tag}}</strong>
- </view>
- <input
- @blur="radioAdd(item.blankcontent,item.tag,scantron,combinationItem)"
- class="uni-input"
- style="display: inline-block;background-color: white;"
- type="text" v-model="item.blankcontent"
- :placeholder="item.tag" />
- </view>
- </label>
- </view>
- </template>
- <template v-if="combinationItem.type===7">
- <view style="height: 5vh;">
- <rich-text :nodes="combinationItem.content"></rich-text>
- </view>
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view style=" height: 500px;width: 700px;background-color: #ff3807;">
- <movable-area style="height: 500px;width: 700px;background-color: #8c8c8c;">
- <movable-view style="width: 50px;height: 50px;border:solid 1px black;"
- :x="x" :y="y">
- </movable-view>
- <movable-view
- style="width: 40px;height: 40px;background-color: #f90005;"
- direction="all" :x="x" :y="y" @change="onChange">
- text
- </movable-view>
- </movable-area>
- </view>
- </template>
- <template v-if="combinationItem.type===8">
- <view style="height: 5vh;">
- <rich-text :nodes="combinationItem.content"></rich-text>
- </view>
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view>
- <view style="height: 600px;width: 800;background-color: #8c8c8c;">
- <movable-area
- style="height: 100%;width: 100%;background-color: #8c8c8c;">
- <movable-view
- style="width: 50px;height: 50px;border:solid 1px black;" :x="95"
- :y="95">
- </movable-view>
- <movable-view
- style="width: 40px;height: 40px;background-color: #f90005;"
- direction="all" :x="x" :y="y" @change="onChange">
- text
- </movable-view>
- </movable-area>
- </view>
- </view>
- </template>
- </uni-card>
- </view>
- </template>
- <template v-if="scantron.type===7">
- <button @click="restart">重置</button>
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view style="height: 600px;width: 800;background-color: #ffffff;">
- <movable-area
- :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;`">
- <!-- <rich-text :nodes="scantron.content"></rich-text> -->
- <!-- <img v-if="drag.background.url!==''" :style="`width:${drag.background.width} px;height:${drag.background.height} px;`" :src="drag.background.url"/> -->
- <template v-for="item in drag[subjectNum].answer">
- <view
- :style="`position: absolute;width: ${item.width}px;height: ${item.height}px;border:solid 1px black;left:${item.x}px;top:${item.y}px;`">
- {{Number(item.id.replace('answer',''))+1}}
- </view>
- </template>
- <template v-for="item in drag[subjectNum].option">
- <movable-view v-if="mbvShow" :id="item.id" :disabled="!disabledDrag"
- :style="'width: '+item.width+'px;height: '+item.height+'px;background-color: '+item.backgroundColor+';'"
- direction="all" :x="item.x" :y="item.y" @mousedown="onMousedown(item)"
- @change="onChange">
- </movable-view>
- <movable-view v-if="!mbvShow" :id="item.id" :disabled="!disabledDrag"
- :style="'width: '+item.width+'px;height: '+item.height+'px;background-color: '+item.backgroundColor+';'"
- direction="all" :x="item.x" :y="item.y" @mousedown="onMousedown(item)"
- @change="onChange">
- </movable-view>
- </template>
- </movable-area>
- </view>
- </template>
- <template v-if="scantron.type===8">
- <view style="height: 5vh;">
- </view>
- <view>
- <l-divider color="#aaaa7f">
- </l-divider>
- </view>
- <view>
- <view
- style="height: 600px;width: 800px;background-color: #8c8c8c;margin: auto;padding-top: 50px;">
- <movable-area
- style="height: 550px;width: 700px;background-color: #f6f6f6;margin: auto;">
- <canvas canvas-id="lineCanvas" style="width: 700px; height: 500px;">
- <template v-for="(item,index) in connectionHtml">
- <view
- style="display: inline-block;margin-top: 30px;margin-left: 30px;margin-right: 70px;">
- <!-- <rich-text :nodes="item.innerHTML"></rich-text> -->
- <view v-for="(item0,index0) in item.children" :key="index">
- <view :id="'option'+index+'-'+(index0+1)"
- 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;">
- </view>
- </view>
- </view>
- </template>
- </canvas>
- </movable-area>
- </view>
- </view>
- </template>
- </uni-section>
- <view v-if="examObject.records[subjectNum-1].disable"
- style="position: absolute;top: 0;background-color:rgb(255, 255, 255,0) ;width: 100%;height: 140%;">
- </view>
- </scroll-view>
- <view style="height: 8vh;">
- <button :disabled="!disabledDrag" v-if="scantron.type!==1&&scantron.type!==3" type="primary"
- style="width: 10vh;display: inline-block;margin-right: 1%;" @click="answerConfirm"><view style="font-size: 2vh;">答案确认</view>
- </button>
- <button type="primary" style="width: 10vh;display: inline-block;"
- @click="answerInspect(3)"> <view style="font-size: 2vh;">答案解析</view>
- </button>
- </view>
- <scroll-view scroll-y="true" style="height: 22vh;border: #a7a7a7 solid 1px;border-radius: 10px;">
- <view style="padding: 1%;">
- <view style="height:20px;">
- <view v-if="answerAnalysis.youAnswerState===0" style="font-size: 20px;color: #00ff00;">
- <strong>恭喜你,做对了!</strong>
- </view>
- <view v-if="answerAnalysis.youAnswerState===1" style="font-size: 20px;color: #c10003;">
- <strong>很遗憾,做错了!</strong>
- </view>
- </view>
- <view style="font-family: '黑体';font-size: 20px;padding-top: 10px;">
- <strong>答案:</strong>
- </view>
- <view style="font-family: '楷体';font-size: 20px;padding-top: 10px;">
- {{" "+answerAnalysis.answer}}
- </view>
- <view style="font-family: '黑体';font-size: 20px;padding-top: 10px;">
- <strong>解析:</strong>
- </view>
- <view v-if="answerAnalysis.analysis!==null"
- style="font-family: '楷体';font-size: 20px;padding-top: 10px;">
- {{" "+answerAnalysis.analysis}}
- </view>
- </view>
- </scroll-view>
- <view style="height: 5vh;">
- <button type="primary" style="margin-top: 10px;width: 48%;display: inline-block;font-size: 100%;"
- @click="previousQuestion">上一题</button>
- <button type="primary" style="margin-left: 1%;margin-top: 10px;width: 48%;display: inline-block;font-size:100%;"
- @click="nextQuestion">下一题</button>
- </view>
- </uni-card>
- </uni-col>
- <uni-col :span="4" style="margin-top: 1vh">
- <uni-card style="height: 92vh;">
- <l-divider color="#8f960c" style="margin-top: 5%;">
- <view style="font-size: 2vh;">当前题型数量</view>
- </l-divider>
- <view
- style="font-family: '微软雅黑', serif;font-size: 1%;color: #000000;height: 30px;text-align: center;padding:1vh;font-size: 3vh;">
- <strong>共{{this.repository.num}}题</strong>
- </view>
- <l-divider color="#251e75">
- <view style="font-size: 2vh;">答题卡</view>
- </l-divider>
- <view>
- <scroll-view scroll-y="true" style="height: 50vh;">
- <label v-for="(item, index) in examObject.records" :key="item">
- <view style="display: inline-block;margin-left: 5px;" @mousedown="radioScantron(index+1)">
- <view>
- <button type="radio"
- :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>
- </view>
- <view>
- {{item.level_dictText}}
- </view>
- </view>
- </label>
- </scroll-view>
- </view>
- <view >
- <view style="text-align: left;;align-items: center;font-size: 15px;width: 200px;display: flex;">
- 当前<input
- style="display: inline-block;width: 40px;border: #c1c1c1 solid 1px;border-radius: 3px;font-size: 2vh;padding-top: 3px;"
- v-model="writePageNo" type="number" min='1' max="100" @input='inspect'
- @blur=" pageReplace(writePageNo,pageSize,0)" />页
- </view>
- <view style="text-align: left;align-items: center;font-size: 15px;width: 200px;display: flex;">
- 每页
- <input
- style="display: inline-block;width: 40px;border: #c1c1c1 solid 1px;border-radius: 3px;font-size: 2vh;padding-top: 3px;"
- v-model="pageSize" type="number" @blur="writePageNo=1;pageReplace(1,pageSize,0)" />条
- </view>
- </view>
- <l-divider color="#251e75" />
- <view style="height: 12vh;">
- <button type="primary" style="margin-top: 1%;height: 5vh;" @click="previousPage" ><view style="font-size: 2vh;">上一页</view></button>
- <button type="primary" style="margin-top: 5%;height: 5vh;" @click="nextPage"><view style="font-size: 2vh;">下一页</view></button>
- </view>
- </uni-card>
- </uni-col>
- </uni-row>
- <uni-popup ref="message" type="message">
- <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
- </uni-popup>
- <uni-popup ref="inputDialog" type="dialog">
- <uni-popup-dialog ref="inputClose" title="提交试卷" @confirm="dialogInputConfirm">
- <view>
- <view>1、提交当前试卷后不可再次作答</view>
- <view>2、本试卷剩余时间不计入下一套</view>
- <view>3、最终试卷提交将结束考试</view>
- <view style="text-align: center;">确认提交?</view>
- </view>
- </uni-popup-dialog>
- </uni-popup>
- <uni-popup ref="cheat" type="dialog">
- <uni-popup-dialog style="width: 50vh;" ref="inputClose" title="作弊提醒">
- <view style="color: red;">
- <view>1、鼠标请勿点击窗口之外的地方</view>
- <view>2、如果不小心退出全屏,请按F11恢复到全屏</view>
- <view>3、鼠标多次点击窗口之外的地方将按作弊处理</view>
- </view>
- </uni-popup-dialog>
- </uni-popup>
- </template>
- <script>
- import {
- exit,
- request,
- getExamDetail,
- getCacheAnswer,
- submitExamPaper,
- getExamQueryById,
- getRepositoryById,
- getListQuestionByMode
- } from '../../examJs/examRequest';
- import screenfull from "screenfull";
- import {
- redirectTo,
- toExamInfo,
- toLogin
- } from '../../examJs/examRoute';
- export default {
- name: "examStart",
- data() {
- return {
- // 所有方块============拖拽
- drag: [],
- // 拖拽元素刷新
- mbvShow: true,
- // 拖拽的方块信息
- dragItem: {},
- // 拖拽位置记录
- subDrag: [],
- // 拖拽后动作未完成禁用
- disabledDrag: true,
- // ==================================
- // 连线===============================
- // 连线题内容页面展示
- connectionHtml: [],
- // 连线题中间存储
- connectionInfo: [],
- // 连线题连线内容保存
- connectionContentALL: [],
- // 连线绘制
- ctx: null,
- // 点击过程颜色
- clickColor: '0px 0px 5px 2px rgba(80, 85, 83, 0.7)',
- // 点击结束颜色
- connectionColor: ['#ffaa00', '#00ff7f', '#6ca7ff', '#1d00ff', '#aa00ff', '#ffff00', '#550000', '#ff0000'],
- // ==============================
- // 所有试卷和试题
- examObject: {},
- // ==========================================
- // 当前题库所有类型
- repositoryType: [],
- repository: '',
- subjectTypes: ['单选题', '多选题', '判断题', '简答题', '填空题', '组合题', '拖拽题', '连线题'],
- subjectType: 1,
- subjectNum: 1,
- pageNo: 1,
- pageSize: 5,
- writePageNo: 1,
- writePageSize: 5,
- title: '',
- answerAnalysis: {
- analysis: '这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析',
- answer: 'ABCD',
- youAnswerState: 0
- },
- // ===========================================
- // 当前题目
- examTopic: {},
- // 答题卡
- scantron: '',
- //选项
- answer: {},
- typeThree: '',
- userExamAnswers: [],
- user: {},
- // 拖动监听测试
- b: true,
- count: 0,
- canvasWidth: 300,
- canvasHeight: 300,
- // 用户当前考试
- userExamPaper: {},
- // 消息弹窗记录=================
- msgType: 'success',
- messageText: '这是一条成功提示',
- };
- },
- methods: {
- // 消息提示
- messageToggle(type, message) {
- this.msgType = type
- this.messageText = message
- this.$refs.message.open()
- },
- // 输入检查
- inspect() {
- this.pageNo = Number(this.pageNo)
- if (this.pageNo < 1) {
- this.pageNo = 1
- }
- },
- // 重置
- restart() {
- this.disabledDrag = true
- this.drag[this.subjectNum].answer = []
- this.drag[this.subjectNum].option = []
- let content = this.stringToHTML(this.scantron.content)
- console.log(content);
- for (var i = 0; i < content.children.length; i++) {
- let thisTop = content.children[i].style.top.toString().replace("px", "")
- let thisLeft = content.children[i].style.left.toString().replace("px", "")
- let thisWidth = content.children[i].style.width.toString().replace("px", "")
- let thisHeight = content.children[i].style.height.toString().replace("px", "")
- let thisBackgroundColor = content.children[i].style.backgroundColor
- let thisInnerHTML = content.children[i].innerHTML
- if (content.children[i].id.includes("option")) {
- this.drag[this.subjectNum].option.push({
- id: content.children[i].id,
- x: Number(thisLeft),
- y: Number(thisTop),
- old: {
- x: 0,
- y: 0,
- ax: Number(thisLeft),
- by: Number(thisTop)
- },
- // 只添加一次拖拽监听
- b: true,
- width: thisWidth,
- height: thisHeight,
- backgroundColor: thisBackgroundColor,
- innerHTML: thisInnerHTML
- })
- }
- if (content.children[i].id.includes("answer")) {
- this.drag[this.subjectNum].answer.push({
- id: content.children[i].id,
- x: Number(thisLeft),
- y: Number(thisTop),
- old: {
- x: 0,
- y: 0
- },
- width: thisWidth,
- height: thisHeight,
- backgroundColor: thisBackgroundColor
- })
- }
- }
- },
- // 上一题目
- previousQuestion() {
- if (this.subjectNum > 1) {
- this.radioScantron(--this.subjectNum)
- }
- },
- // 下一题目
- nextQuestion() {
- if (this.subjectNum < this.examObject.records.length) {
- // this.scantron = this.examObject.records[this.subjectNum]
- this.radioScantron(++this.subjectNum)
- }
- }, // 上一题目
- // 下一页
- previousPage() {
- if (this.pageNo > 1) {
- this.pageReplace(this.pageNo, this.pageSize, -1)
- } else {
- this.messageToggle('warn', "当前在第一页")
- }
- },
- // 下一页
- nextPage() {
- this.pageReplace(this.pageNo, this.pageSize, 1)
- },
- pageReplace(thisPageNo, thisPageSize, num) {
- this.drag = []
- thisPageNo = Number(thisPageNo) + Number(num)
- thisPageSize = Number(thisPageSize)
- num =
- getListQuestionByMode({
- mode: 3,
- pageNo: thisPageNo,
- pageSize: thisPageSize,
- questionType: this.subjectType,
- repositoryId: sessionStorage.getItem('repositoryId')
- }).then(data => {
- if (0 === data.data.result.records.length) {
- this.messageToggle('warn', "新页没有数据")
- return
- }
- this.pageNo = thisPageNo
- this.writePageNo = thisPageNo
- console.log(data);
- this.examObject = data.data.result
- this.scantron = this.examObject.records[0]
- this.radioScantron(1)
- })
- },
- // 答题卡单击题目
- radioScantron(value) {
- this.analysisBlank()
- document.getElementById('scantronNodes').innerHTML = ''
- this.subjectNum = value
- this.scantron = this.examObject.records[value - 1]
- console.log(this.scantron);
- if (this.scantron.type !== 7 && this.scantron.type !== 8) {
- document.getElementById('scantronNodes').innerHTML = this.scantron.content
- } else {
- console.log(this.scantron.content.split('%||||||||%')[0]);
- document.getElementById('scantronNodes').innerHTML = this.scantron.content.split('%||||||||%')[0]
- }
- let combination = setInterval(() => {
- if (this.scantron.type === 6) {
- for (var i = 0; i < this.scantron.subQuestionList.length; i++) {
- if (document.getElementById('combinationItemNodes' + i) === null) {
- console.log("加载中");
- break;
- }
- document.getElementById('combinationItemNodes' + i).innerHTML = this.scantron
- .subQuestionList[i].content
- }
- clearInterval(combination);
- }
- }, 10)
- // 拖拽加载
- if (this.scantron.type == 7) {
- this.mbvShow = !this.mbvShow
- this.disabledDrag = true
- console.log(this.drag[this.subjectNum]);
- if (this.drag[this.subjectNum] !== undefined) {
- setTimeout(() => {
- for (var i = 0; i < this.drag[this.subjectNum].option.length; i++) {
- let drags = this.drag[this.subjectNum].option[i]
- console.log(document.getElementById(drags.id));
- console.log(drags);
- document.getElementById(drags.id).innerHTML = drags.innerHTML
- }
- }, 10)
- return
- }
- this.drag[this.subjectNum] = {}
- this.drag[this.subjectNum].answer = []
- this.drag[this.subjectNum].option = []
- this.drag[this.subjectNum].background = {}
- let content = this.stringToHTML(this.scantron.content)
- for (var i = 0; i < content.children.length; i++) {
- console.log(content.children[i]);
- let thisTop = content.children[i].style.top.toString().replace("px", "")
- let thisLeft = content.children[i].style.left.toString().replace("px", "")
- let thisWidth = content.children[i].style.width.toString().replace("px", "")
- let thisHeight = content.children[i].style.height.toString().replace("px", "")
- let thisBackgroundColor = content.children[i].style.backgroundColor
- let thisInnerHTML = content.children[i].innerHTML
- if (content.children[i].id.includes("option")) {
- this.drag[this.subjectNum].option.push({
- id: content.children[i].id,
- x: Number(thisLeft),
- y: Number(thisTop),
- old: {
- x: 0,
- y: 0,
- ax: Number(thisLeft),
- by: Number(thisTop)
- },
- // 只添加一次拖拽监听
- b: true,
- width: thisWidth,
- height: thisHeight,
- backgroundColor: thisBackgroundColor,
- innerHTML: thisInnerHTML
- })
- }
- if (content.children[i].id.includes("answer")) {
- this.drag[this.subjectNum].answer.push({
- id: content.children[i].id,
- x: Number(thisLeft),
- y: Number(thisTop),
- old: {
- x: 0,
- y: 0
- },
- width: thisWidth,
- height: thisHeight,
- backgroundColor: thisBackgroundColor
- })
- }
- if (content.children[i].tagName === 'IMG') {
- this.drag[this.subjectNum].background.url = content.children[i].src
- this.drag[this.subjectNum].background.width = content.children[i].style.width.toString()
- .replace("px", "")
- this.drag[this.subjectNum].background.height = content.children[i].style.height.toString()
- .replace("px", "")
- }
- }
- console.log(this.drag[this.subjectNum].option.length);
- setTimeout(() => {
- for (var i = 0; i < this.drag[this.subjectNum].option.length; i++) {
- let drags = this.drag[this.subjectNum].option[i]
- console.log(document.getElementById(drags.id));
- document.getElementById(drags.id).innerHTML = drags.innerHTML
- }
- }, 10)
- }
- // 连线题添加监听
- if (this.scantron.type == 8) {
- this.connectionHtml = []
- let content = this.stringToHTML(this.scantron.content)
- for (var i = 0; i < content.children.length; i++) {
- let child = content.children[i]
- for (var j = 0; j < child.children.length; j++) {
- if (child.children[j].id !== undefined && child.children[j].id.includes("option")) {
- this.connectionHtml.push(child.children[j])
- }
- }
- }
- if (this.connectionContentALL[value] === undefined) {
- this.connectionContentALL[value] = []
- }
- this.connectionInfo = []
- setTimeout(() => {
- // 画内容
- this.drawLineWriteContent()
- // 画缓存线
- this.drawLineWrite(value)
- }, 100)
- for (var i = 0; i < this.connectionHtml.length; i++) {
- let option = this.connectionHtml[i]
- for (var j = 0; j < option.children.length; j++) {
- let ids = "option" + i + "-" + (j + 1)
- if (document.getElementById(ids) === null) {
- setTimeout(() => {
- let optionCol = document.getElementById(ids)
- optionCol.addEventListener("mousedown", (event) => {
- console.log(event);
- let id = event.currentTarget.id
- console.log(id);
- let colId = Number(id.replace('option', '').split('-')[0])
- let rowId = Number(id.replace('option', '').split('-')[1])
- let left = event.target.offsetLeft
- let right = Number(event.target.offsetLeft + event.target
- .offsetWidth)
- let top = Number(event.target.offsetTop + event.target
- .offsetHeight / 2)
- if (this.connectionInfo.length === this.connectionHtml.length &&
- colId === 0) {
- this.connectionContentALL[this.subjectNum].push(this
- .connectionInfo)
- this.radioAdd(this.connectionInfo, this
- .connectionInfo[0].id.replace('option', '').split('-')[
- 1], this.scantron)
- this.connectionInfo = []
- }
- let arr = []
- for (var i = 0; i < this.connectionContentALL[this.subjectNum]
- .length; i++) {
- let all = this.connectionContentALL[this.subjectNum][i]
- if (all[0].id !== id) {
- arr.push(this.connectionContentALL[this.subjectNum][i])
- }
- }
- this.connectionContentALL[this.subjectNum] = arr
- let infoLength = this.connectionInfo.length
- if (infoLength <= this.connectionHtml.length) {
- if (infoLength !== 0) {
- if (!this.isLine(id, this.subjectNum)) {
- this.messageToggle('error', "这个已经连过了")
- this.drawLineWrite(this.subjectNum)
- return
- }
- let last = this.connectionInfo[infoLength -
- 1]
- let lastId = Number(last.id.replace('option', '').split(
- '-')[0])
- if (lastId + 1 === colId) {
- this.connectionInfo.push({
- 'id': id,
- 'left': left,
- 'right': right,
- 'top': top
- })
- }
- if (lastId === colId && colId !== this.connectionHtml
- .length - 1) {
- this.connectionInfo[infoLength - 1] = {
- 'id': id,
- 'left': left,
- 'right': right,
- 'top': top
- }
- document.getElementById(ids).style.boxShadow = this
- .clickColor
- if (Number(last.id.replace('option', '').split(
- '-')[1]) === rowId &&
- this.connectionInfo.length === this.connectionHtml
- .length) {
- this.connectionContentALL[this.subjectNum].push(
- this.connectionInfo)
- console.log(this.connectionContentALL[this.scantron
- .sort]);
- this.radioAdd(this.connectionInfo, this
- .connectionInfo[0].id.replace('option', '')
- .split('-')[1], this.scantron)
- this.connectionInfo = []
- }
- } else if (colId === this.connectionHtml.length - 1) {
- this.connectionContentALL[this.subjectNum].push(
- this.connectionInfo)
- console.log(this.connectionContentALL[this.scantron
- .sort]);
- this.radioAdd(this.connectionInfo, this
- .connectionInfo[0].id.replace('option', '')
- .split('-')[1], this.scantron)
- this.connectionInfo = []
- }
- } else if (infoLength === 0) {
- if (colId === 0) {
- this.connectionInfo.push({
- 'id': id,
- 'left': left,
- 'right': right,
- 'top': top
- })
- console.log(document.getElementById(id + ''));
- document.getElementById(id + '').style.boxShadow = this
- .clickColor
- console.log(document.getElementById(id));
- }
- }
- }
- this.shadowClean()
- this.drawLineWrite(this.subjectNum)
- })
- }, 10)
- } else {
- setTimeout(() => {
- this.shadowClean()
- }, 10)
- }
- }
- }
- }
- },
- // 连线绘制
- drawLine(x1, y1, x2, y2, index) {
- this.ctx = uni.createCanvasContext('lineCanvas');
- this.ctx.beginPath();
- let color = this.connectionColor[index]
- if (index === -1) {
- color = '#000000'
- this.ctx.shadowColor = 'red';
- // 设置阴影的模糊级别
- this.ctx.setshadowBlur = 100;
- // 设置阴影的水平偏移
- this.ctx.shadowOffsetX = 1;
- // 设置阴影的垂直偏移
- this.ctx.shadowOffsetY = 1;
- } else {
- this.ctx.shadowColor = '#000000';
- this.ctx.setshadowBlur = 0;
- this.ctx.shadowOffsetX = 0;
- this.ctx.shadowOffsetY = 0;
- }
- this.ctx.setStrokeStyle(color)
- this.ctx.lineWidth = 3
- this.ctx.moveTo(x1, y1); // 开始点
- this.ctx.lineTo(x2, y2); // 结束点
- this.ctx.stroke(); // 绘制线条
- this.ctx.draw(true);
- },
- // 连线清理
- clearRect() {
- const canvas = uni.createCanvasContext('lineCanvas');
- // 使用clearRect方法清空整个画布
- canvas.clearRect(0, 0, 700, 500); // 这里的300x300是画布的宽高,应该与你的实际画布尺寸相匹配
- canvas.draw(true); // 调用draw方法将清空操作应用到画布上
- },
- // 阴影清理
- shadowClean() {
- for (var i = 0; i < this.connectionHtml.length; i++) {
- let option = this.connectionHtml[i]
- for (var j = 0; j < option.children.length; j++) {
- let ids = "option" + i + "-" + (j + 1)
- document.getElementById(ids).style.boxShadow = ''
- }
- }
- },
- isLine(id, value) {
- for (var i = 0; i < this.connectionContentALL[value].length; i++) {
- let option = this.connectionContentALL[value][i]
- for (var j = 0; j < option.length; j++) {
- let oldId = option[j].id
- if (oldId === id) {
- return false
- }
- }
- }
- return true
- },
- // 连线题画内容
- drawLineWriteContent() {
- for (var i = 0; i < this.connectionHtml.length; i++) {
- let option = this.connectionHtml[i]
- for (var j = 0; j < option.children.length; j++) {
- let ids = "option" + i + "-" + (j + 1)
- document.getElementById(ids).innerHTML = option.children[j].innerHTML
- }
- }
- }, // 连线画线
- drawLineWrite(value) {
- this.clearRect()
- if (this.connectionInfo.length >= 2) {
- for (var i = 0; i < this.connectionInfo.length - 1; i++) {
- let one = this.connectionInfo[i]
- let two = this.connectionInfo[i + 1]
- // box-shadow: ;
- document.getElementById(one.id).style.boxShadow = this.clickColor
- document.getElementById(two.id).style.boxShadow = this.clickColor
- this.drawLine(one.right, one.top, two.left, two.top, -1)
- }
- } else if (this.connectionInfo.length === 1) {
- document.getElementById(this.connectionInfo[0].id).style.boxShadow = this.clickColor
- }
- for (var i = 0; i < this.connectionContentALL[value].length; i++) {
- let option = this.connectionContentALL[value][i]
- for (var j = 0; j < option.length - 1; j++) {
- let one = option[j]
- let two = option[j + 1]
- document.getElementById(one.id).style.boxShadow = '0px 0px 5px 2px ' + this.connectionColor[i]
- document.getElementById(two.id).style.boxShadow = '0px 0px 5px 2px ' + this.connectionColor[i]
- this.drawLine(one.right, one.top, two.left, two.top, i)
- }
- }
- },
- // 字符转换html对象
- stringToHTML(str) {
- var dom = document.createElement('div');
- dom.innerHTML = str;
- return dom;
- },
- // 拖动位置固定
- tap(index, subX, subY) {
- let x = subX
- let y = subY
- this.drag[this.subjectNum].option[index].x = this.drag[this.subjectNum].option[index].old.x
- this.drag[this.subjectNum].option[index].y = this.drag[this.subjectNum].option[index].old.y
- this.$nextTick(function() {
- this.drag[this.subjectNum].option[index].x = x
- this.drag[this.subjectNum].option[index].y = y
- })
- },
- // 鼠标按下
- onMousedown(item) {
- console.log(this.drag[this.subjectNum].option.length);
- this.dragItem = item;
- this.count = 0
- },
- // 拖动监听
- onChange: function(e) {
- if (!this.disabledDrag) {
- return
- }
- let index = -1
- for (var j = 0; j < this.drag[this.subjectNum].option.length; j++) {
- let option = this.drag[this.subjectNum].option[j]
- if (option.id === this.dragItem.id) {
- index = j
- break;
- }
- }
- this.drag[this.subjectNum].option[index].old.x = e.detail.x
- this.drag[this.subjectNum].option[index].old.y = e.detail.y
- let asda = (event) => {
- document.removeEventListener('mouseup', asda)
- this.disabledDrag = false
- let bxs = true
- let dragOne;
- // 处理鼠标抬起事件
- for (var i = 0; i < this.drag[this.subjectNum].answer.length; i++) {
- let drag = this.drag[this.subjectNum].answer[i]
- let x = drag.x
- let y = drag.y
- if (
- (Number(this.drag[this.subjectNum].option[index].old.x) <= (Number(drag.x) + Number(
- drag
- .width))) &&
- (Number(this.drag[this.subjectNum].option[index].old.x) + Number(this.drag[this
- .subjectNum].option[index]
- .width)) >= drag.x &&
- (Number(this.drag[this.subjectNum].option[index].old.y) <= (Number(drag.y) + Number(
- drag
- .height))) &&
- (Number(this.drag[this.subjectNum].option[index].old.y) + Number(this.drag[this
- .subjectNum].option[index]
- .height)) >= drag.y
- ) {
- for (var p = 0; p < this.drag[this.subjectNum].answer.length; p++) {
- if (this.drag[this.subjectNum].answer[p].op !== undefined && this.drag[this
- .subjectNum].answer[p].op === index) {
- this.drag[this.subjectNum].answer[p].op = undefined
- }
- }
- if (this.drag[this.subjectNum].answer[i].op !== undefined) {
- this.tap(this.drag[this.subjectNum].answer[i].op, this.drag[this.subjectNum]
- .option[this.drag[this.subjectNum].answer[i].op].old.ax, this.drag[this
- .subjectNum]
- .option[this.drag[this.subjectNum].answer[i].op].old.by);
- this.drag[this.subjectNum].answer[i].op = index
- } else {
- this.drag[this.subjectNum].answer[i].op = index
- }
- this.tap(index, x, y);
- dragOne = drag
- bxs = false
- break;
- }
- }
- // console.log(this.drag[this.subjectNum].option[index]);
- if (bxs) {
- this.tap(index, this.drag[this.subjectNum].option[index].old.ax, this.drag[this.subjectNum]
- .option[index].old.by);
- }
- setTimeout(() => {
- // for (var i = 0; i < this.drag[this.subjectNum].option.length; i++) {
- // let op = this.drag[this.subjectNum].option[i]
- // for (var j = 0; j < this.drag[this.subjectNum].answer.length; j++) {
- // let an = this.drag[this.subjectNum].answer[j]
- // }
- // }
- if (dragOne !== undefined) {
- this.radioAdd(this.dragItem, dragOne.id.replace("answer", ""), this.scantron)
- }
- this.disabledDrag = true
- }, 700)
- }
- // if (this.drag[this.subjectNum].option[index].b) {
- // this.drag[this.subjectNum].option[index].b = false
- document.addEventListener('mouseup', asda);
- // }
- },
- // 题目做答
- radioAdd(value, index, scantron, combinationItem) {
- index = index + ''
- let qIndex = this.subjectNum + ""
- let arr = []
- this.examObject.records[this.subjectNum - 1].isAnswer = true
- if (this.scantron.type === 1 || this.scantron.type === 3) {
- for (var i = 0; i < scantron.answerList.length; i++) {
- scantron.answerList[i].right = false
- }
- scantron.answerList[index].right = true
- this.answerInspect()
- for (var i = 0; i < this.userExamAnswers.length; i++) {
- if (this.userExamAnswers[i].index !== qIndex) {
- arr.push(this.userExamAnswers[i])
- }
- }
- arr.push({
- answerIndex: [index],
- answers: [value.id],
- index: qIndex,
- questionType: this.scantronType
- })
- } else if (this.scantron.type === 2) {
- let b = true
- for (var i = 0; i < this.userExamAnswers.length; i++) {
- if (this.userExamAnswers[i].index !== qIndex) {
- arr.push(this.userExamAnswers[i])
- } else {
- b = false
- let bc = true
- let arrAnswer = []
- let arrAnswerId = []
- let num = this.userExamAnswers[i].answers.length;
- for (var j = 0; j < num; j++) {
- if (this.userExamAnswers[i].answerIndex[j] !== index) {
- arrAnswer.push(this.userExamAnswers[i].answerIndex[j])
- arrAnswerId.push(this.userExamAnswers[i].answers[j])
- } else {
- if (!value.right) {
- bc = false
- }
- }
- }
- if (bc) {
- arrAnswer.push(index)
- arrAnswerId.push(value.id)
- }
- if (arrAnswer.length !== 0) {
- arr.push({
- answerIndex: arrAnswer,
- answers: arrAnswerId,
- index: qIndex,
- questionType: this.scantron.type
- })
- } else {
- this.examObject.records[this.subjectNum - 1].isAnswer = false
- }
- }
- }
- if (b) {
- arr.push({
- answerIndex: [index],
- answers: [value.id],
- index: qIndex,
- questionType: this.scantronType
- })
- }
- } else if (this.scantron.type === 4) {
- for (var i = 0; i < this.userExamAnswers.length; i++) {
- if (this.userExamAnswers[i].index !== qIndex) {
- arr.push(this.userExamAnswers[i])
- }
- }
- if (scantron.subjectiveAnswer === null || scantron.subjectiveAnswer === "") {
- this.examObject.records[this.subjectNum - 1].isAnswer = false
- }
- arr.push({
- subjectiveAnswer: scantron.subjectiveAnswer,
- index: qIndex,
- questionType: this.scantronType
- })
- } else if (this.scantron.type === 5) {
- if (value === undefined) {
- return
- }
- let b = true
- for (var i = 0; i < this.userExamAnswers.length; i++) {
- if (this.userExamAnswers[i].index !== qIndex) {
- arr.push(this.userExamAnswers[i])
- } else {
- b = false
- let bc = true
- let arrAnswer = []
- let blankAnswer = JSON.parse(this.userExamAnswers[i].blankAnswer)
- let num = blankAnswer.length;
- for (var j = 0; j < num; j++) {
- if (blankAnswer[j].tag !== index) {
- arrAnswer.push({
- tag: blankAnswer[j].tag,
- content: blankAnswer[j].content
- })
- } else {
- bc = false
- }
- }
- if (bc) {
- arrAnswer.push({
- tag: index,
- content: value
- })
- }
- if (arrAnswer.length !== 0) {
- arr.push({
- blankAnswer: JSON.stringify(arrAnswer),
- index: qIndex,
- questionType: this.scantronType
- })
- } else {
- this.examObject.records[this.subjectNum - 1].isAnswer = false
- }
- }
- }
- if (b) {
- if (value === null || value === "") {
- this.examObject.records[this.subjectNum - 1].isAnswer = false
- }
- arr.push({
- blankAnswer: JSON.stringify([{
- tag: index,
- content: value
- }]),
- index: qIndex,
- questionType: this.scantronType
- })
- }
- } else if (this.scantron.type === 6) {
- qIndex = qIndex + "." + combinationItem.sort
- if (combinationItem.questionType === 1 || combinationItem.questionType ===
- 3) {
- for (var j = 0; j < combinationItem.answerList.length; j++) {
- combinationItem.answerList[j].right = false
- }
- combinationItem.answerList[index].right = true
- for (var j = 0; j < this.userExamAnswers.length; j++) {
- if (this.userExamAnswers[j].index !== qIndex) {
- arr.push(this.userExamAnswers[j])
- }
- }
- arr.push({
- answerIndex: [index],
- answers: [value.id],
- index: qIndex,
- questionType: combinationItem.questionType
- })
- } else if (combinationItem.questionType === 2) {
- let b = true
- for (var j = 0; j < this.userExamAnswers.length; j++) {
- if (this.userExamAnswers[j].index !== qIndex) {
- arr.push(this.userExamAnswers[j])
- } else {
- b = false
- let bca = true
- let arrAnswer = []
- let arrAnswerId = []
- let num = this.userExamAnswers[j].answers.length;
- for (var k = 0; k < num; k++) {
- if (this.userExamAnswers[j].answerIndex[k] !== index) {
- arrAnswer.push(this.userExamAnswers[j].answerIndex[k])
- arrAnswerId.push(this.userExamAnswers[j].answers[k])
- } else {
- if (!value.right) {
- bca = false
- }
- }
- }
- if (bca) {
- arrAnswer.push(index)
- arrAnswerId.push(value.id)
- }
- if (arrAnswer.length !== 0) {
- arr.push({
- answerIndex: arrAnswer,
- answers: arrAnswerId,
- index: qIndex,
- questionType: combinationItem.questionType
- })
- } else {
- this.examObject.records[this.subjectNum - 1].question
- .isAnswer =
- false
- }
- }
- }
- if (b) {
- arr.push({
- answerIndex: [index],
- answers: [value.id],
- index: qIndex,
- questionType: combinationItem.questionType
- })
- }
- } else if (combinationItem.questionType === 4) {
- for (var j = 0; j < this.userExamAnswers.length; j++) {
- if (this.userExamAnswers[j].index !== qIndex) {
- arr.push(this.userExamAnswers[j])
- }
- }
- if (combinationItem.subjectiveAnswer === null || scantron.subQuestionList[
- i].subjectiveAnswer === "") {
- this.examObject.records[this.subjectNum - 1].isAnswer = false
- }
- arr.push({
- subjectiveAnswer: combinationItem.subjectiveAnswer,
- index: qIndex,
- questionType: combinationItem.questionType
- })
- } else if (combinationItem.questionType === 5) {
- if (value === undefined) {
- return
- }
- let b = true
- for (var j = 0; j < this.userExamAnswers.length; j++) {
- if (this.userExamAnswers[j].index !== qIndex) {
- arr.push(this.userExamAnswers[j])
- } else {
- b = false
- let bc = true
- let arrAnswer = []
- let blankAnswer = JSON.parse(this.userExamAnswers[j].blankAnswer)
- let num = blankAnswer.length;
- for (var q = 0; q < num; q++) {
- if (blankAnswer[q].tag !== index) {
- arrAnswer.push({
- tag: blankAnswer[q].tag,
- content: blankAnswer[q].content
- })
- } else {
- bc = false
- }
- }
- if (bc) {
- arrAnswer.push({
- tag: index,
- content: value
- })
- }
- if (arrAnswer.length !== 0) {
- arr.push({
- blankAnswer: JSON.stringify(arrAnswer),
- index: qIndex,
- questionType: scantron.subQuestionList[i].questionType
- })
- } else {
- this.examObject.records[this.subjectNum - 1].question
- .isAnswer = false
- }
- }
- }
- if (b) {
- if (value === null || value === "") {
- this.examObject.records[this.subjectNum - 1].isAnswer = false
- }
- arr.push({
- blankAnswer: JSON.stringify([{
- tag: index,
- content: value
- }]),
- index: qIndex,
- questionType: scantron.subQuestionList[i].questionType
- })
- }
- }
- } else if (this.scantron.type === 7) {
- if (value === undefined || this.count > 0) {
- return
- }
- console.log(this.drag);
- this.count++
- index = (Number(index) + 1) + ""
- let b = true
- for (var i = 0; i < this.userExamAnswers.length; i++) {
- if (this.userExamAnswers[i].index !== qIndex) {
- arr.push(this.userExamAnswers[i])
- } else {
- b = false
- let bc = true
- let arrAnswer = []
- let blankAnswer = JSON.parse(this.userExamAnswers[i].blankAnswer)
- let num = blankAnswer.length;
- for (var j = 0; j < num; j++) {
- if (blankAnswer[j].tag !== index) {
- arrAnswer.push({
- tag: blankAnswer[j].tag,
- content: blankAnswer[j].content
- })
- } else {
- arrAnswer.push({
- tag: index,
- content: value.id
- })
- this.scantron.answerList[Number(index) - 1].blankcontent = value.id
- bc = false
- }
- }
- console.log(arrAnswer);
- if (bc) {
- arrAnswer.push({
- tag: index,
- content: value.id
- })
- this.scantron.answerList[Number(index) - 1].blankcontent = value.id
- }
- if (arrAnswer.length !== 0) {
- arr.push({
- blankAnswer: JSON.stringify(arrAnswer),
- coordinates: JSON.stringify(this.drag[qIndex]),
- index: qIndex,
- questionType: this.scantronType
- })
- this.scantron.answerList[Number(index) - 1].blankcontent = value.id
- } else {
- this.examObject.records[this.subjectNum - 1].isAnswer = false
- }
- }
- }
- if (b) {
- if (value === null || value === "") {
- this.examObject.records[this.subjectNum - 1].isAnswer = false
- }
- arr.push({
- blankAnswer: JSON.stringify([{
- tag: index,
- content: value.id
- }]),
- coordinates: JSON.stringify(this.drag[qIndex]),
- index: qIndex,
- questionType: this.scantronType
- })
- this.scantron.answerList[Number(index) - 1].blankcontent = value.id
- }
- } else if (this.scantron.type === 8) {
- console.log(this.connectionContentALL[qIndex]);
- let info = value
- value = ""
- for (var i = 0; i < info.length; i++) {
- console.log(info);
- value += info[i].id.replace('option', '').split('-')[1]
- }
- // connectingCoordinates
- if (value === undefined) {
- return
- }
- let b = true
- console.log(this.userExamAnswers.length);
- this.scantron.answerList[Number(index) - 1].blankcontent = value
- for (var j = 0; j < this.userExamAnswers.length; j++) {
- if (this.userExamAnswers[j].index !== qIndex) {
- arr.push(this.userExamAnswers[j])
- } else {
- b = false
- let bc = true
- let arrAnswer = []
- let blankAnswer = JSON.parse(this.userExamAnswers[j].blankAnswer)
- let num = blankAnswer.length;
- for (var q = 0; q < num; q++) {
- if (blankAnswer[q].tag !== index) {
- arrAnswer.push({
- tag: blankAnswer[q].tag,
- content: blankAnswer[q].content
- })
- } else {
- console.log(value);
- bc = false
- }
- }
- if (bc) {
- console.log(value);
- arrAnswer.push({
- tag: index,
- content: value
- })
- }
- if (arrAnswer.length !== 0) {
- arr.push({
- blankAnswer: JSON.stringify(arrAnswer),
- index: qIndex,
- coordinates: JSON.stringify(this.connectionContentALL[qIndex]),
- questionType: this.scantronType
- })
- } else {
- this.examObject.records[this.subjectNum - 1].isAnswer =
- false
- }
- }
- }
- if (b) {
- if (value === null || value === "") {
- this.examObject.records[this.subjectNum - 1].isAnswer =
- false
- }
- this.scantron.answerList[Number(index) - 1].blankcontent = value
- arr.push({
- blankAnswer: JSON.stringify([{
- tag: index,
- content: value
- }]),
- coordinates: JSON.stringify(this.connectionContentALL[qIndex]),
- index: qIndex,
- questionType: this.scantronType
- })
- }
- }
- this.userExamAnswers = arr
- console.log(this.scantron.answerList[Number(index) - 1]);
- console.log(this.userExamAnswers);
- },
- // 类型点击
- subjectTypeClick(item) {
- this.repository = item
- this.pageNo = 1
- setTimeout(() => {
- this.drag = []
- this.shadowClean()
- this.clearRect()
- this.connectionContentALL = []
- }, 100)
- getListQuestionByMode({
- mode: 3,
- pageNo: 1,
- pageSize: this.pageSize,
- questionType: item.type,
- repositoryId: sessionStorage.getItem('repositoryId')
- }).then(data => {
- if (0 === data.data.result.total) {
- this.messageToggle('warn', "该题型数量为空")
- return
- }
- for (var i = 0; i < data.data.result.records.length; i++) {
- data.data.result.records[i].disable = false
- }
- this.subjectType = item.type
- this.examObject = data.data.result
- console.log(this.examObject);
- console.log(this.subjectNum);
- this.scantron = this.examObject.records[0]
- this.radioScantron(1)
- })
- },
- // 答案确认
- answerConfirm() {
- this.answerInspect()
- }, // 答案检查
- answerInspect(state) {
- console.log(this.examObject.records[this.subjectNum - 1]);
- if (this.examObject.records[this.subjectNum - 1].disable) {
- console.log("0");
- return
- }
- this.analysisBlank()
- this.answerAnalysis.youAnswerState = 1
- if (this.scantron.type === 1 || this.scantron.type === 3) {
- for (var i = 0; i < this.scantron.answerList.length; i++) {
- if (this.scantron.answerList[i].isRight && this.scantron.answerList[i].right) {
- this.answerAnalysis.youAnswerState = 0
- }
- if (this.scantron.answerList[i].isRight && !this.scantron.answerList[i].right) {
- this.answerAnalysis.youAnswerState = 1
- }
- if (this.scantron.answerList[i].isRight) {
- this.answerAnalysis.answer += this.scantron.answerList[i].tag
- }
- }
- } else if (this.scantron.type === 5) {
- if (!this.examObject.records[this.subjectNum - 1].answerOrder) {
- console.log(this.scantron.answerList);
- for (var i = 0; i < this.scantron.answerList.length; i++) {
- this.answerAnalysis.youAnswerState = 1
- for (var j = 0; j < this.scantron.answerList.length; j++) {
- if (this.scantron.answerList[i].isRight) {
- let arrAwn = this.scantron.answerList[i].content.split("||")
- for (var a = 0; a < arrAwn.length; a++) {
- if (arrAwn[a] === this.scantron.answerList[j].blankcontent) {
- this.answerAnalysis.youAnswerState = 0
- break
- }
- }
- }
- }
- if (this.answerAnalysis.youAnswerState === 1) {
- break
- }
- }
- for (var i = 0; i < this.scantron.answerList.length; i++) {
- if (this.scantron.answerList[i].isRight) {
- this.answerAnalysis.answer += (i + 1) + "、" + this.scantron.answerList[i].content + ";"
- }
- }
- } else {
- for (var i = 0; i < this.scantron.answerList.length; i++) {
- if (this.scantron.answerList[i].isRight) {
- let arrAwn = this.scantron.answerList[i].content.split("||")
- for (var a = 0; a < arrAwn.length; a++) {
- if (arrAwn[a] === this.scantron.answerList[i].blankcontent) {
- this.answerAnalysis.youAnswerState = 0
- break
- }
- }
- }
- if (this.answerAnalysis.youAnswerState === 1) {
- break
- }
- }
- for (var i = 0; i < this.scantron.answerList.length; i++) {
- if (this.scantron.answerList[i].isRight) {
- this.answerAnalysis.answer += (i + 1) + "、" + this.scantron.answerList[i].content + ";"
- }
- }
- }
- } else if (this.scantron.type === 7 || this.scantron.type === 8) {
- let a = 1
- this.answerAnalysis.youAnswerState = 0
- console.log(this.scantron.answerList);
- for (var i = 0; i < this.scantron.answerList.length; i++) {
- let a = 1
- for (var j = 0; j < this.scantron.answerList.length; j++) {
- if (this.scantron.answerList[i].isRight) {
- if (this.scantron.answerList[i].content === this.scantron.answerList[j].blankcontent) {
- a = 0
- }
- }
- }
- console.log(this.scantron.answerList);
- if (this.scantron.answerList[i].isRight) {
- this.answerAnalysis.answer += (i + 1) + "、" + this.scantron.answerList[i].content + ";"
- }
- if (a === 1) {
- this.answerAnalysis.youAnswerState = 1
- }
- }
- }
- if (state === 3) {
- this.answerAnalysis.youAnswerState = state
- }
- this.answerAnalysis.analysis = this.scantron.analysis
- this.examObject.records[this.subjectNum - 1].disable = true
- },
- // 解析置空
- analysisBlank() {
- this.answerAnalysis.analysis = ''
- this.answerAnalysis.answer = ''
- this.answerAnalysis.youAnswerState = -1
- },
- // 返回
- backPage() {
- toExamInfo()
- }
- },
- mounted() {
- this.user = JSON.parse(sessionStorage.getItem("user"))
- let examId = sessionStorage.getItem('repositoryId')
- getRepositoryById({
- 'id': examId,
- 't': new Date().toString()
- }).then(data => {
- if (data.data.code !== 200) {
- sessionStorage.removeItem('examId')
- toLogin()
- }
- this.repositoryType = data.data.result.questionDTOList
- this.subjectTypeClick(this.repositoryType[0])
- console.log(this.repositoryType);
- this.title = data.data.result.title
- })
- }
- }
- </script>
- <style scoped>
- .svg-container {
- width: 100%;
- height: 100%;
- overflow: hidden;
- position: runiative;
- }
- svg {
- display: block;
- width: 100%;
- height: 100%;
- }
- .scroll-Y {
- height: 50vh;
- }
- .allceter {
- display: flex;
- align-items: center;
- height: 50px;
- }
- .scroll-view_H {
- white-space: nowrap;
- width: 100%;
- }
- .scroll-view-item {
- height: 300rpx;
- line-height: 300rpx;
- text-align: center;
- font-size: 36rpx;
- }
- .scroll-view-item_H {
- display: inline-block;
- width: 100%;
- height: 300rpx;
- line-height: 300rpx;
- text-align: center;
- font-size: 36rpx;
- }
- div {
- margin: 0;
- padding: 0;
- }
- /* CSS 预设*/
- * {
- margin: 0;
- padding: 0;
- }
- a {
- text-decoration: none;
- outline: none;
- }
- body a {
- outline: none;
- blr: expression(this.onFocus=this.blur());
- }
- .uni-input {
- padding-left: 20px;
- border: 1rpx solid #5bb4ee;
- height: 50px;
- margin-left: 10px;
- color: #000000;
- width: 90%;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- img {
- border: none;
- }
- .dialog-text {
- font-size: 14px;
- color: #333;
- }
- .paperCss {
- width: 85%;
- border-radius: 5px;
- padding: 1vh;
- margin-top: 1vh;
- font-size: 15px;
- text-align: left;
- }
- </style>
|