$outcome->response = array_reverse($manager->get_assignable_roles($otheruserroles), true); break; case 'getdefaultcohortrole': //TODO: use in ajax UI MDL-24280 $cohortenrol = enrol_get_plugin('cohort'); $outcome->response = $cohortenrol->get_config('roleid'); break; case 'getcohorts': require_capability('moodle/course:enrolconfig', $context); $outcome->response = $manager->get_cohorts(); break; case 'enrolcohort': require_capability('moodle/course:enrolconfig', $context); $roleid = required_param('roleid', PARAM_INT); $cohortid = required_param('cohortid', PARAM_INT); if (!$manager->enrol_cohort($cohortid, $roleid)) { throw new enrol_ajax_exception('errorenrolcohort'); } break; case 'enrolcohortusers': require_capability('moodle/course:enrolconfig', $context); $roleid = required_param('roleid', PARAM_INT); $cohortid = required_param('cohortid', PARAM_INT); $result = $manager->enrol_cohort_users($cohortid, $roleid); if ($result === false) { throw new enrol_ajax_exception('errorenrolcohortusers'); } $outcome->success = true; $outcome->response->users = $result; $outcome->response->title = get_string('success'); $outcome->response->message = get_string('enrollednewusers', 'enrol', $result);