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) {
editor.registerCommand(uiName, {
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',
name: '基础',
coefficient: 0.2 // 难度系数,试卷里计算试卷难度专用
coefficient: 0.2, // 难度系数,试卷里计算试卷难度专用
theme: 'success',
},
{
id: 'easy',
name: '普通',
coefficient: 0.4
coefficient: 0.4,
theme: '',
},
{
id: 'medium',
name: '较难',
coefficient: 0.6
coefficient: 0.6,
theme: 'warning',
},
{
id: 'hard',
name: '难',
coefficient: 0.8
coefficient: 0.8,
theme: 'danger',
},
],
questionTypes: [

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

@ -578,7 +578,8 @@ export default {
res.list[i].questions.map((e, i) => {
// e.questionVersionId = e.id
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
})

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

@ -66,7 +66,7 @@
@change="val => quesChange(val, item)"></el-checkbox>
<span class="serial">{{ i + 1 }}</span>
<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 effect="dark" :content="item.knowledgePointName" placement="top-start">
<p class="kl">{{ item.knowledgePointName }}</p>
@ -145,7 +145,7 @@
<el-drawer title="新增试题" :visible.sync="addQuesVisible" size="1200px" :close-on-click-modal="false"
custom-class="add-dia">
<QuesDetail :paperType.sync="paperType" @closeAdd="closeAdd" />
<QuesDetail :key="quesKey" :paperType.sync="paperType" :curQues.sync="curRow" @closeAdd="closeAdd" />
</el-drawer>
</div>
</template>
@ -186,6 +186,7 @@ export default {
quesVisible: false,
curRow: {},
addQuesVisible: false,
quesKey: 1,
paperType: 1,
};
},
@ -420,20 +421,21 @@ export default {
},
//
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
},
//
closeAdd () {
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 () {
if (this.submiting) return false
@ -447,9 +449,9 @@ export default {
checked.map((e, i) => {
this.$set(e, 'check', false)
this.$set(e, 'sort', i + 1)
this.$set(e, 'originSort', i + 1)
this.$set(e, 'score', '')
this.$parent.handleFillScore(e)
// this.$set(e, 'questionVersionId', e.questionVersionId)
this.$parent.handleQuesInfo(e)
})
if (curQues) {
@ -572,6 +574,10 @@ export default {
width: calc(100% - 210px);
margin-right: 20px;
@include ellipsis;
&:hover {
opacity: .9;
}
}
.kl {

Loading…
Cancel
Save