$dbtables = $db->MetaTables('TABLES');
+/// Set up the progress bar
+
+ $usertables = array('user_admins', 'user_coursecreators', 'user_teachers', 'user_students');
+
+ $totalcount = $progresscount = 0;
+ foreach ($usertables as $usertable) {
+ if (in_array($CFG->prefix.$usertable, $dbtables)) {
+ $totalcount += count_records($usertable);
+ }
+ }
+
+ print_progress(0, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
/// Upgrade the admins.
/// Sort using id ASC, first one is primary admin.
while (! $rs->EOF) {
$admin = $rs->FetchObj();
role_assign($adminrole, $admin->userid, 0, $systemcontext->id);
+ $progresscount++;
+ print_progress($progresscount, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
$rs->MoveNext();
}
}
while (! $rs->EOF) {
$coursecreator = $rs->FetchObj();
role_assign($coursecreatorrole, $coursecreator->userid, 0, $systemcontext->id);
+ $progresscount++;
+ print_progress($progresscount, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
$rs->MoveNext();
}
}
} else {
role_assign($noneditteacherrole, $teacher->userid, 0, $coursecontext->id);
}
+ $progresscount++;
+ print_progress($progresscount, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
$rs->MoveNext();
}
// assign the default student role
$coursecontext = get_context_instance(CONTEXT_COURSE, $student->course);
role_assign($studentrole, $student->userid, 0, $coursecontext->id);
+ $progresscount++;
+ print_progress($progresscount, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
$rs->MoveNext();
}
if ($guestuser = get_record('user', 'username', 'guest')) {
role_assign($guestrole, $guestuser->id, 0, $systemcontext->id);
}
+ print_progress($totalcount, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
/// Insert the correct records for legacy roles
$starttime = $lasttime = time();
$lasttime = $starttime - $updatetime;
echo '<table width="500" cellpadding="0" cellspacing="0" align="center"><tr><td width="500">';
- echo '<div id="bar" style="border-style:solid;border-width:1px;width:500px;height:50px;">';
- echo '<div id="slider" style="border-style:solid;border-width:1px;height:48px;width:10px;background-color:green;"></div>';
+ echo '<div id="bar'.$total.'" style="border-style:solid;border-width:1px;width:500px;height:50px;">';
+ echo '<div id="slider'.$total.'" style="border-style:solid;border-width:1px;height:48px;width:10px;background-color:green;"></div>';
echo '</div>';
- echo '<div id="text" align="center" style="width:500px;"></div>';
+ echo '<div id="text'.$total.'" align="center" style="width:500px;"></div>';
echo '</td></tr></table>';
echo '</div>';
}