From e98c64a6e1f6aa34b3e25c77c2e673e1906f7e43 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 6 Nov 2008 04:10:22 +0000 Subject: [PATCH] generator: Fix to use role_assign, rather than screwing with the role_assignments table directly. --- admin/generator.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/admin/generator.php b/admin/generator.php index 68a55b6b44..cb87a60732 100755 --- a/admin/generator.php +++ b/admin/generator.php @@ -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++; -- 2.39.5