|
|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <v-app-bar dense app class="indigo lighten-5">
|
|
|
+ <v-app-bar dense app>
|
|
|
<v-row>
|
|
|
<v-col>
|
|
|
<span class="display-1">{{ examInfo.title }}</span>
|
|
|
@@ -10,6 +10,7 @@
|
|
|
class="align-self-center"
|
|
|
:current-time="currentTime"
|
|
|
:end-time="endTime"
|
|
|
+ @timesUp="onTimesUp"
|
|
|
></count-down>
|
|
|
</v-col>
|
|
|
</v-row>
|
|
|
@@ -139,39 +140,27 @@
|
|
|
<v-main class="indigo lighten-5 pa-0">
|
|
|
<v-container fluid class="pa-2" v-if="currentQuestionIndex >= 0">
|
|
|
<choice-pane
|
|
|
- ref="choicePane"
|
|
|
v-show="isChoiceProblem"
|
|
|
@nextQuestion="nextQuestion"
|
|
|
@saveChoiceAnswer="saveChoiceAnswer"
|
|
|
:total-question-num="curTypeQuestionNum"
|
|
|
:question="curChoiceQuestion"
|
|
|
></choice-pane>
|
|
|
- <template v-show="!isChoiceProblem">
|
|
|
- <!-- 用一个不显示的tabs,同时渲染所有的代码题面板,控制代码题的切换,使得代码切换保留已写代码-->
|
|
|
- <!-- <v-tabs v-show="false" v-model="codeIndex">-->
|
|
|
- <!-- <v-tab v-for="i in codeQuestionNum" :key="i"> {{ i }}</v-tab>-->
|
|
|
- <!-- </v-tabs>-->
|
|
|
- <v-window v-model="codeIndex">
|
|
|
- <v-window-item v-for="i in codeQuestionNum" :key="i">
|
|
|
- <code-pane
|
|
|
- :question="codeQuestions[i - 1]"
|
|
|
- :total-question-num="curTypeQuestionNum"
|
|
|
- @nextQuestion="nextQuestion"
|
|
|
- @submitCode="saveSubmittedCode"
|
|
|
- ></code-pane>
|
|
|
- </v-window-item>
|
|
|
- </v-window>
|
|
|
- <!-- <v-tabs-items v-model="codeIndex">-->
|
|
|
- <!-- <v-tab-item v-for="i in codeQuestionNum" :key="i">-->
|
|
|
- <!-- <code-pane-->
|
|
|
- <!-- :question="codeQuestions[i - 1]"-->
|
|
|
- <!-- :total-question-num="curTypeQuestionNum"-->
|
|
|
- <!-- @nextQuestion="nextQuestion"-->
|
|
|
- <!-- @submitCode="saveSubmittedCode"-->
|
|
|
- <!-- ></code-pane>-->
|
|
|
- <!-- </v-tab-item>-->
|
|
|
- <!-- </v-tabs-items>-->
|
|
|
- </template>
|
|
|
+ <!-- 先用v-if(codeIndex只在初始为负数),再用v-show。只用v-show的时候,会出现第一个代码题editor无法渲染的问题,原因未知-->
|
|
|
+ <v-window
|
|
|
+ :value="codeIndex"
|
|
|
+ v-if="codeIndex >= 0"
|
|
|
+ v-show="!isChoiceProblem"
|
|
|
+ >
|
|
|
+ <v-window-item v-for="i in codeQuestionNum" :key="i">
|
|
|
+ <code-pane
|
|
|
+ :question="codeQuestions[i - 1]"
|
|
|
+ :total-question-num="curTypeQuestionNum"
|
|
|
+ @nextQuestion="nextQuestion"
|
|
|
+ @submitCode="saveSubmittedCode"
|
|
|
+ ></code-pane>
|
|
|
+ </v-window-item>
|
|
|
+ </v-window>
|
|
|
</v-container>
|
|
|
<v-snackbar v-model="noticeUnfinished">
|
|
|
还有题目未作答
|
|
|
@@ -214,7 +203,6 @@ export default Vue.extend({
|
|
|
singleChoiceQuestions: [] as Array<ChoiceQuestionSerializer>,
|
|
|
multiChoiceQuestions: [] as Array<ChoiceQuestionSerializer>,
|
|
|
codeQuestions: [] as Array<CodeQuestionSerializer>,
|
|
|
- allQuestions: [] as Array<QuestionSerializer>,
|
|
|
answeredChoices: [] as Array<{ index: number; answered: boolean }>,
|
|
|
answeredCodes: [] as Array<{ index: number; answered: boolean }>,
|
|
|
answerStatus: [] as Array<{ index: number; answered: boolean }>,
|
|
|
@@ -277,12 +265,17 @@ export default Vue.extend({
|
|
|
}
|
|
|
},
|
|
|
currentQuestionIndex(val) {
|
|
|
- if (val > this.choiceQuestionNum) {
|
|
|
+ console.log('before ' + this.codeIndex)
|
|
|
+ if (val >= this.choiceQuestionNum) {
|
|
|
this.codeIndex = val - this.choiceQuestionNum
|
|
|
}
|
|
|
+ console.log(this.codeIndex)
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ onTimesUp() {
|
|
|
+ this.submitAnswer()
|
|
|
+ },
|
|
|
saveSubmittedCode(code: string, lang: string) {
|
|
|
const changedCodeQuestion = this.codeQuestions[this.codeIndex]
|
|
|
const changedCodeTuple =
|
|
|
@@ -292,6 +285,10 @@ export default Vue.extend({
|
|
|
changedCodeTuple.code = code
|
|
|
},
|
|
|
saveChoiceAnswer(answer: string | undefined) {
|
|
|
+ if (this.currentQuestionIndex >= this.choiceQuestionNum) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if (answer === undefined) {
|
|
|
return
|
|
|
}
|
|
|
@@ -304,11 +301,7 @@ export default Vue.extend({
|
|
|
}
|
|
|
},
|
|
|
onSelectQuestion(target: number) {
|
|
|
- // this.saveAnswer()
|
|
|
this.currentQuestionIndex = target - 1
|
|
|
- if (!this.isChoiceProblem) {
|
|
|
- this.codeIndex = target - 1 - this.choiceQuestionNum
|
|
|
- }
|
|
|
},
|
|
|
leaveExam() {
|
|
|
this.exitDialog = false
|
|
|
@@ -342,13 +335,17 @@ export default Vue.extend({
|
|
|
console.log(codes)
|
|
|
this.$router.back()
|
|
|
},
|
|
|
+ prevQuestion() {
|
|
|
+ do {
|
|
|
+ this.currentQuestionIndex =
|
|
|
+ (--this.currentQuestionIndex + this.totalQuestionNum) %
|
|
|
+ this.totalQuestionNum
|
|
|
+ } while (this.answerStatus[this.currentQuestionIndex].answered)
|
|
|
+ },
|
|
|
nextQuestion() {
|
|
|
- // if (this.isChoiceProblem) {
|
|
|
- // this.saveAnswer(answer.toString())
|
|
|
- // }
|
|
|
do {
|
|
|
this.currentQuestionIndex =
|
|
|
- ++this.currentQuestionIndex % this.totalQuestionNum
|
|
|
+ (this.currentQuestionIndex + 1) % this.totalQuestionNum
|
|
|
} while (this.answerStatus[this.currentQuestionIndex].answered)
|
|
|
},
|
|
|
fetchData() {
|
|
|
@@ -378,7 +375,7 @@ export default Vue.extend({
|
|
|
return { ...value, index: index + 1 }
|
|
|
}) ?? []
|
|
|
|
|
|
- this.allQuestions = [
|
|
|
+ const allQuestions = [
|
|
|
...this.singleChoiceQuestions,
|
|
|
...this.multiChoiceQuestions,
|
|
|
...this.codeQuestions
|
|
|
@@ -390,7 +387,7 @@ export default Vue.extend({
|
|
|
return { index: index + 1, answer: '' }
|
|
|
})
|
|
|
|
|
|
- this.answerStatus = this.allQuestions.map((value, index) => {
|
|
|
+ this.answerStatus = allQuestions.map((value, index) => {
|
|
|
return {
|
|
|
index: index + 1,
|
|
|
answered: false
|
|
|
@@ -398,7 +395,7 @@ export default Vue.extend({
|
|
|
})
|
|
|
|
|
|
this.currentQuestionIndex = 0 // 表示数据初始化完成
|
|
|
- this.codeIndex = -1
|
|
|
+ console.log(this.codeIndex)
|
|
|
})
|
|
|
.catch(() => {
|
|
|
console.log('No data')
|