diff --git a/course/classes/local/entities/course_category.php b/course/classes/local/entities/course_category.php index 15191169b2e91..3398feab613f3 100644 --- a/course/classes/local/entities/course_category.php +++ b/course/classes/local/entities/course_category.php @@ -99,6 +99,21 @@ protected function get_all_columns(): array { ->add_fields("{$tablealias}.name") ->set_is_sortable(true); + // Path column. + $columns[] = (new column( + 'path', + new lang_string('categorypath'), + $this->get_entity_name() + )) + ->add_joins($this->get_joins()) + ->set_type(column::TYPE_TEXT) + ->add_fields("{$tablealias}.name, {$tablealias}.id") + ->add_callback(static function(string $name, stdClass $category): string { + return core_course_category::get($category->id, MUST_EXIST, true)->get_nested_name(false); + }) + ->set_disabled_aggregation(['groupconcat', 'groupconcatdistinct']) + ->set_is_sortable(true); + // ID number column. $columns[] = (new column( 'idnumber', diff --git a/lang/en/moodle.php b/lang/en/moodle.php index d3913ab83624a..787aac3a05c07 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -243,6 +243,7 @@ $string['categoryhidden'] = '(hidden)'; $string['categorymodifiedcancel'] = 'Category was modified! Please cancel and try again.'; $string['categoryname'] = 'Category name'; +$string['categorypath'] = 'Category path'; $string['categorysubcategoryof'] = '{$a->category} - subcategory of {$a->parentcategory}'; $string['idnumbercoursecategory'] = 'Category ID number'; $string['idnumbercoursecategory_help'] = 'The ID number of a course category is only used when matching the category against external systems and is not displayed anywhere on the site. If the category has an official code name it may be entered, otherwise the field can be left blank.'; diff --git a/reportbuilder/classes/local/entities/course.php b/reportbuilder/classes/local/entities/course.php index 6fe60c82eb312..13927a3a5e22d 100644 --- a/reportbuilder/classes/local/entities/course.php +++ b/reportbuilder/classes/local/entities/course.php @@ -20,7 +20,6 @@ use context_course; use context_helper; -use core_course_category; use core_reportbuilder\local\filters\boolean_select; use core_reportbuilder\local\filters\course_selector; use core_reportbuilder\local\filters\date; @@ -124,7 +123,6 @@ protected function get_course_fields(): array { return [ 'fullname' => new lang_string('fullnamecourse'), 'shortname' => new lang_string('shortnamecourse'), - 'category' => new lang_string('coursecategory'), 'idnumber' => new lang_string('idnumbercourse'), 'summary' => new lang_string('coursesummary'), 'format' => new lang_string('format'), @@ -177,7 +175,6 @@ protected function get_course_field_type(string $coursefield): int { case 'summary': $fieldtype = column::TYPE_LONGTEXT; break; - case 'category': case 'groupmode': $fieldtype = column::TYPE_INTEGER; break; @@ -356,15 +353,6 @@ public static function get_options_for_groupmode(): array { ]; } - /** - * List of options for the field category. - * - * @return array - */ - public static function get_options_for_category(): array { - return core_course_category::make_categories_list('moodle/category:viewcourselist'); - } - /** * List of options for the field format. * diff --git a/reportbuilder/tests/local/entities/course_test.php b/reportbuilder/tests/local/entities/course_test.php index 884e4d8d05b20..8d4ee0ffef73a 100644 --- a/reportbuilder/tests/local/entities/course_test.php +++ b/reportbuilder/tests/local/entities/course_test.php @@ -44,7 +44,7 @@ * @copyright 2021 David Matamoros * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class course_testcase extends advanced_testcase { +class course_test extends advanced_testcase { /** * Load required classes @@ -142,7 +142,6 @@ public function test_get_columns_with_callbacks(): void { }); $courserow = reset($courserows); - $this->assertEquals($coursecategory1->name, $courserow['category']); $this->assertEquals('Course 1', $courserow['fullname']); $this->assertEquals('C1', $courserow['shortname']); $this->assertEquals('IDNumber1', $courserow['idnumber']); @@ -227,16 +226,6 @@ public function test_filters(): void { 'Course 1', ], array_column($tablerows, 'fullname')); - // Filter by category field. - $filtervalues = [ - 'course:category_operator' => select::EQUAL_TO, - 'course:category_value' => $coursecategory1->id, - ]; - $tablerows = $this->get_report_table_rows($filtervalues); - $this->assertEquals([ - 'Course 1', - ], array_column($tablerows, 'fullname')); - // Filter by group mode field. $filtervalues = [ 'course:groupmode_operator' => select::EQUAL_TO,