소스 검색

公开评测加入

ChengYuXuan 5 년 전
부모
커밋
a5057d5066

+ 6 - 1
src/api/exam.ts

@@ -8,7 +8,6 @@ import {
   ExamQuestionSerializer,
   LocalDateTime,
   ExamState,
-  PageSerializer,
   ExamListSerializer,
   CreateExamResponse
 } from '@/api/types'
@@ -45,6 +44,12 @@ export const joinExamByInviteCode = (inviteCode: string, examId: ID) => {
   )
 }
 
+export const joinPublicExam = (examId: ID) => {
+  return axios.put<ReceivedData<boolean>>(
+    `${EXAM_MODULE}/invite/code?examId=${examId}`
+  )
+}
+
 export const setExamPaperFromSample = (examId: ID, sampleExamPaperId: ID) => {
   return axios.post<ReceivedData>(
     `${EXAM_MODULE}/question/sample/${examId}/?sampleExamPaperId=${sampleExamPaperId}`

+ 0 - 1
src/api/types.d.ts

@@ -9,7 +9,6 @@ export interface ReceivedData<R = {}, E = 0> extends AxiosResponseInfo {
   code: E | 0 | 401
   result: R
   msg: string
-  page?: PageSerializer
 }
 
 export type QuestionType = 'choice' | 'blank' | 'code' | 'multi_choice'

+ 3 - 3
src/views/exam/ExamPane.vue

@@ -113,7 +113,7 @@
               </v-card>
             </v-dialog>
           </div>
-          <div class="pa-2 pl-6 pb-5 text--secondary">All Right Reserve</div>
+          <div class="pa-2 pl-6 pb-5 text--secondary">SEEC-EVAL</div>
         </div>
       </div>
     </v-navigation-drawer>
@@ -148,10 +148,10 @@
               </template>
             </choice-pane>
           </div>
-          <v-spacer></v-spacer>
+          <v-spacer v-if="fetchingStem"></v-spacer>
           <div
             v-if="currentQuestionIndex >= 0"
-            class="d-flex justify-space-around px-10 py-10"
+            class="d-flex justify-center px-10 py-10"
           >
             <v-btn color="info" @click="nextQuestion" :disabled="fetchingStem"
               >下一题</v-btn

+ 3 - 9
src/views/exam/components/ChoicePane.vue

@@ -30,10 +30,7 @@
                 </v-checkbox>
               </v-list-item-action>
               <v-list-item-content class="py-0">
-                <markdown-text
-                  class="mt-4"
-                  :raw="choice.labelText"
-                ></markdown-text>
+                <markdown-text :raw="choice.labelText"></markdown-text>
               </v-list-item-content>
             </template>
           </v-list-item>
@@ -48,11 +45,8 @@
               <v-list-item-action>
                 <v-checkbox hide-details :input-value="active"> </v-checkbox>
               </v-list-item-action>
-              <v-list-item-content class="py-0">
-                <markdown-text
-                  class="mt-4"
-                  :raw="choice.labelText"
-                ></markdown-text>
+              <v-list-item-content>
+                <markdown-text :raw="choice.labelText"></markdown-text>
               </v-list-item-content>
             </template>
           </v-list-item>

+ 2 - 2
src/views/exam/components/MarkdownText.vue

@@ -17,11 +17,11 @@ export default Vue.extend({
 })
 </script>
 
-<style lang="scss" scoped>
+<style lang="scss">
 .markdown-content {
   word-break: break-all;
   white-space: pre-wrap;
-
+  margin-top: 16px;
   p {
     margin-bottom: 0;
   }

+ 4 - 2
src/views/student/Overview.vue

@@ -71,8 +71,8 @@
 <script lang="ts">
 import Vue from 'vue'
 import PageHeader from '@/components/PageHeader.vue'
-import { getAllExamList, joinExamByInviteCode } from '@/api/exam'
-import { ExamSerializer, ExamState, PageSerializer } from '@/api/types'
+import { getAllExamList } from '@/api/exam'
+import { ExamSerializer } from '@/api/types'
 import StudentExamInfoCard from '@/views/student/components/StudentExamInfoCard.vue'
 
 export default Vue.extend({
@@ -122,6 +122,8 @@ export default Vue.extend({
     },
     fetchExams() {
       this.fetching = true
+      this.examList = []
+
       getAllExamList({ pageNum: this.page, pageSize: this.pageSize })
         .then(({ data }) => {
           this.examList = data.result.examVOList

+ 3 - 1
src/views/student/StudentExamList.vue

@@ -53,7 +53,7 @@
 import Vue from 'vue'
 import PageHeader from '@/components/PageHeader.vue'
 import { getExamsByStudentId } from '@/api/exam'
-import { ExamSerializer, ExamState, PageSerializer } from '@/api/types'
+import { ExamSerializer, ExamState } from '@/api/types'
 import StudentExamInfoCard from '@/views/student/components/StudentExamInfoCard.vue'
 
 export default Vue.extend({
@@ -98,6 +98,7 @@ export default Vue.extend({
     onJoinExam() {},
     fetchExams() {
       this.fetching = true
+      this.examList = []
 
       getExamsByStudentId(
         { pageNum: this.page, pageSize: this.pageSize },
@@ -109,6 +110,7 @@ export default Vue.extend({
           this.examList.forEach((val, index) => {
             this.examList[index].isJoined = true // 该变量仅在/exam/list 中有意义
           })
+          this.$forceUpdate()
         })
         .catch((err) => {
           console.log(err)

+ 11 - 2
src/views/student/components/StudentExamInfoCard.vue

@@ -107,7 +107,7 @@
 import Vue, { PropType } from 'vue'
 import { ExamSerializer, ExamStateText, LocalDateTime } from '@/api/types'
 import { computeExamStateText, timeLength } from '@/utils/common'
-import { joinExamByInviteCode } from '@/api/exam'
+import { joinExamByInviteCode, joinPublicExam } from '@/api/exam'
 
 export default Vue.extend({
   name: 'StudentExamInfoCard',
@@ -157,7 +157,16 @@ export default Vue.extend({
 
     onJoinExam() {
       if (this.examInfo.isPublic) {
-        //TODO
+        const examId = this.examInfo.examId ?? 0
+        joinPublicExam(examId).then(({ data }) => {
+          const joinSuccess = data.result
+          if (joinSuccess) {
+            this.joinSuccess = true
+            this.$emit('joinExam')
+          } else {
+            this.joinFailed = true
+          }
+        })
       } else {
         this.inputInviteCode = true
       }

+ 1 - 1
src/views/teacher/EditExam.vue

@@ -139,7 +139,7 @@ export default Vue.extend({
           href: '/teacher'
         },
         {
-          text: '评测列表',
+          text: '评测管理',
           disabled: false,
           href: '/teacher/created-exams'
         },

+ 4 - 2
src/views/teacher/ExamManage.vue

@@ -57,7 +57,7 @@
 import Vue from 'vue'
 import PageHeader from '@/components/PageHeader.vue'
 import TeacherExamInfoCard from '@/views/teacher/components/TeacherExamInfoCard.vue'
-import { ExamSerializer, ExamState, PageSerializer } from '@/api/types'
+import { ExamSerializer, ExamState } from '@/api/types'
 import { getExamsByTeacherId } from '@/api/exam'
 import { mapGetters } from 'vuex'
 
@@ -82,7 +82,7 @@ export default Vue.extend({
           href: '/teacher'
         },
         {
-          text: '评测列表',
+          text: '评测管理',
           disabled: true,
           href: '/'
         }
@@ -105,6 +105,8 @@ export default Vue.extend({
     },
     fetchExams() {
       this.fetching = true
+      this.examList = []
+
       getExamsByTeacherId(
         { pageNum: this.page, pageSize: this.pageSize },
         this.selectItems.indexOf(this.selected) as ExamState

+ 1 - 1
src/views/teacher/TeacherExamDetail.vue

@@ -92,7 +92,7 @@ export default Vue.extend({
           href: '/teacher'
         },
         {
-          text: '评测列表',
+          text: '评测管理',
           disabled: false,
           href: '/teacher/created-exams'
         },