public function get($key) {
        if ($key != 'course') {
            return parent::get($key);
        }
        global $DB;
        if (empty($this->course)) {
            $this->course = $DB->get_record('course', array('id' => $this->cm->course));
        }
        return $this->course;
    }
public function get($key) {
        if ($key != 'course') {
            return parent::get($key);
        }
        global $DB;
        if (empty($this->course)) {
            $this->course = $DB->get_record('course', array('id' => $this->cm->course));
        }
        return $this->course;
    }
public function get ( $ key ) { if ( $ key != 'course' ) { return parent :: get ( $ key ) ; } global $ DB ; if ( empty ( $ this -> course ) ) { $ this -> course = $ DB -> get_record ( 'course' , array ( 'id' => $ this -> cm -> course ) ) ; } return $ this -> course ; }
Override the parent get function
to make sure when we're asked for a course,
We retrieve the object from the database as needed.

@param string $key the name of get function
@return stdClass
Override the parent get function to make sure when we re asked for a course We retrieve the object from the database as needed .