Commit 9c170a43 authored by Petr Skoda's avatar Petr Skoda
Browse files

Merge branch 'MDL-25792' of git://github.com/samhemelryk/moodle

parents 5cfe8aec 631cefc3
......@@ -18,7 +18,7 @@
<FIELD NAME="grademethod" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="maxgrade" NEXT="whatgrade"/>
<FIELD NAME="whatgrade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="grademethod" NEXT="maxattempt"/>
<FIELD NAME="maxattempt" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" PREVIOUS="whatgrade" NEXT="forcecompleted"/>
<FIELD NAME="forcecompleted" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" PREVIOUS="maxattempt" NEXT="forcenewattempt"/>
<FIELD NAME="forcecompleted" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" PREVIOUS="maxattempt" NEXT="forcenewattempt"/>
<FIELD NAME="forcenewattempt" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="forcecompleted" NEXT="lastattemptlock"/>
<FIELD NAME="lastattemptlock" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="forcenewattempt" NEXT="displayattemptstatus"/>
<FIELD NAME="displayattemptstatus" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" PREVIOUS="lastattemptlock" NEXT="displaycoursestructure"/>
......@@ -195,4 +195,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
\ No newline at end of file
</XMLDB>
......@@ -20,6 +20,11 @@
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
/**
* @global moodle_database $DB
* @param int $oldversion
* @return bool
*/
function xmldb_scorm_upgrade($oldversion) {
global $CFG, $DB;
......@@ -220,23 +225,23 @@ function xmldb_scorm_upgrade($oldversion) {
/// Define new fields forcecompleted, forcenewattempt, displayattemptstatus, and displaycoursestructure to be added to scorm
$table = new xmldb_table('scorm');
$field = new xmldb_field('forcecompleted', XMLDB_TYPE_INTEGER, '1', null, null, null, '0', 'maxattempt');
$field = new xmldb_field('forcecompleted', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'maxattempt');
if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('forcenewattempt', XMLDB_TYPE_INTEGER, '1', null, null, null, '0', 'forcecompleted');
$field = new xmldb_field('forcenewattempt', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 0, 'forcecompleted');
if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('lastattemptlock', XMLDB_TYPE_INTEGER, '1', null, null, null, '0', 'forcenewattempt');
$field = new xmldb_field('lastattemptlock', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 0, 'forcenewattempt');
if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('displayattemptstatus', XMLDB_TYPE_INTEGER, '1', null, null, null, '1', 'lastattemptlock');
$field = new xmldb_field('displayattemptstatus', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'lastattemptlock');
if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('displaycoursestructure', XMLDB_TYPE_INTEGER, '1', null, null, null, '1', 'displayattemptstatus');
$field = new xmldb_field('displaycoursestructure', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'displayattemptstatus');
if (!$dbman->field_exists($table,$field)) {
$dbman->add_field($table, $field);
}
......@@ -472,6 +477,58 @@ function xmldb_scorm_upgrade($oldversion) {
/// scorm savepoint reached
upgrade_mod_savepoint(true, 2010092400, 'scorm');
}
if ($oldversion < 2011011400) {
// Fix scorm in the post table after upgrade from 1.9
$table = new xmldb_table('scorm');
$columns = $DB->get_columns('scorm');
// forcecompleted should be bigint(1) NOT NULL DEFAULT '1'
// Fixed in earlier upgrade code
$field = new xmldb_field('forcecompleted', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'maxattempt');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_precision($table, $field);
}
if (array_key_exists('forcenewattempt', $columns) && empty($columns['forcenewattempt']->not_null)) {
// forcenewattempt should be NOT NULL
// Fixed in earlier upgrade code
$field = new xmldb_field('forcenewattempt', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 0, 'forcecompleted');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_notnull($table, $field);
}
}
if (array_key_exists('lastattemptlock', $columns) && empty($columns['lastattemptlock']->not_null)) {
// lastattemptlock should be NOT NULL
// Fixed in earlier upgrade code
$field = new xmldb_field('lastattemptlock', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 0, 'forcenewattempt');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_notnull($table, $field);
}
}
if (array_key_exists('displayattemptstatus', $columns) && empty($columns['displayattemptstatus']->not_null)) {
// displayattemptstatus should be NOT NULL
// Fixed in earlier upgrade code
$field = new xmldb_field('displayattemptstatus', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'lastattemptlock');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_notnull($table, $field);
}
}
if (array_key_exists('displaycoursestructure', $columns) && empty($columns['displaycoursestructure']->not_null)) {
// displaycoursestructure should be NOT NULL
// Fixed in earlier upgrade code
$field = new xmldb_field('displaycoursestructure', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'displayattemptstatus');
if ($dbman->field_exists($table, $field)) {
$dbman->change_field_notnull($table, $field);
}
}
upgrade_mod_savepoint(true, 2011011400, 'scorm');
}
return true;
}
......
......@@ -6,7 +6,7 @@
/////////////////////////////////////////////////////////////////////////////////
$module->version = 2010092400; // The (date) version of this module
$module->version = 2011011400; // The (date) version of this module
$module->requires = 2010080300; // The version of Moodle that is required
$module->cron = 300; // How often should cron check this module (seconds)?
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment