MDL-66336 courses: Show an error when no course categories are visible

This commit is contained in:
Mark Johnson 2019-08-08 09:08:08 +01:00
parent 7e16c70b52
commit 3b75d14315

View File

@ -69,8 +69,11 @@ if ($courseid) {
$course = null;
$courseid = null;
$topchildren = core_course_category::top()->get_children();
if (empty($topchildren)) {
throw new moodle_exception('cannotviewcategory', 'error');
}
$category = reset($topchildren);
$categoryid = $category ? $category->id : 0;
$categoryid = $category->id;
$context = context_coursecat::instance($category->id);
$url->param('categoryid', $category->id);
}