|
|
|
@ -31,6 +31,7 @@ |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="上传" prop="source"> |
|
|
|
|
<el-upload |
|
|
|
|
:accept="acceptExt" |
|
|
|
|
:on-remove="handleRemove" |
|
|
|
|
:on-error="uploadError" |
|
|
|
|
:on-success="uploadSuccess" |
|
|
|
@ -39,17 +40,28 @@ |
|
|
|
|
:on-exceed="handleExceed" |
|
|
|
|
:action="this.api.fileupload" |
|
|
|
|
:file-list="uploadList" |
|
|
|
|
name="file" |
|
|
|
|
> |
|
|
|
|
<el-button type="primary" class="ml20">上传视频/音频</el-button> |
|
|
|
|
</el-upload> |
|
|
|
|
<el-link v-if="uploadFaild" type="primary" @click="showFaild">导入失败,查看原因</el-link> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="题干" prop="questionStem"> |
|
|
|
|
<quill :border="true" :readonly="isDetail" :key="isDetail" v-model="topicForm.questionStem" :minHeight="150" :height="150" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
|
<el-form-item label="选项" prop="optionA" v-if="topicForm.questionType != '填空题' && topicForm.questionType != '简答题'"> |
|
|
|
|
<template v-if="topicForm.questionType == '判断题'"> |
|
|
|
|
<div class="input flex_around bt"> |
|
|
|
|
<span>A</span> |
|
|
|
|
<el-input placeholder="请输入题目" v-model="topicForm.judgeOptionA" disabled></el-input> |
|
|
|
|
<el-radio v-model="topicForm.aisTrue" label="1">设为正确答案</el-radio> |
|
|
|
|
</div> |
|
|
|
|
<div class="input flex_around bt"> |
|
|
|
|
<span>B</span> |
|
|
|
|
<el-input placeholder="请输入题目" v-model="topicForm.judgeOptionB" disabled></el-input> |
|
|
|
|
<el-radio v-model="topicForm.aisTrue" label="2">设为正确答案</el-radio> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
<template v-else> |
|
|
|
|
<div class="input flex_around bt"> |
|
|
|
|
<span>A</span> |
|
|
|
|
<el-input placeholder="请输入题目" v-model="topicForm.optionA"></el-input> |
|
|
|
@ -60,7 +72,6 @@ |
|
|
|
|
<el-input placeholder="请输入题目" v-model="topicForm.optionB"></el-input> |
|
|
|
|
<el-checkbox v-model="topicForm.bisTrue">设为正确答案</el-checkbox> |
|
|
|
|
</div> |
|
|
|
|
<template v-if="topicForm.questionType != '判断题'"> |
|
|
|
|
<div class="input flex_around bt"> |
|
|
|
|
<span>C</span> |
|
|
|
|
<el-input placeholder="请输入题目" v-model="topicForm.optionC"></el-input> |
|
|
|
@ -119,6 +130,7 @@ export default { |
|
|
|
|
props: ['visible','title','isDetail'], |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
acceptExt: '.avi,.wmv,.mpg,.mpeg,.mov,.rm,.ram,.swf,.flv,.mp4,.mp3,.wma,.avi,.rm,.rmvb,.flv,.mpg,.mkv', |
|
|
|
|
quesBankList: [], |
|
|
|
|
typeList: [], |
|
|
|
|
topicForm: { |
|
|
|
@ -142,6 +154,8 @@ export default { |
|
|
|
|
disTrue: false, |
|
|
|
|
eisTrue: false, |
|
|
|
|
fisTrue: false, |
|
|
|
|
judgeOptionA: '正确', |
|
|
|
|
judgeOptionB: '错误', |
|
|
|
|
answerAnalysis: '', |
|
|
|
|
videoAudio: '' |
|
|
|
|
}, |
|
|
|
@ -151,14 +165,11 @@ export default { |
|
|
|
|
knowledgePoints: [{ required: true, message: '请填写知识点', trigger: 'blur' }], |
|
|
|
|
questionType: [{ required: true, message: '请选择题型', trigger: 'change' }], |
|
|
|
|
questionStem: [{ required: true, message: '请填写题干', trigger: 'blur' }], |
|
|
|
|
// optionA: [{ required: true, message: '请选择正确选项', trigger: 'change' }], |
|
|
|
|
// optionB: [{ required: true, message: '请选择正确选项', trigger: 'change' }] |
|
|
|
|
}, |
|
|
|
|
options: 'ABCDEF', |
|
|
|
|
questionType: ['','单选题','多选题','判断题','简答题','填空题'], |
|
|
|
|
fillList: [''], |
|
|
|
|
uploadList: [], |
|
|
|
|
uploadFaild: false |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
@ -197,16 +208,24 @@ export default { |
|
|
|
|
disTrue: false, |
|
|
|
|
eisTrue: false, |
|
|
|
|
fisTrue: false, |
|
|
|
|
judgeOptionA: '正确', |
|
|
|
|
judgeOptionB: '错误', |
|
|
|
|
answerAnalysis: list.answerAnalysis, |
|
|
|
|
videoAudio: list.videoAudio |
|
|
|
|
}, |
|
|
|
|
this.topicForm.questionType = this.questionType[this.topicForm.typeId] |
|
|
|
|
let typeId = this.topicForm.typeId |
|
|
|
|
if(typeId == 1 || typeId == 2 || typeId == 3){ |
|
|
|
|
if(typeId == 1 || typeId == 2){ |
|
|
|
|
let answer = this.topicForm.answer.toLowerCase().split('') |
|
|
|
|
answer.forEach(n => { |
|
|
|
|
this.topicForm[`${n}isTrue`] = true |
|
|
|
|
}) |
|
|
|
|
}else if(typeId == 3){ |
|
|
|
|
if(this.topicForm.answer == 'A'){ |
|
|
|
|
this.topicForm.aisTrue = '1' |
|
|
|
|
}else{ |
|
|
|
|
this.topicForm.aisTrue = '2' |
|
|
|
|
} |
|
|
|
|
}else if(typeId == 5){ |
|
|
|
|
let fillList = [] |
|
|
|
|
for(let n in this.topicForm) { |
|
|
|
@ -232,6 +251,9 @@ export default { |
|
|
|
|
for(let i in this.topicForm){ |
|
|
|
|
if(i.includes('isTrue')) this.topicForm[i] = false |
|
|
|
|
} |
|
|
|
|
if(this.topicForm.questionType == '判断题'){ |
|
|
|
|
this.topicForm.aisTrue = '1' |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
saveTopics() { |
|
|
|
|
this.$refs.topicForm.validate((valid) => { |
|
|
|
@ -241,7 +263,18 @@ export default { |
|
|
|
|
let answer = '' |
|
|
|
|
let isInvalidAnswer = false |
|
|
|
|
this.topicForm.typeId = this.questionType.indexOf(topicForm.questionType) |
|
|
|
|
if(topicForm.typeId != 4 && topicForm.typeId != 5){ |
|
|
|
|
if(this.topicForm.typeId == 3){ |
|
|
|
|
this.topicForm.optionA = '正确' |
|
|
|
|
this.topicForm.optionB = '错误' |
|
|
|
|
if(this.topicForm.aisTrue == 1){ |
|
|
|
|
this.topicForm.aisTrue = true |
|
|
|
|
this.topicForm.answer = 'A' |
|
|
|
|
}else{ |
|
|
|
|
this.topicForm.bisTrue = true |
|
|
|
|
this.topicForm.answer = 'B' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(topicForm.typeId == 1 || topicForm.typeId == 2 || topicForm.typeId == 3){ |
|
|
|
|
for(let n in topicForm) { |
|
|
|
|
if(n.includes('option')) { |
|
|
|
|
topicForm[n] != '' && ++optionCount |
|
|
|
@ -252,9 +285,10 @@ export default { |
|
|
|
|
if(!topicForm[`option${curOpt.toUpperCase()}`].length) isInvalidAnswer = true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(optionCount < 2) return this.$message.warning('请至少添加两个选项!'); |
|
|
|
|
if(!answer) return this.$message.warning('请设置正确答案!'); |
|
|
|
|
if(topicForm.questionType != '多选题' && answer.length > 1) return this.$message.warning('单选题、判断题只能设置一个正确答案!'); |
|
|
|
|
if(optionCount < 2) return this.$message.warning('请至少添加两个选项!') |
|
|
|
|
if(!answer) return this.$message.warning('请设置正确答案!') |
|
|
|
|
if(topicForm.questionType == '单选题' && answer.length > 1) return this.$message.warning('单选题只能设置一个正确选项!') |
|
|
|
|
if(topicForm.questionType == '多选题' && answer.length < 2) return this.$message.warning('多选题必须设置至少两个正确选项!') |
|
|
|
|
if(isInvalidAnswer) return this.$message.warning('正确答案选项为空,请重新设置!'); |
|
|
|
|
this.topicForm.answer = answer.toUpperCase() |
|
|
|
|
}else if(this.topicForm.typeId == 5){ |
|
|
|
@ -271,24 +305,24 @@ export default { |
|
|
|
|
if(this.topicForm.id) { |
|
|
|
|
this.$post(this.api.updateQuestions,this.topicForm).then(res => { |
|
|
|
|
if(res.success) { |
|
|
|
|
this.$message.success('修改成功'); |
|
|
|
|
this.$message.success('修改成功') |
|
|
|
|
this.$emit('getData') |
|
|
|
|
}else{ |
|
|
|
|
this.$message.error(res.data.message); |
|
|
|
|
this.$message.error(res.data.message) |
|
|
|
|
} |
|
|
|
|
}).catch(res => {}); |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}else{ |
|
|
|
|
this.$post(this.api.addQuestions,this.topicForm).then(res => { |
|
|
|
|
if(res.success) { |
|
|
|
|
this.$message.success('新增成功'); |
|
|
|
|
this.$message.success('新增成功') |
|
|
|
|
this.$emit('getData') |
|
|
|
|
}else{ |
|
|
|
|
this.$message.error(res.data.message); |
|
|
|
|
this.$message.error(res.data.message) |
|
|
|
|
} |
|
|
|
|
}).catch(res => {}); |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
return false; |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
@ -317,6 +351,8 @@ export default { |
|
|
|
|
disTrue: false, |
|
|
|
|
eisTrue: false, |
|
|
|
|
fisTrue: false, |
|
|
|
|
judgeOptionA: '正确', |
|
|
|
|
judgeOptionB: '错误', |
|
|
|
|
answerAnalysis: '', |
|
|
|
|
videoAudio: '' |
|
|
|
|
} |
|
|
|
@ -331,7 +367,7 @@ export default { |
|
|
|
|
this.topicForm.id = id |
|
|
|
|
this.topicForm.questionType = this.questionType[this.topicForm.questionType] |
|
|
|
|
this.NewTopics = true |
|
|
|
|
}).catch(res => {}); |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
|
addFill(){ |
|
|
|
|
if(this.fillList.some(n => n === '')) return this.$message.warning('请先填写当前答案') |
|
|
|
@ -343,14 +379,10 @@ export default { |
|
|
|
|
handleExceed(files, fileList) { |
|
|
|
|
this.$message.warning( |
|
|
|
|
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!` |
|
|
|
|
); |
|
|
|
|
) |
|
|
|
|
}, |
|
|
|
|
uploadSuccess(res, file, fileList) { |
|
|
|
|
this.uploadFaild = false |
|
|
|
|
if(res.data.token){ |
|
|
|
|
this.token = res.data.token |
|
|
|
|
this.uploadFaild = true |
|
|
|
|
} |
|
|
|
|
this.topicForm.videoAudio = res.data.filesResult.fileId |
|
|
|
|
}, |
|
|
|
|
showFaild(){ |
|
|
|
|
location.href = `${this.api.export_failure}?token=${this.token}` |
|
|
|
@ -429,4 +461,3 @@ export default { |
|
|
|
|
overflow: auto; |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|
|
|
|
|
|