Skip to content
Snippets Groups Projects
Commit a42a0d4a authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

Finally fixed conditional rendering bug of submission-list

parent eb96698d
No related branches found
No related tags found
1 merge request!25WIP: Resolve "A new student overview page with Vue.js"
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
submit () { submit () {
this.getJWTToken(this.credentials).then(() => { this.getJWTToken(this.credentials).then(() => {
this.$router.push('/student/') this.$router.push('/student/')
this.getExamModule()
this.getUserRole() this.getUserRole()
}).catch(() => { }).catch(() => {
this.error = this.$store.state.error this.error = this.$store.state.error
......
...@@ -3,12 +3,14 @@ ...@@ -3,12 +3,14 @@
<v-layout justify center> <v-layout justify center>
<v-flex md3> <v-flex md3>
<h2>Exam Overview</h2> <h2>Exam Overview</h2>
<exam-information v-if="doneLoading" :exam="exam"></exam-information> <exam-information v-if="!loading" :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>
</v-flex> </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-layout>
</v-container> </v-container>
</template> </template>
...@@ -26,19 +28,15 @@ ...@@ -26,19 +28,15 @@
SubmissionList, SubmissionList,
StudentLayout}, StudentLayout},
name: 'student-page', name: 'student-page',
data () {
return {
doneLoading: false
}
},
created: function () { created: function () {
this.$store.dispatch('getStudentData').then(() => { this.doneLoading = true }) this.$store.dispatch('getStudentData')
}, },
computed: { computed: {
...mapState({ ...mapState({
studentName: state => state.studentPage.studentName, studentName: state => state.studentPage.studentName,
exam: state => state.studentPage.exam, exam: state => state.studentPage.exam,
submissions: state => state.studentPage.submissions submissions: state => state.studentPage.submissions,
loading: state => state.studentPage.loading
}) })
} }
} }
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
props: ['submissions'], props: ['submissions'],
computed: { computed: {
sumScore () { sumScore () {
console.log(this.submissions)
return this.submissions.map(a => a.score).reduce((a, b) => a + b) return this.submissions.map(a => a.score).reduce((a, b) => a + b)
}, },
sumFullScore () { sumFullScore () {
......
...@@ -5,7 +5,8 @@ const studentPage = { ...@@ -5,7 +5,8 @@ const studentPage = {
studentName: '', studentName: '',
exam: {}, exam: {},
submissionTypes: [], submissionTypes: [],
submissions: [] submissions: [],
loading: true
}, },
mutations: { mutations: {
'SET_STUDENT_NAME': function (state, name) { 'SET_STUDENT_NAME': function (state, name) {
...@@ -19,15 +20,21 @@ const studentPage = { ...@@ -19,15 +20,21 @@ const studentPage = {
}, },
'SET_SUBMISSIONS': function (state, submissions) { 'SET_SUBMISSIONS': function (state, submissions) {
state.submissions = submissions state.submissions = submissions
},
'SET_LOADING': function (state, loading) {
state.loading = loading
} }
}, },
actions: { actions: {
getStudentData (context) { getStudentData (context) {
context.commit('SET_LOADING', true)
ax.get('api/student-page/').then(response => { ax.get('api/student-page/').then(response => {
const data = response.data const data = response.data
context.commit('SET_STUDENT_NAME', data.name) context.commit('SET_STUDENT_NAME', data.name)
context.commit('SET_EXAM', data.exam) context.commit('SET_EXAM', data.exam)
context.commit('SET_SUBMISSIONS', data.submissions) context.commit('SET_SUBMISSIONS', data.submissions)
context.commit('SET_LOADING', false)
}) })
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment