本文整理汇总了PHP中course_enrolment_manager::get_cohorts方法的典型用法代码示例。如果您正苦于以下问题:PHP course_enrolment_manager::get_cohorts方法的具体用法?PHP course_enrolment_manager::get_cohorts怎么用?PHP course_enrolment_manager::get_cohorts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类course_enrolment_manager
的用法示例。
在下文中一共展示了course_enrolment_manager::get_cohorts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
throw new enrol_ajax_exception('assignnotpermitted');
}
$outcome->response->roleid = $roleid;
break;
case 'getassignable':
$otheruserroles = optional_param('otherusers', false, PARAM_BOOL);
$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) {
示例2:
throw new enrol_ajax_exception('assignnotpermitted');
}
$outcome->response->roleid = $roleid;
break;
case 'getassignable':
$otheruserroles = optional_param('otherusers', false, PARAM_BOOL);
$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);
require_capability('enrol/cohort:config', $context);
$roleid = required_param('roleid', PARAM_INT);
if (!array_key_exists($roleid, $manager->get_assignable_roles())) {
throw new enrol_ajax_exception('invalidrole');
}
$cohortid = required_param('cohortid', PARAM_INT);
if (!array_key_exists($cohortid, $manager->get_cohorts())) {
throw new enrol_ajax_exception('errorenrolcohort');
}
if (!$manager->enrol_cohort($cohortid, $roleid)) {
throw new enrol_ajax_exception('errorenrolcohort');
}