Adding defaultrole to course table

This commit is contained in:
moodler
2006-09-17 06:37:59 +00:00
parent 90cfbd0ab4
commit 746a04c500
7 changed files with 28 additions and 4 deletions
+8
View File
@@ -1812,6 +1812,14 @@ function main_upgrade($oldversion=0) {
}
}
if ($oldversion < 2006091700) {
table_column('course','','defaultrole','int','10');
if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
$studentrole = array_shift($studentroles); /// Take the first one
execute_sql('UPDATE '.$CFG->prefix.'course SET defaultrole = '.$studentrole->id);
}
}
return $result;
}