From 8fc87aa06a9a67e2438f1d672f2b35559a6649e0 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Wed, 7 Aug 2024 15:26:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E8=AF=95=E9=A2=98=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/ueditorPlus/ueditor.config.js | 2 +- src/pages/ques/detail/index.vue | 143 +++++++++++++---- src/pages/ques/list/index.vue | 60 +------- src/pages/testPaper/detail/auto.vue | 68 ++++---- src/pages/testPaper/detail/index.vue | 162 +++++++++++++++++--- src/pages/testPaper/detail/manual.vue | 51 ++++-- src/pages/testPaper/list/index.vue | 24 +-- src/styles/common.scss | 9 -- 8 files changed, 341 insertions(+), 178 deletions(-) diff --git a/public/static/ueditorPlus/ueditor.config.js b/public/static/ueditorPlus/ueditor.config.js index f07d96a..7c9cfd1 100644 --- a/public/static/ueditorPlus/ueditor.config.js +++ b/public/static/ueditorPlus/ueditor.config.js @@ -101,7 +101,7 @@ // 禁止本地上传 disableUpload: false, } - , zIndex: 3000 + , zIndex: 2000 , fullscreen: false , rgb2Hex: true, diff --git a/src/pages/ques/detail/index.vue b/src/pages/ques/detail/index.vue index 3f569ea..7951e24 100644 --- a/src/pages/ques/detail/index.vue +++ b/src/pages/ques/detail/index.vue @@ -1,8 +1,7 @@ - + @@ -201,11 +200,11 @@ export default { components: { Ueditor, Upload }, data () { return { - typeId: this.$route.query.id, + typeId: this.$route.query.id, // 题库id questionBankName: this.$route.query.questionBankName, questionBankCategory: this.$route.query.questionBankCategory, numToLetter: Util.numToLetter, - detailTypes: ['', '复制', '查看', '编辑'], + detailTypes: ['', '复制', '查看', '编辑', '编辑'], types: [], cascaderValue: [], cascaderProps: { @@ -276,6 +275,21 @@ export default { repeats: [] }; }, + computed: { + // 弹框标题 + diaTitle () { + const type = this.detailType + return (!type || type === 5 ? + '新增' : + type === 1 ? + '复制' : + type === 2 ? + '查看' : + type === 3 ? + '编辑' : + '') + '试题' + }, + }, watch: { visible () { this.quesVisible = this.visible @@ -292,9 +306,14 @@ export default { this.form = _.cloneDeep(this.originForm) this.handleSingleMultiple() + const type = this.detailType // 外面知识点树形选中的知识点默认选中到表单里(选的是知识点才需要默认选中,知识点分类不用) - const knowledgeCheck = this.$parent.$refs.typeTree.getCurrentNode() - if (knowledgeCheck && knowledgeCheck.type) this.form.knowledgePointIds = [knowledgeCheck.path.split('/').map(e => +e)] + if (type < 4) { + const knowledgeCheck = this.$parent.$refs.typeTree.getCurrentNode() + if (knowledgeCheck && knowledgeCheck.type) this.form.knowledgePointIds = [knowledgeCheck.path.split('/').map(e => +e)] + } else if (type === 4) { + this.typeId = this.row.questionBankId + } // 富文本重置 this.$refs.stem && this.$refs.stem.setText('') @@ -314,6 +333,12 @@ export default { const res = await this.$post(`${this.api.findQuestion}?questionId=${this.row.questionId}&version=${this.row.version}`) const r = res.message const opts = r.questionAnswerVersionsList + + if (this.detailType === 4) { + this.questionBankName = r.questionBankName + // this.questionBankCategory = r.questionBankCategory + } + this.form = { questionId: r.questionId, questionType: r.questionType, @@ -347,15 +372,17 @@ export default { }, // 获取知识点 async getKnowledge () { - try { - const { data } = await this.$post(this.api.TreeStructure, { - createSource: 1, - questionBankId: this.typeId, - keyword: '' - }) - this.handleType(data) - this.knowledges = data - } catch (e) { } + if (this.typeId) { + try { + const { data } = await this.$post(this.api.TreeStructure, { + createSource: 1, + questionBankId: this.typeId, + keyword: '', + }) + this.handleType(data) + this.knowledges = data + } catch (e) { } + } }, // 获取所属专业 async getProfessional () { @@ -486,7 +513,6 @@ export default { }, questionItemReset (content) { let spanRegex = new RegExp('(.*?)______(.*?)<\\/span>', 'g') - let _this = this let newFormItem = [] let gapfillingItems = content.match(spanRegex) if (gapfillingItems !== null) { @@ -501,8 +527,6 @@ export default { this.fillBlanks.push(e) } }) - console.log("🚀 ~ questionItemReset ~ spanRegex:", gapfillingItems, newFormItem, this.fillBlanks) - // _this.fillBlanks = newFormItem } }, // 填空题新增填空项 @@ -552,9 +576,15 @@ export default { form.questionAnswerVersions[0].answerAnalysis = answerAnalysis // 解析保存在选项里第一个对象里 if (this.$refs.uploadInstructions) form.uploadInstructions = this.$refs.uploadInstructions.getUEContent() - if (form.questionType === 'fill_blank') form.questionAnswerVersions[0].answerData = JSON.stringify(this.fillBlanks) // 填空题的答案数据,直接把fillBlanks转化成字符串存 + + // 填空题的答案数据,直接把fillBlanks转化成字符串存 + if (form.questionType === 'fill_blank') { + const blanks = this.fillBlanks + blanks.map((e, i) => e.serial = i + 1) // 全部加个序号 + form.questionAnswerVersions[0].answerData = JSON.stringify(blanks) + } if (form.questionType === 'essay' && this.$refs.referenceAnswer) form.questionAnswerVersions[0].referenceAnswer = this.$refs.referenceAnswer.getUEContent() // 参考答案保存在选项里第一个对象里(问答题才有) - debugger + // debugger this.tempForm = form this.keep = keep // 编辑试题的仅更新此题不用查询相似题,其他3种按钮都需要 @@ -566,7 +596,7 @@ export default { } else { // 仅更新此题 try { - await this.$confirm(`

确认仅更新此题吗?

更新后,相关试卷自动同步

`, '提示', { + await this.$confirm(`

确认仅更新此题吗?

${this.detailType === 4 ? '' : '

更新后,相关试卷自动同步

'}`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', @@ -592,7 +622,11 @@ export default { // 保存题目 async saveQues () { const form = this.tempForm - await this.$post(this.api[this.detailType === 1 || !form.questionId ? 'addQuestion' : 'updateQuestion'], form) + const type = this.detailType + // type: 1复制(调新增接口),2查看,3编辑,4是试卷里点编辑试题进来的(调createNewVersion创建新的版本) + const res = await this.$post(this.api[type === 4 ? 'createNewVersion' : type === 1 || !form.questionId ? 'addQuestion' : 'updateQuestion'], form) + type === 4 && this.$emit('updateQues', this.tempForm, res.questionVersionId) + Util.successMsg('保存成功') this.submiting = false !form.questionId && this.keep ? this.init() : (this.quesVisible = false) @@ -636,11 +670,64 @@ export default { } } -/deep/.correct-check { - margin-right: 15px; -} + + /deep/.ques-dia { z-index: 500; + + .fill-blanks { + .fills { + display: inline-flex; + align-items: center; + } + + .fill-item { + display: inline-flex; + align-items: center; + margin-right: 10px; + + .el-input { + width: 100px; + margin-right: 10px; + } + } + + .add-fill { + margin-left: 10px; + } + + .score-wrap { + display: inline-flex; + align-items: center; + + .el-input { + width: 80px; + margin: 0 10px; + } + } + } + + .opts { + .line { + display: flex; + align-items: center; + margin-bottom: 15px; + } + + .el-radio { + margin-right: 15px; + } + + .icon { + margin-left: 10px; + font-size: 18px; + cursor: pointer; + } + } + + /deep/.correct-check { + margin-right: 15px; + } } \ No newline at end of file diff --git a/src/pages/ques/list/index.vue b/src/pages/ques/list/index.vue index 088e807..a58a821 100644 --- a/src/pages/ques/list/index.vue +++ b/src/pages/ques/list/index.vue @@ -152,16 +152,6 @@ - @@ -470,7 +460,7 @@ export default { this.multipleSelection = [] this.$refs.table.clearSelection() this.delVisible = false - this.getData() + this.getList() }, // 禁启用 async switchOff (val, row) { @@ -605,55 +595,7 @@ export default { } } -/deep/.opts { - .line { - display: flex; - align-items: center; - margin-bottom: 15px; - } - .el-radio { - margin-right: 15px; - } - - .icon { - margin-left: 10px; - font-size: 18px; - cursor: pointer; - } -} - -/deep/.fill-blanks { - .fills { - display: inline-flex; - align-items: center; - } - - .fill-item { - display: inline-flex; - align-items: center; - margin-right: 10px; - - .el-input { - width: 100px; - margin-right: 10px; - } - } - - .add-fill { - margin-left: 10px; - } - - .score-wrap { - display: inline-flex; - align-items: center; - - .el-input { - width: 80px; - margin: 0 10px; - } - } -} .papers { margin-top: 10px; diff --git a/src/pages/testPaper/detail/auto.vue b/src/pages/testPaper/detail/auto.vue index 792cb64..607ee3c 100644 --- a/src/pages/testPaper/detail/auto.vue +++ b/src/pages/testPaper/detail/auto.vue @@ -6,7 +6,7 @@
  • - +
  • @@ -179,6 +179,8 @@ export default { this.yearCheck = this.years this.handleQuesList() this.getQuesBank() + this.difficult = this.$parent.form.difficult + this.difficult && this.difficultChange(this.difficult) }, // 获取题库 async getQuesBank () { @@ -284,50 +286,47 @@ export default { }, - calculateQuestionNumbers (list, target) { + // 试卷难度选择回调 + difficultChange (val) { // Decimal(e.score).add(Decimal(score)) const difficultyWeights = [0.2, 0.4, 0.6, 0.8] const names = ['basicDifficulty', 'normalDifficulty', 'hardDifficulty', 'veryHardDifficulty'] // 遍历题型数组 - list.forEach(e => { + this.list.forEach(e => { const total = e.questionNum - if (target === 1) { - let already = 0 - this.$set(e, 'basicDifficulty', Math.floor(total * 0.6)) + let already = 0 // 已经分配的数量 + if (val === 1) { + this.$set(e, 'basicDifficulty', Math.floor(total * 0.7)) this.$set(e, 'normalDifficulty', Math.floor(total * 0.3)) - this.$set(e, 'hardDifficulty', Math.floor(total * 0.1)) + this.$set(e, 'hardDifficulty', 0) this.$set(e, 'veryHardDifficulty', 0) - already = Decimal(already).add(e.basicDifficulty).add(e.normalDifficulty).add(e.hardDifficulty).add(e.veryHardDifficulty).toNumber() - - while (total > already) { - e.basicDifficulty++ - already++ - } - console.log(33, already) + } else if (val === 2) { + this.$set(e, 'basicDifficulty', Math.floor(total * 0.5)) + this.$set(e, 'normalDifficulty', Math.floor(total * 0.5)) + this.$set(e, 'hardDifficulty', 0) + this.$set(e, 'veryHardDifficulty', 0) + } else if (val === 3) { + this.$set(e, 'basicDifficulty', Math.floor(total * 0.3)) + this.$set(e, 'normalDifficulty', Math.floor(total * 0.4)) + this.$set(e, 'hardDifficulty', Math.floor(total * 0.3)) + this.$set(e, 'veryHardDifficulty', 0) + } else if (val === 4) { + this.$set(e, 'basicDifficulty', Math.floor(total * 0.1)) + this.$set(e, 'normalDifficulty', Math.floor(total * 0.2)) + this.$set(e, 'hardDifficulty', Math.floor(total * 0.3)) + this.$set(e, 'veryHardDifficulty', Math.floor(total * 0.5)) } - // 初始分配题目数量 - // let totalWeight = Decimal(total).mul(Decimal(target)).toNumber() - // const maxCount = Math.ceil(total / 4) - // for (let i = 0; i < 4; i++) { - // if (totalWeight > 0) { - // const random = Math.floor(Math.random() * maxCount) + 1 - // const weight = difficultyWeights[i] - // totalWeight = Decimal(totalWeight).sub(Decimal(weight * random)).toNumber() - // this.$set(e, names[i], totalWeight > 0 ? random : 0) - // // e[names[i]] = totalWeight > 0 ? random : 0 - // } - // } + already = Decimal(already).add(e.basicDifficulty).add(e.normalDifficulty).add(e.hardDifficulty).add(e.veryHardDifficulty).toNumber() + // 如果按比例分配还没分配完 + while (total > already) { + e[names[val - 1]]++ + already++ + } + this.$set(e, 'randomDifficulty', 0) }) - - return list - }, - // 试卷难度选择回调 - difficultData (val) { - // debugger - console.log(111, this.calculateQuestionNumbers(this.list, val)) }, // 年份全选回调 yearAllChange (val) { @@ -377,7 +376,7 @@ export default { let invalid = 0 let hasQues = 0 list.map((e, i) => { - if (e.questionNum !== res.list[i].questions.length) invalid = 1 + if (+e.questionNum !== res.list[i].questions.length) invalid = 1 if (e.examQuestions.length) hasQues = 1 e.score = 0 }) @@ -400,6 +399,7 @@ export default { } list.map((e, i) => { res.list[i].questions.map((e, i) => { + // e.questionVersionId = e.id e.serialNumber = i + 1 }) this.$parent.form.paperOutline[i].examQuestions = res.list[i].questions diff --git a/src/pages/testPaper/detail/index.vue b/src/pages/testPaper/detail/index.vue index 7ef93b4..b18f394 100644 --- a/src/pages/testPaper/detail/index.vue +++ b/src/pages/testPaper/detail/index.vue @@ -38,9 +38,27 @@ - + + +
    +

    基础题:难度系数0.2

    +

    普通题:难度系数0.4

    +

    较难题:难度系数0.6

    +

    困难题:难度系数0.8

    +

    (1)题型难度系数=对应题型所有试题的难度系数之和/总试题数

    +

    (2)试卷总难度系数=所有试题的难度系数之和/总试题数

    +

    (3)难度系数评价

    +
    +

    简单:系数 <=0.3

    +

    普通:0.3<系数<=0.4

    +

    较难:0.4<系数<0.5

    +

    困难:系数>=0.5

    +
    +
    + +
    @@ -113,12 +131,13 @@
    -
    +
    {{ j + 1 }} / 10 {{ questionTypes.find(e => e.id === item.questionType).name }}
    -

    分)

    +

    分)

    @@ -140,7 +159,7 @@ 排序
    - 编辑试题 + 编辑试题 更换试题 添加试题 移除试题 @@ -163,6 +182,7 @@