protected function get_cohort_options($instance, $context) {
        global $DB, $CFG;

        require_once($CFG->dirroot . '/cohort/lib.php');

        $cohorts = array();

        if ($instance->id) {
            if ($cohort = $DB->get_record('cohort', array('id' => $instance->customint1))) {
                $name = format_string($cohort->name, true, array('context' => context::instance_by_id($cohort->contextid)));
                $cohorts = array($instance->customint1 => $name);
            } else {
                $cohorts = array($instance->customint1 => get_string('error'));
            }
        } else {
            $cohorts = array('' => get_string('choosedots'));
            $allcohorts = cohort_get_available_cohorts($context, 0, 0, 0);
            foreach ($allcohorts as $c) {
                $cohorts[$c->id] = format_string($c->name);
            }
        }
        return $cohorts;
    }
protected function get_cohort_options($instance, $context) {
        global $DB, $CFG;

        require_once($CFG->dirroot . '/cohort/lib.php');

        $cohorts = array();

        if ($instance->id) {
            if ($cohort = $DB->get_record('cohort', array('id' => $instance->customint1))) {
                $name = format_string($cohort->name, true, array('context' => context::instance_by_id($cohort->contextid)));
                $cohorts = array($instance->customint1 => $name);
            } else {
                $cohorts = array($instance->customint1 => get_string('error'));
            }
        } else {
            $cohorts = array('' => get_string('choosedots'));
            $allcohorts = cohort_get_available_cohorts($context, 0, 0, 0);
            foreach ($allcohorts as $c) {
                $cohorts[$c->id] = format_string($c->name);
            }
        }
        return $cohorts;
    }
protected function get_cohort_options ( $ instance , $ context ) { global $ DB , $ CFG ; require_once ( $ CFG -> dirroot . '/cohort/lib.php' ) ; $ cohorts = array ( ) ; if ( $ instance -> id ) { if ( $ cohort = $ DB -> get_record ( 'cohort' , array ( 'id' => $ instance -> customint1 ) ) ) { $ name = format_string ( $ cohort -> name , true , array ( 'context' => context :: instance_by_id ( $ cohort -> contextid ) ) ) ; $ cohorts = array ( $ instance -> customint1 => $ name ) ; } else { $ cohorts = array ( $ instance -> customint1 => get_string ( 'error' ) ) ; } } else { $ cohorts = array ( '' => get_string ( 'choosedots' ) ) ; $ allcohorts = cohort_get_available_cohorts ( $ context , 0 , 0 , 0 ) ; foreach ( $ allcohorts as $ c ) { $ cohorts [ $ c -> id ] = format_string ( $ c -> name ) ; } } return $ cohorts ; }
Return an array of valid options for the cohorts.

@param stdClass $instance
@param context $context
@return array
Return an array of valid options for the cohorts .