|
@@ -28,10 +28,10 @@
|
|
|
onRadioChange(val, item1)
|
|
onRadioChange(val, item1)
|
|
|
}"
|
|
}"
|
|
|
>
|
|
>
|
|
|
- <el-radio :label="1">A</el-radio>
|
|
|
|
|
- <el-radio :label="2">B</el-radio>
|
|
|
|
|
- <el-radio :label="3">C</el-radio>
|
|
|
|
|
- <el-radio :label="4">D</el-radio>
|
|
|
|
|
|
|
+ <el-radio :label="1" :disabled="paperInfo.viewType !== 2">A</el-radio>
|
|
|
|
|
+ <el-radio :label="2" :disabled="paperInfo.viewType !== 2">B</el-radio>
|
|
|
|
|
+ <el-radio :label="3" :disabled="paperInfo.viewType !== 2">C</el-radio>
|
|
|
|
|
+ <el-radio :label="4" :disabled="paperInfo.viewType !== 2">D</el-radio>
|
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
|
<el-row v-if="paperInfo.viewType !== 2">
|
|
<el-row v-if="paperInfo.viewType !== 2">
|
|
|
<el-divider />
|
|
<el-divider />
|
|
@@ -75,10 +75,10 @@
|
|
|
onCheckboxChange(val, item1)
|
|
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 label="1" :disabled="paperInfo.viewType !== 2">A</el-checkbox>
|
|
|
|
|
+ <el-checkbox label="2" :disabled="paperInfo.viewType !== 2">B</el-checkbox>
|
|
|
|
|
+ <el-checkbox label="3" :disabled="paperInfo.viewType !== 2">C</el-checkbox>
|
|
|
|
|
+ <el-checkbox label="4" :disabled="paperInfo.viewType !== 2">D</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
</el-checkbox-group>
|
|
|
<el-row v-if="paperInfo.viewType !== 2">
|
|
<el-row v-if="paperInfo.viewType !== 2">
|
|
|
<el-divider />
|
|
<el-divider />
|
|
@@ -119,8 +119,8 @@
|
|
|
onRadioChange(val, item1)
|
|
onRadioChange(val, item1)
|
|
|
}"
|
|
}"
|
|
|
>
|
|
>
|
|
|
- <el-radio :label="1">正确</el-radio>
|
|
|
|
|
- <el-radio :label="2">错误</el-radio>
|
|
|
|
|
|
|
+ <el-radio :label="1" :disabled="paperInfo.viewType !== 2">正确</el-radio>
|
|
|
|
|
+ <el-radio :label="2" :disabled="paperInfo.viewType !== 2">错误</el-radio>
|
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
|
<el-row v-if="paperInfo.viewType !== 2">
|
|
<el-row v-if="paperInfo.viewType !== 2">
|
|
|
<el-divider />
|
|
<el-divider />
|
|
@@ -158,6 +158,7 @@
|
|
|
<div v-for="(item2, index2) in userAnswerMap[item1.questionId].submitAnswer" :key="index2">
|
|
<div v-for="(item2, index2) in userAnswerMap[item1.questionId].submitAnswer" :key="index2">
|
|
|
<span style="left: 0;margin-right: 1px;color: black;">第 {{ index2 + 1 }} 题</span>
|
|
<span style="left: 0;margin-right: 1px;color: black;">第 {{ index2 + 1 }} 题</span>
|
|
|
<el-input
|
|
<el-input
|
|
|
|
|
+ :disabled="paperInfo.viewType !== 2"
|
|
|
v-model="userAnswerMap[item1.questionId].submitAnswer[index2]"
|
|
v-model="userAnswerMap[item1.questionId].submitAnswer[index2]"
|
|
|
type="text"
|
|
type="text"
|
|
|
placeholder="请输入答案"
|
|
placeholder="请输入答案"
|
|
@@ -173,7 +174,9 @@
|
|
|
<span style="color: red">正确答案</span>
|
|
<span style="color: red">正确答案</span>
|
|
|
</el-row>
|
|
</el-row>
|
|
|
<el-row>
|
|
<el-row>
|
|
|
- {{ userAnswerMap[item1.questionId].correctAnswer[0] }}
|
|
|
|
|
|
|
+ <div v-for="(answer, answerIndex) in userAnswerMap[item1.questionId].correctAnswer" :key="answerIndex">
|
|
|
|
|
+ <span style="left: 0;margin-right: 1px;color: black;">第 {{ answerIndex + 1 }} 题:</span> {{ answer }}
|
|
|
|
|
+ </div>
|
|
|
</el-row>
|
|
</el-row>
|
|
|
<el-row v-if="paperInfo.viewType >= 3">
|
|
<el-row v-if="paperInfo.viewType >= 3">
|
|
|
<el-divider />
|
|
<el-divider />
|
|
@@ -201,6 +204,7 @@
|
|
|
<span v-html="item1.questionContent" />
|
|
<span v-html="item1.questionContent" />
|
|
|
<el-divider />
|
|
<el-divider />
|
|
|
<editor
|
|
<editor
|
|
|
|
|
+ :disabled="paperInfo.viewType !== 2"
|
|
|
:id="item1.questionId+''"
|
|
:id="item1.questionId+''"
|
|
|
v-model="userAnswerMap[item1.questionId].submitAnswer[0]"
|
|
v-model="userAnswerMap[item1.questionId].submitAnswer[0]"
|
|
|
:init="init"
|
|
:init="init"
|
|
@@ -295,10 +299,10 @@ import 'tinymce/themes/silver/theme.min.js'
|
|
|
import 'tinymce/icons/default/icons'
|
|
import 'tinymce/icons/default/icons'
|
|
|
import Editor from '@tinymce/tinymce-vue'
|
|
import Editor from '@tinymce/tinymce-vue'
|
|
|
|
|
|
|
|
-import { cacheUserAnswer, getPaper, submitExam, submitExamMark } from '@/api/exam'
|
|
|
|
|
|
|
+import { cacheUserAnswer, getExamInfo, getMarkView, getPaper, submitExam, submitExamMark } from '@/api/exam'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
- name: 'ExamQuestionCard',
|
|
|
|
|
|
|
+ name: 'ExamPaperDetail',
|
|
|
components: { Editor },
|
|
components: { Editor },
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
@@ -356,22 +360,32 @@ export default {
|
|
|
userAnswerMap: null,
|
|
userAnswerMap: null,
|
|
|
paperInfo: {
|
|
paperInfo: {
|
|
|
paperId: 0,
|
|
paperId: 0,
|
|
|
- name: '',
|
|
|
|
|
|
|
+ name: '未知试卷',
|
|
|
viewType: 0,
|
|
viewType: 0,
|
|
|
status: 0,
|
|
status: 0,
|
|
|
duration: 0,
|
|
duration: 0,
|
|
|
totalScore: 0
|
|
totalScore: 0
|
|
|
},
|
|
},
|
|
|
paperViewType: [
|
|
paperViewType: [
|
|
|
- '预览', '答卷', '阅卷', '结果'
|
|
|
|
|
- ]
|
|
|
|
|
|
|
+ { '1': '预览' },
|
|
|
|
|
+ { '2': '答卷' },
|
|
|
|
|
+ { '3': '阅卷' },
|
|
|
|
|
+ { '4': '结果' }
|
|
|
|
|
+ ],
|
|
|
|
|
+ userId: '0'
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
|
document.title = '试卷详情'
|
|
document.title = '试卷详情'
|
|
|
- this.paperInfo.paperId = this.$route.params.paperId
|
|
|
|
|
|
|
+ const paperIdStr = this.$route.query.paperId
|
|
|
|
|
+ this.paperInfo.paperId = parseInt(paperIdStr)
|
|
|
|
|
+
|
|
|
const viewTypeStr = this.$route.query.viewType
|
|
const viewTypeStr = this.$route.query.viewType
|
|
|
this.paperInfo.viewType = parseInt(viewTypeStr)
|
|
this.paperInfo.viewType = parseInt(viewTypeStr)
|
|
|
|
|
+
|
|
|
|
|
+ const userIdStr = this.$route.query.userId
|
|
|
|
|
+ this.userId = userIdStr
|
|
|
|
|
+
|
|
|
if (this.paperInfo.viewType === 1) {
|
|
if (this.paperInfo.viewType === 1) {
|
|
|
document.title = '试卷预览'
|
|
document.title = '试卷预览'
|
|
|
} else if (this.paperInfo.viewType === 2) {
|
|
} else if (this.paperInfo.viewType === 2) {
|
|
@@ -381,7 +395,8 @@ export default {
|
|
|
document.title = '试卷结果'
|
|
document.title = '试卷结果'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.getPaperDetail()
|
|
|
|
|
|
|
+ // this.getPaperDetail()
|
|
|
|
|
+ this.getPaperData()
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
renderByMathjax() {
|
|
renderByMathjax() {
|
|
@@ -394,18 +409,24 @@ export default {
|
|
|
this.MathJax.MathQueue1(className)
|
|
this.MathJax.MathQueue1(className)
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+ getPaperData() {
|
|
|
|
|
+ if (this.paperInfo.viewType === 1) {
|
|
|
|
|
+ this.getPaperDetail()
|
|
|
|
|
+ } else if (this.paperInfo.viewType === 2) {
|
|
|
|
|
+ this.startExamPaper()
|
|
|
|
|
+ } else if (this.paperInfo.viewType === 3) {
|
|
|
|
|
+ this.startMarkPaper()
|
|
|
|
|
+ } else if (this.paperInfo.viewType === 4) {
|
|
|
|
|
+ this.getPaperDetail()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error('viewType unknown')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
getPaperDetail() {
|
|
getPaperDetail() {
|
|
|
- getPaper(this.paperInfo.paperId, this.paperInfo.viewType).then((resp) => {
|
|
|
|
|
|
|
+ getPaper(this.paperInfo.paperId, this.paperInfo.viewType, this.userId).then((resp) => {
|
|
|
if (resp.code === 0) {
|
|
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
|
|
|
|
|
-
|
|
|
|
|
- this.questionMap = respData.questionMap
|
|
|
|
|
- this.userAnswerMap = respData.userResult.cachedUserAnswers
|
|
|
|
|
- this.renderByMathjax()
|
|
|
|
|
|
|
+ this.processPaperData(resp)
|
|
|
} else {
|
|
} else {
|
|
|
this.$message.error(resp.msg)
|
|
this.$message.error(resp.msg)
|
|
|
}
|
|
}
|
|
@@ -418,6 +439,102 @@ export default {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+ startExamPaper() {
|
|
|
|
|
+ getExamInfo(this.paperInfo.paperId).then((resp) => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
|
|
+ this.processPaperData(resp)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error(resp.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch((error) => {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: 'Tips',
|
|
|
|
|
+ message: error.message,
|
|
|
|
|
+ type: 'error',
|
|
|
|
|
+ duration: 2000
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ startMarkPaper() {
|
|
|
|
|
+ getMarkView(this.paperInfo.paperId).then((resp) => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
|
|
+ this.processPaperData(resp)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error(resp.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch((error) => {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: 'Tips',
|
|
|
|
|
+ message: error.message,
|
|
|
|
|
+ type: 'error',
|
|
|
|
|
+ duration: 2000
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ getPaperResult() {
|
|
|
|
|
+ },
|
|
|
|
|
+ processPaperData(resp) {
|
|
|
|
|
+ const respData = resp.data
|
|
|
|
|
+ const status = respData.status
|
|
|
|
|
+ if (status === 1) {
|
|
|
|
|
+ this.$message.error('用户没有访问试卷的权限')
|
|
|
|
|
+ return
|
|
|
|
|
+ } else if (status === 2) {
|
|
|
|
|
+ this.$message.error('用户只有管理的权限')
|
|
|
|
|
+ return
|
|
|
|
|
+ } else if (status === 3) {
|
|
|
|
|
+ this.$message.error('用户只有做题的权限')
|
|
|
|
|
+ return
|
|
|
|
|
+ } else if (status === 4) {
|
|
|
|
|
+ this.$message.error('试卷由用户自己批改')
|
|
|
|
|
+ return
|
|
|
|
|
+ } else if (status === 5) {
|
|
|
|
|
+ this.$message.error('试卷访问类型 viewType 未知')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.paperInfo.name = respData.name
|
|
|
|
|
+ this.paperInfo.status = respData.status
|
|
|
|
|
+ this.paperInfo.duration = respData.duration
|
|
|
|
|
+ this.paperInfo.totalScore = respData.totalScore
|
|
|
|
|
+
|
|
|
|
|
+ this.questionMap = respData.questionMap
|
|
|
|
|
+ this.userAnswerMap = respData.userResult.cachedUserAnswers
|
|
|
|
|
+ this.renderByMathjax()
|
|
|
|
|
+ },
|
|
|
|
|
+ onRadioChange(val, item) {
|
|
|
|
|
+ // this.$message.info('change event: ' + val + ' -> ' + item.questionId)
|
|
|
|
|
+ this.cacheAnswer()
|
|
|
|
|
+ },
|
|
|
|
|
+ onCheckboxChange(val, item) {
|
|
|
|
|
+ this.cacheAnswer()
|
|
|
|
|
+ },
|
|
|
|
|
+ onInputBlur(val, item) {
|
|
|
|
|
+ this.cacheAnswer()
|
|
|
|
|
+ },
|
|
|
|
|
+ onEditorBlur(val) {
|
|
|
|
|
+ this.cacheAnswer()
|
|
|
|
|
+ },
|
|
|
|
|
+ cacheAnswer() {
|
|
|
|
|
+ var userAnswers = []
|
|
|
|
|
+ for (const key in this.userAnswerMap) {
|
|
|
|
|
+ const userAnswer = {}
|
|
|
|
|
+ userAnswer.questionId = key
|
|
|
|
|
+ userAnswer.submitAnswer = this.userAnswerMap[key]
|
|
|
|
|
+ userAnswers.push(this.userAnswerMap[key])
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var userResult = {}
|
|
|
|
|
+ userResult.paperId = this.paperInfo.paperId
|
|
|
|
|
+ userResult.submitUserAnswers = userAnswers
|
|
|
|
|
+ cacheUserAnswer(userResult).then(resp => {
|
|
|
|
|
+ if (resp.code !== 0) {
|
|
|
|
|
+ console.log(resp.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch((e) => {
|
|
|
|
|
+ console.log(e)
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
onSubmitPaper() {
|
|
onSubmitPaper() {
|
|
|
this.$confirm('当前试题暂未做完, 是否继续提交o(╥﹏╥)o ?', 'Tips', {
|
|
this.$confirm('当前试题暂未做完, 是否继续提交o(╥﹏╥)o ?', 'Tips', {
|
|
|
confirmButtonText: '确定',
|
|
confirmButtonText: '确定',
|
|
@@ -443,7 +560,7 @@ export default {
|
|
|
type: 'success',
|
|
type: 'success',
|
|
|
duration: 2000
|
|
duration: 2000
|
|
|
})
|
|
})
|
|
|
- this.$router.push('/exam/list')
|
|
|
|
|
|
|
+ this.$router.push('/exam/eval')
|
|
|
}
|
|
}
|
|
|
}).catch((error) => {
|
|
}).catch((error) => {
|
|
|
this.$notify({
|
|
this.$notify({
|
|
@@ -462,39 +579,6 @@ export default {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- onRadioChange(val, item) {
|
|
|
|
|
- // this.$message.info('change event: ' + val + ' -> ' + item.questionId)
|
|
|
|
|
- this.cacheAnswer()
|
|
|
|
|
- },
|
|
|
|
|
- onCheckboxChange(val, item) {
|
|
|
|
|
- this.cacheAnswer()
|
|
|
|
|
- },
|
|
|
|
|
- onInputBlur(val, item) {
|
|
|
|
|
- this.cacheAnswer()
|
|
|
|
|
- },
|
|
|
|
|
- onEditorBlur(val) {
|
|
|
|
|
- this.cacheAnswer()
|
|
|
|
|
- },
|
|
|
|
|
- cacheAnswer() {
|
|
|
|
|
- var userAnswers = []
|
|
|
|
|
- for (const key in this.userAnswerMap) {
|
|
|
|
|
- const userAnswer = {}
|
|
|
|
|
- userAnswer.questionId = key
|
|
|
|
|
- userAnswer.submitAnswer = this.userAnswerMap[key]
|
|
|
|
|
- userAnswers.push(this.userAnswerMap[key])
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- var userResult = {}
|
|
|
|
|
- userResult.paperId = this.paperInfo.paperId
|
|
|
|
|
- userResult.submitUserAnswers = userAnswers
|
|
|
|
|
- cacheUserAnswer(userResult).then(resp => {
|
|
|
|
|
- if (resp.code !== 0) {
|
|
|
|
|
- console.log(resp.msg)
|
|
|
|
|
- }
|
|
|
|
|
- }).catch((e) => {
|
|
|
|
|
- console.log(e)
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
onSubmitMarkPaper() {
|
|
onSubmitMarkPaper() {
|
|
|
this.$confirm('当前试题暂未做完, 是否继续提交o(╥﹏╥)o ?', 'Tips', {
|
|
this.$confirm('当前试题暂未做完, 是否继续提交o(╥﹏╥)o ?', 'Tips', {
|
|
|
confirmButtonText: '确定',
|
|
confirmButtonText: '确定',
|