Merge branch 'MDL-41756-master' of https://github.com/jamiepratt/moodle
authorSam Hemelryk <sam@moodle.com>
Tue, 4 Feb 2014 23:35:11 +0000 (12:35 +1300)
committerSam Hemelryk <sam@moodle.com>
Tue, 4 Feb 2014 23:35:11 +0000 (12:35 +1300)
Conflicts:
lib/db/upgrade.php
version.php

1  2 
lib/db/install.xml
lib/db/upgrade.php
version.php

diff --combined lib/db/install.xml
@@@ -1,5 -1,5 +1,5 @@@
  <?xml version="1.0" encoding="UTF-8" ?>
 -<XMLDB PATH="lib/db" VERSION="20140112" COMMENT="XMLDB file for core Moodle tables"
 +<XMLDB PATH="lib/db" VERSION="20140115" COMMENT="XMLDB file for core Moodle tables"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
  >
          <FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
          <FIELD NAME="slot" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The position in the quiz where this question appears"/>
          <FIELD NAME="subquestion" TYPE="int" LENGTH="4" NOTNULL="true" SEQUENCE="false"/>
+         <FIELD NAME="variant" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
          <FIELD NAME="s" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
          <FIELD NAME="effectiveweight" TYPE="number" LENGTH="15" NOTNULL="false" SEQUENCE="false" DECIMALS="5"/>
          <FIELD NAME="negcovar" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
          <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
        </KEYS>
      </TABLE>
 +    <TABLE NAME="lock_db" COMMENT="Stores active and inactive lock types for db locking method.">
 +      <FIELDS>
 +        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
 +        <FIELD NAME="resourcekey" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="String identifying the resource to be locked. Should use frankenstyle format."/>
 +        <FIELD NAME="expires" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Expiry time for an active lock."/>
 +        <FIELD NAME="owner" TYPE="char" LENGTH="36" NOTNULL="false" SEQUENCE="false" COMMENT="uuid indicating the owner of the lock."/>
 +      </FIELDS>
 +      <KEYS>
 +        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
 +      </KEYS>
 +      <INDEXES>
 +        <INDEX NAME="resourcekey_uniq" UNIQUE="true" FIELDS="resourcekey" COMMENT="Unique index for resourcekey"/>
 +        <INDEX NAME="expires_idx" UNIQUE="false" FIELDS="expires" COMMENT="Index on expires column"/>
 +        <INDEX NAME="owner_idx" UNIQUE="false" FIELDS="owner" COMMENT="Index on owner"/>
 +      </INDEXES>
 +    </TABLE>
    </TABLES>
  </XMLDB>
diff --combined lib/db/upgrade.php
@@@ -85,7 -85,7 +85,7 @@@ defined('MOODLE_INTERNAL') || die()
   * @return bool always true
   */
  function xmldb_main_upgrade($oldversion) {
 -    global $CFG, $USER, $DB, $OUTPUT, $SITE;
 +    global $CFG, $USER, $DB, $OUTPUT, $SITE, $COURSE;
  
      require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions
  
              $dbman->drop_field($table, $field);
          }
  
 +        // Since structure of 'course' table has changed we need to re-read $SITE from DB.
 +        $SITE = $DB->get_record('course', array('id' => $SITE->id));
 +        $COURSE = clone($SITE);
 +
          upgrade_main_savepoint(true, 2012031500.02);
      }
  
              $dbman->add_field($table, $field);
          }
  
 +        // Since structure of 'course' table has changed we need to re-read $SITE from DB.
 +        $SITE = $DB->get_record('course', array('id' => $SITE->id));
 +        $COURSE = clone($SITE);
 +
          // Main savepoint reached
          upgrade_main_savepoint(true, 2012050300.03);
      }
              $dbman->add_field($table, $field);
          }
  
 +        // Since structure of 'course' table has changed we need to re-read $SITE from DB.
 +        $SITE = $DB->get_record('course', array('id' => $SITE->id));
 +        $COURSE = clone($SITE);
 +
          // Add course_sections_availability to add completion & grade availability conditions
          $table = new xmldb_table('course_sections_availability');
  
          // Launch change of type for field format
          $dbman->change_field_type($table, $field);
  
 +        // Since structure of 'course' table has changed we need to re-read $SITE from DB.
 +        $SITE = $DB->get_record('course', array('id' => $SITE->id));
 +        $COURSE = clone($SITE);
 +
          // Main savepoint reached
          upgrade_main_savepoint(true, 2012110200.00);
      }
              }
          }
  
 +        // Since structure of 'course' table has changed we need to re-read $SITE from DB.
 +        $SITE = $DB->get_record('course', array('id' => $SITE->id));
 +        $COURSE = clone($SITE);
 +
          // Main savepoint reached
          upgrade_main_savepoint(true, 2012110201.00);
      }
          if ($SITE->format !== 'site') {
              $DB->set_field('course', 'format', 'site', array('id' => $SITE->id));
              $SITE->format = 'site';
 +            $COURSE->format = 'site';
          }
  
          // Main savepoint reached
              $dbman->drop_field($table, $field);
          }
  
 +        // Since structure of 'course' table has changed we need to re-read $SITE from DB.
 +        $SITE = $DB->get_record('course', array('id' => $SITE->id));
 +        $COURSE = clone($SITE);
 +
          // Main savepoint reached.
          upgrade_main_savepoint(true, 2013040300.01);
      }
              $dbman->add_field($table, $field);
          }
  
 +        // Since structure of 'course' table has changed we need to re-read $SITE from DB.
 +        $SITE = $DB->get_record('course', array('id' => $SITE->id));
 +        $COURSE = clone($SITE);
 +
          // Define field calendartype to be added to user.
          $table = new xmldb_table('user');
          $field = new xmldb_field('calendartype', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, 'gregorian');
              $dbman->add_field($table, $field);
          }
  
 +        // Since structure of 'course' table has changed we need to re-read $SITE from DB.
 +        $SITE = $DB->get_record('course', array('id' => $SITE->id));
 +        $COURSE = clone($SITE);
 +
          // Main savepoint reached.
          upgrade_main_savepoint(true, 2013091000.02);
      }
              $dbman->drop_field($table, $field);
          }
  
 +        // Since structure of 'course' table has changed we need to re-read $SITE from DB.
 +        $SITE = $DB->get_record('course', array('id' => $SITE->id));
 +        $COURSE = clone($SITE);
 +
          // Main savepoint reached.
          upgrade_main_savepoint(true, 2013091000.03);
      }
      }
  
      if ($oldversion < 2014012300.01) {
 +        // Remove deleted users home pages.
 +        $sql = "DELETE FROM {my_pages}
 +                WHERE EXISTS (SELECT {user}.id
 +                                  FROM {user}
 +                                  WHERE {user}.id = {my_pages}.userid
 +                                  AND {user}.deleted = 1)
 +                AND {my_pages}.private = 1";
 +        $DB->execute($sql);
 +
 +        // Reached main savepoint.
 +        upgrade_main_savepoint(true, 2014012300.01);
 +    }
 +
 +    if ($oldversion < 2014012400.00) {
 +        // Define table lock_db to be created.
 +        $table = new xmldb_table('lock_db');
  
 -        upgrade_main_savepoint(true, 2014012300.01);
 +        // Adding fields to table lock_db.
 +        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
 +        $table->add_field('resourcekey', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
 +        $table->add_field('expires', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
 +        $table->add_field('owner', XMLDB_TYPE_CHAR, '36', null, null, null, null);
 +
 +        // Adding keys to table lock_db.
 +        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
 +
 +        // Adding indexes to table lock_db.
 +        $table->add_index('resourcekey_uniq', XMLDB_INDEX_UNIQUE, array('resourcekey'));
 +        $table->add_index('expires_idx', XMLDB_INDEX_NOTUNIQUE, array('expires'));
 +        $table->add_index('owner_idx', XMLDB_INDEX_NOTUNIQUE, array('owner'));
 +
 +        // Conditionally launch create table for lock_db.
 +        if (!$dbman->table_exists($table)) {
 +            $dbman->create_table($table);
 +        }
 +
 +        // Main savepoint reached.
 +        upgrade_main_savepoint(true, 2014012400.00);
 +    }
 +
++    if ($oldversion < 2014020500.00) {
+         // Define field variant to be added to question_statistics.
+         $table = new xmldb_table('question_statistics');
+         $field = new xmldb_field('variant', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'subquestion');
+         // Conditionally launch add field variant.
+         if (!$dbman->field_exists($table, $field)) {
+             $dbman->add_field($table, $field);
+         }
+         // Main savepoint reached.
++        upgrade_main_savepoint(true, 2014020500.00);
+     }
      return true;
  }
diff --combined version.php
  
  defined('MOODLE_INTERNAL') || die();
  
- $version  = 2014013100.00;              // YYYYMMDD      = weekly release date of this DEV branch.
 -$version  = 2014012300.01;              // YYYYMMDD      = weekly release date of this DEV branch.
++$version  = 2014020500.00;              // YYYYMMDD      = weekly release date of this DEV branch.
                                          //         RR    = release increments - 00 in DEV branches.
                                          //           .XX = incremental changes.
  
 -$release  = '2.7dev (Build: 20140123)'; // Human-friendly version name
 +$release  = '2.7dev (Build: 20140131)'; // Human-friendly version name
  
  $branch   = '27';                       // This version's branch.
  $maturity = MATURITY_ALPHA;             // This version's maturity level.