generator: Fix to use role_assign, rather than screwing with the role_assignments table directly.

This commit is contained in:
tjhunt
2008-11-06 04:10:22 +00:00
parent abf1c50ff6
commit e98c64a6e1
+2 -10
View File
@@ -673,17 +673,9 @@ class generator {
shuffle($users);
$users_to_assign = array_slice($users, 0, $this->get('students_per_course'));
$context = get_context_instance(CONTEXT_COURSE, $courseid);
foreach ($users_to_assign as $random_user) {
$context = get_context_instance(CONTEXT_COURSE, $courseid);
$newra = new stdClass();
$newra->roleid = 5; // Student role
$newra->contextid = $context->id;
$newra->userid = $random_user;
$newra->hidden = 0;
$newra->enrol = 1;
$success = $DB->insert_record('role_assignments', $newra);
$success = role_assign(5, $random_user, 0, $context->id);
if ($success) {
$assigned_count++;