From b45eddb9ee379b569b372b54bf4c3365c320e5ab Mon Sep 17 00:00:00 2001 From: 18571350067 Date: Tue, 9 Nov 2021 09:14:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=98=E5=BA=93=E9=A1=B5=E9=9D=A2=E6=95=B4?= =?UTF-8?q?=E6=94=B9=E3=80=81=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/course/question/question.js | 13 +- src/api/sys/oss.js | 7 +- src/views/course/question/QuestionAdd.vue | 90 ++++---- src/views/course/question/QuestionList.vue | 240 +++++++++++++++------ 4 files changed, 240 insertions(+), 110 deletions(-) diff --git a/src/api/course/question/question.js b/src/api/course/question/question.js index fe72398..51c7556 100644 --- a/src/api/course/question/question.js +++ b/src/api/course/question/question.js @@ -4,11 +4,12 @@ const questionApi = { add: 'courseManagement/question/addOrUpdate', get: '/courseManagement/question/details', // update: 'sys/menu/update', - del: 'courseManagement/course/delete', + del: 'courseManagement/question/delete', // updateStatus: 'sys/menu/updateStatus', // list: '/courseManagement/course/listPage', // coursewareList:'/courseManagement/course/courseware/details', -// questionList:'/courseManagement/course/questionList' +// questionList:'/courseManagement/course/questionList', + importTemplate: "courseManagement/question/importTemplate" } @@ -54,5 +55,13 @@ export function getQuestionDeatil (params) { }) } +// 题目批量导入 +export function importTemplate (params) { + return request({ + url: questionApi.importTemplate, + method: 'post', + params: params + }) +} diff --git a/src/api/sys/oss.js b/src/api/sys/oss.js index 76f55d0..f844ecf 100644 --- a/src/api/sys/oss.js +++ b/src/api/sys/oss.js @@ -1,7 +1,8 @@ import request from '@/utils/request' const ossApi = { - list: '/sys/oss/list' + list: '/sys/oss/list', + upload: '/sys/oss/upload' } export function ossList (params) { @@ -11,3 +12,7 @@ export function ossList (params) { params: params }) } + +export function ossUpload () { + return process.env.VUE_APP_API_BASE_URL + ossApi.upload; +} diff --git a/src/views/course/question/QuestionAdd.vue b/src/views/course/question/QuestionAdd.vue index c48f99d..cf0dc7f 100644 --- a/src/views/course/question/QuestionAdd.vue +++ b/src/views/course/question/QuestionAdd.vue @@ -6,7 +6,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -84,7 +84,7 @@ - + @@ -103,7 +103,7 @@ - + @@ -117,7 +117,7 @@ - + @@ -126,8 +126,8 @@ 添加一个新填空 刪除一个新填空 -
- +
+ @@ -155,21 +155,37 @@ export default { multiselect: {}, estimate: {}, shortAnswer: {}, - answerList: ["111","222","333"], - Completion: { }, + Completion: { answerList: [''] }, tabKey: this.$route.query.questionType ? this.$route.query.questionType : '1' - // tabKey, } }, created() { - if (this.$route.query.id) { + if (this.$route.query.id && !this.$route.query.opt) { + + this.radio.disabled = true; + this.multiselect.disabled = true; + this.estimate.disabled = true; + this.shortAnswer.disabled = true; + this.Completion.disabled = true; + getQuestionDeatil({ id: this.$route.query.id }).then((res) => { - console.log(this.tabKey) if (this.tabKey == '1') { - this.radio = res.data + this.radio = res.data; + this.radio.disabled = false; } else if (this.tabKey == '2') { - this.multiselect = res.data + this.multiselect = res.data; + this.multiselect.disabled = false; + this.getRightAnswer(); + } else if(this.tabKey == '3') { + this.estimate = res.data; + this.estimate.disabled = false; + } else if (this.tabKey == '4') { + this.shortAnswer = res.data; + this.shortAnswer.disabled = false; + } else if (this.tabKey == '5') { + this.Completion = res.data; + this.Completion.disabled = false; } }) } @@ -181,41 +197,36 @@ export default { path: '/course/question/QuestionList', query: { id: this.$route.query.courseId, + questionId: this.$route.query.id, + isactive: this.$route.query.isactive, }, }) }, - // getQuestionType() { - // if (!this.$route.query.questionType || this.$route.query.questionType === '') tabKey = '1' - // tabKey = this.$route.query.questionType - // }, - callback(key) { this.radio = {} this.multiselect = {} this.estimate = {} this.shortAnswer = {} - this.Completion = { answerSize: 2 } + this.Completion = { answerList: [''] } this.tabKey = key }, - onChangeInput(e) { - - }, + // 添加填空 addAnswerSize() { - if (this.answerList.length == 10) { + if (this.Completion.answerList.length == 10) { this.$message.error('填空数量最多不能超过10个') return } - this.answerList.push('') + this.Completion.answerList.push('') }, // 刪除填空 delAnswerSize() { - if (this.answerList.length == 1) { + if (this.Completion.answerList.length == 1) { this.$message.error('填空数量最少不能少于1个') return } - this.Completion.answerSize-- + this.Completion.answerList.splice(this.Completion.answerList.length-1, 1); }, // 确定 @@ -368,25 +379,20 @@ export default { this.$message.error('题干不能为空!') return false } - - console.log(this.Completion.conten) - // if (!this.Completion.rightAnswers || this.Completion.rightAnswers === '') { - // this.$message.error('正确答案不能为空!') - // return false - // } - - // let answer =[]; - // for(i in answerSize) { - // let daan ={}; - // } - - let tiank = this.Completion - console.log('tiank ', tiank) - let from = this.Completion from.questionType = 5 return from }, + + // 获取多选题的正确答案 + getRightAnswer(){ + if(this.multiselect.rightAnswers.indexOf('A') > -1) this.multiselect.a = true; + if(this.multiselect.rightAnswers.indexOf('B') > -1) this.multiselect.b = true; + if(this.multiselect.rightAnswers.indexOf('C') > -1) this.multiselect.c = true; + if(this.multiselect.rightAnswers.indexOf('D') > -1) this.multiselect.d = true; + console.log('1---', this.multiselect) + }, + }, } diff --git a/src/views/course/question/QuestionList.vue b/src/views/course/question/QuestionList.vue index 2a6c188..ecc501d 100644 --- a/src/views/course/question/QuestionList.vue +++ b/src/views/course/question/QuestionList.vue @@ -1,76 +1,138 @@ @@ -128,8 +232,14 @@ export default { border: 1px solid #000; margin: 5px 5px; cursor: pointer; + background-color: white; +} + +.active_color { background-color: wheat; } + +/* wheat */ .questionDetail { width: calc(100% - 300px - 20px); height: auto; @@ -158,7 +268,7 @@ export default { font-size: 23px; font: bold; background-color: gainsboro; - margin-top: 45px; + /* margin-top: 45px; */ } .questionContent { margin-left: 10px;