-
Improvement
-
Resolution: Fixed
-
Minor
-
3.4, 3.5
-
MOODLE_34_STABLE, MOODLE_35_STABLE
-
MOODLE_36_STABLE
-
MDL-60710-master -
If a teacher has two of the roles that are shown in the lists of coursecontacts, she/he is only shown once in the coursecontacts with only one of these roles. However, there are cases in which it might be desired to show duplicates, e.g., if examiners should be highlighted or if there is one main contact among the teachers being responsible for a course and this fact is highlighted by a respective role that is additionally assigned to the teacher.
The reason for showing only one role is located in lib/coursecatlib.php#2860 function get_course_contacts that filters out duplicates among the coursecontacts.
To enable administrators to choose themselves whether duplicates are hidden or displayed, we prepared a small patch:
- added a setting on "Site administration > Appearance > Courses" that allows disabling the elimination of duplicates among coursecontacts
- Prepared an adapted version of function get_course_contacts adding an optional parameter $showduplicates (default false).
- Still duplicate role assignment to the same user have to be eliminated nevertheless (e.g., if role 'teacher' is assigned to a certain user in a category and she/he is enrolled as 'teacher' in a course of this category as well, then she/he should be listed only once as teacher)
- Ids of users can no longer be used as indices in the result, because the same user may occur more then once. This required some minor changes.
- Adapted all calls of get_course_contacts, thereby
- In course/renderer.php we utilize the new setting so that duplicates may be filtered or not as desired by the introduced settings
- In course/externallib.php we only added the parameter with value false (i.e., so that the behavior does not change much).
- Additional automated Tests
- Extended existing PHPUnit-tests
- Added behat-tests (that required some additional features in course/tests/behat/behat_course.php)