Teacher role doesn't get unassigned in synced courses

Teacher role doesn't get unassigned in synced courses

by Michael | -
Number of replies: 4
I wonder if this is a bug or a feature or something I just don't 'get'

I have three courses. CourseA is a 'regular' course and courseB and courseC are metacourses with CourseA as the 'child'.

I assign a teacher to CourseA and that teacher is synched correctly as a teacher for courseB and courseC.

But when I uassign the teacher from courseA, the teacher IS NOT unassigned as a teacher from courseB and courseC, just courseA.

I could manually unassign the teacher but that seems to defeat the purpose of having the courses synched.


Any insight into this is greatly appreciated.

I am using a standard, fresh out of the box, 1.8.7 to test this 'issue' on.


Thanks
M=


Average of ratings: Useful (1)
In reply to Michael |

Re: Teacher role doesn't get unassigned in synced courses

by Michael | -
Digging into the code I found this in the sync_metacourse function:

// We do not ever want to unassign the list of metacourse manager, so get a list of them.
if ($users = get_users_by_capability($context, 'moodle/course:managemetacourse')) {
$managers = array_keys($users);
} else {
$managers = array();
}

In the permissions for a teacher, they are indeed set to "course:managemetacourse".

A little bit farther down is the code for the unassign:

if (!in_array($unassignment->userid, $managers)) {
$success = role_unassign($unassignment->roleid, $unassignment->userid, 0, $context->id) && $success;
}

So this would be the cause of the issue.

Since all teachers have by default are 'allowed' to "course:managemetacourse", they can never, with unmodified code, be unassigned from the 'parent' courses.

This just does not make sense to me, since admins should be able to unassign anybody from anything.

As a short term fix I just commented out the in_array check.

And the assignments go properly.

Any info on if this is a bug or feature would be appreciated.


Thanks
M=


In reply to Michael |

Re: Teacher role doesn't get unassigned in synced courses

by Ray Lawrence -
Is it the case that Teachers are not automatically unassigned or that they must be unassigned manually?
In reply to Michael |

Re: Teacher role doesn't get unassigned in synced courses

by Maria SHILINA -
That seems to be rather strange... i don't see any sense in it... in my opinion the teachers must be automatically unassigned from metacourses...
In reply to Michael |

Re: Teacher role doesn't get unassigned in synced courses

by Michael | -
Or you can also change the definition of the teacher role, changing it from the default of "Allow" for Manage metacourse to "Not Set".

Ray, it is both the issues: The teachers are NOT automatically unassigned as they should be and if you want to unassign them, you must do it manually, which defeats the purpose of syncing them in the first place.

Very strange issue indeed, hopefully it is fixed in later versions...