diff --git a/public/course/format/classes/output/local/content.php b/public/course/format/classes/output/local/content.php index 423d6a94884..800022e287e 100644 --- a/public/course/format/classes/output/local/content.php +++ b/public/course/format/classes/output/local/content.php @@ -151,6 +151,18 @@ class content implements named_templatable, renderable { $format = $this->format; $course = $format->get_course(); + + if (!$format->uses_sections()) { + if (has_capability('moodle/course:update', \core\context\course::instance($course->id))) { + $url = new \moodle_url('/course/edit.php', ['id' => $course->id]); + $params = [ + 'courseformat' => $format->get_format_name(), + ]; + throw new \moodle_exception('nosections_editor', 'error', $url, $params); + } + throw new \moodle_exception('nosections_noneditor', 'error'); + } + $modinfo = $this->format->get_modinfo(); // Generate section list. diff --git a/public/lang/en/error.php b/public/lang/en/error.php index 137a924c045..78bab35f806 100644 --- a/public/lang/en/error.php +++ b/public/lang/en/error.php @@ -480,6 +480,9 @@ $string['nopermissiontoviewcalendar'] = 'Sorry, but you do not have permission t $string['nopermissiontoviewgrades'] = 'Cannot view grades.'; $string['nopermissiontoviewletergrade'] = 'Missing permission to view letter grades'; $string['nopermissiontoviewpage'] = 'You are not allowed to look at this page'; +$string['nosections_editor'] = 'The course can\'t be displayed because the current course format \'{$a->courseformat}\' is not compatible with the way the course content is organised. +To display the course correctly, choose a different course format. Use the \'Continue\' button to go to course format settings.'; +$string['nosections_noneditor'] = 'This course is not available right now. Contact your teacher or instructor for help.'; $string['nosite'] = 'Could not find a top-level course!'; $string['nositeid'] = 'No site ID'; $string['nostartdatenoenddate'] = 'A course end date can only be set if a start date is also set.';