Skip to content
Snippets Groups Projects
Commit 8d83eb80 authored by Ron Lucke's avatar Ron Lucke Committed by Jan-Hendrik Willms
Browse files

fix #994

Closes #994

Merge request studip/studip!932
parent ad677ea1
Branches
No related tags found
No related merge requests found
...@@ -1064,8 +1064,12 @@ export const actions = { ...@@ -1064,8 +1064,12 @@ export const actions = {
); );
}, },
loadTeacherStatus({ dispatch, rootGetters, state, commit, getters }, userId) { async loadTeacherStatus({ dispatch, rootGetters, state, commit, getters }, userId) {
const user = rootGetters['users/byId']({ id: userId }); let user = rootGetters['users/byId']({ id: userId });
if (!user) {
await dispatch('users/loadById', { id: userId });
user = rootGetters['users/byId']({ id: userId });
}
if (user.attributes.permission === 'root') { if (user.attributes.permission === 'root') {
commit('setUserIsTeacher', true); commit('setUserIsTeacher', true);
...@@ -1074,10 +1078,13 @@ export const actions = { ...@@ -1074,10 +1078,13 @@ export const actions = {
const membershipId = `${state.context.id}_${userId}`; const membershipId = `${state.context.id}_${userId}`;
return dispatch('course-memberships/loadById', { id: membershipId }) await dispatch('course-memberships/loadById', { id: membershipId });
.then(() => {
const membership = rootGetters['course-memberships/byId']({ id: membershipId }); const membership = rootGetters['course-memberships/byId']({ id: membershipId });
const editingLevel = getters.courseware.attributes['editing-permission-level']; if (membership) {
let editingLevel = 'tutor';
if (getters.courseware.attributes) {
editingLevel = getters.courseware.attributes['editing-permission-level'];
}
const membershipPermission = membership.attributes.permission; const membershipPermission = membership.attributes.permission;
let isTeacher = false; let isTeacher = false;
...@@ -1086,13 +1093,15 @@ export const actions = { ...@@ -1086,13 +1093,15 @@ export const actions = {
} else if (editingLevel === 'tutor') { } else if (editingLevel === 'tutor') {
isTeacher = membershipPermission === 'dozent' || membershipPermission === 'tutor'; isTeacher = membershipPermission === 'dozent' || membershipPermission === 'tutor';
} }
commit('setUserIsTeacher', isTeacher); commit('setUserIsTeacher', isTeacher);
})
.catch((error) => { return true;
} else {
console.error(`Could not find course membership for ${membershipId}.`); console.error(`Could not find course membership for ${membershipId}.`);
commit('setUserIsTeacher', false); commit('setUserIsTeacher', false);
});
return false;
}
}, },
loadFeedback({ dispatch }, blockId) { loadFeedback({ dispatch }, blockId) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment