davidherney / moodle-format_onetopic

Course format Onetopic to LMS Moodle
GNU General Public License v3.0
19 stars 42 forks source link

Endless redirects on unavailable sections for tutors #155

Closed t-schroeder closed 3 months ago

t-schroeder commented 1 year ago

We use a role for tutors that has the capability moodle/course:viewhiddensections but doesn't have moodle/course:ignoreavailabilityrestrictions. Then we have a course that has a section with a date access restriction, so the section only becomes available once a certain date is reached or passed. When a tutor clicks on the section there are infinite redirects.

t-schroeder commented 1 year ago

The error looks the same as the one described in #58 from a user's perspective.

t-schroeder commented 1 year ago

I've debugged this problem and noticed the redirect is performed in course/view.php#L114 and the manipulation of the global $section variable that happens in lib.php#L102 and lib.php#L151 causes it to want to display the unavailable section again on each redirect causing another redirect.

t-schroeder commented 1 year ago

I've supplied a fix that a) disables unavailable tabs in this case and b) ensures that even if someone visits the URL of such a tab with the above mentioned capability combination e.g. through a role switch it won't cause infinite redirects.