我有一个带有 SSO 的 Moodle。
用户登录一个网站并点击一个链接来访问我的 Moodle。
当他们到达时,我想让他们参加我 Moodle 上的每门课程。
但是,我无法让 sql 工作。
这是我所拥有的:
$ra = new object();
$ra->roleid = 5;
$ra->contextid = $contextid;
$ra->userid = $user->id;
$ra->hidden = 0;
$ra->enrol = 'manual';
//$ra->enrol = 'self';
/// Always round timestart downto 100 secs to help DBs to use their own caching algorithms
/// by repeating queries with the same exact parameters in a 100 secs time window
$ra->timestart = 0;
$ra->timeend = 0;
$ra->timemodified = time();
$ra->modifierid = 0;
// Enrol the User for the Course
$ra->id = $DB->insert_record('role_assignments',$ra);