diff --git a/frontend/src/components/Login.vue b/frontend/src/components/Login.vue index 1344def47c2964d613a4014abdba0d1ff387146e..462f3910da343029f755fe37b9c460439cc2bb41 100644 --- a/frontend/src/components/Login.vue +++ b/frontend/src/components/Login.vue @@ -56,7 +56,6 @@ submit () { this.getJWTToken(this.credentials).then(() => { this.$router.push('/student/') - this.getExamModule() this.getUserRole() }).catch(() => { this.error = this.$store.state.error diff --git a/frontend/src/components/student/StudentPage.vue b/frontend/src/components/student/StudentPage.vue index 98332e21dedade7ce7869573e885cfae73672413..1bcb1fc7dd9111067b9f0110a879b862f3751925 100644 --- a/frontend/src/components/student/StudentPage.vue +++ b/frontend/src/components/student/StudentPage.vue @@ -3,12 +3,14 @@ <v-layout justify center> <v-flex md3> <h2>Exam Overview</h2> - <exam-information v-if="doneLoading" :exam="exam"></exam-information> - </v-flex> - <v-flex md7 offset-md1> - <h2>Submissions of {{ studentName }}</h2> - <submission-list v-if="doneLoading" :submissions="submissions"></submission-list> + <exam-information v-if="!loading" :exam="exam"></exam-information> </v-flex> + <template v-if="!loading"> + <v-flex md7 offset-md1> + <h2>Submissions of {{ studentName }}</h2> + <submission-list :submissions="submissions"></submission-list> + </v-flex> + </template> </v-layout> </v-container> </template> @@ -26,19 +28,15 @@ SubmissionList, StudentLayout}, name: 'student-page', - data () { - return { - doneLoading: false - } - }, created: function () { - this.$store.dispatch('getStudentData').then(() => { this.doneLoading = true }) + this.$store.dispatch('getStudentData') }, computed: { ...mapState({ studentName: state => state.studentPage.studentName, exam: state => state.studentPage.exam, - submissions: state => state.studentPage.submissions + submissions: state => state.studentPage.submissions, + loading: state => state.studentPage.loading }) } } diff --git a/frontend/src/components/student/SubmissionList.vue b/frontend/src/components/student/SubmissionList.vue index 38072e00f2b17a8a07012905100c5f1b6679a90b..3a6d39bcbbf2954c337bd084ec9dcdd618af73db 100644 --- a/frontend/src/components/student/SubmissionList.vue +++ b/frontend/src/components/student/SubmissionList.vue @@ -51,6 +51,7 @@ props: ['submissions'], computed: { sumScore () { + console.log(this.submissions) return this.submissions.map(a => a.score).reduce((a, b) => a + b) }, sumFullScore () { diff --git a/frontend/src/store/modules/student-page.js b/frontend/src/store/modules/student-page.js index 8d593808f718bc8b4814d0789546439c7950619c..ce6cc28b92de50247aea85562782e5b4924b8968 100644 --- a/frontend/src/store/modules/student-page.js +++ b/frontend/src/store/modules/student-page.js @@ -5,7 +5,8 @@ const studentPage = { studentName: '', exam: {}, submissionTypes: [], - submissions: [] + submissions: [], + loading: true }, mutations: { 'SET_STUDENT_NAME': function (state, name) { @@ -19,15 +20,21 @@ const studentPage = { }, 'SET_SUBMISSIONS': function (state, submissions) { state.submissions = submissions + }, + 'SET_LOADING': function (state, loading) { + state.loading = loading } }, actions: { + getStudentData (context) { + context.commit('SET_LOADING', true) ax.get('api/student-page/').then(response => { const data = response.data context.commit('SET_STUDENT_NAME', data.name) context.commit('SET_EXAM', data.exam) context.commit('SET_SUBMISSIONS', data.submissions) + context.commit('SET_LOADING', false) }) } }