mirror of
https://github.com/moodle/moodle.git
synced 2025-08-10 03:16:42 +02:00
MDL-48962 mod-lesson: maxtime should use a duration form element
This commit is contained in:
parent
dba564c7db
commit
a1acc00177
13 changed files with 76 additions and 43 deletions
|
@ -137,5 +137,45 @@ function xmldb_lesson_upgrade($oldversion) {
|
|||
// Lesson savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014122900, 'lesson');
|
||||
}
|
||||
|
||||
if ($oldversion < 2015022400) {
|
||||
|
||||
// Creating new field timelimit in lesson table.
|
||||
$table = new xmldb_table('lesson');
|
||||
$field = new xmldb_field('timelimit', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'maxpages');
|
||||
|
||||
// Conditionally launch add field timelimit.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Lesson savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2015022400, 'lesson');
|
||||
}
|
||||
|
||||
if ($oldversion < 2015022401) {
|
||||
|
||||
// Convert maxtime (minutes) to timelimit (seconds).
|
||||
$table = new xmldb_table('lesson');
|
||||
$oldfield = new xmldb_field('maxtime');
|
||||
$newfield = new xmldb_field('timelimit');
|
||||
if ($dbman->field_exists($table, $oldfield) && $dbman->field_exists($table, $newfield)) {
|
||||
$sql = 'UPDATE {lesson} SET timelimit = 60 * maxtime';
|
||||
$DB->execute($sql);
|
||||
// Drop field maxtime.
|
||||
$dbman->drop_field($table, $oldfield);
|
||||
}
|
||||
|
||||
$oldfield = new xmldb_field('timed');
|
||||
if ($dbman->field_exists($table, $oldfield) && $dbman->field_exists($table, $newfield)) {
|
||||
// Set timelimit to 0 for non timed lessons.
|
||||
$DB->set_field_select('lesson', 'timelimit', 0, 'timed = 0');
|
||||
// Drop field timed.
|
||||
$dbman->drop_field($table, $oldfield);
|
||||
}
|
||||
// Lesson savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2015022401, 'lesson');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue