|
|
@@ -11,24 +11,24 @@
|
|
|
<div>最近提交:{{!isEmpty(answersInfo.submitAt) ? momentFromNow(answersInfo.submitAt) : '无提交历史'}}</div>
|
|
|
</div>
|
|
|
<div class="quiz-list-item" :key="question.id" v-for="(question, index) in questions"
|
|
|
- :class="question.studentAnswer.correct ? 'correct' : 'wrong'">
|
|
|
+ :class="question.studentAnswer ? question.studentAnswer.correct === false ? 'wrong' : '' : ''">
|
|
|
<div class="quiz-list-item__index">{{ index + 1 }}.</div>
|
|
|
<div>
|
|
|
<markdown-section class="quiz-list-item-title" :raw="question.stem"/>
|
|
|
- <div v-if="question.type === QuestionKind.choice">
|
|
|
+ <div v-if="question.type === QuestionKind.choice && question.studentAnswer">
|
|
|
<label class="option" :key="index" v-for="(item, index) in question.options">
|
|
|
<input v-model="question.studentAnswer.answer" type="radio" :value="index"/>
|
|
|
<b class="mr-8">{{ index }}.</b>
|
|
|
<markdown-section style="display: inline" :raw="item"/>
|
|
|
</label>
|
|
|
</div>
|
|
|
- <div v-else-if="question.type === QuestionKind.trueOrFalse">
|
|
|
+ <div v-else-if="question.type === QuestionKind.trueOrFalse && question.studentAnswer">
|
|
|
<label class="option">
|
|
|
- <input v-model="question.studentAnswer" type="radio" :value="true"/>
|
|
|
+ <input v-model="question.studentAnswer.answer" type="radio" :value="true"/>
|
|
|
<c-icon>check</c-icon>
|
|
|
</label>
|
|
|
<label class="option">
|
|
|
- <input v-model="question.studentAnswer" type="radio" :value="false"/>
|
|
|
+ <input v-model="question.studentAnswer.answer" type="radio" :value="false"/>
|
|
|
<c-icon>close</c-icon>
|
|
|
</label>
|
|
|
</div>
|
|
|
@@ -60,8 +60,11 @@ export default {
|
|
|
quiz: createDefaultQuiz(),
|
|
|
hasSubmit: false,
|
|
|
questions: null,
|
|
|
- answersInfo: null,
|
|
|
-
|
|
|
+ answersInfo: {
|
|
|
+ submitNumber: 0,
|
|
|
+ score: null,
|
|
|
+ submitAt: null
|
|
|
+ },
|
|
|
QuestionKind
|
|
|
}
|
|
|
},
|
|
|
@@ -87,12 +90,21 @@ export default {
|
|
|
this.questions = res
|
|
|
// 获取之前填写的答案
|
|
|
getOneQuizStudentAnswer({ quizId }).then(answers => {
|
|
|
- this.answersInfo = answers
|
|
|
- this.questions = this.questions.map(question => ({
|
|
|
- ...question,
|
|
|
- studentAnswer: answers.answers[question.id]
|
|
|
- }))
|
|
|
- }).catch(err => { this.$setErrorMessage(err.response.data.msg) })
|
|
|
+ if (!isEmpty(answers) && answers !== '') {
|
|
|
+ this.answersInfo = answers
|
|
|
+ this.questions = this.questions.map(question => ({
|
|
|
+ ...question,
|
|
|
+ studentAnswer: answers.answers[question.id]
|
|
|
+ }))
|
|
|
+ } else {
|
|
|
+ this.questions = this.questions.map(question => ({
|
|
|
+ ...question,
|
|
|
+ studentAnswer: { answer: '' }
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.$setErrorMessage(err.response.data.msg)
|
|
|
+ })
|
|
|
}).catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
},
|
|
|
handleFormSubmit () {
|
|
|
@@ -166,7 +178,8 @@ export default {
|
|
|
.quiz-list-item__index {
|
|
|
color: $theme-red;
|
|
|
}
|
|
|
- .quiz-list-item-title{
|
|
|
+
|
|
|
+ .quiz-list-item-title {
|
|
|
color: $theme-red;
|
|
|
}
|
|
|
}
|