MDL-48390 cohorts: do not limit number of cohorts in dropdowns
authorMarina Glancy <marina@moodle.com>
Thu, 27 Nov 2014 03:14:39 +0000 (11:14 +0800)
committerMarina Glancy <marina@moodle.com>
Thu, 27 Nov 2014 03:14:39 +0000 (11:14 +0800)
enrol/cohort/edit_form.php
enrol/cohort/lib.php
enrol/manual/lib.php
enrol/self/edit_form.php
group/autogroup_form.php

index 21ec3d6..c7d0e2a 100644 (file)
@@ -65,7 +65,7 @@ class enrol_cohort_edit_form extends moodleform {
 
         } else {
             $cohorts = array('' => get_string('choosedots'));
-            $allcohorts = cohort_get_available_cohorts($coursecontext);
+            $allcohorts = cohort_get_available_cohorts($coursecontext, 0, 0, 0);
             foreach ($allcohorts as $c) {
                 $cohorts[$c->id] = format_string($c->name);
             }
index 0f338fb..1f5a221 100644 (file)
@@ -101,7 +101,7 @@ class enrol_cohort_plugin extends enrol_plugin {
         if (!has_capability('moodle/course:enrolconfig', $coursecontext) or !has_capability('enrol/cohort:config', $coursecontext)) {
             return false;
         }
-        return cohort_get_available_cohorts($coursecontext) ? true : false;
+        return cohort_get_available_cohorts($coursecontext, 0, 0, 1) ? true : false;
     }
 
     /**
index 34d4d30..4b035f3 100644 (file)
@@ -247,7 +247,7 @@ class enrol_manual_plugin extends enrol_plugin {
             'defaultDuration'     => $defaultduration,
             'disableGradeHistory' => $CFG->disablegradehistory,
             'recoverGradesDefault'=> '',
-            'cohortsAvailable'    => cohort_get_available_cohorts($manager->get_context(), COHORT_COUNT_MEMBERS, 0, 1) ? true : false
+            'cohortsAvailable'    => cohort_get_available_cohorts($manager->get_context(), COHORT_WITH_NOTENROLLED_MEMBERS_ONLY, 0, 1) ? true : false
         );
 
         if ($CFG->recovergradesdefault) {
index e33da18..a1e3a80 100644 (file)
@@ -106,7 +106,7 @@ class enrol_self_edit_form extends moodleform {
         $mform->setType('customint3', PARAM_INT);
 
         $cohorts = array(0 => get_string('no'));
-        $allcohorts = cohort_get_available_cohorts($context);
+        $allcohorts = cohort_get_available_cohorts($context, 0, 0, 0);
         if ($instance->customint5 && !isset($allcohorts[$instance->customint5]) &&
                 ($c = $DB->get_record('cohort', array('id' => $instance->customint5), 'id, name, idnumber, contextid, visible', IGNORE_MISSING))) {
             // Current cohort was not found because current user can not see it. Still keep it.
index df43b4f..a04da01 100644 (file)
@@ -82,7 +82,7 @@ class autogroup_form extends moodleform {
             $mform->setDefault('roleid', $student->id);
         }
 
-        if ($cohorts = cohort_get_available_cohorts(context_course::instance($COURSE->id), COHORT_WITH_ENROLLED_MEMBERS_ONLY)) {
+        if ($cohorts = cohort_get_available_cohorts(context_course::instance($COURSE->id), COHORT_WITH_ENROLLED_MEMBERS_ONLY, 0, 0)) {
             $options = array(0 => get_string('anycohort', 'cohort'));
             foreach ($cohorts as $c) {
                 $options[$c->id] = format_string($c->name, true, context::instance_by_id($c->contextid));