I'm trying to add a new Role at the Category Level - so for example, a Legal Studies Convenor has non-editing teacher rights to all the courses in the Legal Studies category to assist students, teachers, etc.
So I set the new Role moodle/course:view to allow.
But this Legal Convenor also teaches so does not want ALL the courses listed in the My Courses block, just those he/she is a 'Teacher' in.
The only way I can see to do this is to re-create the Administrator Role, or a new role selecting: moodle/site:doanything - allow AND moodle/course:view - Prevent
However... I don't want the Role to have full editing capabilities. I tried to Prevent or Prohibit other capabilities manually but it seems that moodle/site:doanything over-rides this?
The problem is that the library routine that selects "my courses" does not discriminate between "my own" and "my-inhereted-by-category-role" courses. Only a programmer from Moodle Headquarter can solve this problme deep, deep in the library.
It is a big (also performance) problem.
If I were you, I would make a separate user for the Legal Studies Convenor. When a teacher, your teacher logs in as Teacher. When a Convenor, as a Convenor.
As you know, "do anything" pretty much makes you an omniscient god, so it's difficult to blind someone who is omniscient
As with voting, please report back early and often.
If you contemplate jumping through a Stargate, ask for a rope and backup everything first.
We faced a similar issue when we wanted our teaching staff to be able to roam in and out of other teacher's courses, without displaying 900 (!) courses in their "My Courses" list. We ended up:
1. Creating a new capability "Participate in Courses" (moodle/course:participate)
2. Set it to Allow for the roles where the courses should be listed in My Courses
3. Set it to Not Set for the roles where the courses should not be listed in My Courses (like your Legal Convenor role)
4. Alter a few lines of code to ensure the My Courses list is dependent upon a user having the "Participate" permission, rather than the "View courses" permission. I changed 2 files:
a) lib/datalib.php -> around line 937, change the capability checked to be 'moodle/course:participate'. eg:
$courses = get_user_courses_bycap($userid, 'moodle/course:participate', $accessinfo, $doanything, $sort, $fields, $limit);
b) lib/db/access.php -> between 'moodle/course:view' and 'moodle/course:bulkmessagin', add this code:
'moodle/course:participate' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE
I believe there are plans for this sort of thing in Moodle 2.0, but we needed the solution 2 years ago, so went ahead and did it. There are probably spots in code that I've neglected, but it works for us, or at least for how we use Moodle.
Thanks so much for sharing! Very appreciated. We might give this a try...
1. Won't receive emails from classes
2. Cannot make changes to the classes
Our Moodle is hosted by a third party, so code changes are limited.
It seems that the problem can partially be fixed with hidden role assignments.
If you create a role that has the capability "moodle:course/view" (in a certain context: globally, in a category, etc.), and assign this role to somebody as a hidden role assignment, then this person can enter the course but does not get subscribed to forums.
However, they still see the course in their "my courses" list, and have the course events in their calendar, which can be annoying.
Maybe, excluding hidden role assignments from "My Courses" and from the calendar would be a performance-saving way of implementing this in Moodle 1.9?
Thank you--that appears to work for the Forum subscriptions...
Besides the full course list for the administrator, the teachers still see the administrators in their assignments (unless the teacher is using groups). I assume these are related, and fixing one would fix the other.
Unfortunately, we're already using 1.9.7, so maybe this will be a later fix?
Re the course list and calendar entries: I made a suggestion to exclude hidden roles in these places, but not more - I'm not one of the Moodle developers. So, as things stand, I don't think there's a forthcoming fix. However, if we agree here that excluding the hidden roles in "My courses" lists and in the calendar would be a good thing, we can open a request on the Moodle Tracker - and the more people vote on it, the more likely it will be implemented, for all I understand.
I added the capability to mdl_capabilities database table then added the code to lib/datalib.php and lib/db/access.php as specified, made a slight change to access.php as specified though to make role assignments / overrides clearer:
'moodle/course:participate' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'legacy' => array(
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW
Then added to lang/role.php just to make it look nicer:
$string['course:participate'] = 'Participate in courses';
Edit the roles for teacher, non-edit teacher and student to allow this capability else were not set.
This works well, in the my page only courses where the user is enrolled as a teacher, non-edit teacher or student are listed, in the my courses block we use only the same course list is used (we don't really use the my page but may change now because of this fix) but with the inspector role (we call it teacher view-all) set to allow course:view but not set for course:participate allows teachers to go to moodle/course/index.php and see the course list and can get into any course to look at the techniques and resources being used by other staff members.
All in all an excellent work around. Working in Moodle 1.9.7+ (Build: 20100210).
Same problem here with non edit teacher seeing all the courses under my courses! If anyone knows a great solution please let me know