yujialong 3 months ago
parent 0a07ceed91
commit b15d416d74
  1. 2
      public/static/ueditorPlus/plugins/gapfilling/gapfilling.js
  2. 12
      src/const/ques.js
  3. 30
      src/pages/ques/detail/index.vue
  4. 3
      src/pages/testPaper/detail/auto.vue
  5. 85
      src/pages/testPaper/detail/index.vue
  6. 30
      src/pages/testPaper/detail/manual.vue

@ -2,7 +2,7 @@
UE.registerUI('gapfilling', function (editor, uiName) { UE.registerUI('gapfilling', function (editor, uiName) {
editor.registerCommand(uiName, { editor.registerCommand(uiName, {
execCommand: function (cmdName, value) { execCommand: function (cmdName, value) {
editor.execCommand('insertHtml', `<span class="gapfilling-span" data-id="${Math.random() * 100000}">______</span>`) editor.execCommand('insertHtml', `<span class="gapfilling-span" data-id="${Date.now()}">______</span>`)
} }
}) })

@ -3,22 +3,26 @@ export default {
{ {
id: 'basic', id: 'basic',
name: '基础', name: '基础',
coefficient: 0.2 // 难度系数,试卷里计算试卷难度专用 coefficient: 0.2, // 难度系数,试卷里计算试卷难度专用
theme: 'success',
}, },
{ {
id: 'easy', id: 'easy',
name: '普通', name: '普通',
coefficient: 0.4 coefficient: 0.4,
theme: '',
}, },
{ {
id: 'medium', id: 'medium',
name: '较难', name: '较难',
coefficient: 0.6 coefficient: 0.6,
theme: 'warning',
}, },
{ {
id: 'hard', id: 'hard',
name: '难', name: '难',
coefficient: 0.8 coefficient: 0.8,
theme: 'danger',
}, },
], ],
questionTypes: [ questionTypes: [

@ -2,6 +2,7 @@
<div class="page h-full"> <div class="page h-full">
<Breadcrumb v-if="!paperType" :data="crumbs" /> <Breadcrumb v-if="!paperType" :data="crumbs" />
<p class="page-name mb">试题</p> <p class="page-name mb">试题</p>
<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="detailType === 2">
<div class="item-line"> <div class="item-line">
@ -170,7 +171,8 @@
v-model="answerAnalysis" /> v-model="answerAnalysis" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-if="detailType !== 2" class="btns"> <div class="btns">
<template v-if="detailType !== 2">
<el-button v-if="detailType === 1" type="primary" :loading="submiting && keep === 0" <el-button v-if="detailType === 1" type="primary" :loading="submiting && keep === 0"
@click="submit(1)">保存</el-button> @click="submit(1)">保存</el-button>
<template v-else> <template v-else>
@ -179,7 +181,9 @@
: :
'保存并继续新增' }}</el-button> '保存并继续新增' }}</el-button>
</template> </template>
<el-button @click="back">取消</el-button> </template>
<el-button @click="back">{{ detailType !== 2 ? '取消' : '返回' }}</el-button>
</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">
@ -216,6 +220,7 @@ import Oss from '@/components/upload/upload.js'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import _ from 'lodash' import _ from 'lodash'
import Const from '@/const/ques' import Const from '@/const/ques'
import Decimal from 'decimal.js'
export default { export default {
props: ['paperType', 'curQues'], // props: ['paperType', 'curQues'], //
components: { Breadcrumb, UeditorPlus, Upload }, components: { Breadcrumb, UeditorPlus, Upload },
@ -229,6 +234,7 @@ export default {
questionBankCategory: this.$route.query.questionBankCategory, questionBankCategory: this.$route.query.questionBankCategory,
detailType: +this.$route.query.detailType, detailType: +this.$route.query.detailType,
numToLetter: Util.numToLetter, numToLetter: Util.numToLetter,
loading: false,
questionBankTypes: [], questionBankTypes: [],
questionBanks: [], questionBanks: [],
professionals: [], professionals: [],
@ -328,6 +334,7 @@ export default {
} else if (this.curQues) { } else if (this.curQues) {
this.questionId = this.curQues.questionId this.questionId = this.curQues.questionId
this.version = this.curQues.version this.version = this.curQues.version
if (this.paperType === 3) this.detailType = 2
} }
this.editorConfig = this.paperType ? { this.editorConfig = this.paperType ? {
@ -342,6 +349,7 @@ export default {
methods: { methods: {
// //
init (v) { init (v) {
this.loading = true
this.form = _.cloneDeep(this.originForm) this.form = _.cloneDeep(this.originForm)
const type = this.detailType const type = this.detailType
@ -419,16 +427,19 @@ export default {
}] }]
} }
// //
if (this.paperType === 2) { if (this.paperType > 1) {
this.questionBankName = r.questionBankName this.questionBankName = r.questionBankName
console.log("🚀 ~ getKnowledge ~ id:", this.form)
// this.questionBankCategory = r.questionBankCategory // this.questionBankCategory = r.questionBankCategory
this.$nextTick(() => { this.$nextTick(() => {
this.getKnowledge() this.getKnowledge()
}) })
} }
} else {
this.loading = false
}
} finally {
this.loading = false
} }
} catch (e) { }
}, },
// //
async getKnowledge () { async getKnowledge () {
@ -595,9 +606,10 @@ export default {
let gapfillingItems = content.match(spanRegex) let gapfillingItems = content.match(spanRegex)
if (gapfillingItems !== null) { if (gapfillingItems !== null) {
gapfillingItems.forEach(function (span, index) { gapfillingItems.forEach(function (span, index) {
const pairRegex = /<span class="gapfilling-span" (.*?)">(.*?)______(.*?)<\/span>/ let pairRegex = /<span class="gapfilling-span" data-id="(.*?)">(.*?)______(.*?)<\/span>/
if (span.includes('data-id')) pairRegex = /<span class="gapfilling-span" (.*?)">(.*?)______(.*?)<\/span>/
pairRegex.test(span) pairRegex.test(span)
newFormItem.push({ fills: [{ val: '' }], uuid: RegExp.$1, scoreProportion: '0' }) newFormItem.push({ fills: [{ val: '' }], uuid: RegExp.$1, scoreProportion: '' })
}) })
newFormItem.forEach(e => { newFormItem.forEach(e => {
@ -650,13 +662,17 @@ export default {
if (invalid) return false if (invalid) return false
if (!opt.find(e => e.answerIsCorrect)) return Util.warningMsg('请设置正确答案') if (!opt.find(e => e.answerIsCorrect)) return Util.warningMsg('请设置正确答案')
} else if (form.questionType === 'fill_blank') { } else if (form.questionType === 'fill_blank') {
let scorePro = 0
for (const e of blanks) { for (const e of blanks) {
if (e.fills.every(n => !n.val)) { if (e.fills.every(n => !n.val)) {
Util.warningMsg('请输入填空项正确答案') Util.warningMsg('请输入填空项正确答案')
invalid = 1 invalid = 1
break break
} }
const pro = e.scoreProportion
if (pro && !isNaN(pro)) scorePro = Decimal(scorePro).add(pro || 0).toNumber()
} }
if (scorePro && scorePro !== 100) return Util.warningMsg('分值占比不满100,请重新调整')
} }
this.submiting = true this.submiting = true

@ -578,7 +578,8 @@ export default {
res.list[i].questions.map((e, i) => { res.list[i].questions.map((e, i) => {
// e.questionVersionId = e.id // e.questionVersionId = e.id
e.serialNumber = i + 1 e.serialNumber = i + 1
this.$parent.handleFillScore(e) e.originSort = i + 1
this.$parent.handleQuesInfo(e)
}) })
this.$parent.form.paperOutline[i].examQuestions = res.list[i].questions this.$parent.form.paperOutline[i].examQuestions = res.list[i].questions
}) })

@ -1,6 +1,7 @@
<template> <template>
<div class="page"> <div class="page">
<Breadcrumb :data="crumbs" /> <Breadcrumb :data="crumbs" />
<div v-loading="loading">
<el-form :model="form" :rules="rules" class="input-form model" ref="form" label-width="140px"> <el-form :model="form" :rules="rules" class="input-form model" ref="form" label-width="140px">
<p class="page-name mb">试卷基础信息</p> <p class="page-name mb">试卷基础信息</p>
<el-form-item prop="name" label="试卷名称"> <el-form-item prop="name" label="试卷名称">
@ -146,26 +147,11 @@
<div class="labels"> <div class="labels">
<span class="label">{{ j + 1 }} / {{ item.examQuestions.length }}</span> <span class="label">{{ j + 1 }} / {{ item.examQuestions.length }}</span>
<span class="label">{{ questionTypes.find(e => e.id === item.questionType).name }}</span> <span class="label">{{ questionTypes.find(e => e.id === item.questionType).name }}</span>
<span v-if="ques.givenYear" class="label">{{ ques.givenYear }}</span>
</div> </div>
<div class="stem" :id="'stem' + ques.questionVersionId" v-html="ques.stem"></div> <el-tag v-if="ques.difficult" :type="ques.difficultTheme">{{ ques.difficult }}</el-tag>
</div>
</div>
<!-- 单选多选判断的选项 -->
<template
v-if="item.questionType !== 'fill_blank' && item.questionType !== 'essay' && ques.questionAnswerVersionsList">
<div v-for="(opt, j) in ques.questionAnswerVersionsList" :key="j" class="opt">
<span>{{ numToLetter(j) }}.&nbsp;</span>
<div class="text" v-html="opt.optionText"></div>
</div> </div>
</template>
<div class="bottom-line">
<div class="correct">
{{ item.questionType === 'essay' ? '参考答案' : '正确答案' }}
<div v-html="getCorrectAnswer(ques)"></div>
</div>
</div>
<div class="actions"> <div class="actions">
<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>
@ -193,6 +179,29 @@
</div> </div>
</div> </div>
</div> </div>
<div class="stem" :id="'stem' + ques.questionVersionId" v-html="ques.stem"></div>
<!-- 单选多选判断的选项 -->
<template
v-if="item.questionType !== 'fill_blank' && item.questionType !== 'essay' && ques.questionAnswerVersionsList">
<div v-for="(opt, j) in ques.questionAnswerVersionsList" :key="j" class="opt">
<span>{{ numToLetter(j) }}.&nbsp;</span>
<div class="text" v-html="opt.optionText"></div>
</div>
</template>
<div class="bottom-line">
{{ item.questionType === 'essay' ? '参考答案' : '正确答案' }}
<div v-html="getCorrectAnswer(ques)" class="ans"></div>
</div>
<div v-if="ques.knowledgePointList && ques.knowledgePointList.length" class="bottom-line">
<span>知识点</span>
<el-tag v-for="(kp, k) in ques.knowledgePointList" :key="k" class="m-r-5" type="info"
effect="plain">{{
kp.name }}</el-tag>
</div>
</div>
</div> </div>
</draggable> </draggable>
</div> </div>
@ -205,6 +214,7 @@
<el-button v-if="paperId" @click="preview">预览</el-button> <el-button v-if="paperId" @click="preview">预览</el-button>
<el-button @click="back">取消</el-button> <el-button @click="back">取消</el-button>
</div> </div>
</div>
<Template :visible.sync="templateVisible" /> <Template :visible.sync="templateVisible" />
<Manual :visible.sync="manualVisible" :questionType.sync="curType.questionType" /> <Manual :visible.sync="manualVisible" :questionType.sync="curType.questionType" />
@ -248,6 +258,7 @@ export default {
paperId: this.$route.query.paperId, paperId: this.$route.query.paperId,
libraryId: this.$route.query.libraryId, libraryId: this.$route.query.libraryId,
isCopy: this.$route.query.isCopy, isCopy: this.$route.query.isCopy,
loading: false,
headers: { headers: {
token: Util.local.get(Setting.tokenKey) token: Util.local.get(Setting.tokenKey)
}, },
@ -400,6 +411,7 @@ export default {
try { try {
const { paperId } = this const { paperId } = this
if (paperId) { if (paperId) {
this.loading = true
const res = await this.$get(this.api.examPaperDetails, { const res = await this.$get(this.api.examPaperDetails, {
id: paperId id: paperId
}) })
@ -411,7 +423,7 @@ export default {
e.examQuestions.map((n, j) => { e.examQuestions.map((n, j) => {
n.originSort = j + 1 n.originSort = j + 1
Object.assign(n, n.question) Object.assign(n, n.question)
this.handleFillScore(n) this.handleQuesInfo(n)
}) })
}) })
@ -419,7 +431,9 @@ export default {
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
} }
} catch (e) { } } finally {
this.loading = false
}
}, },
// //
async getType () { async getType () {
@ -605,10 +619,21 @@ export default {
} }
}, },
// //
handleFillScore (ques) { handleQuesInfo (ques) {
try { try {
//
const { difficults } = QuesConst
if (ques.difficulty) {
const curDiff = difficults.find(m => m.id === ques.difficulty)
if (curDiff) {
ques.difficult = curDiff.name
ques.difficultTheme = curDiff.theme
}
}
const opts = ques.questionAnswerVersionsList const opts = ques.questionAnswerVersionsList
//
if (ques.questionType === 'fill_blank' && opts && opts.length) { if (ques.questionType === 'fill_blank' && opts && opts.length) {
// json // json
let { answerData } = opts[0] let { answerData } = opts[0]
@ -1084,7 +1109,7 @@ export default {
} }
.stem { .stem {
max-width: calc(100% - 120px); margin-bottom: 10px;
} }
/deep/.l-input { /deep/.l-input {
@ -1117,21 +1142,19 @@ export default {
.bottom-line { .bottom-line {
display: flex; display: flex;
justify-content: space-between; align-items: baseline;
align-items: center; margin-bottom: 10px;
}
.correct {
display: flex;
font-size: 13px; font-size: 13px;
color: #333; color: #333;
} }
.ans {
max-width: calc(100% - 100px);
}
.actions { .actions {
display: flex; display: inline-flex;
justify-content: flex-end;
align-items: center; align-items: center;
margin-top: 10px;
.el-button { .el-button {
margin: 0 20px 0 0; margin: 0 20px 0 0;

@ -66,7 +66,7 @@
@change="val => quesChange(val, item)"></el-checkbox> @change="val => quesChange(val, item)"></el-checkbox>
<span class="serial">{{ i + 1 }}</span> <span class="serial">{{ i + 1 }}</span>
<el-tooltip effect="dark" :content="item.stemText" placement="top-start"> <el-tooltip effect="dark" :content="item.stemText" placement="top-start">
<p class="stem">{{ item.stemText }}</p> <p class="stem cursor-pointer" @click="toShowQues(item)">{{ item.stemText }}</p>
</el-tooltip> </el-tooltip>
<el-tooltip effect="dark" :content="item.knowledgePointName" placement="top-start"> <el-tooltip effect="dark" :content="item.knowledgePointName" placement="top-start">
<p class="kl">{{ item.knowledgePointName }}</p> <p class="kl">{{ item.knowledgePointName }}</p>
@ -145,7 +145,7 @@
<el-drawer title="新增试题" :visible.sync="addQuesVisible" size="1200px" :close-on-click-modal="false" <el-drawer title="新增试题" :visible.sync="addQuesVisible" size="1200px" :close-on-click-modal="false"
custom-class="add-dia"> custom-class="add-dia">
<QuesDetail :paperType.sync="paperType" @closeAdd="closeAdd" /> <QuesDetail :key="quesKey" :paperType.sync="paperType" :curQues.sync="curRow" @closeAdd="closeAdd" />
</el-drawer> </el-drawer>
</div> </div>
</template> </template>
@ -186,6 +186,7 @@ export default {
quesVisible: false, quesVisible: false,
curRow: {}, curRow: {},
addQuesVisible: false, addQuesVisible: false,
quesKey: 1,
paperType: 1, paperType: 1,
}; };
}, },
@ -420,20 +421,21 @@ export default {
}, },
// //
toAddQues () { toAddQues () {
// this.$router.push('/ques/detail?detailType=5') this.quesKey++
this.paperType = 1
this.addQuesVisible = true
},
//
toShowQues (ques) {
this.quesKey++
this.curRow = ques
this.paperType = 3
this.addQuesVisible = true this.addQuesVisible = true
}, },
// //
closeAdd () { closeAdd () {
this.addQuesVisible = false this.addQuesVisible = false
}, },
//
updateQues (ques, id) {
// ques.questionAnswerVersionsList = ques.questionAnswerVersions
// delete ques.questionAnswerVersions
// ques.questionVersionId = id
// this.curType.examQuestions[this.curQuesIndex] = Object.assign(this.curRow, ques)
},
// //
async submit () { async submit () {
if (this.submiting) return false if (this.submiting) return false
@ -447,9 +449,9 @@ export default {
checked.map((e, i) => { checked.map((e, i) => {
this.$set(e, 'check', false) this.$set(e, 'check', false)
this.$set(e, 'sort', i + 1) this.$set(e, 'sort', i + 1)
this.$set(e, 'originSort', i + 1)
this.$set(e, 'score', '') this.$set(e, 'score', '')
this.$parent.handleFillScore(e) this.$parent.handleQuesInfo(e)
// this.$set(e, 'questionVersionId', e.questionVersionId)
}) })
if (curQues) { if (curQues) {
@ -572,6 +574,10 @@ export default {
width: calc(100% - 210px); width: calc(100% - 210px);
margin-right: 20px; margin-right: 20px;
@include ellipsis; @include ellipsis;
&:hover {
opacity: .9;
}
} }
.kl { .kl {

Loading…
Cancel
Save