diff --git a/admin/tool/recyclebin/tests/behat/basic_functionality.feature b/admin/tool/recyclebin/tests/behat/basic_functionality.feature index c806b7fc3bd..6b4ea5bf2e5 100644 --- a/admin/tool/recyclebin/tests/behat/basic_functionality.feature +++ b/admin/tool/recyclebin/tests/behat/basic_functionality.feature @@ -42,10 +42,6 @@ Feature: Basic recycle bin functionality And I should see "Test assign" in the "Topic 1" "section" Scenario: Restore a deleted course - # TODO MDL-57250 remove extra category. - Given the following "categories" exist: - | name | idnumber | - | There is a bug with navigation and we need an extra category | CAT1 | Given I log in as "admin" And I go to the courses management page And I click on "delete" action for "Course 2" in management course listing @@ -54,7 +50,7 @@ Feature: Basic recycle bin functionality And I should see "C2 has been completely deleted" And I press "Continue" And I am on course index - And I follow "Miscellaneous" + And I should see "Course 1" And I should not see "Course 2" When I navigate to "Recycle bin" in current page administration Then I should see "Course 2" diff --git a/course/index.php b/course/index.php index ce327ae41ab..f961ee2b9c0 100644 --- a/course/index.php +++ b/course/index.php @@ -37,9 +37,18 @@ if ($categoryid) { // And the object has been loaded for us no need for another DB call $category = $PAGE->category; } else { - $categoryid = 0; + // Check if there is only one category, if so use that. + if (coursecat::count_all() == 1) { + $category = coursecat::get_default(); + + $categoryid = $category->id; + $PAGE->set_category_by_id($categoryid); + $PAGE->set_pagetype('course-index-category'); + } else { + $PAGE->set_context(context_system::instance()); + } + $PAGE->set_url('/course/index.php'); - $PAGE->set_context(context_system::instance()); } $PAGE->set_pagelayout('coursecategory'); diff --git a/course/renderer.php b/course/renderer.php index ff6065354d2..90ad00f4694 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -1554,15 +1554,21 @@ class core_course_renderer extends plugin_renderer_base { $this->page->set_title("$site->shortname: $strcategories"); } } else { - $this->page->set_title("$site->shortname: ". $coursecat->get_formatted_name()); + $title = $site->shortname; + if (coursecat::count_all() > 1) { + $title .= ": ". $coursecat->get_formatted_name(); + } + $this->page->set_title($title); // Print the category selector - $output .= html_writer::start_tag('div', array('class' => 'categorypicker')); - $select = new single_select(new moodle_url('/course/index.php'), 'categoryid', - coursecat::make_categories_list(), $coursecat->id, null, 'switchcategory'); - $select->set_label(get_string('categories').':'); - $output .= $this->render($select); - $output .= html_writer::end_tag('div'); // .categorypicker + if (coursecat::count_all() > 1) { + $output .= html_writer::start_tag('div', array('class' => 'categorypicker')); + $select = new single_select(new moodle_url('/course/index.php'), 'categoryid', + coursecat::make_categories_list(), $coursecat->id, null, 'switchcategory'); + $select->set_label(get_string('categories').':'); + $output .= $this->render($select); + $output .= html_writer::end_tag('div'); // .categorypicker + } } // Print current category description