Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-75285

Course category entity in report builder does not work in left join

XMLWordPrintable

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • MDL-75285-master
    • Hide
      1. Create at least one course in the default category and one course in any other category
      2. Create a custom report (Site administration>Reports>Custom reports) from the "Courses" data source, add a course name there and all columns from the "Category" section
      3. Preview the report
      4. Make sure the report is displayed and all categories are shown
      5. Download the following diff to your moodle root folder (75285.diff):

        diff --git a/course/classes/reportbuilder/datasource/courses.php b/course/classes/reportbuilder/datasource/courses.php
        index 13dd4edf748..18f983b6388 100644
        --- a/course/classes/reportbuilder/datasource/courses.php
        +++ b/course/classes/reportbuilder/datasource/courses.php
        @@ -60,8 +60,8 @@ class courses extends datasource {
                 $coursecatentity = new course_category();
                 $coursecattablealias = $coursecatentity->get_table_alias('course_categories');
                 $this->add_entity($coursecatentity
        -            ->add_join("JOIN {course_categories} {$coursecattablealias}
        -                ON {$coursecattablealias}.id = {$coursetablealias}.category"));
        +            ->add_join("LEFT JOIN {course_categories} {$coursecattablealias}
        +                ON {$coursecattablealias}.id = {$coursetablealias}.category AND {$coursecattablealias}.id <> 1"));
         
                 // Add all columns/filters/conditions from entities to be available in custom reports.
                 $this->add_all_from_entity($coursecatentity->get_entity_name());
        

      6. Open a terminal and apply the diff.

        git apply 75285.diff
        

      7. Reload the report page and preview the report.
      8. Make sure the report does not show category information for the "Default" category and shows it for all others
      Show
      Create at least one course in the default category and one course in any other category Create a custom report (Site administration>Reports>Custom reports) from the "Courses" data source, add a course name there and all columns from the "Category" section Preview the report Make sure the report is displayed and all categories are shown Download the following diff to your moodle root folder ( 75285.diff ): diff --git a/course/classes/reportbuilder/datasource/courses.php b/course/classes/reportbuilder/datasource/courses.php index 13dd4edf748..18f983b6388 100644 --- a/course/classes/reportbuilder/datasource/courses.php +++ b/course/classes/reportbuilder/datasource/courses.php @@ -60,8 +60,8 @@ class courses extends datasource { $coursecatentity = new course_category(); $coursecattablealias = $coursecatentity->get_table_alias('course_categories'); $this->add_entity($coursecatentity - ->add_join("JOIN {course_categories} {$coursecattablealias} - ON {$coursecattablealias}.id = {$coursetablealias}.category")); + ->add_join("LEFT JOIN {course_categories} {$coursecattablealias} + ON {$coursecattablealias}.id = {$coursetablealias}.category AND {$coursecattablealias}.id <> 1")); // Add all columns/filters/conditions from entities to be available in custom reports. $this->add_all_from_entity($coursecatentity->get_entity_name()); Open a terminal and apply the diff. git apply 75285.diff Reload the report page and preview the report. Make sure the report does not show category information for the "Default" category and shows it for all others
    • WP 4.0 ES1 (TM)

      I have a datasource where there is a left join with courses entity and left join with categories entity, it throws exceptions such as:

      Exception - Argument 1 passed to core_course\local\entities\course_category::core_course\local\entities\{closure}() must be of the type string, null given, called in [dirroot]/reportbuilder/classes/local/report/column.php on line 686
      Error code: generalexceptionmessage
      * line 100 of /course/classes/local/entities/course_category.php: TypeError thrown
      * line 686 of /reportbuilder/classes/local/report/column.php: call to core_course\local\entities\course_category::core_course\local\entities\{closure}()
      * line 201 of /reportbuilder/classes/table/custom_report_table.php: call to core_reportbuilder\local\report\column->format_value()
      * line 2009 of /lib/tablelib.php: call to core_reportbuilder\table\custom_report_table->format_row()
      * line 2133 of /lib/tablelib.php: call to table_sql->build_table()
      * line 262 of /lib/table/classes/external/dynamic/get.php: call to table_sql->out()
      * line ? of unknownfile: call to core_table\external\dynamic\get::execute()
      * line 261 of /lib/externallib.php: call to call_user_func_array()
      * line 86 of /lib/ajax/service.php: call to external_api::call_external_function()
      

            marina Marina Glancy
            marina Marina Glancy
            Paul Holden Paul Holden
            Jun Pataleta Jun Pataleta
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 45 minutes
                3h 45m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.