From 1af3178ea3720141ae17cc75447f1d6912cc9f5f Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Wed, 7 Aug 2024 16:38:38 +0800 Subject: [PATCH] fix --- public/static/ueditorPlus/ueditor.config.js | 2 +- src/components/ueditor/index.vue | 2 +- src/const/ques.js | 12 ++++++--- src/pages/testPaper/detail/auto.vue | 1 + src/pages/testPaper/detail/index.vue | 30 ++++++++++++++++++++- src/pages/testPaper/detail/manual.vue | 1 + 6 files changed, 41 insertions(+), 7 deletions(-) diff --git a/public/static/ueditorPlus/ueditor.config.js b/public/static/ueditorPlus/ueditor.config.js index 7c9cfd1..5006162 100644 --- a/public/static/ueditorPlus/ueditor.config.js +++ b/public/static/ueditorPlus/ueditor.config.js @@ -50,7 +50,7 @@ // 服务器统一请求接口路径 - serverUrl: "http://192.168.31.51:9000/exam/exam/upload/configAndUpload", + serverUrl: "http://121.37.12.51/exam/exam/upload/configAndUpload", imageActionName: "imgUpload", imageAllowFiles: [ ".png", diff --git a/src/components/ueditor/index.vue b/src/components/ueditor/index.vue index 93b305b..1d97a15 100644 --- a/src/components/ueditor/index.vue +++ b/src/components/ueditor/index.vue @@ -46,7 +46,7 @@ export default { // eslint-disable-next-line no-undef this.instance = UE.getEditor(this.randomId, { UEDITOR_HOME_URL: '/static/ueditorPlus/', - serverUrl: "http://192.168.31.51:9000/exam/exam/upload/configAndUpload", + serverUrl: "http://121.37.12.51/exam/exam/upload/configAndUpload", plugins: 'gapfilling' }) diff --git a/src/const/ques.js b/src/const/ques.js index f073468..ba8d6e5 100644 --- a/src/const/ques.js +++ b/src/const/ques.js @@ -2,19 +2,23 @@ export default { difficults: [ { id: 'basic', - name: '基础' + name: '基础', + coefficient: 0.2 // 难度系数,试卷里计算试卷难度专用 }, { id: 'easy', - name: '普通' + name: '普通', + coefficient: 0.4 }, { id: 'medium', - name: '较难' + name: '较难', + coefficient: 0.6 }, { id: 'hard', - name: '难' + name: '难', + coefficient: 0.8 }, ], questionTypes: [ diff --git a/src/pages/testPaper/detail/auto.vue b/src/pages/testPaper/detail/auto.vue index 607ee3c..0097f4a 100644 --- a/src/pages/testPaper/detail/auto.vue +++ b/src/pages/testPaper/detail/auto.vue @@ -405,6 +405,7 @@ export default { this.$parent.form.paperOutline[i].examQuestions = res.list[i].questions }) this.quesVisible = false + this.$parent.calcDifficult() this.submiting = false } catch (e) { this.submiting = false diff --git a/src/pages/testPaper/detail/index.vue b/src/pages/testPaper/detail/index.vue index b18f394..37516ce 100644 --- a/src/pages/testPaper/detail/index.vue +++ b/src/pages/testPaper/detail/index.vue @@ -38,7 +38,7 @@ - + @@ -307,6 +307,8 @@ export default { quesVisible: false, curRow: {}, detailType: '', + + difficultSelected: false, }; }, computed: { @@ -443,6 +445,29 @@ export default { }) } }, + // 自动计算试卷难度 + calcDifficult () { + // 如果试卷难度用户已经选择过了,则不用再计算;如果没选择过,则通过公式计算难度:所有试题的难度系数之和/总试题数 + if (this.difficultSelected) return false + let coefficient = 0 // 试题总系数 + let len = 0 // 试题总数 + const diffs = QuesConst.difficults + this.form.paperOutline.map(e => { + len += e.examQuestions.length + coefficient += e.examQuestions.reduce((e, j) => { + const val = diffs.find(n => n.id === j.difficulty) + return e += val ? +val.coefficient : 0 + }, 0) + }) + const result = coefficient / len + this.form.difficult = result <= 0.3 ? + 1 : + result > 0.3 && result <= 0.4 ? + 2 : + result > 0.4 && result <= 0.5 ? + 3 : + 4 + }, // 自动选题 showAuto () { this.autoVisible = true @@ -482,6 +507,7 @@ export default { delete ques.questionAnswerVersions ques.questionVersionId = id this.curType.examQuestions[this.curQuesIndex] = Object.assign(this.curRow, ques) + this.calcDifficult() }, // 添加题目 showManualDia (item, i, ques) { @@ -505,6 +531,7 @@ export default { const cur = item.examQuestions.findIndex(n => n.questionVersionId === e.questionVersionId) cur >= 0 && item.examQuestions.splice(cur, 1) }) + this.calcDifficult() } else { Util.warningMsg('请选择数据') } @@ -532,6 +559,7 @@ export default { // 移除试题 delQues (item, i) { item.examQuestions.splice(i, 1) + this.calcDifficult() }, // 提交 async submit (status) { diff --git a/src/pages/testPaper/detail/manual.vue b/src/pages/testPaper/detail/manual.vue index 2006c1d..5209bc5 100644 --- a/src/pages/testPaper/detail/manual.vue +++ b/src/pages/testPaper/detail/manual.vue @@ -348,6 +348,7 @@ export default { this.$set(e, 'serialNumber', i + 1) }) + this.$parent.calcDifficult() this.selectQuesVisible = false this.submiting = false } catch (e) {