12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762 |
- <template>
- <div
- v-loading="loading"
- class="edit-paper"
- element-loading-text="拼命加载中。。。"
- >
- <div class="edit-header">
- <div class="edit-header-top box-justify">
- <div class="header-info">
- <div class="header-info-item">
- <span>课程代码:</span>
- <span>{{ paper.course.code }}</span>
- </div>
- <div class="header-info-item">
- <span>课程名称:</span>
- <span>{{ paper.course.name }}</span>
- </div>
- <div class="header-info-item">
- <span>试卷名称:</span>
- <span>
- <el-tooltip class="item" effect="dark" placement="top-start">
- <div slot="content">{{ paper.name }}</div>
- <el-input
- v-model="paper.name"
- size="mini"
- class="header-info-input"
- placeholder="试卷名称"
- ></el-input>
- </el-tooltip>
- </span>
- </div>
- <div class="header-info-item">
- <span>试卷标题:</span>
- <span>
- <el-tooltip class="item" effect="dark" placement="top-start">
- <div slot="content">{{ paper.title }}</div>
- <el-input
- v-model="paper.title"
- size="mini"
- class="header-info-input"
- placeholder="试卷标题"
- ></el-input>
- </el-tooltip>
- </span>
- </div>
- <div class="header-info-item">
- <span>试卷总分:</span>
- <span>{{ paper.totalScore }}</span>
- </div>
- </div>
- <div class="header-btns">
- <el-button type="primary" size="small" @click="savePaper">
- 保存
- </el-button>
- <el-button
- type="danger"
- plain
- size="small"
- @click="deletePaper(paper.id)"
- >
- 删除
- </el-button>
- <el-button
- v-if="showCheckDuplicateBtn"
- type="primary"
- size="small"
- plain
- @click="checkDuplicate"
- >
- 进入查重
- </el-button>
- <el-dropdown>
- <el-button type="primary" size="small" plain>
- 更多<i class="el-icon-more el-icon--right"></i>
- </el-button>
- <el-dropdown-menu slot="dropdown" class="action-dropdown">
- <el-dropdown-item>
- <el-button type="primary" plain size="small" @click="openDialog"
- >上传音频
- </el-button>
- </el-dropdown-item>
- <el-dropdown-item>
- <el-button
- size="small"
- type="primary"
- plain
- @click="exportPaperAnswer()"
- >导出答案</el-button
- >
- </el-dropdown-item>
- <el-dropdown-item>
- <el-button
- type="primary"
- size="small"
- plain
- @click="openAnswerDialog"
- >导入答案
- </el-button>
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- <el-button
- size="small"
- type="danger"
- plain
- icon="icon icon-back"
- @click="back"
- >返回</el-button
- >
- </div>
- </div>
- <div class="edit-header-bottom box-justify">
- <div>
- <el-button type="info" size="small" @click="showBasicDialog">
- 基础构成
- </el-button>
- <el-button type="info" size="small" @click="showTypeDialog">
- 题型分布
- </el-button>
- <el-button type="info" size="small" @click="showBlueDialog">
- 蓝图分布
- </el-button>
- <el-button type="info" size="small" @click="showAuditDialog">
- 审核记录
- </el-button>
- <el-button
- v-if="enableCardEdit"
- type="info"
- size="small"
- @click="toEditCard"
- >
- 编辑题卡
- </el-button>
- </div>
- <div>
- <el-button type="primary" size="small" plain @click="quesTagShowHide">
- {{ quesTagShow ? "隐藏" : "显示" }}属性
- </el-button>
- <el-button
- type="primary"
- size="small"
- plain
- @click="quesAnswerShowHide"
- >
- {{ quesAnswerShow ? "隐藏" : "显示" }}答案
- </el-button>
- </div>
- </div>
- </div>
- <div class="edit-body">
- <div class="edit-part-list">
- <div class="edit-part">
- <div class="edit-cont">
- <div class="edit-cont-title">
- <h3>考试说明</h3>
- </div>
- <div class="edit-cont-action">
- <el-button
- type="primary"
- plain
- size="small"
- @click="openEditExamPaperRemark"
- >编辑</el-button
- >
- </div>
- <div class="edit-cont-body">
- <rich-text :text-json="paper.examRemark"></rich-text>
- </div>
- </div>
- </div>
- </div>
- <!-- 循环大题 -->
- <div
- v-for="(paperDetail, detailIndex) in paper.paperDetails"
- v-show="paperDetailShow(paperDetail)"
- :key="detailIndex"
- class="edit-part-list"
- >
- <div class="edit-part">
- <div
- class="edit-cont"
- @mouseover="quesMouseOver(paperDetail.id)"
- @mouseout="quesMouseOut(paperDetail.id)"
- >
- <div class="edit-cont-title">
- <h3>
- <span>{{ paperDetail.cnNum }}</span> <span>.</span>
- <span>{{ paperDetail.name }}</span>
- <span>
- ({{
- !paperDetail.title ? "本大题" : paperDetail.title + ","
- }}共{{ paperDetail.unitCount }}小题,满分{{
- paperDetail.score
- }}分)
- </span>
- </h3>
- </div>
- <rich-text
- class="edit-cont-body"
- :text-json="paperDetail.description"
- ></rich-text>
- <div
- :id="paperDetail.id"
- class="edit-cont-action"
- style="visibility: hidden"
- >
- <el-button
- v-show="parentView == 'gen_paper'"
- size="small"
- type="primary"
- plain
- @click="selectQues(paperDetail.id)"
- >选题
- </el-button>
- <el-button
- size="small"
- type="primary"
- plain
- @click="openEditPaperDetail(paperDetail)"
- >编辑
- </el-button>
- <el-button
- v-if="showUp(paperDetail)"
- size="small"
- type="primary"
- plain
- @click="movePaperDetail(paperDetail, 'up')"
- >上移
- </el-button>
- <el-button
- v-if="showDown(paperDetail)"
- size="small"
- type="primary"
- plain
- @click="movePaperDetail(paperDetail, 'down')"
- >下移
- </el-button>
- <el-button
- size="small"
- type="danger"
- @click="deletePaperDetail(paperDetail.id)"
- >删除
- </el-button>
- <el-button
- v-show="showButtons[detailIndex].up"
- size="small"
- type="primary"
- plain
- icon="el-icon-arrow-up"
- @click.stop="hideContent(detailIndex)"
- ></el-button>
- <el-button
- v-show="!showButtons[detailIndex].up"
- size="small"
- icon="el-icon-arrow-down"
- type="primary"
- plain
- @click.stop="showContent(detailIndex)"
- ></el-button>
- </div>
- </div>
- <div v-show="quesTagShow" class="edit-property">
- <div class="edit-property-box">
- <div
- v-for="(paperDetailTag, tagIndex) in paperDetail.tags"
- :key="tagIndex"
- class="edit-property-item"
- >
- <div class="edit-property-body edit-property-danger">
- <div class="edit-property-title">
- {{ paperDetailTag.tag }}
- </div>
- <div class="edit-property-content">
- {{ paperDetailTag.content }}
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- 循环小题 -->
- <div
- v-show="showQuestions[detailIndex].is_show"
- class="edit-paper-questions"
- >
- <template
- v-for="(paperDetailUnit, unitIndex) in paperDetail.paperDetailUnits"
- >
- <div
- v-show="quesShow(paperDetailUnit.id)"
- :key="`question-${unitIndex}`"
- :class="[
- 'edit-part',
- {
- 'question-duplicate':
- paperDetailUnit.question.checkDuplicateStatus ==
- 'TO_BE_DISPOSE',
- },
- ]"
- >
- <div
- class="edit-cont"
- @mouseover="quesMouseOver(paperDetailUnit.id)"
- @mouseout="quesMouseOut(paperDetailUnit.id)"
- >
- <div class="edit-cont-title">
- <span>{{ paperDetailUnit.number }}.</span>
- <rich-text
- :text-json="paperDetailUnit.question.quesBody"
- ></rich-text>
- <span> ({{ paperDetailUnit.score }}分) </span>
- </div>
- <div class="edit-cont-body">
- <div
- v-for="(quesOption, optionIndex) in paperDetailUnit.question
- .quesOptions"
- :key="optionIndex"
- class="paper-option"
- >
- <span>{{ optionIndex | optionOrderWordFilter }}. </span>
- <rich-text :text-json="quesOption.optionBody"></rich-text>
- </div>
- <div v-if="!isNested(paperDetailUnit.questionType)">
- <div v-show="quesAnswerShow" class="paper-answer">
- <span>答案:</span>
- <question-answer
- :data="paperDetailUnit.question"
- ></question-answer>
- </div>
- </div>
- </div>
- <div
- :id="paperDetailUnit.id"
- class="edit-cont-action"
- style="visibility: hidden"
- >
- <span class="tips-info">
- {{ paperDetailUnit.question.bodyLengthText }}
- </span>
- <el-button
- v-if="
- paperDetailUnit.question.checkDuplicateStatus ==
- 'TO_BE_DISPOSE'
- "
- size="small"
- type="primary"
- plain
- @click="checkDuplicateQuestion(paperDetailUnit.question.id)"
- >进入查重
- </el-button>
- <el-button
- size="small"
- type="primary"
- plain
- @click="editQues(paperDetailUnit, paperDetailUnit.question)"
- >编辑
- </el-button>
- <el-button
- v-if="showUnitUp(paperDetail, paperDetailUnit.id)"
- size="small"
- type="primary"
- plain
- @click="
- movePaperDetailUnit(
- paperDetail.id,
- paperDetailUnit.id,
- 'up'
- )
- "
- >上移
- </el-button>
- <el-button
- v-if="showUnitDown(paperDetail, paperDetailUnit.id)"
- size="small"
- type="primary"
- plain
- @click="
- movePaperDetailUnit(
- paperDetail.id,
- paperDetailUnit.id,
- 'down'
- )
- "
- >下移
- </el-button>
- <el-button
- type="danger"
- size="small"
- @click="deleteQues(paperDetailUnit)"
- >删除
- </el-button>
- <el-button
- v-show="
- isNested(paperDetailUnit.questionType) &&
- showSubButtons[detailIndex + '-' + unitIndex]
- "
- size="small"
- icon="el-icon-arrow-up"
- @click.stop="hideSubContent(detailIndex + '-' + unitIndex)"
- ></el-button>
- <el-button
- v-show="
- isNested(paperDetailUnit.questionType) &&
- !showSubButtons[detailIndex + '-' + unitIndex]
- "
- size="small"
- type="primary"
- plain
- icon="el-icon-arrow-down"
- @click.stop="showSubContent(detailIndex + '-' + unitIndex)"
- ></el-button>
- </div>
- </div>
- <div v-show="quesTagShow" class="edit-property">
- <div class="edit-property-box">
- <div
- v-for="(questionTag, tagIndex) in paperDetailUnit.question
- .tags"
- :key="tagIndex"
- class="edit-property-item"
- >
- <div class="edit-property-body">
- <div class="edit-property-title">
- {{ questionTag.tag }}
- </div>
- <div class="edit-property-content">
- {{ questionTag.content }}
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div
- v-show="showSubQuestions[detailIndex + '-' + unitIndex]"
- :key="`question-sub-${unitIndex}`"
- class="edit-paper-question-subs"
- >
- <div
- v-for="(subQuestion, subIndex) in paperDetailUnit.question
- .subQuestions"
- v-show="quesShow(subQuestion.id)"
- :key="subIndex"
- class="edit-part"
- >
- <div
- class="edit-cont"
- @mouseover="
- quesMouseOver(
- getSubQuesEditId(paperDetailUnit, subQuestion)
- )
- "
- @mouseout="
- quesMouseOut(getSubQuesEditId(paperDetailUnit, subQuestion))
- "
- >
- <div class="edit-cont-title">
- <span>{{ subQuestion.subNumber }}. </span>
- <rich-text :text-json="subQuestion.quesBody"></rich-text>
- <span
- >({{ paperDetailUnit.subScoreList[subIndex] }}分)</span
- >
- </div>
- <div
- v-if="!isMatchingQuestion(paperDetailUnit.questionType)"
- class="edit-cont-body"
- >
- <div
- v-for="(
- subQuesOption, subOptIndex
- ) in subQuestion.quesOptions"
- :key="subOptIndex"
- class="paper-option"
- >
- <span>{{ subOptIndex | optionOrderWordFilter }}. </span>
- <rich-text
- :text-json="subQuesOption.optionBody"
- ></rich-text>
- </div>
- </div>
- <div v-show="quesAnswerShow" class="paper-answer">
- <span>答案:</span>
- <question-answer :data="subQuestion"></question-answer>
- <!-- <rich-text :text-json="subQuestion.quesAnswer"></rich-text> -->
- </div>
- <div
- :id="getSubQuesEditId(paperDetailUnit, subQuestion)"
- class="edit-cont-action"
- style="visibility: hidden"
- >
- <el-button
- size="small"
- type="primary"
- plain
- @click="editQues(paperDetailUnit, subQuestion)"
- >编辑
- </el-button>
- <el-button
- v-if="showUnitSubUp(paperDetailUnit, subQuestion.id)"
- size="small"
- type="primary"
- plain
- @click="
- movePaperDetailUnitSub(
- paperDetailUnit.id,
- subQuestion.id,
- 'up'
- )
- "
- >上移
- </el-button>
- <el-button
- v-if="showUnitSubDown(paperDetailUnit, subQuestion.id)"
- size="small"
- type="primary"
- plain
- @click="
- movePaperDetailUnitSub(
- paperDetailUnit.id,
- subQuestion.id,
- 'down'
- )
- "
- >下移
- </el-button>
- </div>
- </div>
- <div v-show="quesTagShow" class="edit-property">
- <div class="edit-property-box">
- <div
- v-for="(subQuestionTag, tagIndex) in subQuestion.tags"
- :key="tagIndex"
- class="edit-property-item"
- >
- <div class="edit-property-body">
- <div class="edit-property-title">
- {{ subQuestionTag.tag }}
- </div>
- <div class="edit-property-content">
- {{ subQuestionTag.content }}
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- </div>
- </div>
- </div>
- <!-- 编辑大题弹框 -->
- <el-dialog
- v-loading.body="detailLoading"
- width="600px"
- title="大题名称编辑"
- element-loading-text="保存中。。。"
- :visible.sync="paperDatailDialog"
- :modal="false"
- append-to-body
- custom-class="side-dialog"
- @close="closeQuesDialog"
- >
- <el-form :model="editpaperDetail" label-width="80px">
- <el-form-item label="大题名称">
- <el-input
- v-model="editpaperDetail.name"
- placeholder="请输入大题名称"
- ></el-input>
- </el-form-item>
- <el-form-item label="大题描述">
- <v-editor
- v-model="editpaperDetail.description"
- :enable-formula="false"
- ></v-editor>
- </el-form-item>
- </el-form>
- <div slot="footer">
- <el-button type="primary" @click="savePaperDatail(editpaperDetail)"
- >保存</el-button
- >
- <el-button type="danger" plain @click="closePaperDatailDialog()"
- >取消</el-button
- >
- </div>
- </el-dialog>
- <!-- 编辑试题弹框 -->
- <el-dialog
- v-loading.body="dialogLoading"
- title="试题编辑"
- width="900px"
- element-loading-text="保存中。。。"
- :visible.sync="quesDialog"
- :modal="false"
- append-to-body
- custom-class="side-dialog"
- @close="closeQuesDialog"
- >
- <el-form :model="quesModel" label-position="right" label-width="80px">
- <el-row :gutter="10">
- <el-col :span="12">
- <el-form-item label="题型">
- <el-select
- v-model="quesModel.questionType"
- :disabled="true"
- placeholder="请输入题型"
- >
- <el-option
- v-for="item in questionTypes"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="分值">
- <el-input-number
- v-model="quesModel.score"
- placeholder="分值"
- :precision="1"
- :min="0"
- :disabled="isNested(quesModel.questionType)"
- ></el-input-number>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="难度">
- <el-select
- v-model="quesModel.difficulty"
- placeholder="请输入难度"
- :disabled="
- isNested(quesModel.questionType) ? true : updatePorperty
- "
- >
- <el-option
- v-for="item in difficultyList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="公开度">
- <el-select
- v-model="quesModel.publicity"
- placeholder="请输入公开度"
- :disabled="updatePorperty"
- >
- <el-option
- v-for="item in publicityList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col
- v-if="quesModel.questionType == 'TEXT_ANSWER_QUESTION'"
- :span="12"
- >
- <el-form-item label="作答类型">
- <el-select
- v-model="quesModel.answerType"
- :disabled="updatePorperty"
- >
- <el-option
- v-for="item in answerTypes"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col
- v-if="quesModel.questionType && !isNested(quesModel.questionType)"
- :span="12"
- >
- <el-form-item label="时长">
- <el-input-number
- v-model="quesModel.control.maxAnswerTime"
- :precision="0"
- :min="1"
- :disabled="updatePorperty"
- ></el-input-number>
- </el-form-item>
- </el-col>
- <el-col v-if="isMatchingQuestion(quesModel.questionType)" :span="12">
- <el-form-item label="答题模式">
- <el-select
- v-model="quesModel.quesParam.matchingMode"
- :disabled="updatePorperty"
- >
- <el-option
- v-for="item in matchingModes"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item label="属性列表">
- <el-tooltip
- v-for="(content, propIndex) in quesModel.quesProperties"
- :key="propIndex"
- placement="top"
- >
- <div slot="content">
- <span v-if="content.firstProperty != null"
- >一级属性:{{ content.firstProperty.name }}({{
- content.firstProperty.code
- }})</span
- ><br />
- <span v-if="content.secondProperty != null"
- >二级属性:{{ content.secondProperty.name }}({{
- content.secondProperty.code
- }})</span
- >
- </div>
- <span>
- <el-tag
- :key="content.id"
- style="margin-right: 5px"
- :closable="
- isNested(quesModel.questionType) ? false : !updatePorperty
- "
- type="primary"
- effect="dark"
- @close="handleClose(content)"
- >
- {{ content.courseProperty.name }}
- </el-tag>
- </span>
- </el-tooltip>
- </el-form-item>
- <el-row v-if="!isNested(quesModel.questionType)" :gutter="10">
- <el-col :span="8">
- <el-form-item label="属性名" label-width="80px">
- <el-select
- v-model="coursePropertyId"
- :remote-method="getCoursesProperty"
- :loading="coursePropertyLoading"
- remote
- filterable
- clearable
- placeholder="属性名"
- class="property_with"
- :disabled="updatePorperty"
- @change="searchFirst"
- >
- <el-option label="请选择" value=""></el-option>
- <el-option
- v-for="item in coursePropertyList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="一级" label-width="48px">
- <el-select
- v-model="firstPropertyId"
- placeholder="一级"
- class="property_with"
- :disabled="updatePorperty"
- @change="searchSecond"
- >
- <el-option label="请选择" value=""></el-option>
- <el-option
- v-for="item in firstPropertyList"
- :key="item.id"
- :label="item.name + '(' + item.code + ')'"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="二级" label-width="48px">
- <el-select
- v-model="secondPropertyId"
- placeholder="二级"
- class="property_with"
- :disabled="updatePorperty"
- >
- <el-option label="请选择" value=""></el-option>
- <el-option
- v-for="item in secondPropertyList"
- :key="item.id"
- :label="item.name + '(' + item.code + ')'"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <el-form-item label-width="0px">
- <el-button
- type="primary"
- :disabled="updatePorperty"
- @click="insertProperty"
- ><i class="el-icon-plus"></i>新增属性
- </el-button>
- </el-form-item>
- </el-col>
- </el-row>
- <!-- end by weiwenhai -->
- <el-form-item label="题目">
- <v-editor
- v-model="quesModel.quesBody"
- :enable-answer-point="enableAnswerPoint"
- @change="quesBodyChange"
- ></v-editor>
- </el-form-item>
- <el-form-item
- v-for="(quesOption, optIndex) in quesModel.quesOptions"
- :key="optIndex"
- >
- <div class="question-edit-option">
- <div class="option-check">
- <div
- v-if="
- !quesModel.parentType ||
- !isMatchingQuestion(quesModel.parentType) ||
- !isInOtherSelect(optIndex, quesModel)
- "
- >
- <el-radio
- v-if="quesModel.questionType === 'SINGLE_ANSWER_QUESTION'"
- v-model="singleRightAnswer"
- :label="optIndex | optionOrderWordFilter"
- ></el-radio>
- <el-checkbox
- v-if="quesModel.questionType === 'MULTIPLE_ANSWER_QUESTION'"
- v-model="multipleRightAnswer"
- :label="optIndex | optionOrderWordFilter"
- ></el-checkbox>
- <span v-if="isMatchingQuestion(quesModel.questionType)">{{
- optIndex | optionOrderWordFilter
- }}</span>
- </div>
- <div
- v-if="
- quesModel.parentType &&
- isMatchingQuestion(quesModel.parentType) &&
- isInOtherSelect(optIndex, quesModel)
- "
- >
- <el-tooltip
- class="item"
- effect="dark"
- :content="otherSelect(optIndex, quesModel)"
- placement="top-start"
- >
- <el-radio
- v-if="quesModel.questionType === 'SINGLE_ANSWER_QUESTION'"
- v-model="singleRightAnswer"
- :disabled="true"
- :label="optIndex | optionOrderWordFilter"
- ></el-radio>
- <el-checkbox
- v-if="quesModel.questionType === 'MULTIPLE_ANSWER_QUESTION'"
- v-model="multipleRightAnswer"
- :disabled="true"
- :label="optIndex | optionOrderWordFilter"
- ></el-checkbox>
- <span v-if="isMatchingQuestion(quesModel.questionType)">{{
- optIndex | optionOrderWordFilter
- }}</span>
- </el-tooltip>
- </div>
- </div>
- <div
- v-if="
- !quesModel.parentType ||
- !isMatchingQuestion(quesModel.parentType)
- "
- class="option-body"
- >
- <v-editor v-model="quesOption.optionBody"></v-editor>
- </div>
- <div
- v-if="
- quesModel.parentType && isMatchingQuestion(quesModel.parentType)
- "
- class="option-body"
- >
- <rich-text :text-json="quesOption.optionBody"></rich-text>
- </div>
- <div
- v-if="
- !quesModel.parentType ||
- !isMatchingQuestion(quesModel.parentType)
- "
- class="option-delete"
- >
- <el-button
- size="mini"
- circle
- type="danger"
- icon="el-icon-delete"
- title="删除"
- @click.prevent="removeQuesOption(quesOption)"
- ></el-button>
- </div>
- </div>
- </el-form-item>
- <el-form-item>
- <el-button
- v-if="
- (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
- quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION' ||
- isMatchingQuestion(quesModel.questionType)) &&
- !isMatchingQuestion(quesModel.parentType)
- "
- type="primary"
- @click="addQuesOption"
- ><i class="el-icon-plus"></i> 新增选项
- </el-button>
- </el-form-item>
- <!-- 答案 -->
- <!-- 填空, -->
- <div v-if="quesModel.questionType == 'FILL_BLANK_QUESTION'">
- <el-form-item label="答案" prop="quesAnswer">
- <div v-if="quesAnswer" class="option-list">
- <div
- v-for="(opt, index) of quesAnswer"
- :key="index"
- class="option-item"
- >
- <div class="option-item-info">
- <span>({{ index + 1 }})</span>
- </div>
- <v-editor
- :value="opt"
- class="option-item-body"
- @change="(val) => updateAnswerPoint(index, val)"
- />
- </div>
- </div>
- </el-form-item>
- </div>
- <!-- 简答 -->
- <div v-if="quesModel.questionType === 'TEXT_ANSWER_QUESTION'">
- <el-form-item label="答案" prop="quesAnswer">
- <v-editor
- v-model="quesAnswer"
- @change="textAnswerChange"
- ></v-editor>
- </el-form-item>
- </div>
- <!-- 单选或多选 -->
- <div
- v-if="
- quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
- quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'
- "
- >
- <el-form-item label="答案">
- <span v-html="answer"></span>
- </el-form-item>
- </div>
- <!-- 判断 -->
- <div v-if="quesModel.questionType == 'BOOL_ANSWER_QUESTION'">
- <el-row>
- <el-col>
- <el-form-item label="答案">
- <el-select
- v-model="quesAnswer"
- placeholder="请选择"
- @change="boolAnswerChange"
- >
- <el-option
- v-for="op in options"
- :key="op.value"
- :label="op.label"
- :value="op.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- </div>
- </el-form>
- <div slot="footer">
- <el-button type="primary" @click="savePaperDetailUnit()"
- >保存</el-button
- >
- <el-button type="danger" plain @click="closeQuesDialog">取消</el-button>
- </div>
- </el-dialog>
- <!-- 考试说明弹框 -->
- <el-dialog
- title="考试说明编辑"
- :visible.sync="paperRemarkDialog"
- width="600px"
- :modal="false"
- append-to-body
- custom-class="side-dialog"
- >
- <el-form label-position="top">
- <el-form-item label="考试说明:">
- <v-editor v-model="examRemark" :enable-formula="false"></v-editor>
- </el-form-item>
- </el-form>
- <div slot="footer">
- <el-button type="primary" @click="savePaperRemark">保存</el-button>
- <el-button type="danger" plain @click="closPaperRemark">取消</el-button>
- </div>
- </el-dialog>
- <!-- 上传音频弹框 -->
- <el-dialog
- title="上传音频文件"
- :visible.sync="dialogRadioFile"
- :before-close="closeAudioDialog"
- :modal="false"
- width="520px"
- append-to-body
- custom-class="side-dialog"
- >
- <div>
- <div tabindex="0" class="el-upload el-upload--text">
- <el-button
- type="primary"
- icon="icon icon-search-white"
- @click="selectAudioFile"
- >选择文件</el-button
- >
- <input
- id="radioFile"
- class="el-upload__input"
- name="files"
- type="file"
- value="上传音频文件"
- webkitdirectory
- @change="audioFileChange"
- />
- </div>
- <el-button type="warning" @click="checkFile">检查文件名</el-button>
- <el-button
- type="info"
- :loading="uploadAudioLoading"
- :disabled="isUpload || uploadAudioLoading"
- @click="uploadAudioFile"
- >
- <span v-show="!uploadAudioLoading">开始上传</span>
- <span v-show="uploadAudioLoading">正在上传中...</span>
- </el-button>
- </div>
- <p class="tips-info"><i class="el-icon-info"></i>只能上传MP3文件</p>
- <p v-if="audioFileName" class="tips-info">文件: {{ audioFileName }}</p>
- <div v-if="checkResult" style="margin-top: 20px">
- <span>检查结果:</span><br /><br />
- <span v-show="message == 'OK!'" style="color: #13ce66">OK!</span>
- <span v-show="message != 'OK!'" style="color: #ff4949">{{
- message
- }}</span>
- </div>
- </el-dialog>
- <!-- 上传答案文件 -->
- <el-dialog
- title="上传答案文件"
- :visible.sync="dialogAnswerFile"
- :before-close="closeAnswerDialog"
- :modal="false"
- width="520px"
- append-to-body
- custom-class="side-dialog"
- >
- <div>
- <div tabindex="0" class="el-upload el-upload--text">
- <el-button
- type="primary"
- icon="icon icon-search-white"
- @click="selectAnswerFile"
- >选择文件</el-button
- >
- <input
- id="answerFile"
- class="el-upload__input"
- name="answerFiles"
- type="file"
- value="上传答案文件"
- accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
- @change="answerFileChange"
- />
- </div>
- <el-button type="primary" @click="downAnswerTemplate">
- <span>下载模板</span>
- </el-button>
- <el-button
- type="primary"
- :loading="uploadAnswerLoading"
- :disabled="uploadAnswerLoading"
- @click="uploadAnswerFile"
- >
- <span v-show="!uploadAnswerLoading">开始上传</span>
- <span v-show="uploadAnswerLoading">正在上传中...</span>
- </el-button>
- </div>
- <p v-if="answerFileName" class="tips-info">文件: {{ answerFileName }}</p>
- <div style="margin-top: 20px">
- <span v-show="answerMessage != ''" style="color: #ff4949">{{
- answerMessage
- }}</span>
- </div>
- </el-dialog>
- <!-- 基础构成 -->
- <el-dialog
- title="基础构成"
- width="100%"
- :visible.sync="basicDialog"
- :modal="false"
- append-to-body
- custom-class="side-dialog"
- >
- <PaperBasicComposition
- v-if="basicDialog"
- :paper-id="paperId"
- ></PaperBasicComposition>
- </el-dialog>
- <!-- 题型分布 -->
- <el-dialog
- title="题型分布"
- width="100%"
- :visible.sync="typeDialog"
- :modal="false"
- append-to-body
- custom-class="side-dialog"
- >
- <PaperQuestionType
- v-if="typeDialog"
- :paper-id="paperId"
- ></PaperQuestionType>
- </el-dialog>
- <!-- 蓝图分布 -->
- <el-dialog
- title="蓝图分布"
- width="100%"
- :visible.sync="blueDialog"
- :modal="false"
- append-to-body
- custom-class="side-dialog"
- >
- <PaperBlue
- v-if="blueDialog"
- :paper-id="paperId"
- :course-id="paper.course.id"
- ></PaperBlue>
- </el-dialog>
- <!-- 审核记录 -->
- <el-dialog
- title="审核记录"
- width="700px"
- :visible.sync="auditInfoDialog"
- :modal="false"
- append-to-body
- custom-class="side-dialog"
- >
- <AuditInfo v-if="auditInfoDialog" :paper-id="paperId"></AuditInfo>
- </el-dialog>
- </div>
- </template>
- <script>
- import { QUESTION_API } from "@/constants/constants";
- import { isEmptyStr, QUESTION_TYPES } from "../constants/constants";
- import { mapState } from "vuex";
- import PaperBasicComposition from "./PaperBasicComposition.vue";
- import PaperQuestionType from "./PaperQuestionType.vue";
- import PaperBlue from "./PaperBlue.vue";
- import AuditInfo from "./AuditInfo.vue";
- import QuestionAnswer from "../../question/components/QuestionAnswer.vue";
- import { checkRichTextContentIsEmpty } from "@/plugins/utils";
- export default {
- name: "EditPaperApp",
- components: {
- PaperBasicComposition,
- PaperQuestionType,
- PaperBlue,
- AuditInfo,
- QuestionAnswer,
- },
- data() {
- return {
- coursePropertyLoading: false,
- showCheckDuplicateBtn: false,
- auditInfoDialog: false,
- blueDialog: false,
- typeDialog: false,
- basicDialog: false,
- quesAnswerShow: true,
- quesTagShow: true,
- hValue: "100px",
- wValue: "560px",
- display: "block",
- uploadAction: "",
- fileList: [],
- answerFileList: [],
- paperId: null,
- paperDetailId: "",
- editPaperDetailUnit: "",
- quesDialog: false,
- paperDatailDialog: false,
- paperRemarkDialog: false,
- parentView: "",
- paper: {
- course: {
- code: "",
- name: "",
- },
- examRemark: "",
- },
- loading: false,
- dialogLoading: false,
- detailLoading: false,
- uploadAudioLoading: false,
- uploadAnswerLoading: false,
- questionTypes: QUESTION_TYPES,
- questionType: "",
- quesModel: { quesProperties: [] },
- quesAnswer: null,
- prevAnswerPointCount: 0,
- editpaperDetail: {},
- reduplicateQuestions: [],
- reduplicateGroup: [],
- reduplicateQuesColor: [],
- singleRightAnswer: "", //接收单选答案
- multipleRightAnswer: [], //接收多选答案
- options: [
- {
- value: 0,
- label: "错误",
- },
- {
- value: 1,
- label: "正确",
- },
- ],
- duplicateLoading: false,
- dialogRadioFile: false,
- dialogAnswerFile: false,
- isUpload: true,
- isUploadAnswer: true,
- message: "",
- answerMessage: "",
- answerFileName: "",
- audioFileName: "",
- checkResult: false,
- checkResultAnswer: false,
- fileNameList: [],
- defaultColor: [
- "Red",
- "Blue",
- "LimeGreen",
- "GoldenRod",
- "Black",
- "BlueViolet",
- "Chocolate",
- "DarkCyan",
- "HotPink",
- "Orange",
- "IndianRed",
- "Indigo",
- "Green",
- "Aqua",
- "CadetBlue",
- "SkyBlue",
- "SlateBlue",
- "SlateGray",
- "Tomato",
- "VioletRed",
- ],
- difficultyList: [
- { label: "难", value: "难" },
- { label: "中", value: "中" },
- { label: "易", value: "易" },
- ],
- publicityList: [
- { label: "公开", value: true },
- { label: "非公开", value: false },
- ],
- answerTypes: [
- { label: "文本", value: "DIVERSIFIED_TEXT" },
- { label: "音频", value: "SINGLE_AUDIO" },
- ],
- matchingTypes: [
- { label: "填词", value: 1 },
- { label: "段落", value: 2 },
- ],
- matchingModes: [
- { label: "单用", value: 1 },
- { label: "复用", value: 2 },
- ],
- coursePropertyList: [],
- coursePropertyId: "", //课程属性名
- firstPropertyList: [], //一级属性集合
- firstPropertyId: "", //一级属性id
- secondPropertyList: [], //二级属性集合
- secondPropertyId: "", //二级属性id
- examRemark: "",
- showQuestions: [],
- showButtons: [],
- showSubQuestions: {},
- showSubButtons: {},
- };
- },
- computed: {
- ...mapState({
- user: (state) => state.user,
- }),
- updatePorperty() {
- return false;
- },
- answer() {
- if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
- return this.singleRightAnswer;
- } else if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
- var obj = this.multipleRightAnswer;
- return obj.sort().toString();
- }
- return this.quesModel.quesAnswer;
- },
- enableAnswerPoint() {
- return (
- this.quesModel.questionType == "FILL_BLANK_QUESTION" ||
- this.quesModel.questionType == "CLOZE" ||
- this.quesModel.questionType == "BANKED_CLOZE"
- );
- },
- enableCardEdit() {
- return (
- this.paper.auditStatus === "PASS" && this.paper.paperType === "GENERATE"
- );
- },
- },
- created() {
- let qt = sessionStorage.getItem("quesTagShow");
- if (qt) {
- this.quesTagShow = qt == "true";
- }
- let qa = sessionStorage.getItem("quesAnswerShow");
- if (qa) {
- this.quesAnswerShow = qa == "true";
- }
- document.getElementsByTagName("body")[0].style = "";
- this.paperId = Number(this.$route.params.id);
- this.parentView = this.$route.params.parentView;
- this.initPaper();
- this.uploadAction = QUESTION_API + "/uploadRadio/" + this.paperId;
- this.uploadHeaders = {
- key: this.user.key,
- token: this.user.token,
- };
- },
- methods: {
- getQuesPropertyKey(quesProp) {
- if (!quesProp) {
- return "";
- } else if (quesProp.secondProperty.id) {
- return (
- quesProp.courseProperty.id +
- "-" +
- quesProp.firstProperty.id +
- "-" +
- quesProp.secondProperty.id
- );
- } else {
- return quesProp.courseProperty.id + "-" + quesProp.firstProperty.id;
- }
- },
- getCoursesProperty(name) {
- this.coursePropertyLoading = true;
- this.$httpWithMsg
- .get(
- QUESTION_API +
- "/courseProperty/enable?courseId=" +
- this.paper.course.id +
- "&name=" +
- name
- )
- .then((response) => {
- this.coursePropertyList = response.data;
- this.coursePropertyLoading = false;
- });
- },
- showCheckDuplicate() {
- if (this.paper.checkDuplicateStatus == "DISPOSED") {
- this.showCheckDuplicateBtn = false;
- } else if (this.paper.paperDetails) {
- for (let paperDetilData of this.paper.paperDetails) {
- if (paperDetilData.paperDetailUnits) {
- for (let unit of paperDetilData.paperDetailUnits) {
- if (unit.question.checkDuplicateStatus == "TO_BE_DISPOSE") {
- this.showCheckDuplicateBtn = true;
- return;
- }
- }
- }
- }
- this.showCheckDuplicateBtn = false;
- }
- },
- checkDuplicate() {
- this.$router.push({
- name: "check_duplicate_info",
- query: {
- basePaperId: this.paper.id,
- from: "paper",
- },
- });
- },
- checkDuplicateQuestion(questionId) {
- this.$router.push({
- name: "check_duplicate_info",
- query: {
- quesId: questionId,
- basePaperId: this.paper.id,
- from: "paper",
- },
- });
- },
- toEditCard() {
- this.$router.push({
- name: "CardEdit",
- params: {
- idType: "paper",
- paperOrCardId: this.paperId,
- },
- });
- },
- showAuditDialog() {
- this.auditInfoDialog = true;
- },
- showBlueDialog() {
- this.blueDialog = true;
- },
- showTypeDialog() {
- this.typeDialog = true;
- },
- showBasicDialog() {
- this.basicDialog = true;
- },
- quesAnswerShowHide() {
- this.quesAnswerShow = !this.quesAnswerShow;
- sessionStorage.setItem("quesAnswerShow", this.quesAnswerShow);
- },
- quesTagShowHide() {
- this.quesTagShow = !this.quesTagShow;
- sessionStorage.setItem("quesTagShow", this.quesTagShow);
- },
- isMatchingQuestion(questionType) {
- if (
- questionType == "PARAGRAPH_MATCHING" ||
- questionType == "BANKED_CLOZE"
- ) {
- return true;
- } else {
- return false;
- }
- },
- isNested(questionType) {
- if (
- questionType == "PARAGRAPH_MATCHING" ||
- questionType == "BANKED_CLOZE" ||
- questionType == "CLOZE" ||
- questionType == "READING_COMPREHENSION" ||
- questionType == "LISTENING_QUESTION"
- ) {
- return true;
- } else {
- return false;
- }
- },
- otherSelect(optIndex, quesModel) {
- return "该选项被第" + quesModel.optionsSelected[optIndex + 1] + "题选用";
- },
- isInOtherSelect(optIndex, quesModel) {
- if (quesModel.parentQuesParam.matchingMode != 1) {
- return false;
- }
- if (!quesModel.optionsSelected) {
- return false;
- }
- if (!quesModel.optionsSelected[optIndex + 1]) {
- return false;
- }
- if (
- quesModel.optionsSelected[optIndex + 1].includes(quesModel.subNumber)
- ) {
- return false;
- }
- return true;
- },
- movePaperDetailUnitSub(unitid, subid, vector) {
- let vectorStr = vector == "up" ? "上移" : "下移";
- this.$alert("您确定" + vectorStr + "吗?", "提示", {
- confirmButtonText: "确定",
- callback: (action) => {
- if (action == "confirm") {
- this.loading = true;
- this.$httpWithMsg
- .put(
- QUESTION_API +
- "/paperDetailUnit/sub/" +
- unitid +
- "/" +
- subid +
- "/" +
- vector
- )
- .then(() => {
- this.initPaper();
- this.loading = true;
- this.$notify({
- message: vectorStr + "成功",
- type: "success",
- });
- })
- .finally(() => {
- this.loading = false;
- });
- }
- },
- });
- },
- showUnitSubDown(unit, subid) {
- if (unit.question.subQuestions.length <= 1) {
- return false;
- }
- if (
- subid !=
- unit.question.subQuestions[unit.question.subQuestions.length - 1].id
- ) {
- return true;
- } else {
- return false;
- }
- },
- showUnitSubUp(unit, subid) {
- if (unit.question.subQuestions.length <= 1) {
- return false;
- }
- if (subid != unit.question.subQuestions[0].id) {
- return true;
- } else {
- return false;
- }
- },
- movePaperDetailUnit(detailId, unitid, vector) {
- let vectorStr = vector == "up" ? "上移" : "下移";
- this.$alert("您确定" + vectorStr + "吗?", "提示", {
- confirmButtonText: "确定",
- callback: (action) => {
- if (action == "confirm") {
- this.loading = true;
- this.$httpWithMsg
- .put(
- QUESTION_API +
- "/paperDetailUnit/" +
- detailId +
- "/" +
- unitid +
- "/" +
- vector
- )
- .then(() => {
- this.initPaper();
- this.loading = true;
- this.$notify({
- message: vectorStr + "成功",
- type: "success",
- });
- })
- .finally(() => {
- this.loading = false;
- });
- }
- },
- });
- },
- showUnitDown(detail, unitid) {
- if (detail.paperDetailUnits.length <= 1) {
- return false;
- }
- if (
- unitid != detail.paperDetailUnits[detail.paperDetailUnits.length - 1].id
- ) {
- return true;
- } else {
- return false;
- }
- },
- showUnitUp(detail, unitid) {
- if (detail.paperDetailUnits.length <= 1) {
- return false;
- }
- if (unitid != detail.paperDetailUnits[0].id) {
- return true;
- } else {
- return false;
- }
- },
- movePaperDetail(detail, vector) {
- let vectorStr = vector == "up" ? "上移" : "下移";
- this.$alert("您确定" + vectorStr + "吗?", "提示", {
- confirmButtonText: "确定",
- callback: (action) => {
- if (action == "confirm") {
- this.loading = true;
- this.$httpWithMsg
- .put(
- QUESTION_API +
- "/paperDetail/" +
- this.paperId +
- "/" +
- detail.id +
- "/" +
- vector
- )
- .then(() => {
- this.initPaper();
- this.loading = true;
- this.$notify({
- message: vectorStr + "成功",
- type: "success",
- });
- })
- .finally(() => {
- this.loading = false;
- });
- }
- },
- });
- },
- showUp(detail) {
- if (this.paper.paperDetails.length <= 1) {
- return false;
- }
- if (detail.id != this.paper.paperDetails[0].id) {
- return true;
- } else {
- return false;
- }
- },
- showDown(detail) {
- if (this.paper.paperDetails.length <= 1) {
- return false;
- }
- if (
- detail.id !=
- this.paper.paperDetails[this.paper.paperDetails.length - 1].id
- ) {
- return true;
- } else {
- return false;
- }
- },
- downAnswerTemplate() {
- var key = this.user.key;
- var token = this.user.token;
- window.open(
- QUESTION_API + "/paper/answer/template?$key=" + key + "&$token=" + token
- );
- },
- openAnswerDialog() {
- this.checkResultAnswer = false;
- this.isUploadAnswer = true;
- if (document.getElementById("answerFile")) {
- document.getElementById("answerFile").value = "";
- }
- this.answerFileName = "";
- this.dialogAnswerFile = true;
- this.answerFileList = [];
- },
- closeAnswerDialog() {
- this.answerMessage = "";
- this.dialogAnswerFile = this.uploadAnswerLoading;
- },
- selectAnswerFile() {
- document.getElementById("answerFile").click();
- },
- answerFileChange() {
- let fileList = document.getElementById("answerFile").files;
- if (fileList.length == 0) {
- this.answerFileName = "";
- } else {
- this.answerFileName = fileList[0].name;
- }
- },
- uploadAnswerFile() {
- this.answerMessage = "";
- var fileList = document.getElementById("answerFile").files;
- if (fileList.length == 0) {
- this.answerMessage = "请选择文件!";
- return;
- }
- let param = new FormData();
- //循环添加到formData中
- for (var i = 0; i < fileList.length; i++) {
- var file = fileList[i];
- param.append("dataFile", file, file.name);
- }
- let config = {
- headers: { "Content-Type": "multipart/form-data" },
- };
- this.uploadAnswerLoading = true;
- this.$http
- .post(
- QUESTION_API + "/paper/answer/import/" + this.paperId,
- param,
- config
- )
- .then(() => {
- this.dialogAnswerFile = false;
- this.uploadAnswerLoading = false;
- this.checkResultAnswer = false;
- this.isUploadAnswer = true;
- document.getElementById("answerFile").value = "";
- this.initPaper();
- })
- .catch((error) => {
- this.answerMessage = error.response.data.desc;
- document.getElementById("answerFile").value = "";
- this.uploadAnswerLoading = false;
- });
- },
- //隐藏大题下的所有小题
- hideContent(index) {
- this.showQuestions[index].is_show = false;
- this.showButtons[index].up = false;
- },
- //展开大题下所有小题
- showContent(index) {
- this.showQuestions[index].is_show = true;
- this.showButtons[index].up = true;
- },
- //隐藏大题下的所有小题
- hideSubContent(index) {
- this.showSubQuestions[index] = false;
- this.showSubButtons[index] = false;
- this.$forceUpdate();
- },
- //展开大题下所有小题
- showSubContent(index) {
- this.showSubQuestions[index] = true;
- this.showSubButtons[index] = true;
- this.$forceUpdate();
- },
- quesMouseOver(index) {
- document.getElementById(index).style.visibility = "visible";
- },
- quesMouseOut(index) {
- document.getElementById(index).style.visibility = "hidden";
- },
- selectQues(id) {
- this.paperDetailId = id;
- var courseId = this.paper.course.id;
- this.$router.push({
- path:
- "/select_question/" +
- this.paper.id +
- "/" +
- courseId +
- "/" +
- this.paperDetailId +
- "/" +
- this.parentView,
- });
- },
- //打开编辑大题题目弹窗
- openEditPaperDetail(paperDetail) {
- this.paperDatailDialog = true;
- this.editpaperDetail = Object.assign({}, paperDetail); //浅拷贝
- },
- //关闭编辑大题题目弹窗
- closePaperDatailDialog() {
- this.paperDatailDialog = false;
- this.editpaperDetail = {};
- },
- //保存大题题目信息
- savePaperDatail(editpaperDetail) {
- this.detailLoading = true;
- var paperId = this.paper.id;
- this.$http
- .post(QUESTION_API + "/updatePaperDetail/" + paperId, editpaperDetail)
- .then(() => {
- this.$notify({
- message: "保存成功",
- type: "success",
- });
- this.detailLoading = false;
- this.closePaperDatailDialog();
- this.initPaper();
- });
- },
- //初始化试卷
- initPaper() {
- const scrollPosition =
- document.documentElement.scrollTop || document.body.scrollTop;
- this.loading = true;
- this.paper = {
- course: {
- code: "",
- name: "",
- },
- };
- this.$http
- .get(QUESTION_API + "/paper/" + this.paperId)
- .then((response) => {
- this.paper = response.data;
- //查询所有课程属性名
- this.getCoursesProperty("");
- //将所有小题分为公开和非公开
- if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
- let dindx = 0;
- for (let paperDetil of this.paper.paperDetails) {
- this.showQuestions.push({ is_show: true });
- this.showButtons.push({ up: true });
- paperDetil.pubCount = 0;
- paperDetil.noPubCount = 0;
- if (
- paperDetil.paperDetailUnits &&
- paperDetil.paperDetailUnits.length > 0
- ) {
- let uindx = 0;
- for (let paperDetilUt of paperDetil.paperDetailUnits) {
- this.showSubQuestions[dindx + "-" + uindx] = true;
- this.showSubButtons[dindx + "-" + uindx] = true;
- if (!this.isNested(paperDetilUt.question.questionType)) {
- //非套题
- if (paperDetilUt.question.publicity) {
- paperDetil.pubCount = paperDetil.pubCount + 1;
- } else {
- paperDetil.noPubCount = paperDetil.noPubCount + 1;
- }
- } else {
- //循环所有子题
- for (let ques of paperDetilUt.question.subQuestions) {
- if (ques.publicity) {
- paperDetil.pubCount = paperDetil.pubCount + 1;
- } else {
- paperDetil.noPubCount = paperDetil.noPubCount + 1;
- }
- }
- }
- uindx++;
- }
- }
- dindx++;
- }
- }
- this.showCheckDuplicate();
- setTimeout(() => {
- document.documentElement.scrollTop = document.body.scrollTop =
- scrollPosition;
- console.log(scrollPosition);
- }, 1000);
- this.loading = false;
- })
- .catch(() => {
- this.loading = false;
- });
- },
- //删除大题
- deletePaperDetail(paperDetailsId) {
- //先判断大题下面是否还有小题
- var count = 0;
- for (var i = 0, imax = this.paper.paperDetails.length; i < imax; i++) {
- if (paperDetailsId == this.paper.paperDetails[i].id) {
- if (this.paper.paperDetails[i].paperDetailUnits) {
- count += this.paper.paperDetails[i].paperDetailUnits.length;
- break;
- }
- }
- }
- if (count == 0) {
- this.$alert("您确定删除吗?", "提示", {
- confirmButtonText: "确定",
- callback: (action) => {
- if (action == "confirm") {
- this.loading = true;
- this.$http
- .delete(
- QUESTION_API +
- "/paperDetail/" +
- this.paperId +
- "/" +
- paperDetailsId
- )
- .then(() => {
- this.initPaper();
- this.loading = true;
- this.$notify({
- message: "删除成功",
- type: "success",
- });
- this.loading = false;
- })
- .catch(() => {
- this.loading = false;
- });
- }
- },
- });
- } else {
- this.$alert("大题下还有小题,不可删除!", "提示", {
- confirmButtonText: "确定",
- callback: () => {},
- });
- }
- },
- quesShow(id) {
- if (this.reduplicateGroup.length < 1) {
- return true;
- }
- for (var i = 0, imax = this.reduplicateGroup.length; i < imax; i++) {
- if (id == this.reduplicateGroup[i]) {
- return true;
- }
- }
- return false;
- },
- //编辑题目
- editQues(paperDetailUnit, question) {
- console.log("question:", question);
- this.coursePropertyId = "";
- this.firstPropertyId = "";
- this.secondPropertyId = "";
- this.editPaperDetailUnit = paperDetailUnit;
- this.quesModel = JSON.parse(JSON.stringify(question)); //深拷贝
- if (!this.quesModel.control) {
- this.quesModel.control = {};
- }
- this.quesModel.score = paperDetailUnit.score;
- //如果是套题下面的小题编辑 ( paperDetailUnit的类型是套题,question的类型不是套题)
- if (
- this.isNested(paperDetailUnit.questionType) &&
- question.questionType != paperDetailUnit.questionType
- ) {
- for (var i = 0; i < paperDetailUnit.question.subQuestions.length; i++) {
- if (
- paperDetailUnit.question.subQuestions[i].id == this.quesModel.id
- ) {
- this.quesModel.score = paperDetailUnit.subScoreList[i];
- this.quesModel.parentType = paperDetailUnit.questionType;
- this.quesModel.optionsSelected = paperDetailUnit.optionsSelected;
- this.quesModel.parentQuesParam = paperDetailUnit.question.quesParam;
- break;
- }
- }
- }
- if (isEmptyStr(this.quesModel.answerType)) {
- this.quesModel.answerType = "DIVERSIFIED_TEXT";
- }
- if (this.quesModel.questionType === "BOOL_ANSWER_QUESTION") {
- this.quesAnswer = this.quesModel.quesAnswer === "true" ? 1 : 0;
- } else if (this.quesModel.questionType === "TEXT_ANSWER_QUESTION") {
- const answer = JSON.parse(this.quesModel.quesAnswer);
- this.quesAnswer = answer[0];
- } else if (this.quesModel.questionType == "FILL_BLANK_QUESTION") {
- const answer = JSON.parse(this.quesModel.quesAnswer);
- this.quesAnswer = answer;
- } else {
- this.quesAnswer = null;
- }
- this.prevAnswerPointCount = this.getAnswerPointCount(
- this.quesModel.quesBody
- );
- this.assignAnswers(); //给singleRightAnswer或multipleRightAnswer赋值
- this.openQuesDialog();
- console.log(this.quesModel);
- },
- //给singleRightAnswer和multipleRightAnswer赋值
- assignAnswers() {
- if (this.quesModel.quesOptions && this.quesModel.quesOptions.length > 0) {
- this.singleRightAnswer = "";
- this.multipleRightAnswer = [];
- for (let i = 0; i < this.quesModel.quesOptions.length; i++) {
- let option = this.quesModel.quesOptions[i];
- if (
- this.quesModel.questionType == "SINGLE_ANSWER_QUESTION" &&
- option.isCorrect == 1
- ) {
- this.singleRightAnswer = String.fromCharCode(65 + i);
- }
- if (
- this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION" &&
- option.isCorrect == 1
- ) {
- this.multipleRightAnswer.push(String.fromCharCode(65 + i));
- }
- }
- }
- },
- boolAnswerChange(val) {
- this.quesModel.quesAnswer = val ? "true" : "false";
- },
- textAnswerChange(val) {
- this.quesModel.quesAnswer = JSON.stringify([val]);
- },
- resetNumberAndSaveAnswerPoints(answer) {
- this.quesAnswer = answer.map((element, index) => {
- element.index = index + 1;
- return element;
- });
- this.quesModel.quesAnswer = JSON.stringify(this.quesAnswer);
- },
- updateAnswerPoint(index, value) {
- // console.log(index, this.question.answer[index]);
- this.quesAnswer[index] = { ...value };
- this.resetNumberAndSaveAnswerPoints(this.quesAnswer);
- },
- getAnswerPointCount(bodyJson) {
- let count = 0;
- bodyJson.sections.forEach((section) => {
- section.blocks.forEach((block) => {
- if (block.type === "cloze") count++;
- });
- });
- return count;
- },
- quesBodyChange(quesBodyJson) {
- console.log(quesBodyJson);
- this.quesModel.quesBody = quesBodyJson;
- if (this.quesModel.questionType == "FILL_BLANK_QUESTION") {
- let curPonitCount = this.getAnswerPointCount(quesBodyJson);
- if (curPonitCount === this.prevAnswerPointCount) return;
- this.prevAnswerPointCount = curPonitCount;
- let newAnswer = [];
- for (let i = 0; i < curPonitCount; i++) {
- newAnswer.push(
- (this.quesAnswer && this.quesAnswer[i]) || { sections: [] }
- );
- }
- this.resetNumberAndSaveAnswerPoints(newAnswer);
- }
- },
- //打开修改试题编辑框
- openQuesDialog() {
- this.quesDialog = true;
- },
- //关闭试题编辑框
- closeQuesDialog() {
- this.quesDialog = false;
- this.quesModel = {};
- },
- //删除属性
- handleClose(tag) {
- this.quesModel.quesProperties.splice(
- this.quesModel.quesProperties.indexOf(tag),
- 1
- );
- },
- //查询一级属性
- searchFirst() {
- this.firstPropertyId = "";
- this.secondPropertyId = "";
- this.secondPropertyList = [];
- if (this.coursePropertyId) {
- for (let courseProperty of this.coursePropertyList) {
- if (courseProperty.id == this.coursePropertyId) {
- this.$http
- .get(QUESTION_API + "/property/first/" + courseProperty.id)
- .then((response) => {
- this.firstPropertyList = response.data;
- });
- }
- }
- }
- },
- //查询二级属性
- searchSecond() {
- this.secondPropertyId = "";
- if (this.firstPropertyId) {
- this.$http
- .get(QUESTION_API + "/property/second/" + this.firstPropertyId)
- .then((response) => {
- this.secondPropertyList = response.data;
- });
- }
- },
- //新增属性
- insertProperty() {
- if (!this.checkInsertPro()) {
- return false;
- }
- var quesProperty = {
- key: "",
- courseProperty: {},
- firstProperty: {},
- secondProperty: {},
- };
- if (
- this.quesModel.quesProperties == null ||
- this.quesModel.quesProperties.length == 0
- ) {
- this.quesModel.quesProperties = [];
- }
- let quesPropertyKey =
- this.coursePropertyId +
- "-" +
- this.firstPropertyId +
- "-" +
- this.secondPropertyId;
- for (let quesPro of this.quesModel.quesProperties) {
- if (quesPro.key == quesPropertyKey) {
- this.$notify({
- message: "该属性已存在,请重新选择",
- type: "error",
- });
- return false;
- }
- }
- for (let property of this.coursePropertyList) {
- if (property.id == this.coursePropertyId) {
- quesProperty.courseProperty = property;
- }
- }
- //取到一级属性对象
- for (let property of this.firstPropertyList) {
- if (property.id == this.firstPropertyId) {
- quesProperty.firstProperty = property;
- }
- }
- //判断是否有二级属性
- if (
- this.secondPropertyList != undefined &&
- this.secondPropertyList.length > 0
- ) {
- if (!this.secondPropertyId) {
- this.$notify({
- message: "请选择二级属性",
- type: "error",
- });
- return false;
- }
- }
- //取到二级属性对象
- for (let property of this.secondPropertyList) {
- if (property.id == this.secondPropertyId) {
- quesProperty.secondProperty = property;
- }
- }
- quesProperty.key = this.getQuesPropertyKey(quesProperty);
- this.quesModel.quesProperties.push(quesProperty);
- this.quesModel = Object.assign({}, this.quesModel);
- //清空下拉框
- this.coursePropertyId = "";
- this.firstPropertyId = "";
- this.secondPropertyId = "";
- this.firstPropertyList = [];
- this.secondPropertyList = [];
- },
- //新增属性验证
- checkInsertPro() {
- if (!this.coursePropertyId) {
- this.$notify({
- message: "请选择属性",
- type: "error",
- });
- return false;
- }
- if (!this.firstPropertyId) {
- this.$notify({
- message: "请选择一级属性",
- type: "error",
- });
- return false;
- }
- return true;
- },
- //删除选项
- removeQuesOption(option) {
- if (this.quesModel.quesOptions.length == 1) {
- this.$notify({
- message: "不能删除最后一个选项",
- type: "error",
- });
- return;
- }
- this.singleRightAnswer = "";
- this.multipleRightAnswer = [];
- let index = this.quesModel.quesOptions.indexOf(option);
- if (index !== -1) {
- this.quesModel.quesOptions.splice(index, 1);
- }
- if (this.quesModel.quesOptions.length > 0) {
- for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
- var quesOption = this.quesModel.quesOptions[i];
- quesOption["number"] = i + 1;
- if (quesOption.isCorrect == 1) {
- var answerOrderNum = String.fromCharCode(65 + i);
- if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
- this.singleRightAnswer = answerOrderNum;
- }
- if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
- this.multipleRightAnswer.push(answerOrderNum);
- }
- }
- }
- }
- },
- //新增选项
- addQuesOption() {
- if (this.quesModel.quesOptions.length >= 20) {
- this.$notify({
- message: "选项最多20个",
- type: "error",
- });
- return;
- }
- this.quesModel.quesOptions.push({
- number: "",
- optionBody: "",
- isCorrect: "",
- });
- for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
- this.quesModel.quesOptions[i]["number"] = i + 1;
- }
- },
- savePaperDetailUnit() {
- this.setRightAnswer();
- if (/^\d+(?=\.{0,1}\d+$|$)/.test(this.quesModel.score)) {
- console.log("正确");
- } else {
- this.$notify({
- message: "分数只能为正数",
- type: "error",
- });
- return;
- }
- if (this.enableAnswerPoint) {
- const pointCount = this.getAnswerPointCount(this.quesModel.quesBody);
- if (!pointCount) {
- this.$notify({
- message: "请插入答题点",
- type: "error",
- });
- return;
- }
- }
- if (this.quesModel.quesOptions) {
- if (this.quesModel.quesOptions.length > 20) {
- this.$notify({
- message: "选项最多20个",
- type: "error",
- });
- return;
- }
- if (
- this.quesModel.quesOptions.length &&
- this.quesModel.quesOptions.some((item) =>
- checkRichTextContentIsEmpty(item.optionBody)
- )
- ) {
- this.$notify({
- message: "有选项内容为空",
- type: "error",
- });
- return;
- }
- }
- if (this.paper.paperType == "GENERATE") {
- this.$confirm(
- "试题内容修改,会影响所有关联试卷,是否确定进行?",
- "提示",
- {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }
- ).then(() => {
- this.submitPaperDetailUnit();
- });
- } else {
- this.submitPaperDetailUnit();
- }
- },
- submitPaperDetailUnit() {
- let paperDetailUnitExp = {
- id: this.editPaperDetailUnit.id,
- question: this.quesModel,
- score: this.quesModel.score,
- };
- if (
- (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION" ||
- this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") &&
- this.quesModel.quesOptions.length == 0
- ) {
- this.$confirm("无选项将删除该试题, 是否继续?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- this.dialogLoading = true;
- this.$http
- .delete(
- QUESTION_API +
- "/paper/deleteQuestion/" +
- this.editPaperDetailUnit.id +
- "/" +
- this.quesModel.id
- )
- .then((response) => {
- if (response.data.length > 0) {
- var deleteInfo =
- "该试题被试卷:" +
- response.data.join(" , ") +
- "使用,不能删除";
- this.$notify({
- message: deleteInfo,
- type: "error",
- });
- } else {
- this.$notify({
- message: "保存成功",
- type: "success",
- });
- }
- this.dialogLoading = false;
- });
- });
- } else {
- this.dialogLoading = true;
- //校验音频重复
- let audiomap = new Map();
- let regex = new RegExp(
- '<a id="[^<>]+" name="([^<>]+\\.mp3)"></a>',
- "ig"
- );
- let ret = "";
- let quesBodyStr = paperDetailUnitExp.question.quesBody;
- if (quesBodyStr) {
- while ((ret = regex.exec(quesBodyStr))) {
- if (audiomap.get(ret[1])) {
- this.dialogLoading = false;
- this.$notify({
- type: "error",
- message: "题干中存在相同的音频文件",
- });
- return;
- } else {
- audiomap.set(ret[1], ret[1]);
- }
- }
- }
- let quesAnswerStr = paperDetailUnitExp.question.quesAnswer;
- if (quesAnswerStr) {
- while ((ret = regex.exec(quesAnswerStr))) {
- if (audiomap.get(ret[1])) {
- this.dialogLoading = false;
- this.$notify({
- type: "error",
- message: "答案中存在相同的音频文件",
- });
- return;
- } else {
- audiomap.set(ret[1], ret[1]);
- }
- }
- }
- let quesOptions = paperDetailUnitExp.question.quesOptions;
- if (quesOptions) {
- for (let i = 0; i < quesOptions.length; i++) {
- let quesOptionStr = quesOptions[i].optionBody;
- while ((ret = regex.exec(quesOptionStr))) {
- if (audiomap.get(ret[1])) {
- this.dialogLoading = false;
- this.$notify({
- type: "error",
- message: "选项中存在相同的音频文件",
- });
- return;
- } else {
- audiomap.set(ret[1], ret[1]);
- }
- }
- }
- }
- // paperDetailUnitExp.question.quesAnswer = this.answer;
- this.$http
- .put(QUESTION_API + "/paperDetailUnit", paperDetailUnitExp)
- .then(() => {
- this.$notify({
- message: "保存成功",
- type: "success",
- });
- this.dialogLoading = false;
- this.closeQuesDialog();
- this.initPaper();
- })
- .catch((err) => {
- this.dialogLoading = false;
- this.$notify({
- type: "error",
- message: err.response.data.desc,
- });
- });
- }
- },
- //在正确的option上设置isCorrect=1
- setRightAnswer() {
- if (
- !this.quesModel.quesOptions ||
- this.quesModel.quesOptions.length == 0
- ) {
- return false;
- }
- let quesAnswer = [];
- for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
- var option = this.quesModel.quesOptions[i];
- var answerOrderNum = String.fromCharCode(65 + i);
- if (this.quesModel.questionType == "SINGLE_ANSWER_QUESTION") {
- option["isCorrect"] =
- answerOrderNum == this.singleRightAnswer ? 1 : 0;
- }
- if (this.quesModel.questionType == "MULTIPLE_ANSWER_QUESTION") {
- option["isCorrect"] =
- this.multipleRightAnswer.indexOf(answerOrderNum) > -1 ? 1 : 0;
- }
- if (option["isCorrect"]) quesAnswer.push(i + 1);
- }
- this.quesModel.quesAnswer = JSON.stringify(quesAnswer);
- },
- //删除试题
- deleteQues(paperDetailUnit) {
- let paperDetailUnitId = paperDetailUnit.id;
- if (this.paper.paperType == "GENERATE") {
- this.deleteQues01(paperDetailUnitId);
- } else {
- let questionId = paperDetailUnit.question.id;
- this.deleteQues02(questionId, paperDetailUnitId);
- }
- },
- deleteQues01(paperDetailUnitId) {
- this.$alert("您确定删除吗?", "提示", {
- confirmButtonText: "确定",
- callback: (action) => {
- if (action == "confirm") {
- this.loading = true;
- this.$http
- .delete(QUESTION_API + "/paperDetailUnit/" + paperDetailUnitId)
- .then(() => {
- this.initPaper();
- this.reduplicateGroup = [];
- this.loading = true;
- this.$notify({
- message: "删除成功",
- type: "success",
- });
- this.loading = false;
- })
- .catch(() => {
- this.loading = false;
- });
- }
- },
- });
- },
- deleteQues02(questionId, paperDetailUnitId) {
- this.$alert("您确定删除吗?", "提示", {
- confirmButtonText: "确定",
- callback: (action) => {
- if (action == "confirm") {
- this.loading = true;
- this.$http
- .delete(
- QUESTION_API +
- "/paper/deleteQuestion/" +
- paperDetailUnitId +
- "/" +
- questionId
- )
- .then((response) => {
- if (response.data.length > 0) {
- var deleteInfo =
- "该试题被试卷:" +
- response.data.join(" , ") +
- "使用,不能删除";
- this.$notify({
- message: deleteInfo,
- type: "error",
- });
- } else {
- this.initPaper();
- this.reduplicateGroup = [];
- this.loading = true;
- this.$notify({
- message: "保存成功",
- type: "success",
- });
- }
- this.loading = false;
- })
- .catch(() => {
- this.loading = false;
- });
- }
- },
- });
- },
- exportPaperAnswer() {
- var key = this.user.key;
- var token = this.user.token;
- window.open(
- QUESTION_API +
- "/paper/answer/export/" +
- this.paperId +
- "?$key=" +
- key +
- "&$token=" +
- token
- );
- },
- getSubQuesEditId(paperDetailUnit, subQuestion) {
- return paperDetailUnit.question.id + "_" + subQuestion.subNumber;
- },
- //打开考试说明编辑框
- openEditExamPaperRemark() {
- if (this.paper.examRemark) {
- this.examRemark = this.paper.examRemark;
- } else {
- this.examRemark = "";
- }
- this.paperRemarkDialog = true;
- },
- //保存考试说明
- savePaperRemark() {
- this.paper.examRemark = this.examRemark;
- this.savePaper();
- this.paperRemarkDialog = false;
- },
- //关闭考试说明编辑框
- closPaperRemark() {
- this.examRemark = "";
- this.paperRemarkDialog = false;
- },
- //保存试卷
- savePaper() {
- this.loading = true;
- this.$http
- .put(QUESTION_API + "/paper", this.paper)
- .then(() => {
- this.$notify({
- message: "保存成功",
- type: "success",
- });
- this.loading = false;
- this.initPaper();
- })
- .catch((error) => {
- this.loading = false;
- this.$notify({
- type: "error",
- message: error.response.data.desc,
- });
- });
- },
- //删除试卷
- deletePaper(id) {
- this.$confirm("确认删除试卷吗?", "提示", {
- type: "warning",
- }).then(() => {
- this.loading = true;
- this.$http.delete(QUESTION_API + "/paper/" + id).then(
- () => {
- this.$notify({
- message: "删除成功",
- type: "success",
- });
- this.back();
- },
- (error) => {
- this.$notify({
- message: error.response.data.desc,
- type: "error",
- title: "错误",
- });
- this.loading = false;
- }
- );
- });
- },
- //打开上传音频弹框
- openDialog() {
- this.checkResult = false;
- this.isUpload = true;
- if (document.getElementById("radioFile")) {
- document.getElementById("radioFile").value = "";
- }
- this.audioFileName = "";
- this.dialogRadioFile = true;
- this.fileList = [];
- },
- //关闭音频弹框
- closeAudioDialog() {
- this.dialogRadioFile = this.uploadAudioLoading;
- },
- //返回
- back() {
- if (sessionStorage.getItem("question_back") == "true") {
- this.$router.push({
- path: "/questions/" + this.parentView + "/0",
- });
- } else {
- this.$router.push({
- path: "/questions/" + this.parentView + "/1",
- });
- }
- },
- paperDetailShow(paperDetail) {
- if (this.reduplicateGroup.length == 0) {
- return true;
- }
- let paperDetailUnits = paperDetail.paperDetailUnits;
- for (let i = 0, imax = paperDetailUnits.length; i < imax; i++) {
- for (var j = 0, jmax = this.reduplicateGroup.length; j < jmax; j++) {
- if (paperDetailUnits[i].id == this.reduplicateGroup[j]) {
- return true;
- }
- }
- }
- return false;
- },
- //上传文件检查
- checkFile() {
- this.fileNameList = [];
- //读取选取的文件夹里面的文件
- this.checkResult = true;
- var files = document.getElementById("radioFile").files;
- if (files.length == 0) {
- this.message = "请选择音频文件夹!";
- return;
- }
- var size = 0;
- var isGo = false;
- //取到所有文件的文件名
- for (var i = 0; i < files.length; i++) {
- if (this.checkAudioFormat(files[i].name)) {
- this.fileNameList.push(files[i].name);
- if (files[i].size > 5 * 1024 * 1024) {
- isGo = true;
- break;
- }
- size = files[i].size + size;
- }
- }
- if (isGo) {
- this.message = "上传单个文件不能超过5M";
- this.isUpload = true;
- }
- if (size > 50 * 1024 * 1024) {
- this.message = "上传文件总和不能超过50M";
- this.isUpload = true;
- return;
- }
- this.$http
- .post(
- QUESTION_API + "/checkRadioFile/" + this.paperId,
- this.fileNameList
- )
- .then((response) => {
- console.log("response:", response);
- this.message = response.data.errorMsg;
- if (this.message == "OK") {
- this.message = "OK!";
- this.isUpload = false;
- } else {
- this.isUpload = true;
- }
- })
- .catch((error) => {
- console.log(error);
- });
- },
- checkAudioFormat(name) {
- return name.endsWith(".mp3");
- },
- // 音频文件
- selectAudioFile() {
- document.getElementById("radioFile").click();
- },
- audioFileChange() {
- let fileList = document.getElementById("radioFile").files;
- if (fileList.length == 0) {
- this.audioFileName = "";
- } else {
- let names = [];
- for (var i = 0; i < fileList.length; i++) {
- var file = fileList[i];
- if (this.checkAudioFormat(file.name)) names.push(file.name);
- }
- this.audioFileName = names.join();
- }
- },
- uploadAudioFile() {
- let param = new FormData();
- var fileList = document.getElementById("radioFile").files;
- //循环添加到formData中
- for (var i = 0; i < fileList.length; i++) {
- var file = fileList[i];
- if (this.checkAudioFormat(file.name))
- param.append("files", file, file.name);
- }
- let config = {
- headers: { "Content-Type": "multipart/form-data" },
- };
- this.$http
- .post(QUESTION_API + "/uploadRadio/" + this.paperId, param, config)
- .then(() => {
- this.dialogRadioFile = false;
- this.uploadAudioLoading = false;
- this.checkResult = false;
- this.isUpload = true;
- document.getElementById("radioFile").value = "";
- this.initPaper();
- })
- .catch((error) => {
- this.message = error.response.data.desc;
- this.uploadAudioLoading = false;
- });
- },
- },
- };
- </script>
|