|
|
@@ -200,7 +200,7 @@
|
|
|
|
|
|
<el-table-column label="是否答案" width="80" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-checkbox v-model="scope.row.isTrue" @change="checked=>checkUpdateAnswer(checked,scope.row.id)">答案
|
|
|
+ <el-checkbox v-model="scope.row.correct" @change="checked=>checkUpdateAnswer(checked,scope.row.id)">答案
|
|
|
</el-checkbox>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
@@ -330,7 +330,7 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
<el-button
|
|
|
- v-if="addQuForm.questionType!==4"
|
|
|
+ v-if="addQuForm.questionType < 5"
|
|
|
type="primary"
|
|
|
plain
|
|
|
size="small"
|
|
|
@@ -338,20 +338,18 @@
|
|
|
style="margin-left: 40px"
|
|
|
@click="addAnswer"
|
|
|
>
|
|
|
- 添加候选答案
|
|
|
+ 添加问题选项
|
|
|
</el-button>
|
|
|
<!--存放答案表单的信息-->
|
|
|
- <el-form-item v-if="addQuForm.questionType!==4" prop="answer">
|
|
|
- <el-table :data="addQuForm.answer" border style="width: 96%;margin-left: 40px;margin-top: 10px">
|
|
|
-
|
|
|
+ <el-form-item v-if="addQuForm.questionType < 5" prop="options">
|
|
|
+ <el-table :data="addQuForm.options" border style="width: 96%;margin-left: 40px;margin-top: 10px">
|
|
|
<el-table-column label="是否答案" width="80" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-checkbox v-model="scope.row.isTrue" @change="checked=>checkAnswer(checked,scope.row.id)">答案
|
|
|
+ <el-checkbox v-model="scope.row.correct" @change="checked=>checkAnswer(checked,scope.row.id)">答案
|
|
|
</el-checkbox>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
-
|
|
|
- <el-table-column label="答案图片">
|
|
|
+ <el-table-column label="选项图片">
|
|
|
<template slot-scope="scope">
|
|
|
<el-upload
|
|
|
:limit="1"
|
|
|
@@ -366,21 +364,18 @@
|
|
|
<el-button size="small" type="primary">点击上传</el-button>
|
|
|
</el-upload>
|
|
|
</template>
|
|
|
-
|
|
|
</el-table-column>
|
|
|
-
|
|
|
- <el-table-column label="答案内容">
|
|
|
+ <el-table-column label="选项内容">
|
|
|
<template slot-scope="scope">
|
|
|
<el-input
|
|
|
- v-model="scope.row.answer"
|
|
|
+ v-model="scope.row.content"
|
|
|
style="margin-left: 5px"
|
|
|
type="textarea"
|
|
|
:rows="2"
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
-
|
|
|
- <el-table-column label="答案解析">
|
|
|
+ <el-table-column label="选项解析">
|
|
|
<template slot-scope="scope">
|
|
|
<el-input
|
|
|
v-model="scope.row.analysis"
|
|
|
@@ -390,18 +385,34 @@
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
-
|
|
|
<el-table-column label="操作" width="80" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button type="danger" icon="el-icon-delete" circle @click="delAnswer(scope.row.id)" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
-
|
|
|
</el-table>
|
|
|
</el-form-item>
|
|
|
+ <div v-else>
|
|
|
+ <el-divider/>
|
|
|
+ <el-form-item label="答案" label-width="120px" prop="answerContent">
|
|
|
+ <el-input
|
|
|
+ v-model="addQuForm.answerContent"
|
|
|
+ style="margin-left: 5px"
|
|
|
+ type="textarea"
|
|
|
+ :rows="5"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="答案解析" label-width="120px" prop="answerAnalysis">
|
|
|
+ <el-input
|
|
|
+ v-model="addQuForm.answerAnalysis"
|
|
|
+ style="margin-left: 5px"
|
|
|
+ type="textarea"
|
|
|
+ :rows="5"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
</el-form>
|
|
|
</el-card>
|
|
|
-
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button @click="addQuTableVisible = false">取 消</el-button>
|
|
|
<el-button type="primary" @click="addQuestion">确 定</el-button>
|
|
|
@@ -414,7 +425,7 @@
|
|
|
<span> {{ questionDetail.subject }} </span>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="试题类型" label-width="120px">
|
|
|
- <span> {{ questionDetail.type }} </span>
|
|
|
+ <span> {{ questionDetail.typeStr }} </span>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="试题难度" label-width="120px">
|
|
|
<span> {{ questionDetail.level }} </span>
|
|
|
@@ -428,15 +439,30 @@
|
|
|
<span> {{ questionDetail.analysis }} </span>
|
|
|
</el-form-item>
|
|
|
<el-divider />
|
|
|
- <el-form-item label="试题答案" label-width="120px" />
|
|
|
- <el-form-item v-if="addQuForm.questionType!==4">
|
|
|
- <el-table :data="questionDetail.answers" border style="width: 96%;margin-left: 40px;margin-top: 10px">
|
|
|
+ <el-form-item v-if="questionDetail.type < 5" label="试题选项" label-width="120px">
|
|
|
+ <el-table :data="questionDetail.options" border style="width: 96%;margin-left: 40px;margin-top: 10px">
|
|
|
<el-table-column label="正确答案" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
<span v-if="scope.row.correct">YES</span>
|
|
|
<span v-else>NO</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="option"
|
|
|
+ label="选项"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ prop="content"
|
|
|
+ label="内容"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ prop="analysis"
|
|
|
+ label="解析"
|
|
|
+ />
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="试题答案" label-width="120px">
|
|
|
+ <el-table :data="questionDetail.answers" border style="width: 96%;margin-left: 40px;margin-top: 10px">
|
|
|
<el-table-column
|
|
|
prop="option"
|
|
|
label="选项"
|
|
|
@@ -565,11 +591,11 @@ export default {
|
|
|
},
|
|
|
{
|
|
|
id: 4,
|
|
|
- name: '填空题'
|
|
|
+ name: '判断题'
|
|
|
},
|
|
|
{
|
|
|
id: 5,
|
|
|
- name: '判断题'
|
|
|
+ name: '填空题'
|
|
|
},
|
|
|
{
|
|
|
id: 6,
|
|
|
@@ -650,7 +676,10 @@ export default {
|
|
|
analysis: '',
|
|
|
createPerson: localStorage.getItem('username'),
|
|
|
// 答案对象
|
|
|
- answer: []
|
|
|
+ // answer: [],
|
|
|
+ options: [],
|
|
|
+ answerContent: '',
|
|
|
+ answerAnalysis: ''
|
|
|
},
|
|
|
// 添加试题表单的验证规则
|
|
|
addQuFormRules: {
|
|
|
@@ -949,10 +978,10 @@ export default {
|
|
|
},
|
|
|
// 新增试题中的新增答案填写框
|
|
|
addAnswer() {
|
|
|
- this.addQuForm.answer.push({
|
|
|
- id: this.addQuForm.answer.length,
|
|
|
- isTrue: false,
|
|
|
- answer: '',
|
|
|
+ this.addQuForm.options.push({
|
|
|
+ id: this.addQuForm.options.length,
|
|
|
+ correct: false,
|
|
|
+ content: '',
|
|
|
images: [],
|
|
|
analysis: ''
|
|
|
})
|
|
|
@@ -961,7 +990,7 @@ export default {
|
|
|
addUpdateAnswer() {
|
|
|
this.updateQuForm.answer.push({
|
|
|
id: this.updateQuForm.answer.length,
|
|
|
- isTrue: false,
|
|
|
+ correct: false,
|
|
|
answer: '',
|
|
|
images: [],
|
|
|
analysis: ''
|
|
|
@@ -969,8 +998,8 @@ export default {
|
|
|
},
|
|
|
// 新增试题中的删除答案填写框
|
|
|
delAnswer(id) { // 当前答案的id
|
|
|
- this.addQuForm.answer.map((item, index) => {
|
|
|
- if (item.id === id) this.addQuForm.answer.splice(index, 1)
|
|
|
+ this.addQuForm.options.map((item, index) => {
|
|
|
+ if (item.id === id) this.addQuForm.options.splice(index, 1)
|
|
|
})
|
|
|
},
|
|
|
// 新增试题中的删除答案填写框
|
|
|
@@ -981,7 +1010,7 @@ export default {
|
|
|
},
|
|
|
// 答案上传照片了
|
|
|
uploadAnswerImgSuccess(response, id) {
|
|
|
- this.addQuForm.answer[id].images.push(response.data)
|
|
|
+ this.addQuForm.options[id].images.push(response.data)
|
|
|
},
|
|
|
// 更新的答案上传图片了
|
|
|
uploadUpdateAnswerImgSuccess(response, id) {
|
|
|
@@ -989,7 +1018,7 @@ export default {
|
|
|
},
|
|
|
// 答案上传成功后删除
|
|
|
handleAnswerRemove(file) {
|
|
|
- this.addQuForm.answer.images.map((item, index) => { // 移除图片在表单中的数据
|
|
|
+ this.addQuForm.options.images.map((item, index) => { // 移除图片在表单中的数据
|
|
|
if (item === file.response.data) this.addQuForm.images.splice(index, 1)
|
|
|
})
|
|
|
},
|
|
|
@@ -1004,20 +1033,20 @@ export default {
|
|
|
if (checked) {
|
|
|
if (this.addQuForm.questionType === 1 || this.addQuForm.questionType === 3) { // 单选或者判断
|
|
|
// 当前已经有一个正确的选择了
|
|
|
- this.addQuForm.answer.map(item => {
|
|
|
- item.isTrue = false
|
|
|
+ this.addQuForm.options.map(item => {
|
|
|
+ item.correct = false
|
|
|
})
|
|
|
- this.addQuForm.answer.map(item => {
|
|
|
- if (item.id === id) item.isTrue = true
|
|
|
+ this.addQuForm.options.map(item => {
|
|
|
+ if (item.id === id) item.correct = true
|
|
|
})
|
|
|
} else { // 多选 可以有多个答案
|
|
|
- this.addQuForm.answer.map(item => {
|
|
|
- if (item.id === id) item.isTrue = true
|
|
|
+ this.addQuForm.options.map(item => {
|
|
|
+ if (item.id === id) item.correct = true
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
- this.addQuForm.answer.map(item => {
|
|
|
- if (item.id === id) item.isTrue = false
|
|
|
+ this.addQuForm.options.map(item => {
|
|
|
+ if (item.id === id) item.correct = false
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
@@ -1027,26 +1056,26 @@ export default {
|
|
|
if (this.updateQuForm.questionType === 1 || this.updateQuForm.questionType === 3) { // 单选或者判断
|
|
|
// 当前已经有一个正确的选择了
|
|
|
this.updateQuForm.answer.map(item => {
|
|
|
- item.isTrue = false
|
|
|
+ item.correct = false
|
|
|
})
|
|
|
this.updateQuForm.answer.map(item => {
|
|
|
- if (item.id === id) item.isTrue = true
|
|
|
+ if (item.id === id) item.correct = true
|
|
|
})
|
|
|
} else { // 多选 可以有多个答案
|
|
|
this.updateQuForm.answer.map(item => {
|
|
|
- if (item.id === id) item.isTrue = true
|
|
|
+ if (item.id === id) item.correct = true
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
this.updateQuForm.answer.map(item => {
|
|
|
- if (item.id === id) item.isTrue = false
|
|
|
+ if (item.id === id) item.correct = false
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
// 新增试题
|
|
|
addQuestion() {
|
|
|
this.$refs['addQuForm'].validate((valid) => {
|
|
|
- if (valid && this.addQuForm.answer.some(item => item.isTrue) && this.addQuForm.questionType !== 4) { // 单选或者多选或者判断
|
|
|
+ if (valid && this.addQuForm.options.some(item => item.correct) && this.addQuForm.questionType !== 4) { // 单选或者多选或者判断
|
|
|
postExamQuestion(this.addQuForm).then((resp) => {
|
|
|
if (resp.code === 0) {
|
|
|
this.addQuTableVisible = false
|
|
|
@@ -1059,13 +1088,13 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- } else if (valid && !this.addQuForm.answer.some(item => item.isTrue) && this.addQuForm.questionType !== 4) { // 无答案
|
|
|
+ } else if (valid && !this.addQuForm.options.some(item => item.correct) && this.addQuForm.questionType < 5) { // 无答案
|
|
|
this.$message.error('必须有一个答案')
|
|
|
return false
|
|
|
- } else if (valid && this.addQuForm.questionType === 4) { // 简答题 无标准答案直接发请求
|
|
|
+ } else if (valid && this.addQuForm.questionType >= 5) { // 简答题 无标准答案直接发请求
|
|
|
// 当是简答题的时候需要清除answer
|
|
|
- this.addQuForm.answer = []
|
|
|
- addQuestion(this.addQuForm).then((resp) => {
|
|
|
+ this.addQuForm.options = []
|
|
|
+ postExamQuestion(this.addQuForm).then((resp) => {
|
|
|
if (resp.code === 0) {
|
|
|
this.addQuTableVisible = false
|
|
|
this.getQuestionInfo()
|
|
|
@@ -1089,7 +1118,7 @@ export default {
|
|
|
if (resp.code === 0) {
|
|
|
if (resp.data.questionType !== 4) {
|
|
|
resp.data.answer.map(item => {
|
|
|
- item.isTrue = item.isTrue === 'true'
|
|
|
+ item.correct = item.correct === 'true'
|
|
|
})
|
|
|
}
|
|
|
this.updateQuForm = resp.data
|
|
|
@@ -1110,7 +1139,7 @@ export default {
|
|
|
// 提交更新表单
|
|
|
updateQuestion() {
|
|
|
this.$refs['updateQuForm'].validate((valid) => {
|
|
|
- if (valid && this.updateQuForm.questionType !== 4 && this.updateQuForm.answer.some(item => item.isTrue)) { // 单选或者多选或者判断
|
|
|
+ if (valid && this.updateQuForm.questionType !== 4 && this.updateQuForm.answer.some(item => item.correct)) { // 单选或者多选或者判断
|
|
|
// 保证答案的图片只有一张
|
|
|
this.updateQuForm.answer.map(item => {
|
|
|
if (item.images.length > 1) {
|
|
|
@@ -1129,12 +1158,12 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- } else if (valid && this.updateQuForm.questionType !== 4 && !this.updateQuForm.answer.some(item => item.isTrue)) { // 无答案
|
|
|
+ } else if (valid && this.updateQuForm.questionType !== 4 && !this.updateQuForm.answer.some(item => item.correct)) { // 无答案
|
|
|
this.$message.error('必须有一个答案')
|
|
|
return false
|
|
|
} else if (valid && this.updateQuForm.questionType === 4) { // 简答题 无标准答案直接发请求
|
|
|
// 当是简答题的时候需要清除answer
|
|
|
- this.addQuForm.answer = []
|
|
|
+ this.addQuForm.options = []
|
|
|
updateQuestion(this.updateQuForm).then((resp) => {
|
|
|
if (resp.code === 0) {
|
|
|
this.updateQuTableVisible = false
|