|
|
@@ -184,6 +184,9 @@
|
|
|
<v-snackbar v-model="examAvailableDialog" centered absolute color="error">
|
|
|
评测不可用
|
|
|
</v-snackbar>
|
|
|
+ <v-snackbar v-model="submittedError" absolute>
|
|
|
+ 提交失败,请重试
|
|
|
+ </v-snackbar>
|
|
|
</v-main>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -199,7 +202,10 @@ import {
|
|
|
ExamSerializer,
|
|
|
CodeQuestionSerializer,
|
|
|
QuestionStemSerializer,
|
|
|
- QuestionType
|
|
|
+ QuestionType,
|
|
|
+ Record,
|
|
|
+ LocalDateTime,
|
|
|
+ ID
|
|
|
} from '@/api/types'
|
|
|
import { getExamById, getExamQuestions } from '@/api/exam'
|
|
|
import { getQuestionStem } from '@/api/question'
|
|
|
@@ -220,7 +226,7 @@ export default Vue.extend({
|
|
|
fetchingStem: true,
|
|
|
exitDialog: false,
|
|
|
submitDialog: false,
|
|
|
- submitted: false,
|
|
|
+ submittedError: false,
|
|
|
currentTime: 0,
|
|
|
examInfo: (null as unknown) as ExamSerializer,
|
|
|
endTime: 0,
|
|
|
@@ -228,9 +234,9 @@ export default Vue.extend({
|
|
|
|
|
|
currentQuestion: (null as unknown) as QuestionStemSerializer,
|
|
|
currentQuestionIndex: -1,
|
|
|
- objectiveAnswers: [] as Array<string>,
|
|
|
+ objectiveAnswers: {} as Map<ID, Record>,
|
|
|
questionIds: [] as Array<string>,
|
|
|
-
|
|
|
+ questionStartTime: dayjs().format(TIME_FORMAT) as LocalDateTime,
|
|
|
examId: 0,
|
|
|
// codeQuestions: [] as Array<CodeQuestionSerializer>,
|
|
|
// codeIndex: -1
|
|
|
@@ -288,8 +294,12 @@ export default Vue.extend({
|
|
|
// changedCodeTuple.code = code
|
|
|
// },
|
|
|
saveObjectiveAnswer(answer: string) {
|
|
|
- this.objectiveAnswers[this.currentQuestionIndex] = answer
|
|
|
- console.log(answer)
|
|
|
+ let questionEndTime = dayjs().format(TIME_FORMAT)
|
|
|
+ this.objectiveAnswers.set(this.questionIds[this.currentQuestionIndex], {
|
|
|
+ answer,
|
|
|
+ startAt: this.questionStartTime,
|
|
|
+ endAt: questionEndTime
|
|
|
+ })
|
|
|
},
|
|
|
leaveExam() {
|
|
|
this.exitDialog = false
|
|
|
@@ -302,7 +312,14 @@ export default Vue.extend({
|
|
|
console.log(this.objectiveAnswers)
|
|
|
console.log(this.questionIds)
|
|
|
|
|
|
- objectiveJudge(this.objectiveAnswers, this.questionIds)
|
|
|
+ let mapObj = Object.create(null)
|
|
|
+ for (let [k, v] of this.objectiveAnswers) {
|
|
|
+ if (v.answer) {
|
|
|
+ mapObj[k] = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ objectiveJudge(this.examId, mapObj)
|
|
|
.then(() => {
|
|
|
setTimeout(() => {
|
|
|
this.$router.push({
|
|
|
@@ -314,23 +331,19 @@ export default Vue.extend({
|
|
|
}, 1000)
|
|
|
})
|
|
|
.catch(() => {
|
|
|
- objectiveJudge(this.objectiveAnswers, this.questionIds).then(() => {
|
|
|
- setTimeout(() => {
|
|
|
- this.$router.push({
|
|
|
- name: 'result',
|
|
|
- params: {
|
|
|
- examId: this.examId.toString()
|
|
|
- }
|
|
|
- })
|
|
|
- }, 1000)
|
|
|
- })
|
|
|
+ this.submittedError = true
|
|
|
})
|
|
|
- .catch(() => {})
|
|
|
},
|
|
|
nextQuestion() {
|
|
|
if (this.currentQuestionIndex < this.totalQuestionNum - 1) {
|
|
|
- if (this.objectiveAnswers[this.currentQuestionIndex] === '') {
|
|
|
+ if (
|
|
|
+ !this.objectiveAnswers.get(
|
|
|
+ this.questionIds[this.currentQuestionIndex]
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ //TODO 提示未答题?
|
|
|
}
|
|
|
+ this.questionStartTime = dayjs().format(TIME_FORMAT)
|
|
|
|
|
|
this.currentQuestionIndex++
|
|
|
this.fetchQuestionStem(this.currentQuestionIndex)
|
|
|
@@ -362,8 +375,7 @@ export default Vue.extend({
|
|
|
this.currentQuestionIndex = 0
|
|
|
this.fetchQuestionStem(0)
|
|
|
|
|
|
- this.objectiveAnswers = Array(this.objectiveQuestionNum)
|
|
|
- this.objectiveAnswers.fill('')
|
|
|
+ this.objectiveAnswers = new Map<ID, Record>()
|
|
|
})
|
|
|
}
|
|
|
},
|