Differences

This shows you the differences between two versions of the page.

Link to this comparison view

totara:report_sources [2017/07/12 11:04]
totara:report_sources [2016/05/20 10:02] (current)
onno [Report Sources]
Line 1: Line 1:
 +====== Report Sources ======
 +Documentation:
 +  * [[https://docs.moodle.org/dev/reportbuilder|https://docs.moodle.org/dev/reportbuilder]]
 +  * [[https://docs.moodle.org/dev/reportbuilder/API|https://docs.moodle.org/dev/reportbuilder/API]]
 +
 +Please note that the moodle.org documentation is neither complete nor entirely up to date, since it is about a project meant to port the Totara report builder to Moodle.
 +===== Required Columns =====
 +Required columns are not like default columns. There's an asymmetry here, because the defaultcolumns are defined by just listing the existing columns in the defaultcolumns array. For the required columns, you have to actually **define** them in the context of a requiredcolumns array.
 +<code>
 + /**
 +     * Defines the columns that a report must have if it is created from this source
 +     *
 +     * @return array An array of required columns.
 +     */
 +    protected function define_requiredcolumns() {
 +        $requiredcolumns = array(
 +            new rb_column(
 +                'learning_points',
 +                'points_spent',
 +                get_string('points_spent', 'rb_source_learning_points'),
 +                'points_spent.total',
 +                array(
 +                    'joins' => 'points_spent',
 +                    'hidden' => 1
 +                )
 +            )
 +        );
 +        return $requiredcolumns;
 +    } // function define_requiredcolumns
 +</code>
 +
 +
 +Things to pay attention to when using required columns:
 +  * Use rb_column class (instead of rb_column_option)
 +  * Don’t define the column elsewhere
 +  * Use the hidden option if you don’t want the column to show up in the report (but you still need the data)
 +  * It looks as though you can’t define filters for required columns… (I haven’t found out how, at least). If you use the standard way of defining filters, Totara will complain that it can’t find the “column option” - no wonder, it’s not an option, it’s required.
  

Personal Tools