本文整理汇总了PHP中enrol_cohort_sync函数的典型用法代码示例。如果您正苦于以下问题:PHP enrol_cohort_sync函数的具体用法?PHP enrol_cohort_sync怎么用?PHP enrol_cohort_sync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enrol_cohort_sync函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enroluserincourse
/**
*
* @param type $user
* @param type $course
* @param type $cohort
* @param type $mode
*/
private function enroluserincourse($course, $cohort, $mode)
{
$enrol = enrol_get_plugin('cohort');
$instance = array();
$instance['name'] = 'name';
$instance['status'] = ENROL_INSTANCE_ENABLED;
// Enable it.
$instance['customint1'] = $cohort->id;
// Used to store the cohort id.
$teacherroleid = $enrol->get_config('roleid');
if ($mode == 'teacher') {
$teacherroleid = G\getteacherroleid();
}
$instance['roleid'] = $teacherroleid;
$instance['customint2'] = 0;
// Optional group id.
$enrol->add_instance($course, $instance);
$trace = new null_progress_trace();
enrol_cohort_sync($trace, $course->id);
$trace->finished();
}
示例2: test_student_courses
/**
* @runInSeparateProcess
*/
public function test_student_courses()
{
$this->resetAfterTest(true);
$user = $this->getDataGenerator()->create_user();
$row = array();
$row['user_id'] = $user->id;
$row['email'] = null;
$row['timestamp'] = time();
G\addvaliduser($row);
$this->setUser($user);
$course = $this->getDataGenerator()->create_course();
$cohort = $this->getDataGenerator()->create_cohort(array('idnumber' => 1234.56789));
cohort_add_member($cohort->id, $user->id);
G\addtermid('1234');
$enrol = enrol_get_plugin('cohort');
$instance = array();
$instance['name'] = 'name';
$instance['status'] = ENROL_INSTANCE_ENABLED;
// Enable it.
$instance['customint1'] = $cohort->id;
// Used to store the cohort id.
$instance['roleid'] = $enrol->get_config('roleid');
// Default role for cohort enrol which is usually student.
$instance['customint2'] = 0;
// Optional group id.
$enrol->add_instance($course, $instance);
$trace = new null_progress_trace();
enrol_cohort_sync($trace, $course->id);
$trace->finished();
$courses = G\coursesas($user->id, 'student');
$courseids = array();
foreach ($courses as $newcourse) {
array_push($courseids, $newcourse->id);
}
$this->assertContains($course->id, $courseids);
}
示例3: restore_instance
/**
* Restore instance and map settings.
*
* @param restore_enrolments_structure_step $step
* @param stdClass $data
* @param stdClass $course
* @param int $oldid
*/
public function restore_instance(restore_enrolments_structure_step $step, stdClass $data, $course, $oldid)
{
global $DB, $CFG;
if (!$step->get_task()->is_samesite()) {
// No cohort restore from other sites.
$step->set_mapping('enrol', $oldid, 0);
return;
}
if (!empty($data->customint2)) {
$data->customint2 = $step->get_mappingid('group', $data->customint2);
}
if ($data->roleid and $DB->record_exists('cohort', array('id' => $data->customint1))) {
$instance = $DB->get_record('enrol', array('roleid' => $data->roleid, 'customint1' => $data->customint1, 'courseid' => $course->id, 'enrol' => $this->get_name()));
if ($instance) {
$instanceid = $instance->id;
} else {
$instanceid = $this->add_instance($course, (array) $data);
}
$step->set_mapping('enrol', $oldid, $instanceid);
require_once "{$CFG->dirroot}/enrol/cohort/locallib.php";
$trace = new null_progress_trace();
enrol_cohort_sync($trace, $course->id);
$trace->finished();
} else {
if ($this->get_config('unenrolaction') == ENROL_EXT_REMOVED_SUSPENDNOROLES) {
$data->customint1 = 0;
$instance = $DB->get_record('enrol', array('roleid' => $data->roleid, 'customint1' => $data->customint1, 'courseid' => $course->id, 'enrol' => $this->get_name()));
if ($instance) {
$instanceid = $instance->id;
} else {
$data->status = ENROL_INSTANCE_DISABLED;
$instanceid = $this->add_instance($course, (array) $data);
}
$step->set_mapping('enrol', $oldid, $instanceid);
require_once "{$CFG->dirroot}/enrol/cohort/locallib.php";
$trace = new null_progress_trace();
enrol_cohort_sync($trace, $course->id);
$trace->finished();
} else {
$step->set_mapping('enrol', $oldid, 0);
}
}
}
示例4: process_course_cohort_membership_node
private function process_course_cohort_membership_node($membershipnode, $xpath, $role = '01')
{
global $DB, $CFG;
$idnumber = $xpath->evaluate("sourcedid/id", $membershipnode)->item(0);
$course = $DB->get_record('course', array('idnumber' => $idnumber->nodeValue), '*', MUST_EXIST);
$members = $xpath->evaluate("member", $membershipnode);
foreach ($members as $mmember) {
$midnumber = $xpath->evaluate("sourcedid/id", $mmember)->item(0);
$idtype = $xpath->evaluate("idtype", $mmember)->item(0);
if ($midnumber) {
$member = new stdClass();
$member->idnumber = $midnumber->nodeValue;
$cohortid = $DB->get_field('cohort', 'id', array('idnumber' => $member->idnumber));
$cohortname = $DB->get_field('cohort', 'name', array('idnumber' => $member->idnumber));
if ($idtype->nodeValue == 'Add' && $cohortid) {
if (!($cohortinstanceid = $DB->get_field('enrol', 'id', array('enrol' => 'cohort', 'customint1' => $cohortid, 'courseid' => $course->id)))) {
$enrol = enrol_get_plugin('cohort');
$enrol->add_instance($course, array('name' => $cohortname, 'status' => 0, 'customint1' => $cohortid, 'roleid' => 5, 'customint2' => 0));
$trace = new null_progress_trace();
enrol_cohort_sync($trace, $course->id);
$trace->finished();
}
if (substr($idnumber->nodeValue, 0, 8) == 'UOFAB-XL') {
$data = new stdClass();
if (!($data->id = $DB->get_field('groups', 'id', array('courseid' => $course->id, 'name' => $cohortname)))) {
$data->timecreated = time();
$data->timemodified = time();
$data->name = trim($cohortname);
$data->description = '';
$data->descriptionformat = '1';
$data->courseid = $course->id;
$data->id = groups_create_group($data);
}
$cohortrec = $DB->get_fieldset_select('cohort_members', 'userid', 'cohortid=' . $cohortid);
foreach ($cohortrec as $curmember) {
$latestlist[$curmember] = $curmember;
groups_add_member($data->id, $curmember);
}
$grouprec = $DB->get_fieldset_select('groups_members', 'userid', 'groupid=' . $data->id);
foreach ($grouprec as $grpmember) {
if (!isset($latestlist[$grpmember])) {
groups_remove_member($data->id, $grpmember);
}
}
}
} else {
if ($idtype->nodeValue == 'Delete') {
if ($cohortinstance = $DB->get_record('enrol', array('enrol' => 'cohort', 'customint1' => $cohortid, 'courseid' => $course->id))) {
$enrol = enrol_get_plugin('cohort');
$enrol->delete_instance($cohortinstance);
}
}
}
}
}
}
示例5: enrol_cohort
/**
* Enrols a cohort in a course.
*
* Essentially this just adds a cohort enrolment plugin instance to the course
*
* @param int $cohortid
* @param int $roleid
* @return bool
*/
public function enrol_cohort($cohortid, $roleid) {
global $CFG;
require_capability('moodle/course:enrolconfig', $this->get_context());
require_once($CFG->dirroot.'/enrol/cohort/locallib.php');
$roles = $this->get_assignable_roles();
$cohorts = $this->get_cohorts();
if (!array_key_exists($cohortid, $cohorts) || !array_key_exists($roleid, $roles)) {
return false;
}
$enrol = enrol_get_plugin('cohort');
$enrol->add_instance($this->course, array('customint1'=>$cohortid, 'roleid'=>$roleid));
enrol_cohort_sync($this->course->id);
return true;
}
示例6: test_sync_all_courses
public function test_sync_all_courses()
{
global $DB;
$this->resetAfterTest();
$trace = new null_progress_trace();
// Setup a few courses and categories.
$cohortplugin = enrol_get_plugin('cohort');
$manualplugin = enrol_get_plugin('manual');
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
$this->assertNotEmpty($studentrole);
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
$this->assertNotEmpty($teacherrole);
$managerrole = $DB->get_record('role', array('shortname' => 'manager'));
$this->assertNotEmpty($managerrole);
$cat1 = $this->getDataGenerator()->create_category();
$cat2 = $this->getDataGenerator()->create_category();
$course1 = $this->getDataGenerator()->create_course(array('category' => $cat1->id));
$course2 = $this->getDataGenerator()->create_course(array('category' => $cat1->id));
$course3 = $this->getDataGenerator()->create_course(array('category' => $cat2->id));
$course4 = $this->getDataGenerator()->create_course(array('category' => $cat2->id));
$maninstance1 = $DB->get_record('enrol', array('courseid' => $course1->id, 'enrol' => 'manual'), '*', MUST_EXIST);
$user1 = $this->getDataGenerator()->create_user();
$user2 = $this->getDataGenerator()->create_user();
$user3 = $this->getDataGenerator()->create_user();
$user4 = $this->getDataGenerator()->create_user();
$cohort1 = $this->getDataGenerator()->create_cohort(array('contextid' => context_coursecat::instance($cat1->id)->id));
$cohort2 = $this->getDataGenerator()->create_cohort(array('contextid' => context_coursecat::instance($cat2->id)->id));
$cohort3 = $this->getDataGenerator()->create_cohort();
$this->disable_plugin();
// Prevents event sync.
$manualplugin->enrol_user($maninstance1, $user4->id, $teacherrole->id);
$manualplugin->enrol_user($maninstance1, $user3->id, $managerrole->id);
$this->assertEquals(2, $DB->count_records('role_assignments', array()));
$this->assertEquals(2, $DB->count_records('user_enrolments', array()));
$id = $cohortplugin->add_instance($course1, array('customint1' => $cohort1->id, 'roleid' => $studentrole->id));
$cohortinstance1 = $DB->get_record('enrol', array('id' => $id));
$id = $cohortplugin->add_instance($course1, array('customint1' => $cohort2->id, 'roleid' => $teacherrole->id));
$cohortinstance2 = $DB->get_record('enrol', array('id' => $id));
$id = $cohortplugin->add_instance($course2, array('customint1' => $cohort2->id, 'roleid' => $studentrole->id));
$cohortinstance3 = $DB->get_record('enrol', array('id' => $id));
cohort_add_member($cohort1->id, $user1->id);
cohort_add_member($cohort1->id, $user2->id);
cohort_add_member($cohort1->id, $user4->id);
cohort_add_member($cohort2->id, $user3->id);
cohort_add_member($cohort3->id, $user3->id);
$this->assertEquals(2, $DB->count_records('role_assignments', array()));
$this->assertEquals(2, $DB->count_records('user_enrolments', array()));
// Test sync of one course only.
enrol_cohort_sync($trace, null);
$this->assertEquals(2, $DB->count_records('role_assignments', array()));
$this->assertEquals(2, $DB->count_records('user_enrolments', array()));
$this->enable_plugin();
enrol_cohort_sync($trace, null);
$this->assertEquals(7, $DB->count_records('user_enrolments', array()));
$this->assertTrue($DB->record_exists('user_enrolments', array('enrolid' => $cohortinstance1->id, 'userid' => $user1->id)));
$this->assertTrue($DB->record_exists('user_enrolments', array('enrolid' => $cohortinstance1->id, 'userid' => $user2->id)));
$this->assertTrue($DB->record_exists('user_enrolments', array('enrolid' => $cohortinstance1->id, 'userid' => $user4->id)));
$this->assertTrue($DB->record_exists('user_enrolments', array('enrolid' => $cohortinstance2->id, 'userid' => $user3->id)));
$this->assertEquals(7, $DB->count_records('role_assignments', array()));
$this->assertTrue($DB->record_exists('role_assignments', array('contextid' => context_course::instance($course1->id)->id, 'userid' => $user1->id, 'roleid' => $studentrole->id, 'component' => 'enrol_cohort', 'itemid' => $cohortinstance1->id)));
$this->assertTrue($DB->record_exists('role_assignments', array('contextid' => context_course::instance($course1->id)->id, 'userid' => $user2->id, 'roleid' => $studentrole->id, 'component' => 'enrol_cohort', 'itemid' => $cohortinstance1->id)));
$this->assertTrue($DB->record_exists('role_assignments', array('contextid' => context_course::instance($course1->id)->id, 'userid' => $user4->id, 'roleid' => $studentrole->id, 'component' => 'enrol_cohort', 'itemid' => $cohortinstance1->id)));
$this->assertTrue($DB->record_exists('role_assignments', array('contextid' => context_course::instance($course1->id)->id, 'userid' => $user3->id, 'roleid' => $teacherrole->id, 'component' => 'enrol_cohort', 'itemid' => $cohortinstance2->id)));
$cohortplugin->set_config('unenrolaction', ENROL_EXT_REMOVED_SUSPENDNOROLES);
$DB->delete_records('cohort_members', array('cohortid' => $cohort2->id, 'userid' => $user3->id));
// Use low level DB api to prevent events!
enrol_cohort_sync($trace, $course1->id);
$this->assertEquals(7, $DB->count_records('user_enrolments', array()));
$this->assertEquals(6, $DB->count_records('role_assignments', array()));
$this->assertFalse($DB->record_exists('role_assignments', array('contextid' => context_course::instance($course1->id)->id, 'userid' => $user3->id, 'roleid' => $teacherrole->id, 'component' => 'enrol_cohort', 'itemid' => $cohortinstance2->id)));
$cohortplugin->set_config('unenrolaction', ENROL_EXT_REMOVED_UNENROL);
$DB->delete_records('cohort_members', array('cohortid' => $cohort1->id, 'userid' => $user1->id));
// Use low level DB api to prevent events!
enrol_cohort_sync($trace, $course1->id);
$this->assertEquals(5, $DB->count_records('user_enrolments', array()));
$this->assertFalse($DB->record_exists('user_enrolments', array('enrolid' => $cohortinstance2->id, 'userid' => $user3->id)));
$this->assertFalse($DB->record_exists('user_enrolments', array('enrolid' => $cohortinstance1->id, 'userid' => $user1->id)));
$this->assertEquals(5, $DB->count_records('role_assignments', array()));
$this->assertFalse($DB->record_exists('role_assignments', array('contextid' => context_course::instance($course1->id)->id, 'userid' => $user3->id, 'roleid' => $teacherrole->id, 'component' => 'enrol_cohort', 'itemid' => $cohortinstance2->id)));
$this->assertFalse($DB->record_exists('role_assignments', array('contextid' => context_course::instance($course1->id)->id, 'userid' => $user1->id, 'roleid' => $studentrole->id, 'component' => 'enrol_cohort', 'itemid' => $cohortinstance1->id)));
$cohortplugin->set_config('unenrolaction', ENROL_EXT_REMOVED_SUSPENDNOROLES);
$DB->delete_records('cohort_members', array('cohortid' => $cohort1->id));
// Use low level DB api to prevent events!
$DB->delete_records('cohort', array('id' => $cohort1->id));
// Use low level DB api to prevent events!
enrol_cohort_sync($trace, $course1->id);
$this->assertEquals(5, $DB->count_records('user_enrolments', array()));
$this->assertEquals(3, $DB->count_records('role_assignments', array()));
$cohortplugin->set_config('unenrolaction', ENROL_EXT_REMOVED_UNENROL);
enrol_cohort_sync($trace, $course1->id);
$this->assertEquals(3, $DB->count_records('user_enrolments', array()));
$this->assertEquals(3, $DB->count_records('role_assignments', array()));
// Test group sync.
$this->disable_plugin();
// No event sync
// Trigger sync to remove extra role assignments.
enrol_cohort_sync($trace, $course1->id);
$this->assertEquals(2, $DB->count_records('role_assignments', array()));
$id = groups_create_group((object) array('name' => 'Group 1', 'courseid' => $course1->id));
$group1 = $DB->get_record('groups', array('id' => $id), '*', MUST_EXIST);
//.........这里部分代码省略.........
示例7: update_status
/**
* Update instance status
*
* @param stdClass $instance
* @param int $newstatus ENROL_INSTANCE_ENABLED, ENROL_INSTANCE_DISABLED
* @return void
*/
public function update_status($instance, $newstatus)
{
global $CFG;
parent::update_status($instance, $newstatus);
require_once "{$CFG->dirroot}/enrol/cohort/locallib.php";
enrol_cohort_sync($instance->courseid);
}
示例8: optional_param
$offset = optional_param('offset', 0, PARAM_INT);
$search = optional_param('search', '', PARAM_RAW);
$outcome->response = enrol_cohort_search_cohorts($manager, $offset, 25, $search);
break;
case 'enrolcohort':
require_capability('moodle/course:enrolconfig', $context);
require_capability('enrol/cohort:config', $context);
$roleid = required_param('roleid', PARAM_INT);
$cohortid = required_param('cohortid', PARAM_INT);
$roles = $manager->get_assignable_roles();
if (!enrol_cohort_can_view_cohort($cohortid) || !array_key_exists($roleid, $roles)) {
throw new enrol_ajax_exception('errorenrolcohort');
}
$enrol = enrol_get_plugin('cohort');
$enrol->add_instance($manager->get_course(), array('customint1' => $cohortid, 'roleid' => $roleid));
enrol_cohort_sync($manager->get_course()->id);
break;
case 'enrolcohortusers':
require_capability('enrol/manual:enrol', $context);
$roleid = required_param('roleid', PARAM_INT);
$cohortid = required_param('cohortid', PARAM_INT);
$result = enrol_cohort_enrol_all_users($manager, $cohortid, $roleid);
$roles = $manager->get_assignable_roles();
if (!enrol_cohort_can_view_cohort($cohortid) || !array_key_exists($roleid, $roles)) {
throw new enrol_ajax_exception('errorenrolcohort');
}
if ($result === false) {
throw new enrol_ajax_exception('errorenrolcohortusers');
}
$outcome->success = true;
$outcome->response->users = $result;
示例9: require_login
$context = context_course::instance($course->id, MUST_EXIST);
require_login($course);
require_capability('moodle/course:enrolconfig', $context);
require_capability('enrol/cohort:config', $context);
$PAGE->set_url('/enrol/cohort/addinstance.php', array('id' => $course->id));
$PAGE->set_pagelayout('admin');
navigation_node::override_active_url(new moodle_url('/enrol/instances.php', array('id' => $course->id)));
// Try and make the manage instances node on the navigation active.
$courseadmin = $PAGE->settingsnav->get('courseadmin');
if ($courseadmin && $courseadmin->get('users') && $courseadmin->get('users')->get('manageinstances')) {
$courseadmin->get('users')->get('manageinstances')->make_active();
}
$enrol = enrol_get_plugin('cohort');
if (!$enrol->get_newinstance_link($course->id)) {
redirect(new moodle_url('/enrol/instances.php', array('id' => $course->id)));
}
$mform = new enrol_cohort_addinstance_form(NULL, $course);
if ($mform->is_cancelled()) {
redirect(new moodle_url('/enrol/instances.php', array('id' => $course->id)));
} else {
if ($data = $mform->get_data()) {
$enrol->add_instance($course, array('customint1' => $data->cohortid, 'roleid' => $data->roleid));
enrol_cohort_sync($course->id);
redirect(new moodle_url('/enrol/instances.php', array('id' => $course->id)));
}
}
$PAGE->set_heading($course->fullname);
$PAGE->set_title(get_string('pluginname', 'enrol_cohort'));
echo $OUTPUT->header();
$mform->display();
echo $OUTPUT->footer();
示例10: define
* - it is required to use the web server account when executing PHP CLI scripts
* - you need to change the "www-data" to match the apache user account
* - use "su" if "sudo" not available
*
* @package enrol_cohort
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require __DIR__ . '/../../../config.php';
require_once "{$CFG->libdir}/clilib.php";
require_once "{$CFG->dirroot}/enrol/cohort/locallib.php";
// Now get cli options.
list($options, $unrecognized) = cli_get_params(array('verbose' => false, 'help' => false), array('v' => 'verbose', 'h' => 'help'));
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
if ($options['help']) {
$help = "Execute cohort course enrol sync.\n\nOptions:\n-v, --verbose Print verbose progess information\n-h, --help Print out this help\n\nExample:\n\$ sudo -u www-data /usr/bin/php enrol/cohort/cli/sync.php\n";
echo $help;
die;
}
if (empty($options['verbose'])) {
$trace = new null_progress_trace();
} else {
$trace = new text_progress_trace();
}
$result = enrol_cohort_sync($trace, null);
$trace->finished();
exit($result);
示例11: require_capability
}
$DB->update_record('enrol', $instance);
\core\event\enrol_instance_updated::create_from_record($instance)->trigger();
} else {
// Create a new group for the cohort if requested.
if ($data->customint2 == COHORT_CREATE_GROUP) {
require_capability('moodle/course:managegroups', $context);
$groupid = enrol_cohort_create_new_group($course->id, $data->customint1);
$enrol->add_instance($course, array('name' => $data->name, 'status' => $data->status, 'customint1' => $data->customint1, 'roleid' => $data->roleid, 'customint2' => $groupid));
} else {
$enrol->add_instance($course, array('name' => $data->name, 'status' => $data->status, 'customint1' => $data->customint1, 'roleid' => $data->roleid, 'customint2' => $data->customint2));
}
if (!empty($data->submitbuttonnext)) {
$returnurl = new moodle_url($PAGE->url);
$returnurl->param('message', 'added');
}
}
$trace = new null_progress_trace();
enrol_cohort_sync($trace, $course->id);
$trace->finished();
redirect($returnurl);
}
}
$PAGE->set_heading($course->fullname);
$PAGE->set_title(get_string('pluginname', 'enrol_cohort'));
echo $OUTPUT->header();
if ($message === 'added') {
echo $OUTPUT->notification(get_string('instanceadded', 'enrol'), 'notifysuccess');
}
$mform->display();
echo $OUTPUT->footer();
示例12: define
/**
* CLI sync for cohort enrolments, use for debugging or immediate sync
* of all courses.
*
* Notes:
* - it is required to use the web server account when executing PHP CLI scripts
* - you need to change the "www-data" to match the apache user account
* - use "su" if "sudo" not available
*
* @package enrol_cohort
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php';
require_once $CFG->libdir . '/clilib.php';
require_once "{$CFG->dirroot}/enrol/cohort/locallib.php";
// Now get cli options.
list($options, $unrecognized) = cli_get_params(array('verbose' => false, 'help' => false), array('v' => 'verbose', 'h' => 'help'));
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
if ($options['help']) {
$help = "Execute cohort course enrol sync.\n\nOptions:\n-v, --verbose Print verbose progess information\n-h, --help Print out this help\n\nExample:\n\$sudo -u www-data /usr/bin/php enrol/cohort/cli/sync.php\n";
echo $help;
die;
}
$verbose = !empty($options['verbose']);
$result = enrol_cohort_sync(null, $verbose);
exit($result);
示例13: course_updated
/**
* Called after updating/inserting course.
*
* @param bool $inserted true if course just inserted
* @param object $course
* @param object $data form data
* @return void
*/
public function course_updated($inserted, $course, $data) {
global $CFG;
if (!$inserted) {
// sync cohort enrols
require_once("$CFG->dirroot/enrol/cohort/locallib.php");
enrol_cohort_sync($course->id);
} else {
// cohorts are never inserted automatically
}
}
示例14: enrol_cohort_sync
protected function enrol_cohort_sync($courseid)
{
$trace = new \null_progress_trace();
enrol_cohort_sync($trace, $courseid);
$trace->finished();
}
示例15: enrol_cohort_sync
/**
* Sync all cohort course links.
*
* @return int 0 means ok, 1 means error, 2 means plugin disabled
*/
public static final function enrol_cohort_sync()
{
global $CFG;
require_once $CFG->dirroot . '/enrol/cohort/locallib.php';
if ($CFG->version < 2013051400) {
return enrol_cohort_sync();
} else {
$trace = new \null_progress_trace();
return enrol_cohort_sync($trace);
}
}