2006-10-26 17:33:40 +00:00
|
|
|
<?php //$Id$
|
|
|
|
|
|
|
|
// This file keeps track of upgrades to
|
|
|
|
// the lesson module
|
|
|
|
//
|
|
|
|
// Sometimes, changes between versions involve
|
|
|
|
// alterations to database structures and other
|
|
|
|
// major things that may break installations.
|
|
|
|
//
|
|
|
|
// The upgrade function in this file will attempt
|
|
|
|
// to perform all the necessary actions to upgrade
|
|
|
|
// your older installtion to the current version.
|
|
|
|
//
|
|
|
|
// If there's something it cannot do itself, it
|
|
|
|
// will tell you what you need to do.
|
|
|
|
//
|
|
|
|
// The commands in here will all be database-neutral,
|
2008-06-15 10:32:50 +00:00
|
|
|
// using the methods of database_manager class
|
2008-08-16 12:16:01 +00:00
|
|
|
//
|
|
|
|
// Please do not forget to use upgrade_set_timeout()
|
|
|
|
// before any action that may take longer time to finish.
|
2006-10-26 17:33:40 +00:00
|
|
|
|
2008-08-16 12:16:01 +00:00
|
|
|
function xmldb_lesson_upgrade($oldversion) {
|
|
|
|
global $CFG, $DB;
|
2006-10-26 17:33:40 +00:00
|
|
|
|
2008-05-15 21:40:00 +00:00
|
|
|
$dbman = $DB->get_manager();
|
|
|
|
$result = true;
|
2007-02-23 17:31:05 +00:00
|
|
|
|
2008-05-15 21:40:00 +00:00
|
|
|
//===== 1.9.0 upgrade line ======//
|
2007-06-11 11:25:24 +00:00
|
|
|
|
2008-01-27 15:39:05 +00:00
|
|
|
if ($result && $oldversion < 2007072201) {
|
|
|
|
|
2008-05-20 23:24:40 +00:00
|
|
|
$table = new xmldb_table('lesson');
|
|
|
|
$field = new xmldb_field('usegrademax');
|
|
|
|
$field2 = new xmldb_field('usemaxgrade');
|
2008-01-27 15:39:05 +00:00
|
|
|
|
|
|
|
/// Rename lesson->usegrademax to lesson->usemaxgrade. Some old sites can have it incorrect. MDL-13177
|
2008-05-15 21:40:00 +00:00
|
|
|
if ($dbman->field_exists($table, $field) && !$dbman->field_exists($table, $field2)) {
|
2008-01-27 15:39:05 +00:00
|
|
|
/// Set field specs
|
2009-05-01 01:19:16 +00:00
|
|
|
$field->set_attributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0', 'ongoing');
|
2008-01-27 15:39:05 +00:00
|
|
|
/// Launch rename field usegrademax to usemaxgrade
|
2008-06-22 16:51:55 +00:00
|
|
|
$dbman->rename_field($table, $field, 'usemaxgrade');
|
2008-01-27 15:39:05 +00:00
|
|
|
}
|
2008-06-22 23:35:52 +00:00
|
|
|
|
|
|
|
upgrade_mod_savepoint($result, 2007072201, 'lesson');
|
2008-01-27 15:39:05 +00:00
|
|
|
}
|
2009-03-06 19:03:46 +00:00
|
|
|
|
|
|
|
if ($result && $oldversion < 2008112601) {
|
|
|
|
require_once($CFG->dirroot.'/mod/lesson/lib.php');
|
2009-03-09 03:11:29 +00:00
|
|
|
|
|
|
|
lesson_upgrade_grades();
|
2009-03-06 19:03:46 +00:00
|
|
|
|
|
|
|
upgrade_mod_savepoint($result, 2008112601, 'lesson');
|
|
|
|
}
|
|
|
|
|
2006-10-26 17:33:40 +00:00
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|