我正在尝试通过Using MOODLE create users and enroll them in courses via SQL
提出解决方案添加用户-完成
将用户添加到课程-完成
但是没有角色的用户会进入课程。角色列中没有角色。
“ googleoauth2”作为使用社交网络API登录的身份验证值。这是工作。 问题仍然存在,如果我将“ auth”值更改为“ manual”。
将数据库中的所有记录放入查询中。
请帮助。
UPD :抱歉,我需要在instanceid字段中将enlorID更改为courseID ...
代码:
for entry in glob(source_files_glob).expect("Failed to read glob pattern") {
match entry {
OK(path) => {
println!("{}", path.display());
let file_content = fs::read_to_string(path).expect("...");
println!("Content: {}", file_content);
}
Err(e) => {
// handle error
}
}
}
答案 0 :(得分:0)
通过查看您的代码,看起来您正在使用Javascript。 我有一种解决方案,可以使学生通过以下PHP编程语言来招收课程。
$plugin = enrol_get_plugin('manual');
$course = $DB->get_record('course', array('id' => $courseid)); // Get course object by courseid
$instance = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => 'manual'));
if (empty($instance)) {
// Only add an enrol instance to the course if non-existent.
$enrolid = $plugin->add_instance($course);
$instance = $DB->get_record('enrol', array('id' => $enrolid));
}
// Take care of timestart/timeend in course settings.
$timestart = time();
// Remove time part from the timestamp and keep only the date part.
$timestart = make_timestamp(date('Y', $timestart), date('m', $timestart), date('d', $timestart), 0, 0, 0);
if ($instance->enrolperiod) {
$timeend = $timestart + $instance->enrolperiod;
} else {
$timeend = 0;
}
// Enrol the user with this plugin instance.
$plugin->enrol_user($instance, $user->id, $roleid); // This will enroll user in course with roleid you provided.
希望这会帮助您解决问题。
谢谢。