|
|
@@ -2,7 +2,14 @@
|
|
|
<div class="do-quiz">
|
|
|
<back-title>{{ quiz.name }}</back-title>
|
|
|
<form @submit.prevent="handleFormSubmit">
|
|
|
- <c-button class="mb-16" theme="green" icon="check">提交答案</c-button>
|
|
|
+ <div class="info">
|
|
|
+ <div>
|
|
|
+ 提交次数:
|
|
|
+ <span :class="answersInfo.submitNumber === quiz.maxSubmitTime ? 'red' : null">{{answersInfo.submitNumber}} / {{quiz.maxSubmitTime}}</span>
|
|
|
+ </div>
|
|
|
+ <div>上次得分:{{answersInfo.score}}</div>
|
|
|
+ <div>最近提交:{{momentFromNow(answersInfo.submitAt)}}</div>
|
|
|
+ </div>
|
|
|
<div class="quiz-list mb-16" :key="question.id" v-for="(question, index) in questions">
|
|
|
<div class="quiz-list__index">{{ index + 1 }}.</div>
|
|
|
<div>
|
|
|
@@ -39,6 +46,7 @@ import CButton from '@/components/Basic/CButton'
|
|
|
import CIcon from '@/components/Basic/CIcon'
|
|
|
import { getOneQuiz, getOneQuizStudentAnswer, submitQuizStudentAnswer } from '@/server/quiz'
|
|
|
import { getQuestionsOfQuiz } from '@/server/question'
|
|
|
+import momentFromNow from '@/utils/moment-from-now'
|
|
|
|
|
|
export default {
|
|
|
name: 'StudentDoQuiz',
|
|
|
@@ -48,6 +56,7 @@ export default {
|
|
|
quiz: createDefaultQuiz(),
|
|
|
hasSubmit: false,
|
|
|
questions: null,
|
|
|
+ answersInfo: null,
|
|
|
|
|
|
QuestionKind
|
|
|
}
|
|
|
@@ -74,6 +83,7 @@ export default {
|
|
|
this.questions = res
|
|
|
// 获取之前填写的答案
|
|
|
getOneQuizStudentAnswer({ quizId }).then(answers => {
|
|
|
+ this.answersInfo = answers
|
|
|
this.questions = this.questions.map(question => ({
|
|
|
...question,
|
|
|
studentAnswer: answers.answers[question.id]
|
|
|
@@ -100,27 +110,31 @@ export default {
|
|
|
this.$setSuccessMessage('提交成功')
|
|
|
this.$router.go(-1)
|
|
|
}).catch(err => { this.$setErrorMessage(err.response.data.msg) })
|
|
|
- // submitQuiz({ quizId, answers: this.quiz.questions })
|
|
|
- // .then(() => {
|
|
|
- // this.hasSubmit = true
|
|
|
- // this.$setSuccessMessage('提交成功')
|
|
|
- // this.$router.go(-1)
|
|
|
- // })
|
|
|
- // .catch(err =>
|
|
|
- // this.$setErrorMessage(err.response.data.msg)
|
|
|
- // )
|
|
|
- }
|
|
|
+ },
|
|
|
+ momentFromNow
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
+@import "~@/style/theme.scss";
|
|
|
.do-quiz {
|
|
|
margin: 0 auto;
|
|
|
max-width: 800px;
|
|
|
padding: 64px 24px;
|
|
|
}
|
|
|
|
|
|
+.info {
|
|
|
+ line-height: 1.6;
|
|
|
+ color: #7a8a9a;
|
|
|
+ margin-bottom: 24px;
|
|
|
+ background: #f7f7f7;
|
|
|
+ padding: 8px 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.red {
|
|
|
+ color: $theme-red;
|
|
|
+}
|
|
|
.quiz-list {
|
|
|
display: flex;
|
|
|
|