davidherney/moodle-format_onetopic

Endless redirects on unavailable sections for tutors

Closed this issue · 3 comments

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.

  • Moodle version: 4.1.4
  • Plugin version: 4.1.03(PiedrasTeherán) 2022081607

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

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.

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.