|
|
@@ -18,9 +18,12 @@
|
|
|
<el-card class="box-card">
|
|
|
<div class="text item">
|
|
|
<span v-html="item1.questionContent" />
|
|
|
+ <div v-for="(option, optionIndex) in item1.questionOptions" :key="optionIndex">
|
|
|
+ <span v-html="option.content" />
|
|
|
+ </div>
|
|
|
<el-divider />
|
|
|
<el-radio-group
|
|
|
- v-model="userAnswerMap[item1.questionId][0]"
|
|
|
+ v-model="userAnswerMap[item1.questionId].submitAnswer[0]"
|
|
|
@change="(val) => {
|
|
|
onRadioChange(val, item1)
|
|
|
}"
|
|
|
@@ -30,65 +33,115 @@
|
|
|
<el-radio :label="3">C</el-radio>
|
|
|
<el-radio :label="4">D</el-radio>
|
|
|
</el-radio-group>
|
|
|
+ <el-row v-if="status !== 2">
|
|
|
+ <el-divider />
|
|
|
+ <el-row>
|
|
|
+ <span style="color: red">正确答案</span>
|
|
|
+ </el-row>
|
|
|
+ <el-row v-for="(item2, index2) in userAnswerMap[item1.questionId].correctAnswer" :key="index2">
|
|
|
+ {{ item2 }}
|
|
|
+ </el-row>
|
|
|
+ </el-row>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
</div>
|
|
|
- <el-divider />
|
|
|
</div>
|
|
|
- <div v-else-if="key === '2' || key === '3'">
|
|
|
+ <div v-else-if="key === '2'">
|
|
|
<h1>多项选择题/不定项选择题</h1>
|
|
|
<div v-for="(item1, index1) in values" :key="index1">
|
|
|
- <span v-html="item1.questionContent" />
|
|
|
- <el-checkbox-group
|
|
|
- v-model="userAnswerMap[item1.questionId]"
|
|
|
- @change="(val) => {
|
|
|
- onCheckboxChange(val, item1)
|
|
|
- }"
|
|
|
- >
|
|
|
- <el-checkbox label="1">A</el-checkbox>
|
|
|
- <el-checkbox label="2">B</el-checkbox>
|
|
|
- <el-checkbox label="3">C</el-checkbox>
|
|
|
- <el-checkbox label="4">D</el-checkbox>
|
|
|
- </el-checkbox-group>
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div class="text item">
|
|
|
+ <span v-html="item1.questionContent" />
|
|
|
+ <div v-for="(option, optionIndex) in item1.questionOptions" :key="optionIndex">
|
|
|
+ <span v-html="option.content" />
|
|
|
+ </div>
|
|
|
+ <el-divider />
|
|
|
+ <el-checkbox-group
|
|
|
+ v-model="userAnswerMap[item1.questionId].submitAnswer"
|
|
|
+ @change="(val) => {
|
|
|
+ onCheckboxChange(val, item1)
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <el-checkbox label="1">A</el-checkbox>
|
|
|
+ <el-checkbox label="2">B</el-checkbox>
|
|
|
+ <el-checkbox label="3">C</el-checkbox>
|
|
|
+ <el-checkbox label="4">D</el-checkbox>
|
|
|
+ </el-checkbox-group>
|
|
|
+ <el-row v-if="status !== 2">
|
|
|
+ <el-divider />
|
|
|
+ <el-row>
|
|
|
+ <span style="color: red">正确答案</span>
|
|
|
+ </el-row>
|
|
|
+ <el-row v-for="(item2, index2) in userAnswerMap[item1.questionId].correctAnswer" :key="index2">
|
|
|
+ {{ item2 }}
|
|
|
+ </el-row>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
</div>
|
|
|
<el-divider />
|
|
|
</div>
|
|
|
- <div v-else-if="key === '4'">
|
|
|
+ <div v-else-if="key === '3'">
|
|
|
<h1>判断题</h1>
|
|
|
<div v-for="(item1, index1) in values" :key="index1">
|
|
|
- <span v-html="item1.questionContent" />
|
|
|
- <el-radio-group
|
|
|
- v-model="userAnswerMap[item1.questionId][0]"
|
|
|
- @change="(val) => {
|
|
|
- onRadioChange(val, item1)
|
|
|
- }"
|
|
|
- >
|
|
|
- <el-radio :label="1">正确</el-radio>
|
|
|
- <el-radio :label="2">错误</el-radio>
|
|
|
- </el-radio-group>
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div class="text item">
|
|
|
+ <span v-html="item1.questionContent" />
|
|
|
+ <el-radio-group
|
|
|
+ v-model="userAnswerMap[item1.questionId].submitAnswer[0]"
|
|
|
+ @change="(val) => {
|
|
|
+ onRadioChange(val, item1)
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <el-radio :label="1">正确</el-radio>
|
|
|
+ <el-radio :label="2">错误</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ <el-row v-if="status !== 2">
|
|
|
+ <el-divider />
|
|
|
+ <el-row>
|
|
|
+ <span style="color: red">正确答案</span>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ {{ userAnswerMap[item1.questionId].correctAnswer[0] }}
|
|
|
+ </el-row>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
</div>
|
|
|
<el-divider />
|
|
|
</div>
|
|
|
- <div v-else-if="key === '5'">
|
|
|
+ <div v-else-if="key === '4'">
|
|
|
<h1>填空题</h1>
|
|
|
<div v-for="(item1, index1) in values" :key="index1">
|
|
|
- <span v-html="item1.questionContent" />
|
|
|
- <div v-for="(item2, index2) in userAnswerMap[item1.questionId]" :key="index2">
|
|
|
- <span style="left: 0;margin-right: 1px;color: black;">第 {{ index2 + 1 }} 题</span>
|
|
|
- <el-input
|
|
|
- v-model="userAnswerMap[item1.questionId][index2]"
|
|
|
- type="text"
|
|
|
- placeholder="请输入答案"
|
|
|
- style="width: 20%; padding-right: 2px"
|
|
|
- @blur="(val) => {
|
|
|
- onInputBlur(val, item1)
|
|
|
- }"
|
|
|
- />
|
|
|
- </div>
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div class="text item">
|
|
|
+ <span v-html="item1.questionContent" />
|
|
|
+ <div v-for="(item2, index2) in userAnswerMap[item1.questionId].submitAnswer" :key="index2">
|
|
|
+ <span style="left: 0;margin-right: 1px;color: black;">第 {{ index2 + 1 }} 题</span>
|
|
|
+ <el-input
|
|
|
+ v-model="userAnswerMap[item1.questionId].submitAnswer[index2]"
|
|
|
+ type="text"
|
|
|
+ placeholder="请输入答案"
|
|
|
+ style="width: 20%; padding-right: 2px"
|
|
|
+ @blur="(val) => {
|
|
|
+ onInputBlur(val, item1)
|
|
|
+ }"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <el-row v-if="status !== 2">
|
|
|
+ <el-divider />
|
|
|
+ <el-row>
|
|
|
+ <span style="color: red">正确答案</span>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ {{ userAnswerMap[item1.questionId].correctAnswer[0] }}
|
|
|
+ </el-row>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
</div>
|
|
|
- <el-divider />
|
|
|
</div>
|
|
|
- <div v-else-if="key === '6'">
|
|
|
+ <div v-else-if="key === '5'">
|
|
|
<h1>问答题</h1>
|
|
|
<div v-for="(item1, index1) in values" :key="index1" class="movie-list">
|
|
|
<el-card class="box-card">
|
|
|
@@ -97,26 +150,43 @@
|
|
|
<el-divider />
|
|
|
<editor
|
|
|
:id="item1.questionId+''"
|
|
|
- v-model="userAnswerMap[item1.questionId][0]"
|
|
|
+ v-model="userAnswerMap[item1.questionId].submitAnswer[0]"
|
|
|
:init="init"
|
|
|
style="width: 50%"
|
|
|
/>
|
|
|
+ <el-row v-if="status !== 2">
|
|
|
+ <el-divider />
|
|
|
+ <el-row>
|
|
|
+ <span style="color: red">正确答案</span>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ {{ userAnswerMap[item1.questionId].correctAnswer[0] }}
|
|
|
+ </el-row>
|
|
|
+ </el-row>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
</div>
|
|
|
<el-divider />
|
|
|
</div>
|
|
|
- <div v-else-if="key === '8'">
|
|
|
+ <div v-else-if="key === '6'">
|
|
|
<h1>组合题</h1>
|
|
|
<div v-for="(item1, index1) in values" :key="index1">
|
|
|
- <span v-html="item1.questionContent" />
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div class="text item">
|
|
|
+ <span v-html="item1.questionContent" />
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
</div>
|
|
|
<el-divider />
|
|
|
</div>
|
|
|
<div v-else>
|
|
|
<h1>未知试题类型</h1>
|
|
|
<div v-for="(item1, index1) in values" :key="index1">
|
|
|
- <span v-html="item1.questionContent" />
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div class="text item">
|
|
|
+ <span v-html="item1.questionContent" />
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
</div>
|
|
|
<el-divider />
|
|
|
</div>
|
|
|
@@ -188,12 +258,10 @@ export default {
|
|
|
questionTypeList: [
|
|
|
{ id: 1, name: '单选题' },
|
|
|
{ id: 2, name: '多选题' },
|
|
|
- { id: 3, name: '不定项选择题' },
|
|
|
- { id: 4, name: '判断题' },
|
|
|
- { id: 5, name: '填空题' },
|
|
|
- { id: 6, name: '问答题' },
|
|
|
- { id: 7, name: '理解题' },
|
|
|
- { id: 8, name: '組题' }
|
|
|
+ { id: 3, name: '判断题' },
|
|
|
+ { id: 4, name: '填空题' },
|
|
|
+ { id: 5, name: '问答题' },
|
|
|
+ { id: 6, name: '组合题' }
|
|
|
],
|
|
|
examInfo: null,
|
|
|
questionMap: null,
|
|
|
@@ -205,8 +273,10 @@ export default {
|
|
|
],
|
|
|
userAnswerMap: null,
|
|
|
paperId: 0,
|
|
|
+ status: 0,
|
|
|
paperInfo: {
|
|
|
name: '',
|
|
|
+ status: 0,
|
|
|
duration: 0,
|
|
|
totalScore: 0
|
|
|
},
|
|
|
@@ -217,9 +287,19 @@ export default {
|
|
|
},
|
|
|
created() {
|
|
|
document.title = '试卷详情'
|
|
|
-
|
|
|
this.paperId = this.$route.params.paperId
|
|
|
- this.getPaperDetail(this.paperId)
|
|
|
+ const statusStr = this.$route.query.status
|
|
|
+ this.status = parseInt(statusStr)
|
|
|
+ if (this.status === 1) {
|
|
|
+ document.title = '试卷预览'
|
|
|
+ } else if (this.status === 2) {
|
|
|
+ } else if (this.status === 3) {
|
|
|
+ document.title = '试卷批改'
|
|
|
+ } else if (this.status === 4) {
|
|
|
+ document.title = '试卷结果'
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getPaperDetail()
|
|
|
},
|
|
|
methods: {
|
|
|
renderByMathjax() {
|
|
|
@@ -232,11 +312,12 @@ export default {
|
|
|
this.MathJax.MathQueue1(className)
|
|
|
})
|
|
|
},
|
|
|
- getPaperDetail(paperId) {
|
|
|
- getPaper(paperId).then((resp) => {
|
|
|
+ getPaperDetail() {
|
|
|
+ getPaper(this.paperId, this.status).then((resp) => {
|
|
|
if (resp.code === 0) {
|
|
|
const respData = resp.data
|
|
|
this.paperInfo.name = respData.name
|
|
|
+ this.paperInfo.status = respData.status
|
|
|
this.paperInfo.duration = respData.duration
|
|
|
this.paperInfo.totalScore = respData.totalScore
|
|
|
|
|
|
@@ -246,6 +327,13 @@ export default {
|
|
|
} else {
|
|
|
this.$message.error(resp.msg)
|
|
|
}
|
|
|
+ }).catch((error) => {
|
|
|
+ this.$notify({
|
|
|
+ title: 'Tips',
|
|
|
+ message: error.message,
|
|
|
+ type: 'error',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
onSubmitPaper() {
|
|
|
@@ -254,12 +342,34 @@ export default {
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
- this.submitPaper()
|
|
|
- this.$notify({
|
|
|
- title: 'Tips',
|
|
|
- message: '试卷已提交, 继续加油! *^▽^*',
|
|
|
- type: 'success',
|
|
|
- duration: 2000
|
|
|
+ var userAnswers = []
|
|
|
+ for (const key in this.userAnswerMap) {
|
|
|
+ const userAnswer = {}
|
|
|
+ userAnswer.questionId = key
|
|
|
+ userAnswer.answers = this.userAnswerMap[key]
|
|
|
+ userAnswers.push(this.userAnswerMap[key])
|
|
|
+ }
|
|
|
+
|
|
|
+ var userResult = {}
|
|
|
+ userResult.paperId = this.paperId
|
|
|
+ userResult.userAnswers = userAnswers
|
|
|
+ submitExam(userResult).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ this.$notify({
|
|
|
+ title: 'Tips',
|
|
|
+ message: '试卷已提交, 继续加油! *^▽^*',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ this.$router.push('/exam/list')
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ this.$notify({
|
|
|
+ title: 'Tips',
|
|
|
+ message: error.message,
|
|
|
+ type: 'error',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
})
|
|
|
}).catch(() => {
|
|
|
this.$notify({
|
|
|
@@ -291,8 +401,8 @@ export default {
|
|
|
for (const key in this.userAnswerMap) {
|
|
|
const userAnswer = {}
|
|
|
userAnswer.questionId = key
|
|
|
- userAnswer.answers = this.userAnswerMap[key]
|
|
|
- userAnswers.push(userAnswer)
|
|
|
+ userAnswer.submitAnswer = this.userAnswerMap[key]
|
|
|
+ userAnswers.push(this.userAnswerMap[key])
|
|
|
}
|
|
|
|
|
|
var userResult = {}
|
|
|
@@ -305,26 +415,6 @@ export default {
|
|
|
}).catch((e) => {
|
|
|
console.log(e)
|
|
|
})
|
|
|
- },
|
|
|
- submitPaper() {
|
|
|
- var userAnswers = []
|
|
|
- for (const key in this.userAnswerMap) {
|
|
|
- const userAnswer = {}
|
|
|
- userAnswer.questionId = key
|
|
|
- userAnswer.answers = this.userAnswerMap[key]
|
|
|
- userAnswers.push(userAnswer)
|
|
|
- }
|
|
|
-
|
|
|
- var userResult = {}
|
|
|
- userResult.paperId = this.paperId
|
|
|
- userResult.userAnswers = userAnswers
|
|
|
- submitExam(userResult).then(resp => {
|
|
|
- if (resp.code !== 0) {
|
|
|
- console.log(resp.msg)
|
|
|
- }
|
|
|
- }).catch((e) => {
|
|
|
- console.log(e)
|
|
|
- })
|
|
|
}
|
|
|
}
|
|
|
}
|