public function definition_after_data() {

        $mform = $this->_form;

        // The default end date depends on the course format.
        $format = course_get_format((object)array('format' => get_config('moodlecourse', 'format')));

        // Check if course end date form field should be enabled by default.
        // If a default date is provided to the form element, it is magically enabled by default in the
        // MoodleQuickForm_date_time_selector class, otherwise it's disabled by default.
        if (get_config('moodlecourse', 'courseenddateenabled')) {
            $enddate = $format->get_default_course_enddate($mform, array('startdate' => 'defaults[startdate]'));
            $mform->setDefault('defaults[enddate]', $enddate);
        }
    }