Report Sources

Documentation:

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.

 /**
     * 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

Things to pay attention to when using required columns: