| 1 | 
           efrain | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
           // This file is part of Moodle - http://moodle.org/
  | 
        
        
            | 
            | 
           3 | 
           //
  | 
        
        
            | 
            | 
           4 | 
           // Moodle is free software: you can redistribute it and/or modify
  | 
        
        
            | 
            | 
           5 | 
           // it under the terms of the GNU General Public License as published by
  | 
        
        
            | 
            | 
           6 | 
           // the Free Software Foundation, either version 3 of the License, or
  | 
        
        
            | 
            | 
           7 | 
           // (at your option) any later version.
  | 
        
        
            | 
            | 
           8 | 
           //
  | 
        
        
            | 
            | 
           9 | 
           // Moodle is distributed in the hope that it will be useful,
  | 
        
        
            | 
            | 
           10 | 
           // but WITHOUT ANY WARRANTY; without even the implied warranty of
  | 
        
        
            | 
            | 
           11 | 
           // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  | 
        
        
            | 
            | 
           12 | 
           // GNU General Public License for more details.
  | 
        
        
            | 
            | 
           13 | 
           //
  | 
        
        
            | 
            | 
           14 | 
           // You should have received a copy of the GNU General Public License
  | 
        
        
            | 
            | 
           15 | 
           // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  | 
        
        
            | 
            | 
           16 | 
           //
  | 
        
        
            | 
            | 
           17 | 
           // This file is part of BasicLTI4Moodle
  | 
        
        
            | 
            | 
           18 | 
           //
  | 
        
        
            | 
            | 
           19 | 
           // BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
  | 
        
        
            | 
            | 
           20 | 
           // consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
  | 
        
        
            | 
            | 
           21 | 
           // based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
  | 
        
        
            | 
            | 
           22 | 
           // specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
  | 
        
        
            | 
            | 
           23 | 
           // are already supporting or going to support BasicLTI. This project Implements the consumer
  | 
        
        
            | 
            | 
           24 | 
           // for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
  | 
        
        
            | 
            | 
           25 | 
           // BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
  | 
        
        
            | 
            | 
           26 | 
           // at the GESSI research group at UPC.
  | 
        
        
            | 
            | 
           27 | 
           // SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
  | 
        
        
            | 
            | 
           28 | 
           // by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
  | 
        
        
            | 
            | 
           29 | 
           // Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
  | 
        
        
            | 
            | 
           30 | 
           //
  | 
        
        
            | 
            | 
           31 | 
           // BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
  | 
        
        
            | 
            | 
           32 | 
           // of the Universitat Politecnica de Catalunya http://www.upc.edu
  | 
        
        
            | 
            | 
           33 | 
           // Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu.
  | 
        
        
            | 
            | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
           /**
  | 
        
        
            | 
            | 
           36 | 
            * This file keeps track of upgrades to the lti module
  | 
        
        
            | 
            | 
           37 | 
            *
  | 
        
        
            | 
            | 
           38 | 
            * @package mod_lti
  | 
        
        
            | 
            | 
           39 | 
            * @copyright  2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
  | 
        
        
            | 
            | 
           40 | 
            *  marc.alier@upc.edu
  | 
        
        
            | 
            | 
           41 | 
            * @copyright  2009 Universitat Politecnica de Catalunya http://www.upc.edu
  | 
        
        
            | 
            | 
           42 | 
            * @author     Marc Alier
  | 
        
        
            | 
            | 
           43 | 
            * @author     Jordi Piguillem
  | 
        
        
            | 
            | 
           44 | 
            * @author     Nikolas Galanis
  | 
        
        
            | 
            | 
           45 | 
            * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
        
        
            | 
            | 
           46 | 
            */
  | 
        
        
            | 
            | 
           47 | 
              | 
        
        
            | 
            | 
           48 | 
           /**
  | 
        
        
            | 
            | 
           49 | 
            * xmldb_lti_upgrade is the function that upgrades
  | 
        
        
            | 
            | 
           50 | 
            * the lti module database when is needed
  | 
        
        
            | 
            | 
           51 | 
            *
  | 
        
        
            | 
            | 
           52 | 
            * This function is automaticly called when version number in
  | 
        
        
            | 
            | 
           53 | 
            * version.php changes.
  | 
        
        
            | 
            | 
           54 | 
            *
  | 
        
        
            | 
            | 
           55 | 
            * @param int $oldversion New old version number.
  | 
        
        
            | 
            | 
           56 | 
            *
  | 
        
        
            | 
            | 
           57 | 
            * @return boolean
  | 
        
        
            | 
            | 
           58 | 
            */
  | 
        
        
            | 
            | 
           59 | 
           function xmldb_lti_upgrade($oldversion) {
  | 
        
        
            | 
            | 
           60 | 
               global $CFG, $DB, $OUTPUT;
  | 
        
        
            | 
            | 
           61 | 
              | 
        
        
            | 
            | 
           62 | 
               $dbman = $DB->get_manager();
  | 
        
        
            | 
            | 
           63 | 
              | 
        
        
            | 
            | 
           64 | 
               // Automatically generated Moodle v4.2.0 release upgrade line.
  | 
        
        
            | 
            | 
           65 | 
               // Put any upgrade step following this.
  | 
        
        
            | 
            | 
           66 | 
              | 
        
        
            | 
            | 
           67 | 
               if ($oldversion < 2023070501) {
  | 
        
        
            | 
            | 
           68 | 
                   // Define table lti_types_categories to be created.
  | 
        
        
            | 
            | 
           69 | 
                   $table = new xmldb_table('lti_types_categories');
  | 
        
        
            | 
            | 
           70 | 
              | 
        
        
            | 
            | 
           71 | 
                   // Adding fields to table lti_types_categories.
  | 
        
        
            | 
            | 
           72 | 
                   $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
  | 
        
        
            | 
            | 
           73 | 
                   $table->add_field('typeid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
  | 
        
        
            | 
            | 
           74 | 
                   $table->add_field('categoryid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
  | 
        
        
            | 
            | 
           75 | 
              | 
        
        
            | 
            | 
           76 | 
                   // Adding keys to table lti_types_categories.
  | 
        
        
            | 
            | 
           77 | 
                   $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
  | 
        
        
            | 
            | 
           78 | 
                   $table->add_key('typeid', XMLDB_KEY_FOREIGN, ['typeid'], 'lti_types', ['id']);
  | 
        
        
            | 
            | 
           79 | 
                   $table->add_key('categoryid', XMLDB_KEY_FOREIGN, ['categoryid'], 'course_categories', ['id']);
  | 
        
        
            | 
            | 
           80 | 
              | 
        
        
            | 
            | 
           81 | 
                   // Conditionally launch create table for lti_types_categories.
  | 
        
        
            | 
            | 
           82 | 
                   if (!$dbman->table_exists($table)) {
  | 
        
        
            | 
            | 
           83 | 
                       $dbman->create_table($table);
  | 
        
        
            | 
            | 
           84 | 
                   }
  | 
        
        
            | 
            | 
           85 | 
                   // Lti savepoint reached.
  | 
        
        
            | 
            | 
           86 | 
                   upgrade_mod_savepoint(true, 2023070501, 'lti');
  | 
        
        
            | 
            | 
           87 | 
               }
  | 
        
        
            | 
            | 
           88 | 
              | 
        
        
            | 
            | 
           89 | 
               if ($oldversion < 2023081101) {
  | 
        
        
            | 
            | 
           90 | 
                   // Define table to override coursevisible for a tool on course level.
  | 
        
        
            | 
            | 
           91 | 
                   $table = new xmldb_table('lti_coursevisible');
  | 
        
        
            | 
            | 
           92 | 
              | 
        
        
            | 
            | 
           93 | 
                   // Adding fields to table lti_coursevisible.
  | 
        
        
            | 
            | 
           94 | 
                   $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
  | 
        
        
            | 
            | 
           95 | 
                   $table->add_field('typeid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'id');
  | 
        
        
            | 
            | 
           96 | 
                   $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'typeid');
  | 
        
        
            | 
            | 
           97 | 
                   $table->add_field('coursevisible', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, 'courseid');
  | 
        
        
            | 
            | 
           98 | 
              | 
        
        
            | 
            | 
           99 | 
                   // Add key.
  | 
        
        
            | 
            | 
           100 | 
                   $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
  | 
        
        
            | 
            | 
           101 | 
              | 
        
        
            | 
            | 
           102 | 
                   // Define index courseid (not unique) to be added to lti_coursevisible.
  | 
        
        
            | 
            | 
           103 | 
                   $table->add_index('courseid', XMLDB_INDEX_NOTUNIQUE, ['courseid']);
  | 
        
        
            | 
            | 
           104 | 
                   // Define index typeid (not unique) to be added to lti_coursevisible.
  | 
        
        
            | 
            | 
           105 | 
                   $table->add_index('typeid', XMLDB_INDEX_NOTUNIQUE, ['typeid']);
  | 
        
        
            | 
            | 
           106 | 
              | 
        
        
            | 
            | 
           107 | 
                   // Conditionally launch create table for overriding coursevisible.
  | 
        
        
            | 
            | 
           108 | 
                   if (!$dbman->table_exists($table)) {
  | 
        
        
            | 
            | 
           109 | 
                       $dbman->create_table($table);
  | 
        
        
            | 
            | 
           110 | 
                   }
  | 
        
        
            | 
            | 
           111 | 
              | 
        
        
            | 
            | 
           112 | 
                   // Lti savepoint reached.
  | 
        
        
            | 
            | 
           113 | 
                   upgrade_mod_savepoint(true, 2023081101, 'lti');
  | 
        
        
            | 
            | 
           114 | 
               }
  | 
        
        
            | 
            | 
           115 | 
              | 
        
        
            | 
            | 
           116 | 
               // Automatically generated Moodle v4.3.0 release upgrade line.
  | 
        
        
            | 
            | 
           117 | 
               // Put any upgrade step following this.
  | 
        
        
            | 
            | 
           118 | 
              | 
        
        
            | 
            | 
           119 | 
               // Automatically generated Moodle v4.4.0 release upgrade line.
  | 
        
        
            | 
            | 
           120 | 
               // Put any upgrade step following this.
  | 
        
        
            | 
            | 
           121 | 
              | 
        
        
           | 1441 | 
           ariadna | 
           122 | 
               // Automatically generated Moodle v4.5.0 release upgrade line.
  | 
        
        
            | 
            | 
           123 | 
               // Put any upgrade step following this.
  | 
        
        
            | 
            | 
           124 | 
              | 
        
        
            | 
            | 
           125 | 
               // Automatically generated Moodle v5.0.0 release upgrade line.
  | 
        
        
            | 
            | 
           126 | 
               // Put any upgrade step following this.
  | 
        
        
            | 
            | 
           127 | 
              | 
        
        
           | 1 | 
           efrain | 
           128 | 
               return true;
  | 
        
        
            | 
            | 
           129 | 
           }
  |