MDL-29627 quiz old popup int column => new browsersecurity column.

The new column store more meaningful string constants.
This commit is contained in:
Tim Hunt 2011-10-06 20:15:01 +01:00
parent 0eafc98852
commit 4344c5d5d9
15 changed files with 170 additions and 46 deletions

View file

@ -36,9 +36,9 @@
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="timelimit"/>
<FIELD NAME="timelimit" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timemodified" NEXT="password"/>
<FIELD NAME="password" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="timelimit" NEXT="subnet"/>
<FIELD NAME="subnet" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="password" NEXT="popup"/>
<FIELD NAME="popup" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="subnet" NEXT="delay1"/>
<FIELD NAME="delay1" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="popup" NEXT="delay2"/>
<FIELD NAME="subnet" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="password" NEXT="browsersecurity"/>
<FIELD NAME="browsersecurity" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" PREVIOUS="subnet" NEXT="delay1"/>
<FIELD NAME="delay1" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="browsersecurity" NEXT="delay2"/>
<FIELD NAME="delay2" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="delay1" NEXT="showuserpicture"/>
<FIELD NAME="showuserpicture" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Option to show the user's picture during the attempt and on the review page." PREVIOUS="delay2" NEXT="showblocks"/>
<FIELD NAME="showblocks" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Whether blocks should be shown on the attempt.php and review.php pages." PREVIOUS="showuserpicture"/>

View file

@ -1121,6 +1121,76 @@ function xmldb_quiz_upgrade($oldversion) {
// Moodle v2.1.0 release upgrade line
// Put any upgrade step following this
if ($oldversion < 2011100600) {
// Define field browsersecurity to be added to quiz
$table = new xmldb_table('quiz');
$field = new xmldb_field('browsersecurity', XMLDB_TYPE_CHAR, '32', null,
XMLDB_NOTNULL, null, '[unknownvalue]', 'subnet');
// Conditionally launch add field browsersecurity
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// quiz savepoint reached
upgrade_mod_savepoint(true, 2011100600, 'quiz');
}
if ($oldversion < 2011100601) {
$DB->set_field('quiz', 'browsersecurity', '-', array('popup' => 0));
$DB->set_field('quiz', 'browsersecurity', 'securewindow', array('popup' => 1));
$DB->set_field('quiz', 'browsersecurity', 'safebrowser', array('popup' => 2));
upgrade_mod_savepoint(true, 2011100601, 'quiz');
}
if ($oldversion < 2011100602) {
// Changing the default of field browsersecurity on table quiz to drop it
$table = new xmldb_table('quiz');
$field = new xmldb_field('browsersecurity', XMLDB_TYPE_CHAR, '32', null,
XMLDB_NOTNULL, null, null, 'subnet');
// Launch change of default for field browsersecurity
$dbman->change_field_default($table, $field);
// quiz savepoint reached
upgrade_mod_savepoint(true, 2011100602, 'quiz');
}
if ($oldversion < 2011100603) {
// Define field popup to be dropped from quiz
$table = new xmldb_table('quiz');
$field = new xmldb_field('popup');
// Conditionally launch drop field popup
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// quiz savepoint reached
upgrade_mod_savepoint(true, 2011100603, 'quiz');
}
if ($oldversion < 2011100604) {
switch (get_config('quiz', 'popup')) {
case 1:
set_config('browsersecurity', 'securewindow', 'quiz');
case 2:
set_config('browsersecurity', 'safebrowser', 'quiz');
default:
set_config('browsersecurity', '-', 'quiz');
}
unset_config('quiz', 'popup');
set_config('browsersecurity_adv', get_config('quiz', 'popup_adv'), 'quiz');
unset_config('quiz', 'popup_adv');
upgrade_mod_savepoint(true, 2011100604, 'quiz');
}
return true;
}