Hello,
I think I found a bug in this function.
I had a user who is enrolled in 5 courses as teacher/editingteacher and 1 as guest.
When this user log in, no courses are shown in My Courses panel. Then, if I modify guest enrolment putting a teacher role, all courses are shown.
To do my tries, I modify these files
lib/datalib.php, l.800 - I've added
has_capability("clearcache");
before
!has_capability('moodle/legacy:guest', $context, $userid, false) &&to ensure capabilities to be reloaded each time.
($course->visible || has_capability('moodle/course:viewhiddencourses', $context, $userid))) {
and added
$USER->capabilities = array(); for same reason.
load_user_capability() seems to mix all contexts to give us this result...and moodle/legacy:guest appears even in courses where the user is enrolled as teacher
What do you think about this behaviour ?