yujialong 6 months ago
parent babfe30a92
commit 1db6084af8
  1. 1
      src/api/index.js
  2. 7
      src/libs/util.js
  3. 78
      src/pages/ques/detail/index.vue
  4. 10
      src/pages/ques/list/index.vue
  5. 25
      src/pages/quesBankType/index.vue
  6. 8
      src/pages/testPaper/detail/auto.vue
  7. 169
      src/pages/testPaper/detail/index.vue
  8. 12
      src/pages/testPaper/detail/repeatQues.vue
  9. 8
      src/pages/testPaperLibrary/index.vue
  10. 3
      src/pages/testPaperLibraryType/index.vue
  11. 9
      src/styles/common.scss

@ -39,6 +39,7 @@ export default {
paperLibrarySave: `/exam/exam/paperLibrary/save`, paperLibrarySave: `/exam/exam/paperLibrary/save`,
paperLibraryUpdate: `/exam/exam/paperLibrary/update`, paperLibraryUpdate: `/exam/exam/paperLibrary/update`,
paperLibraryDisable: `/exam/exam/paperLibrary/updateStatus`, paperLibraryDisable: `/exam/exam/paperLibrary/updateStatus`,
copyExamPaperLibrary: `/exam/exam/paperLibrary/copyExamPaperLibrary`,
examClassificationDel: `/exam/exam/classification/delete`, examClassificationDel: `/exam/exam/classification/delete`,
examClassificationSave: `/exam/exam/classification/save`, examClassificationSave: `/exam/exam/classification/save`,

@ -176,6 +176,13 @@ const util = {
resolve(new Date(data.currentTime)) resolve(new Date(data.currentTime))
}) })
}, },
getUuid () {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
})
}
}; };
export default util; export default util;

@ -4,7 +4,7 @@
<p class="page-name mb">试题</p> <p class="page-name mb">试题</p>
<div v-loading="loading"> <div v-loading="loading">
<el-form :model="form" :rules="rules" :class="['input-form model', { paper: paperType }]" ref="form" <el-form :model="form" :rules="rules" :class="['input-form model', { paper: paperType }]" ref="form"
label-width="110px" :disabled="detailType === 2"> label-width="110px" :disabled="isDisabled">
<div class="item-line"> <div class="item-line">
<template v-if="paperType === 1"> <template v-if="paperType === 1">
<el-form-item prop="questionBankTypeId" label="题库分类"> <el-form-item prop="questionBankTypeId" label="题库分类">
@ -13,7 +13,8 @@
@change="getQuesBank"></el-cascader> @change="getQuesBank"></el-cascader>
</el-form-item> </el-form-item>
<el-form-item prop="questionBankId" label="题库"> <el-form-item prop="questionBankId" label="题库">
<el-select v-model="form.questionBankId" filterable placeholder="请选择题库" @change="getKnowledge"> <el-select v-model="form.questionBankId" filterable placeholder="请选择题库"
:disabled="!form.questionBankTypeId.length" @change="getKnowledge">
<el-option v-for="(item, i) in questionBanks" :key="i" :label="item.questionBankName" <el-option v-for="(item, i) in questionBanks" :key="i" :label="item.questionBankName"
:value="item.id"></el-option> :value="item.id"></el-option>
</el-select> </el-select>
@ -90,7 +91,7 @@
</div> </div>
<UeditorPlus v-else class="opt-editor" :ref="'opt' + item.optionNumber" :config="editorConfig" <UeditorPlus v-else class="opt-editor" :ref="'opt' + item.optionNumber" :config="editorConfig"
v-model="item.optionText" @ready="editor => optReady(editor, item)" /> v-model="item.optionText" @ready="editor => optReady(editor, item)" />
<template v-if="form.questionType !== 'judgement'"> <template v-if="form.questionType !== 'judgement' && !isDisabled">
<i class="icon el-icon-circle-plus-outline m-t-8" @click="addOpt(i)"></i> <i class="icon el-icon-circle-plus-outline m-t-8" @click="addOpt(i)"></i>
<i v-if="form.questionAnswerVersions.length > 2" class="icon el-icon-remove-outline m-t-8" <i v-if="form.questionAnswerVersions.length > 2" class="icon el-icon-remove-outline m-t-8"
@click="delOpt(i)"></i> @click="delOpt(i)"></i>
@ -179,17 +180,18 @@
@click="submit(0)">保存</el-button> @click="submit(0)">保存</el-button>
<template v-else> <template v-else>
<el-button type="primary" :loading="submiting && keep === 0" @click="submit(0)">保存</el-button> <el-button type="primary" :loading="submiting && keep === 0" @click="submit(0)">保存</el-button>
<el-button type="primary" :loading="submiting && keep === 1" @click="submit(1)">{{ questionId ? '保存并同步更新相似题' <el-button v-if="!questionId" type="primary" :loading="submiting && keep === 1" @click="submit(1)">{{
: questionId ? '保存并同步更新相似题'
'保存并继续新增' }}</el-button> :
'保存并继续新增' }}</el-button>
</template> </template>
</template> </template>
<el-button @click="back">{{ detailType !== 2 ? '取消' : '返回' }}</el-button> <el-button @click="back">{{ detailType !== 2 ? '取消' : '返回' }}</el-button>
</div> </div>
</div> </div>
<el-dialog title="提示" :visible.sync="repeatVisible" width="800px" :close-on-click-modal="false"> <el-dialog title="提示" :visible.sync="repeatVisible" width="800px" :close-on-click-modal="false" append-to-body>
<template v-if="form.questionBankId"> <template v-if="form.questionId">
<el-alert title="您确定要保存对本题所做的更改吗?更新后,所有关联的试卷将会自动更新" type="warning" effect="dark" :closable="false" /> <el-alert title="您确定要保存对本题所做的更改吗?更新后,所有关联的试卷将会自动更新" type="warning" effect="dark" :closable="false" />
<p class="m-t-10 m-b-10 fs-12">系统已经识别出题库中有与本题相似的其他题目如果您选择同步更新这些相似题目那么所有关联的试卷将会自动更新</p> <p class="m-t-10 m-b-10 fs-12">系统已经识别出题库中有与本题相似的其他题目如果您选择同步更新这些相似题目那么所有关联的试卷将会自动更新</p>
</template> </template>
@ -197,7 +199,7 @@
<el-table class="m-t-10" :data="repeats" stripe header-align="center" @selection-change="handleSelectionChange" <el-table class="m-t-10" :data="repeats" stripe header-align="center" @selection-change="handleSelectionChange"
row-key="id"> row-key="id">
<el-table-column v-if="form.questionBankId" type="selection" width="45" align="center" <el-table-column v-if="form.questionId" type="selection" width="45" align="center"
:reserve-selection="true"></el-table-column> :reserve-selection="true"></el-table-column>
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column> <el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
<el-table-column prop="name" label="题型" align="center" min-width="120"> <el-table-column prop="name" label="题型" align="center" min-width="120">
@ -248,7 +250,7 @@ export default {
questionBankId: this.$route.query.questionBankId, // id questionBankId: this.$route.query.questionBankId, // id
questionBankName: this.$route.query.questionBankName, questionBankName: this.$route.query.questionBankName,
questionBankCategory: this.$route.query.questionBankCategory, questionBankCategory: this.$route.query.questionBankCategory,
detailType: +this.$route.query.detailType, detailType: +this.$route.query.detailType, // 1()23paperTypetype123
numToLetter: Util.numToLetter, numToLetter: Util.numToLetter,
loading: false, loading: false,
questionBankTypes: [], questionBankTypes: [],
@ -274,7 +276,7 @@ export default {
fillBlanks: [], fillBlanks: [],
uploadList: [], uploadList: [],
form: { form: {
questionBankTypeId: '', questionBankTypeId: [],
difficulty: '', difficulty: '',
givenYear: new Date(), givenYear: new Date(),
knowledgePointIds: [], knowledgePointIds: [],
@ -331,6 +333,10 @@ export default {
'编辑' : '编辑' :
'') + '试题' '') + '试题'
}, },
//
isDisabled () {
return this.detailType === 2
},
}, },
mounted () { mounted () {
const { query } = this.$route const { query } = this.$route
@ -374,7 +380,6 @@ export default {
const type = this.detailType const type = this.detailType
if (this.paperType === 1) { if (this.paperType === 1) {
this.getQuesBankType() this.getQuesBankType()
this.getQuesBank()
} else if (!type) { } else if (!type) {
// //
const { path } = this.$route.query const { path } = this.$route.query
@ -392,6 +397,8 @@ export default {
// //
if (v) { if (v) {
const { form, beforeSubmitForm: before } = this const { form, beforeSubmitForm: before } = this
form.questionBankTypeId = v.questionBankTypeId
form.questionBankId = v.questionBankId
form.difficulty = v.difficulty form.difficulty = v.difficulty
form.givenYear = v.givenYear form.givenYear = v.givenYear
form.knowledgePointIds = this.beforeSubmitForm.knowledgePointIds form.knowledgePointIds = this.beforeSubmitForm.knowledgePointIds
@ -516,16 +523,20 @@ export default {
// //
async getQuesBank () { async getQuesBank () {
try { try {
let type
const val = this.form.questionBankTypeId const val = this.form.questionBankTypeId
if (val.length) type = val[val.length - 1] if (val.length) {
const res = await this.$post(this.api.questionBankList, { let type = val[val.length - 1]
status: 1, const res = await this.$post(this.api.questionBankList, {
pageNum: 1, status: 1,
pageSize: 1000, pageNum: 1,
questionCategoryId: type || '', pageSize: 1000,
}) questionCategoryId: type || '',
this.questionBanks = res.message.records })
this.questionBanks = res.message.records
} else {
this.questionBanks = []
}
this.form.questionBankId = ''
} catch (e) { } } catch (e) { }
}, },
// //
@ -574,22 +585,26 @@ export default {
}, },
// //
stemReady (editor) { stemReady (editor) {
editor.addListener('contentChange', () => { if (this.isDisabled) {
this.questionItemReset(editor.getContent()) editor.setDisabled()
}) } else {
editor.addListener('contentChange', () => {
this.questionItemReset(editor.getContent())
})
}
editor.setContent(this.form.stem) editor.setContent(this.form.stem)
}, },
// //
answerAnalysisReady (editor) { answerAnalysisReady (editor) {
editor.setContent(this.answerAnalysis) this.isDisabled ? editor.setDisabled() : editor.setContent(this.answerAnalysis)
}, },
// //
uploadInstructionsReady (editor) { uploadInstructionsReady (editor) {
editor.setContent(this.form.uploadInstructions) this.isDisabled ? editor.setDisabled() : editor.setContent(this.form.uploadInstructions)
}, },
// //
referenceAnswerReady (editor) { referenceAnswerReady (editor) {
editor.setContent(this.form.questionAnswerVersions[0].referenceAnswer) this.isDisabled ? editor.setDisabled() : editor.setContent(this.form.questionAnswerVersions[0].referenceAnswer)
}, },
// //
correctChange (i) { correctChange (i) {
@ -610,9 +625,11 @@ export default {
}, },
// //
optFocus (e) { optFocus (e) {
const opts = this.form.questionAnswerVersions if (!this.isDisabled) {
opts.map(n => n.focus = 0) const opts = this.form.questionAnswerVersions
e.focus = 1 opts.map(n => n.focus = 0)
e.focus = 1
}
}, },
// //
optReady (editor, opt) { optReady (editor, opt) {
@ -766,7 +783,6 @@ export default {
const form = this.tempForm const form = this.tempForm
const type = this.detailType const type = this.detailType
const paperEdit = this.curQues // const paperEdit = this.curQues //
// type: 1()234
await this.$post(this.api[type === 1 || !form.questionId ? 'addQuestion' : 'updateQuestion'], form) await this.$post(this.api[type === 1 || !form.questionId ? 'addQuestion' : 'updateQuestion'], form)
paperEdit && this.$emit('updateQues', form) paperEdit && this.$emit('updateQues', form)

@ -107,8 +107,10 @@
<template slot-scope="scope">{{ questionTypes.find(e => e.id === scope.row.questionType) ? <template slot-scope="scope">{{ questionTypes.find(e => e.id === scope.row.questionType) ?
questionTypes.find(e => e.id === scope.row.questionType).name : '' }}</template> questionTypes.find(e => e.id === scope.row.questionType).name : '' }}</template>
</el-table-column> </el-table-column>
<el-table-column prop="professionalName" label="专业" align="center" min-width="100"></el-table-column> <el-table-column prop="professionalName" label="专业" align="center" min-width="100"
<el-table-column prop="knowledgePointName" label="知识点" align="center" min-width="100"></el-table-column> show-overflow-tooltip></el-table-column>
<el-table-column prop="knowledgePointName" label="知识点" align="center" min-width="100"
show-overflow-tooltip></el-table-column>
<el-table-column prop="givenYear" label="年份" align="center" width="70" sortable="custom"></el-table-column> <el-table-column prop="givenYear" label="年份" align="center" width="70" sortable="custom"></el-table-column>
<el-table-column prop="difficulty" label="难度" align="center" width="70" sortable="custom"> <el-table-column prop="difficulty" label="难度" align="center" width="70" sortable="custom">
<template slot-scope="scope">{{ difficults.find(e => e.id === scope.row.difficulty) ? difficults.find(e => <template slot-scope="scope">{{ difficults.find(e => e.id === scope.row.difficulty) ? difficults.find(e =>
@ -534,8 +536,8 @@ export default {
async switchOff (val, row) { async switchOff (val, row) {
try { try {
row.status = val ? 0 : 1 // row.status = val ? 0 : 1 //
if (!val) { if (!val && row.referenceCount) {
await this.$confirm(`<p>确认要禁用【${row.stem}】吗?</p><p style="color: #f56c6c;">禁用后已引用该试题的试卷将会变成草稿,再次启用后,试卷将自动发布</p>`, '提示', { await this.$confirm(`<p>确认要禁用【${row.stem}】吗?</p><p style="color: #f56c6c;">禁用后已引用该试题的试卷将会变成草稿</p>`, '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',

@ -177,17 +177,20 @@ export default {
// //
async typeSubmit () { async typeSubmit () {
if (this.submiting) return false if (this.submiting) return false
const { form, parentId } = this try {
if (!form.name) return Util.warningMsg('请输入题库分类名称') const { form, parentId } = this
this.submiting = true if (!form.name) return Util.warningMsg('请输入题库分类名称')
if (parentId.length) form.parentId = parentId[parentId.length - 1] this.submiting = true
// form.systemId = this.systemId if (parentId.length) form.parentId = parentId[parentId.length - 1]
form.createSource = 1 // form.systemId = this.systemId
await this.$post(this.api.categoriesSave, form) form.createSource = 1
Util.successMsg('保存成功') await this.$post(this.api.categoriesSave, form)
this.typeVisible = false Util.successMsg('保存成功')
this.submiting = false this.typeVisible = false
this.getData() this.getData()
} finally {
this.submiting = false
}
}, },
// //
del (row) { del (row) {

@ -260,10 +260,10 @@ export default {
methods: { methods: {
// //
init () { init () {
this.handleQuesList()
if (!this.loaded) { if (!this.loaded) {
this.loaded = 1 this.loaded = 1
this.yearCheck = this.years this.yearCheck = this.years
this.handleQuesList()
this.getQuesBankType() this.getQuesBankType()
this.initQuesBank() this.initQuesBank()
this.difficult = this.$parent.form.difficult this.difficult = this.$parent.form.difficult
@ -393,6 +393,7 @@ export default {
// //
handleQuesList () { handleQuesList () {
this.list = _.cloneDeep(this.$parent.form.paperOutline) this.list = _.cloneDeep(this.$parent.form.paperOutline)
console.log("🚀 ~ handleQuesList ~ this.list:", this.list)
}, },
// //
async clearChecked () { async clearChecked () {
@ -507,13 +508,15 @@ export default {
let total = Decimal(e.basicDifficulty || 0).add(e.normalDifficulty || 0).add(e.hardDifficulty || 0).add(e.veryHardDifficulty || 0).toNumber() // 4 let total = Decimal(e.basicDifficulty || 0).add(e.normalDifficulty || 0).add(e.hardDifficulty || 0).add(e.veryHardDifficulty || 0).toNumber() // 4
if (total) { // 41 if (total) { // 41
this.$set(e, 'randomDifficulty', 0) this.$set(e, 'randomDifficulty', 0)
} else {
total = +e.randomDifficulty || 0
} }
if (total > e.questionNum) { if (total > e.questionNum) {
Util.warningMsg(`${name}的小题总数大于目标题数,请重新输入`) Util.warningMsg(`${name}的小题总数大于目标题数,请重新输入`)
invalid = 1 invalid = 1
break break
} }
total = Decimal(total).add(e.randomDifficulty || 0).toNumber()
e.count = total e.count = total
totalCount = Decimal(totalCount).add(total).toNumber() totalCount = Decimal(totalCount).add(total).toNumber()
} }
@ -536,7 +539,6 @@ export default {
} }
}) })
list.map(e => { list.map(e => {
// e.randomDifficulty = 0
e.givenYears = years e.givenYears = years
e.knowledgePointsIds = k e.knowledgePointsIds = k
}) })

@ -155,15 +155,15 @@
<p v-if="item.questionType !== 'fill_blank'" class="m-r-10 input-wrap"> <p v-if="item.questionType !== 'fill_blank'" class="m-r-10 input-wrap">
<el-input class="l-input" placeholder="请输入分值" v-model="ques.score" /></p> <el-input class="l-input" placeholder="请输入分值" v-model="ques.score" /></p>
<el-popover v-else placement="bottom" width="400" trigger="click"> <el-popover v-else-if="ques.fillScores" placement="bottom" width="350" trigger="click">
<div v-if="ques.fillScores" class="fill-scores"> <div class="fill-scores">
<p class="fill-title">每空分值</p> <p class="fill-title">每空分值</p>
<div v-for="(score, k) in ques.fillScores" :key="k" class="input-wrap"> <div v-for="(score, k) in ques.fillScores" :key="k" class="input-wrap">
<el-input class="l-input" placeholder="请输入分值" v-model="score.val" <el-input class="l-input" placeholder="请输入分值" v-model="score.val"
@change="fillScoreChange(ques)" /> @change="fillScoreChange(ques)" />
&emsp;填空项{{ k + 1 }} &emsp;填空项{{ k + 1 }}
<span <span
v-if="ques.answerData && ques.answerData.length && ques.answerData[k]">&emsp;建议分值占比{{ v-if="ques.answerData && ques.answerData.length && ques.answerData[k] && ques.answerData[k].scoreProportion != 0">&emsp;建议分值占比{{
ques.answerData[k].scoreProportion }}%</span> ques.answerData[k].scoreProportion }}%</span>
</div> </div>
</div> </div>
@ -171,7 +171,7 @@
查看每空分值<el-input class="l-input" placeholder="请输入分值" v-model="ques.score" readonly /> 查看每空分值<el-input class="l-input" placeholder="请输入分值" v-model="ques.score" readonly />
</div> </div>
</el-popover> </el-popover>
<el-button v-if="!ques.isDel" type="text" @click="toQues(item, j, ques, 1)">编辑试题</el-button> <el-button v-if="!ques.isDel" type="text" @click="toQues(item, j, ques, 2)">编辑试题</el-button>
<el-button type="text" @click="showManualDia(item, j, ques)">更换试题</el-button> <el-button type="text" @click="showManualDia(item, j, ques)">更换试题</el-button>
<el-button type="text" @click="showManualDia(item, j)">添加试题</el-button> <el-button type="text" @click="showManualDia(item, j)">添加试题</el-button>
<el-button type="text" @click="delQues(item, j)">移除试题</el-button> <el-button type="text" @click="delQues(item, j)">移除试题</el-button>
@ -223,33 +223,29 @@
</div> </div>
</div> </div>
<draggable v-if="form.paperOutline && form.paperOutline.length"> <div v-if="form.paperOutline && form.paperOutline.length" class="layer" id="layer">
<!-- <transition-group :key="1"> --> <table class="table">
<div class="layer" id="layer" ref="layer"> <thead>
<table class="table"> <tr>
<thead> <th width="30%">大题</th>
<tr> <th width="35%">已添加题数/目标题数</th>
<th width="30%">大题</th> <th width="35%">已分配分值/目标分值</th>
<th width="35%">已添加题数/目标题数</th> </tr>
<th width="35%">已分配分值/目标分值</th> </thead>
</tr> <tbody>
</thead> <tr v-for="(item, i) in form.paperOutline" :key="i">
<tbody> <td>{{ arabicToChinese(i + 1) }}大题</td>
<tr v-for="(item, i) in form.paperOutline" :key="i"> <td>{{ item.examQuestions.length }}/{{ item.questionNum }}</td>
<td>{{ arabicToChinese(i + 1) }}大题</td> <td>{{ item.examQuestions.reduce((e, j) => (e += +j.score), 0) || 0 }}/{{ item.targetScore }}</td>
<td>{{ item.examQuestions.length }}/{{ item.questionNum }}</td> </tr>
<td>{{ item.examQuestions.reduce((e, j) => (e += +j.score), 0) || 0 }}/{{ item.targetScore }}</td> <tr>
</tr> <td>总计</td>
<tr> <td>{{ overview.alreadyQuesCount }}/{{ overview.questionCount }}</td>
<td>总计</td> <td>{{ overview.alreadyScore }}/{{ overview.totalScore }}</td>
<td>{{ overview.alreadyQuesCount }}/{{ overview.questionCount }}</td> </tr>
<td>{{ overview.alreadyScore }}/{{ overview.totalScore }}</td> </tbody>
</tr> </table>
</tbody> </div>
</table>
</div>
<!-- </transition-group> -->
</draggable>
<Template :visible.sync="templateVisible" /> <Template :visible.sync="templateVisible" />
<Manual :visible.sync="manualVisible" :questionType.sync="curType.questionType" /> <Manual :visible.sync="manualVisible" :questionType.sync="curType.questionType" />
@ -265,7 +261,6 @@
</template> </template>
<script> <script>
import Draggable from 'vuedraggable' import Draggable from 'vuedraggable'
import Sortable from 'sortablejs'
import UeditorPlus from '@/components/ueditorPlus' import UeditorPlus from '@/components/ueditorPlus'
import Breadcrumb from '@/components/breadcrumb' import Breadcrumb from '@/components/breadcrumb'
import Template from './template' import Template from './template'
@ -454,11 +449,8 @@ export default {
name: '创建试卷' name: '创建试卷'
}, },
] ]
// console.log(44, Sortable, document.querySelector('#layer'))
// new Sortable(document.querySelector('#layer'), { this.drag()
// group: "name",
// sort: true,
// })
this.getDetail() this.getDetail()
this.getType() this.getType()
this.getProfessional() this.getProfessional()
@ -490,8 +482,9 @@ export default {
if (r.particularYear) r.particularYear = r.particularYear + '' if (r.particularYear) r.particularYear = r.particularYear + ''
r.professionalId = r.professionalId ? r.professionalId.split(',').map(e => +e) : [] r.professionalId = r.professionalId ? r.professionalId.split(',').map(e => +e) : []
this.form = r this.form = r
this.loading = false
} }
} finally { } catch (e) {
this.loading = false this.loading = false
} }
}, },
@ -602,7 +595,7 @@ export default {
async fillBlankAllocation (list) { async fillBlankAllocation (list) {
const param = list.map(e => { const param = list.map(e => {
let { answerData } = e let { answerData } = e
if (answerData) { if (answerData && e.questionAnswerVersionsList) {
return { return {
questionType: e.questionType, questionType: e.questionType,
answerData: e.questionAnswerVersionsList[0].answerData, answerData: e.questionAnswerVersionsList[0].answerData,
@ -659,6 +652,7 @@ export default {
}, },
// //
getCorrectAnswer (e) { getCorrectAnswer (e) {
const opts = e.questionAnswerVersionsList
if (e.questionType === 'fill_blank') { // if (e.questionType === 'fill_blank') { //
// answerData // answerData
let data = e.answerData let data = e.answerData
@ -671,10 +665,10 @@ export default {
} }
return '' return ''
} else if (e.questionType === 'essay') { // } else if (e.questionType === 'essay') { //
return e.questionAnswerVersionsList[0].referenceAnswer || '暂无' if (opts) return opts[0].referenceAnswer || '暂无'
} else { } else {
if (e.questionAnswerVersionsList) { if (opts) {
const correct = e.questionAnswerVersionsList.filter(e => e.answerIsCorrect) const correct = opts.filter(e => e.answerIsCorrect)
return correct ? (e.questionType === 'judgement' ? correct[0].optionText : correct.map(e => Util.numToLetter(e.optionNumber - 1)).join('')) : '' // ABC return correct ? (e.questionType === 'judgement' ? correct[0].optionText : correct.map(e => Util.numToLetter(e.optionNumber - 1)).join('')) : '' // ABC
} }
} }
@ -742,10 +736,12 @@ export default {
this.addQuesVisible = false this.addQuesVisible = false
}, },
// //
updateQues (ques, id) { updateQues (ques) {
ques.questionAnswerVersionsList = ques.questionAnswerVersions ques.questionAnswerVersionsList = ques.questionAnswerVersions
delete ques.questionAnswerVersions delete ques.questionAnswerVersions
ques.score = ''
this.curType.examQuestions[this.curQuesIndex] = Object.assign(this.curRow, ques) this.curType.examQuestions[this.curQuesIndex] = Object.assign(this.curRow, ques)
this.handleQuesInfo(this.curType.examQuestions[this.curQuesIndex])
this.calcDifficult() this.calcDifficult()
}, },
@ -814,46 +810,39 @@ export default {
}, },
// //
hasRepeatQues (list) { hasRepeatQues (list) {
const result = []
list.forEach(e => { list.forEach(e => {
list.forEach(n => { list.forEach(n => {
if (e.questionVersionId !== n.questionVersionId && !e.repeat) { if (e.questionVersionId !== n.questionVersionId && !e.repeat) {
// ++ let diff = 0
// ++/+
if (e.questionType !== 'fill_blank' && e.questionType !== 'essay') { if (e.questionType !== 'fill_blank' && e.questionType !== 'essay') {
// //
const opts = e.questionAnswerVersionsList const opts = e.questionAnswerVersionsList
if (opts) { if (opts) {
let diff = 0
for (const j in opts) { for (const j in opts) {
// debugger
if (!n.questionAnswerVersionsList || !n.questionAnswerVersionsList[j] || n.questionAnswerVersionsList[j].optionText !== opts[j].optionText) { if (!n.questionAnswerVersionsList || !n.questionAnswerVersionsList[j] || n.questionAnswerVersionsList[j].optionText !== opts[j].optionText) {
diff = 1 diff = 1
break break
} }
} }
if (e.questionType === n.questionType && e.stem === n.stem && !diff) {
e.repeat = true
n.repeat = true
}
} }
} else { }
// /+ if (e.questionType === n.questionType && e.stem === n.stem && !diff) {
if (e.questionType === n.questionType && e.stem === n.stem) { const i = result.findIndex(m => m.questionVersionId === e.questionVersionId || m.questionVersionId === n.questionVersionId)
if (!e.repeat) {
i === -1 ? result.push(e) : result.splice(i, 0, e)
e.repeat = true e.repeat = true
}
if (!n.repeat) {
i === -1 ? result.push(n) : result.splice(i, 0, n)
n.repeat = true n.repeat = true
} }
} }
} }
}) })
}) })
const result = list.filter(e => e.repeat) return result
//
if (result.length) {
this.repeatVisible = true
this.repeatQues = result
return true
}
return false
}, },
// //
submit (status) { submit (status) {
@ -889,6 +878,7 @@ export default {
async validForm (status) { async validForm (status) {
if (this.submiting) return false if (this.submiting) return false
const { isCopy, overview } = this // const { isCopy, overview } = this //
const { getUuid } = Util
const form = _.cloneDeep(this.form) const form = _.cloneDeep(this.form)
const paper = form.paperOutline const paper = form.paperOutline
const allQues = [] const allQues = []
@ -897,6 +887,8 @@ export default {
if (status) { if (status) {
if (isNaN(form.suggestTime) || form.suggestTime < 1 || form.suggestTime % 1) return Util.warningMsg('估计用时请输入正整数') if (isNaN(form.suggestTime) || form.suggestTime < 1 || form.suggestTime % 1) return Util.warningMsg('估计用时请输入正整数')
let invalid = 0 let invalid = 0
loop1:
for (const i in paper) { for (const i in paper) {
const e = paper[i] const e = paper[i]
const chineseNum = this.arabicToChinese(+i + 1) const chineseNum = this.arabicToChinese(+i + 1)
@ -931,14 +923,21 @@ export default {
// //
if (e.questionType === 'fill_blank') { if (e.questionType === 'fill_blank') {
let totalScore = 0 let totalScore = 0
e.examQuestions.map(n => {
for (const j in e.examQuestions) {
const n = e.examQuestions[j]
const { fillScores } = n const { fillScores } = n
if (fillScores) { if (fillScores) {
for (const e of fillScores) { for (const e of fillScores) {
if (e.val === '' || e.val === undefined || e.val === null) {
Util.warningMsg(`${chineseNum}大题的第${this.arabicToChinese(+j + 1)}小题填空分数未填写完成,请重新修改`)
invalid = 1
break loop1
}
totalScore = Decimal(totalScore).add(e.val || 0).toNumber() totalScore = Decimal(totalScore).add(e.val || 0).toNumber()
} }
} }
}) }
if (+e.targetScore !== totalScore) { if (+e.targetScore !== totalScore) {
Util.warningMsg(`${chineseNum}大题的小题总分跟目标分值不一致,请重新修改`) Util.warningMsg(`${chineseNum}大题的小题总分跟目标分值不一致,请重新修改`)
@ -959,6 +958,7 @@ export default {
break break
} }
e.examQuestions.map((n, j) => { e.examQuestions.map((n, j) => {
e.uuid = getUuid()
n.outlineName = e.outlineName n.outlineName = e.outlineName
n.paperIndex = i n.paperIndex = i
n.quesIndex = j n.quesIndex = j
@ -1014,7 +1014,15 @@ export default {
if (isCopy) form.paperId = '' if (isCopy) form.paperId = ''
this.tempForm = form this.tempForm = form
if (this.hasRepeatQues(allQues)) return false
//
const repeats = this.hasRepeatQues(allQues)
if (repeats.length) {
this.repeatVisible = true
this.repeatQues = repeats
return false
}
this.saveTestPaper() this.saveTestPaper()
}, },
// //
@ -1024,7 +1032,35 @@ export default {
// //
back () { back () {
this.$router.back() this.$router.back()
} },
//
drag () {
const el = document.querySelector('#layer')
if (el) {
const drag = e => {
e.stopPropagation && e.stopPropagation()
e.preventDefault && e.preventDefault()
e.cancelBubble = true
e.returnValue = false
let x = e.clientX - el.offsetLeft
let y = e.clientY - el.offsetTop
let left = 0
let top = 0
document.onmousemove = function (eve) {
left = eve.clientX - x
top = eve.clientY - y
el.style.left = left + 'px'
el.style.top = top + 'px'
}
document.onmouseup = e => {
document.onmousemove = null
document.onmouseup = null
}
}
el.onmousedown = drag
}
},
} }
}; };
</script> </script>
@ -1270,6 +1306,7 @@ export default {
background-color: #fff; background-color: #fff;
box-shadow: 0 0 7px rgba(235, 235, 235, .8); box-shadow: 0 0 7px rgba(235, 235, 235, .8);
overflow: auto; overflow: auto;
cursor: move;
.table { .table {
text-align: center; text-align: center;

@ -3,7 +3,7 @@
:show-close="false" custom-class="ques-dia" @closed="closeDia"> :show-close="false" custom-class="ques-dia" @closed="closeDia">
<div class="wrap p-20"> <div class="wrap p-20">
<el-alert title="以下试题在试卷中疑似出现重复,是否要继续发布!" type="warning" effect="dark" :closable="false" /> <el-alert title="以下试题在试卷中疑似出现重复,是否要继续发布!" type="warning" effect="dark" :closable="false" />
<el-table class="m-t-10" :data="data" stripe header-align="center" row-key="id"> <el-table class="m-t-10" :data="data" stripe header-align="center" row-key="uuid">
<el-table-column prop="outlineName" label="大题名称" align="center" width="90"></el-table-column> <el-table-column prop="outlineName" label="大题名称" align="center" width="90"></el-table-column>
<el-table-column prop="serialNumber" label="题号" align="center" width="60"></el-table-column> <el-table-column prop="serialNumber" label="题号" align="center" width="60"></el-table-column>
<el-table-column prop="stem" label="题干" align="center" min-width="120"> <el-table-column prop="stem" label="题干" align="center" min-width="120">
@ -65,7 +65,11 @@ export default {
closeOnClickModal: false, closeOnClickModal: false,
}) })
this.$parent.delQues(this.$parent.form.paperOutline[row.paperIndex], row.quesIndex, 1) this.$parent.delQues(this.$parent.form.paperOutline[row.paperIndex], row.quesIndex, 1)
this.data.splice(i, 1)
const { data } = this
data.splice(i, 1)
data.map(e => e.repeat = false)
this.data = this.$parent.hasRepeatQues(data)
} catch (e) { } } catch (e) { }
}, },
// //
@ -76,10 +80,10 @@ export default {
}, },
// //
async check () { async check () {
const { list } = this const { data } = this
this.$parent.form.paperOutline.map(e => { this.$parent.form.paperOutline.map(e => {
e.examQuestions.map(n => { e.examQuestions.map(n => {
if (list.find(m => m.questionVersionId === n.questionVersionId)) this.$set(n, 'repeat', true) this.$set(n, 'repeat', !!data.find(m => m.questionVersionId === n.questionVersionId))
}) })
}) })
this.$parent.submiting = false this.$parent.submiting = false

@ -78,7 +78,7 @@
<el-dialog :title="isCopy ? '复制试卷库' : !form.libraryId ? '创建试卷库' : '编辑试卷库'" :visible.sync="quesBankVisible" <el-dialog :title="isCopy ? '复制试卷库' : !form.libraryId ? '创建试卷库' : '编辑试卷库'" :visible.sync="quesBankVisible"
width="400px" :close-on-click-modal="false"> width="400px" :close-on-click-modal="false">
<p v-if="isCopy" style="margin: -10px 0 20px;font-size: 12px;color: #f00;">您将复制当前试卷库中的所有题目到新试卷库请输入新试卷库名称</p> <p v-if="isCopy" style="margin: -10px 0 20px;font-size: 12px;color: #f00;">您将复制当前试卷库中的所有试卷到新试卷库请输入新试卷库名称</p>
<el-form :model="form" :rules="rules" label-width="100px"> <el-form :model="form" :rules="rules" label-width="100px">
<el-form-item prop="userName" label="分类"> <el-form-item prop="userName" label="分类">
<el-cascader placeholder="请选择试卷库分类" v-model="libraryClassificationId" :options="enableTypes" <el-cascader placeholder="请选择试卷库分类" v-model="libraryClassificationId" :options="enableTypes"
@ -333,7 +333,11 @@ export default {
// form.systemId = this.systemId // form.systemId = this.systemId
form.createSource = 1 form.createSource = 1
try { try {
await this.$post(this.api[this.isCopy ? 'copyQuestionBank' : form.libraryId ? 'paperLibraryUpdate' : 'paperLibrarySave'], form) if (this.isCopy) {
form.copyLibraryId = form.libraryId
form.libraryId = ''
}
await this.$post(this.api[this.isCopy ? 'copyExamPaperLibrary' : form.libraryId ? 'paperLibraryUpdate' : 'paperLibrarySave'], form)
Util.successMsg(this.isCopy ? '复制成功' : '保存成功') Util.successMsg(this.isCopy ? '复制成功' : '保存成功')
this.quesBankVisible = false this.quesBankVisible = false
this.submiting = false this.submiting = false

@ -204,9 +204,8 @@ export default {
await this.$post(this.api[form.libraryClassificationId ? 'libraryClassificationUpdate' : 'libraryClassificationSave'], form) await this.$post(this.api[form.libraryClassificationId ? 'libraryClassificationUpdate' : 'libraryClassificationSave'], form)
Util.successMsg('保存成功') Util.successMsg('保存成功')
this.typeVisible = false this.typeVisible = false
this.submiting = false
this.getData() this.getData()
} catch (e) { } finally {
this.submiting = false this.submiting = false
} }
}, },

@ -382,13 +382,8 @@
.el-switch__label span { .el-switch__label span {
font-size: 12px; font-size: 12px;
} }
.el-tooltip__popper[x-placement^="top"] { .el-tooltip__popper {
.popper__arrow { max-width: 100%;
border-top-color: #fff;
&:after {
border-top-color: #fff;
}
}
} }
.tox-notifications-container { .tox-notifications-container {
display: none; display: none;

Loading…
Cancel
Save