提交 7790f1c8 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 课后作业支持判断题

上级 6f7d89e9
...@@ -145,7 +145,7 @@ export default { ...@@ -145,7 +145,7 @@ export default {
return [] return []
} }
return list.map(data => { return list.map(data => {
let { radioList, checkboxList, shortAnswerList } = data let { radioList, checkboxList, shortAnswerList, judgeList } = data
// 单选 // 单选
radioList = radioList.map(item => { radioList = radioList.map(item => {
const temp = { const temp = {
...@@ -174,7 +174,15 @@ export default { ...@@ -174,7 +174,15 @@ export default {
} }
return Object.assign({}, item, temp) return Object.assign({}, item, temp)
}) })
return [...radioList, ...checkboxList, ...shortAnswerList] // 判断题
judgeList = judgeList.map(item => {
const temp = {
type: 4,
formModel: { id: item.id, user_answer: item.user_answer || '' }
}
return Object.assign({}, item, temp)
})
return [...radioList, ...checkboxList, ...judgeList, ...shortAnswerList]
}) })
}, },
// 获取考试结果 // 获取考试结果
...@@ -262,9 +270,13 @@ export default { ...@@ -262,9 +270,13 @@ export default {
}) })
result.shortAnswerList.push(formModel) result.shortAnswerList.push(formModel)
} }
// 判断题
if (item.type === 4) {
result.judgeList.push(item.formModel)
}
return result return result
}, },
{ radioList: [], checkboxList: [], shortAnswerList: [] } { radioList: [], checkboxList: [], shortAnswerList: [], judgeList: [] }
) )
}) })
}, },
......
...@@ -266,7 +266,7 @@ export default { ...@@ -266,7 +266,7 @@ export default {
return [] return []
} }
return list.map(data => { return list.map(data => {
let { radioList, checkboxList, shortAnswerList } = data let { radioList, checkboxList, shortAnswerList, judgeList } = data
// 单选 // 单选
radioList = radioList.map(item => { radioList = radioList.map(item => {
const temp = { const temp = {
...@@ -295,7 +295,15 @@ export default { ...@@ -295,7 +295,15 @@ export default {
} }
return Object.assign({}, item, temp) return Object.assign({}, item, temp)
}) })
return [...radioList, ...checkboxList, ...shortAnswerList] // 判断题
judgeList = judgeList.map(item => {
const temp = {
type: 4,
formModel: { id: item.id, user_answer: item.user_answer || '' }
}
return Object.assign({}, item, temp)
})
return [...radioList, ...checkboxList, ...judgeList, ...shortAnswerList]
}) })
}, },
...@@ -360,9 +368,13 @@ export default { ...@@ -360,9 +368,13 @@ export default {
}) })
result.shortAnswerList.push(formModel) result.shortAnswerList.push(formModel)
} }
// 判断题
if (item.type === 4) {
result.judgeList.push(item.formModel)
}
return result return result
}, },
{ radioList: [], checkboxList: [], shortAnswerList: [] } { radioList: [], checkboxList: [], shortAnswerList: [], judgeList: [] }
) )
}) })
}, },
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</div> </div>
<div class="q-item-bd"> <div class="q-item-bd">
<!-- 单选 --> <!-- 单选 -->
<el-radio-group v-model="currentValue.user_answer" v-if="type === 1"> <el-radio-group v-model="currentValue.user_answer" v-if="[1, 4].includes(type)">
<div class="q-option-item" v-for="item in currentOptions" :key="item.id"> <div class="q-option-item" v-for="item in currentOptions" :key="item.id">
<el-radio :class="genClass(item)" :label="item.id"> <el-radio :class="genClass(item)" :label="item.id">
<div class="q-option-item__answer" v-html="item.abc_option"></div> <div class="q-option-item__answer" v-html="item.abc_option"></div>
...@@ -126,7 +126,7 @@ export default { ...@@ -126,7 +126,7 @@ export default {
}, },
// 选项类型 // 选项类型
typeText() { typeText() {
const map = { 1: this.$t('viewerWork.singleChoice'), 2: this.$t('viewerWork.multipleChoice') } const map = { 1: this.$t('viewerWork.singleChoice'), 2: this.$t('viewerWork.multipleChoice'), 4: '判断题' }
return map[this.type] return map[this.type]
}, },
// 处理后的options数据 // 处理后的options数据
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论