|
|
@@ -114,8 +114,9 @@
|
|
|
<v-btn
|
|
|
color="primary"
|
|
|
class="mx-2 mb-2 align-self-center"
|
|
|
- small
|
|
|
v-on:click="submitCode"
|
|
|
+ :disabled="running"
|
|
|
+ :loading="running"
|
|
|
>保存测试</v-btn
|
|
|
>
|
|
|
</div>
|
|
|
@@ -125,6 +126,9 @@
|
|
|
></code-editor>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <v-snackbar v-model="error" top color="warning" absolute
|
|
|
+ >提交失败</v-snackbar
|
|
|
+ >
|
|
|
</v-card>
|
|
|
</template>
|
|
|
|
|
|
@@ -137,9 +141,11 @@ import {
|
|
|
CodeQuestionSerializer,
|
|
|
CodeSubmitSerializer,
|
|
|
CodeTuple,
|
|
|
+ ExamQuestionSubmitRecord,
|
|
|
ID
|
|
|
} from '@/api/types'
|
|
|
import { codeJudge } from '@/api/judge'
|
|
|
+import { getExamQuestionSubmitRecord } from '@/api/record'
|
|
|
|
|
|
interface CodeJudgeInfo extends CodeJudgeResult {
|
|
|
id: ID
|
|
|
@@ -155,10 +161,6 @@ export default Vue.extend({
|
|
|
question: {
|
|
|
required: true,
|
|
|
type: Object as PropType<CodeQuestionSerializer>
|
|
|
- },
|
|
|
- totalQuestionNum: {
|
|
|
- required: true,
|
|
|
- type: Number
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
@@ -170,15 +172,25 @@ export default Vue.extend({
|
|
|
currentLang: '',
|
|
|
currentCode: '',
|
|
|
codeCache: [] as CodeTuple[], // 切换语言时,将当前编辑的保存到cache中,下次切换回来可继续编辑
|
|
|
+ submitRecords: [] as ExamQuestionSubmitRecord[],
|
|
|
statusTags: [
|
|
|
'Accepted',
|
|
|
'Wrong Answer',
|
|
|
'Compile Error',
|
|
|
'Time Limit Exceeded',
|
|
|
- 'Memory Limit Exceeded'
|
|
|
+ 'Memory Limit Exceeded',
|
|
|
+ 'Running'
|
|
|
+ ],
|
|
|
+ statusColors: [
|
|
|
+ 'success',
|
|
|
+ 'error',
|
|
|
+ 'warning',
|
|
|
+ 'warning',
|
|
|
+ 'warning',
|
|
|
+ 'info'
|
|
|
],
|
|
|
- statusColors: ['success', 'error', 'warning', 'warning', 'warning']
|
|
|
- // lastCommitCode: [] as CodeSubmitSerializer[]
|
|
|
+ running: false,
|
|
|
+ error: false
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
@@ -208,9 +220,13 @@ export default Vue.extend({
|
|
|
return { lang: val, code: '' }
|
|
|
})
|
|
|
|
|
|
- this.codeJudgeResults = [
|
|
|
- { id: 1, result: 'Accepted', timeused: 123, memoryused: 12345 }
|
|
|
- ]
|
|
|
+ const examId = this.$route.params.examId
|
|
|
+ getExamQuestionSubmitRecord(examId, this.question.id).then(({ data }) => {
|
|
|
+ this.submitRecords = data.result
|
|
|
+ })
|
|
|
+ // this.codeJudgeResults = [
|
|
|
+ // { id: 1, result: 'Accepted', timeused: 123, memoryused: 12345 }
|
|
|
+ // ]
|
|
|
},
|
|
|
methods: {
|
|
|
submitCode(): void {
|
|
|
@@ -220,11 +236,19 @@ export default Vue.extend({
|
|
|
code: this.currentCode,
|
|
|
language: this.currentLang
|
|
|
}
|
|
|
- codeJudge(examId, this.question.id, codeToSubmit).then(({ data }) => {
|
|
|
- this.codeJudgeResults = data.result.result_list.map((val, index) => {
|
|
|
- return { ...val, id: index + 1 }
|
|
|
+ this.running = true
|
|
|
+ codeJudge(examId, this.question.id, codeToSubmit)
|
|
|
+ .then(({ data }) => {
|
|
|
+ this.codeJudgeResults = data.result.result_list.map((val, index) => {
|
|
|
+ return { ...val, id: index + 1 }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.error = true
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ this.running = false
|
|
|
})
|
|
|
- })
|
|
|
},
|
|
|
statusToColor(status: string): string {
|
|
|
return this.statusColors[this.statusTags.indexOf(status)]
|