Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/scorm/db/upgrade.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00032 function xmldb_scorm_upgrade($oldversion) {
00033     global $CFG, $DB;
00034 
00035     $dbman = $DB->get_manager();
00036 
00037 //===== 1.9.0 upgrade line ======//
00038 
00039     // Adding missing 'whatgrade' field to table scorm
00040     if ($oldversion < 2008073000) {
00041         $table = new xmldb_table('scorm');
00042         $field = new xmldb_field('whatgrade');
00043         $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'grademethod');
00044 
00046         if (!$dbman->field_exists($table,$field)) {
00047             $dbman->add_field($table, $field);
00048             $whatgradefixed = get_config('scorm', 'whatgradefixed');
00049             if (empty($whatgradefixed)) {
00051                 $scorms = $DB->get_records('scorm');
00052                 foreach ($scorms as $scorm) {
00053                     $scorm->whatgrade = $scorm->grademethod/10;
00054                     $DB->update_record('scorm', $scorm);
00055                 }
00056             }
00057         } else {
00058             //dump this config var as it isn't needed anymore.
00059             unset_config('whatgradefixed', 'scorm');
00060         }
00061 
00062         upgrade_mod_savepoint(true, 2008073000, 'scorm');
00063     }
00064 
00065      if ($oldversion < 2008082500) {
00066 
00068         $table = new xmldb_table('scorm');
00069         $field = new xmldb_field('scormtype', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, 'local', 'name');
00070 
00072         $dbman->add_field($table, $field);
00073 
00075         upgrade_mod_savepoint(true, 2008082500, 'scorm');
00076     }
00077 
00078     if ($oldversion < 2008090300) {
00079 
00081         $table = new xmldb_table('scorm');
00082         $field = new xmldb_field('sha1hash', XMLDB_TYPE_CHAR, '40', null, null, null, null, 'updatefreq');
00083 
00085         $dbman->add_field($table, $field);
00086 
00088         upgrade_mod_savepoint(true, 2008090300, 'scorm');
00089     }
00090 
00091     if ($oldversion < 2008090301) {
00092 
00094         $table = new xmldb_table('scorm');
00095         $field = new xmldb_field('revision', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'md5hash');
00096 
00098         $dbman->add_field($table, $field);
00099 
00101         upgrade_mod_savepoint(true, 2008090301, 'scorm');
00102     }
00103 
00104     if ($oldversion < 2008090302) {
00105         $sql = "UPDATE {scorm}
00106                    SET scormtype = 'external'
00107                  WHERE reference LIKE ? OR reference LIKE ? OR reference LIKE ?";
00108         $DB->execute($sql, array('http://%imsmanifest.xml', 'https://%imsmanifest.xml', 'www.%imsmanifest.xml'));
00109 
00110         $sql = "UPDATE {scorm}
00111                    SET scormtype = 'localsync'
00112                  WHERE reference LIKE ? OR reference LIKE ? OR reference LIKE ?
00113                        OR reference LIKE ? OR reference LIKE ? OR reference LIKE ?";
00114         $DB->execute($sql, array('http://%.zip', 'https://%.zip', 'www.%.zip', 'http://%.pif', 'https://%.pif', 'www.%.pif'));
00115 
00116         $sql = "UPDATE {scorm} SET scormtype = 'imsrepository' WHERE reference LIKE ?";
00117         $DB->execute($sql, array('#%'));
00118 
00120         upgrade_mod_savepoint(true, 2008090302, 'scorm');
00121     }
00122 
00123     if ($oldversion < 2008090303) {
00124         //remove obsoleted config settings
00125         unset_config('scorm_advancedsettings');
00126         unset_config('scorm_windowsettings');
00127 
00129         upgrade_mod_savepoint(true, 2008090303, 'scorm');
00130     }
00131 
00132     if ($oldversion < 2008090304) {
00136 
00137         require_once("$CFG->dirroot/mod/scorm/db/upgradelib.php");
00138 
00139         $fs = get_file_storage();
00140 
00141         $sqlfrom = "FROM {scorm} s
00142                     JOIN {modules} m ON m.name = 'scorm'
00143                     JOIN {course_modules} cm ON (cm.module = m.id AND cm.instance = s.id)";
00144 
00145         $count = $DB->count_records_sql("SELECT COUNT('x') $sqlfrom");
00146 
00147         $rs = $DB->get_recordset_sql("SELECT s.id, s.scormtype, s.reference, s.course, cm.id AS cmid $sqlfrom ORDER BY s.course, s.id");
00148         if ($rs->valid()) {
00149 
00150             $pbar = new progress_bar('migratescormfiles', 500, true);
00151 
00152             $i = 0;
00153             foreach ($rs as $scorm) {
00154                 $i++;
00155                 upgrade_set_timeout(180); // set up timeout, may also abort execution
00156                 $pbar->update($i, $count, "Migrating scorm files - $i/$count.");
00157 
00158                 $context       = get_context_instance(CONTEXT_MODULE, $scorm->cmid);
00159                 $coursecontext = get_context_instance(CONTEXT_COURSE, $scorm->course);
00160 
00161                 if ($scorm->scormtype === 'local' and preg_match('/.*(\.zip|\.pif)$/i', $scorm->reference)) {
00162                     // first copy local packages if found - do not delete in case they are shared ;-)
00163                     $packagefile = clean_param($scorm->reference, PARAM_PATH);
00164                     $pathnamehash = sha1("/$coursecontext->id/course/legacy/0/$packagefile");
00165                     if ($file = $fs->get_file_by_hash($pathnamehash)) {
00166                         $file_record = array('contextid'=>$context->id, 'component'=>'mod_scorm', 'filearea'=>'package',
00167                                              'itemid'=>0, 'filepath'=>'/');
00168                         try {
00169                             $fs->create_file_from_storedfile($file_record, $file);
00170                         } catch (Exception $x) {
00171                             // ignore any errors, we can not do much anyway
00172                         }
00173                         $scorm->reference = $file->get_filepath().$file->get_filename();
00174 
00175                     } else {
00176                         $scorm->reference = '';
00177                     }
00178                     $DB->update_record('scorm', $scorm);
00179                     // the package should be already extracted, we need to move the files there
00180                     // just in case somebody modified it directly there
00181                     scorm_migrate_moddata_files($scorm, $context);
00182 
00183                 } else if ($scorm->scormtype === 'local' and preg_match('/.*\/imsmanifest\.xml$/i', $scorm->reference)) {
00184                     // ignore imsmanifest in course root because we would be duplicating all course files which is not acceptable
00185                     // moddata dir is not used at all, ignore any rubbish there
00186                     $manifest = clean_param($scorm->reference, PARAM_PATH);
00187 
00188                     $pathnamehash = sha1("/$coursecontext->id/course/legacy/0/$manifest");
00189                     if ($file = $fs->get_file_by_hash($pathnamehash)) {
00190                         $scorm->reference = $file->get_filepath().$file->get_filename();
00191 
00192                         $manifestdir = '/'.str_ireplace('/imsmanifest.xml', '', $manifest).'/';
00193                         $pregmanifestdir = preg_quote($manifestdir, '/');
00194                         $file_record = array('contextid'=>$context->id, 'component'=>'mod_scorm', 'filearea'=>'content', 'itemid'=>0);
00195                         if ($files = $fs->get_directory_files($coursecontext->id, 'course', 'legacy', 0, $manifestdir, true)) {
00196                             foreach ($files as $file) {
00197                                 $file_record['filepath'] = preg_replace("/^$pregmanifestdir/", '/', $file->get_filepath());
00198                                 try {
00199                                     $fs->create_file_from_storedfile($file_record, $file);
00200                                 } catch (Exception $x) {
00201                                     // ignore any errors, we can not do much anyway
00202                                 }
00203                             }
00204                         }
00205 
00206                     } else {
00207                         $scorm->reference = '';
00208                     }
00209                     $DB->update_record('scorm', $scorm);
00210 
00211                 } else {
00212                     // just try to migrate anything from moddata
00213                     scorm_migrate_moddata_files($scorm, $context);
00214                 }
00215 
00216                 // remove dirs if empty
00217                 @rmdir("$CFG->dataroot/$scorm->course/$CFG->moddata/scorm/$scorm->id/");
00218                 @rmdir("$CFG->dataroot/$scorm->course/$CFG->moddata/scorm/");
00219                 @rmdir("$CFG->dataroot/$scorm->course/$CFG->moddata/");
00220             }
00221         }
00222         $rs->close();
00223 
00225         upgrade_mod_savepoint(true, 2008090304, 'scorm');
00226     }
00227 
00228 
00229     if ($oldversion < 2008090305) {
00230 
00232         $table = new xmldb_table('scorm');
00233         $field = new xmldb_field('forcecompleted', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'maxattempt');
00234         if (!$dbman->field_exists($table,$field)) {
00235             $dbman->add_field($table, $field);
00236         }
00237         $field = new xmldb_field('forcenewattempt', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 0, 'forcecompleted');
00238         if (!$dbman->field_exists($table,$field)) {
00239             $dbman->add_field($table, $field);
00240         }
00241         $field = new xmldb_field('lastattemptlock', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 0, 'forcenewattempt');
00242         if (!$dbman->field_exists($table,$field)) {
00243             $dbman->add_field($table, $field);
00244         }
00245         $field = new xmldb_field('displayattemptstatus', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'lastattemptlock');
00246         if (!$dbman->field_exists($table,$field)) {
00247             $dbman->add_field($table, $field);
00248         }
00249         $field = new xmldb_field('displaycoursestructure', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'displayattemptstatus');
00250         if (!$dbman->field_exists($table,$field)) {
00251             $dbman->add_field($table, $field);
00252         }
00253 
00255         upgrade_mod_savepoint(true, 2008090305, 'scorm');
00256     }
00257 
00258 
00259     // remove redundant config values
00260     if ($oldversion < 2008090306) {
00261         /*
00262          * comment this out as it is handled by the update mark 2008090310 below
00263          * left for historical documentation as some early adopters may have done
00264          * this already.
00265          $redundant_config = array(
00266                          'scorm_allowapidebug',
00267                          'scorm_allowtypeexternal',
00268                          'scorm_allowtypeimsrepository',
00269                          'scorm_allowtypelocalsync',
00270                          'scorm_apidebugmask',
00271                          'scorm_frameheight',
00272                          'scorm_framewidth',
00273                          'scorm_maxattempts',
00274                          'scorm_updatetime');
00275         foreach ($redundant_config as $rcfg) {
00276             if (isset($CFG->$rcfg)) {
00277                 unset_config($rcfg);
00278             }
00279         }
00280          */
00282         upgrade_mod_savepoint(true, 2008090306, 'scorm');
00283     }
00284 
00285 
00286 
00287     // remove redundant config values
00288     if ($oldversion < 2008090307) {
00289         /*
00290          * comment this out as it is handled by the update mark 2008090310 below
00291          * left for historical documentation as some early adopters may have done
00292          * this already.
00293          $redundant_config = array(
00294                          'scorm_allowapidebug',
00295                          'scorm_allowtypeexternal',
00296                          'scorm_allowtypeimsrepository',
00297                          'scorm_allowtypelocalsync',
00298                          'scorm_apidebugmask',
00299                          'scorm_frameheight',
00300                          'scorm_framewidth',
00301                          'scorm_maxattempts',
00302                          'scorm_updatetime',
00303                          'scorm_resizable',
00304                          'scorm_scrollbars',
00305                          'scorm_directories',
00306                          'scorm_location',
00307                          'scorm_menubar',
00308                          'scorm_toolbar',
00309                          'scorm_status',
00310                          'scorm_grademethod',
00311                          'scorm_maxgrade',
00312                          'scorm_whatgrade',
00313                          'scorm_popup',
00314                          'scorm_skipview',
00315                          'scorm_hidebrowse',
00316                          'scorm_hidetoc',
00317                          'scorm_hidenav',
00318                          'scorm_auto',
00319                          'scorm_updatefreq'
00320          );
00321         foreach ($redundant_config as $rcfg) {
00322             if (isset($CFG->$rcfg)) {
00323                 unset_config($rcfg);
00324             }
00325         }
00326          */
00327 
00329         upgrade_mod_savepoint(true, 2008090307, 'scorm');
00330     }
00331 
00332     if ($oldversion < 2008090308) {
00333         $table = new xmldb_table('scorm');
00334         $field = new xmldb_field('timeopen', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'height');
00335         if (!$dbman->field_exists($table,$field)) {
00336             $dbman->add_field($table, $field);
00337         }
00338         $field = new xmldb_field('timeclose', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timeopen');
00339         if (!$dbman->field_exists($table,$field)) {
00340             $dbman->add_field($table, $field);
00341         }
00342 
00344         upgrade_mod_savepoint(true, 2008090308, 'scorm');
00345     }
00346 
00347 
00348     if ($oldversion < 2008090310) {
00349         // take above blocks that delete config and move the values in to config_plugins
00350 
00351         $redundant_config = array(
00352                          'scorm_allowapidebug',
00353                          'scorm_allowtypeexternal',
00354                          'scorm_allowtypeimsrepository',
00355                          'scorm_allowtypelocalsync',
00356                          'scorm_apidebugmask',
00357                          'scorm_frameheight',
00358                          'scorm_framewidth',
00359                          'scorm_maxattempts',
00360                          'scorm_updatetime',
00361                          'scorm_resizable',
00362                          'scorm_scrollbars',
00363                          'scorm_directories',
00364                          'scorm_location',
00365                          'scorm_menubar',
00366                          'scorm_toolbar',
00367                          'scorm_status',
00368                          'scorm_grademethod',
00369                          'scorm_maxgrade',
00370                          'scorm_whatgrade',
00371                          'scorm_popup',
00372                          'scorm_skipview',
00373                          'scorm_hidebrowse',
00374                          'scorm_hidetoc',
00375                          'scorm_hidenav',
00376                          'scorm_auto',
00377                          'scorm_updatefreq',
00378                          'scorm_displayattemptstatus',
00379                          'scorm_displaycoursestructure',
00380                          'scorm_forcecompleted',
00381                          'scorm_forcenewattempt',
00382                          'scorm_lastattemptlock'
00383          );
00384 
00385         foreach ($redundant_config as $rcfg) {
00386             if (isset($CFG->$rcfg)) {
00387                 $shortname = substr($rcfg, 6);
00388                 set_config($shortname, $CFG->$rcfg, 'scorm');
00389                 unset_config($rcfg);
00390             }
00391         }
00392 
00394         upgrade_mod_savepoint(true, 2008090310, 'scorm');
00395     }
00396 
00397     if ($oldversion < 2009042000) {
00398 
00400         $table = new xmldb_table('scorm');
00401         $field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'reference');
00402 
00404         $dbman->rename_field($table, $field, 'intro');
00405 
00407         upgrade_mod_savepoint(true, 2009042000, 'scorm');
00408     }
00409 
00410     if ($oldversion < 2009042001) {
00411 
00413         $table = new xmldb_table('scorm');
00414         $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
00415 
00417         if (!$dbman->field_exists($table, $field)) {
00418             $dbman->add_field($table, $field);
00419         }
00420 
00421         // conditionally migrate to html format in intro
00422         if ($CFG->texteditors !== 'textarea') {
00423             $rs = $DB->get_recordset('scorm', array('introformat'=>FORMAT_MOODLE), '', 'id,intro,introformat');
00424             foreach ($rs as $s) {
00425                 $s->intro       = text_to_html($s->intro, false, false, true);
00426                 $s->introformat = FORMAT_HTML;
00427                 $DB->update_record('scorm', $s);
00428                 upgrade_set_timeout();
00429             }
00430             $rs->close();
00431         }
00432 
00434         upgrade_mod_savepoint(true, 2009042001, 'scorm');
00435     }
00436 
00437     if ($oldversion < 2009042002) {
00438 
00440         $table = new xmldb_table('scorm_scoes');
00441         $field = new xmldb_field('launch', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null);
00442 
00444         $dbman->change_field_type($table, $field);
00445 
00447         upgrade_mod_savepoint(true, 2009042002, 'scorm');
00448     }
00449     if ($oldversion < 2010070800) {
00450     //check to see if this has already been tidied up by a 1.9 upgrade.
00451         $grademethodfixed = get_config('scorm', 'grademethodfixed');
00452         if (empty($grademethodfixed)) {
00454             $scorms = $DB->get_records('scorm');
00455             if (!empty($scorm)) {
00456                 foreach ($scorms as $scorm) {
00457                     $scorm->grademethod = $scorm->grademethod%10;
00458                     $DB->update_record('scorm', $scorm);
00459                 }
00460             }
00461         } else {
00462             //dump this config var as it isn't needed anymore.
00463             unset_config('grademethodfixed', 'scorm');
00464         }
00465 
00467         upgrade_mod_savepoint(true, 2010070800, 'scorm');
00468     }
00469     if ($oldversion < 2010092400) {
00470         $count = $DB->count_records('scorm', array('scormtype'=>'external'));
00471         if (!empty($count)) {
00472             set_config('allowtypeexternal', '1', 'scorm');
00473         }
00474         $count = $DB->count_records('scorm', array('scormtype'=>'localsync'));
00475         if (!empty($count)) {
00476             set_config('allowtypelocalsync', '1', 'scorm');
00477         }
00478         $count = $DB->count_records('scorm', array('scormtype'=>'imsrepository'));
00479         if (!empty($count)) {
00480             set_config('allowtypeimsrepository', '1', 'scorm');
00481         }
00483         upgrade_mod_savepoint(true, 2010092400, 'scorm');
00484     }
00485 
00486     if ($oldversion < 2011011400) {
00487         // Fix scorm in the post table after upgrade from 1.9
00488         $table = new xmldb_table('scorm');
00489         $columns = $DB->get_columns('scorm');
00490 
00491         // forcecompleted should be int(1) not null default 1
00492         // Changing to NOT NULL, let's fill the current nulls with default 1
00493         $DB->set_field('scorm', 'forcecompleted', 1, array('forcecompleted' => null));
00494         $field = new xmldb_field('forcecompleted', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'maxattempt');
00495         if ($dbman->field_exists($table, $field)) {
00496             $dbman->change_field_precision($table, $field);
00497         }
00498 
00499         if (array_key_exists('forcenewattempt', $columns) && empty($columns['forcenewattempt']->not_null)) {
00500             // forcenewattempt should be int(1) not null default 0
00501             // Changing to NOT NULL, let's fill the current nulls with default 0
00502             $DB->set_field('scorm', 'forcenewattempt', 0, array('forcenewattempt' => null));
00503             $field = new xmldb_field('forcenewattempt', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 0, 'forcecompleted');
00504             if ($dbman->field_exists($table, $field)) {
00505                 $dbman->change_field_notnull($table, $field);
00506             }
00507         }
00508 
00509         if (array_key_exists('lastattemptlock', $columns) && empty($columns['lastattemptlock']->not_null)) {
00510             // lastattemptlock should be int(1) not null default 0
00511             // Changing to NOT NULL, let's fill the current nulls with default 0
00512             $DB->set_field('scorm', 'lastattemptlock', 0, array('lastattemptlock' => null));
00513             $field = new xmldb_field('lastattemptlock', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 0, 'forcenewattempt');
00514             if ($dbman->field_exists($table, $field)) {
00515                 $dbman->change_field_notnull($table, $field);
00516             }
00517         }
00518 
00519         if (array_key_exists('displayattemptstatus', $columns) && empty($columns['displayattemptstatus']->not_null)) {
00520             // displayattemptstatus should be int(1) not null default 1
00521             // Changing to NOT NULL, let's fill the current nulls with default 1
00522             $DB->set_field('scorm', 'displayattemptstatus', 1, array('displayattemptstatus' => null));
00523             $field = new xmldb_field('displayattemptstatus', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'lastattemptlock');
00524             if ($dbman->field_exists($table, $field)) {
00525                 $dbman->change_field_notnull($table, $field);
00526             }
00527         }
00528 
00529         if (array_key_exists('displaycoursestructure', $columns) && empty($columns['displaycoursestructure']->not_null)) {
00530             // displaycoursestructure should be int(1) not null default 1
00531             // Changing to NOT NULL, let's fill the current nulls with default 1
00532             $DB->set_field('scorm', 'displaycoursestructure', 1, array('displaycoursestructure' => null));
00533             $field = new xmldb_field('displaycoursestructure', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, 1, 'displayattemptstatus');
00534             if ($dbman->field_exists($table, $field)) {
00535                 $dbman->change_field_notnull($table, $field);
00536             }
00537         }
00538 
00539         upgrade_mod_savepoint(true, 2011011400, 'scorm');
00540     }
00541 
00542     // Moodle v2.1.0 release upgrade line
00543     // Put any upgrade step following this
00544 
00545     if ($oldversion < 2011021402) {
00546         unset_config('updatetime', 'scorm');
00547         upgrade_mod_savepoint(true, 2011021402, 'scorm');
00548     }
00549 
00550     if ($oldversion < 2011073100) {
00551         // change field type of objectiveid
00552         $table = new xmldb_table('scorm_seq_objective');
00553         $field = new xmldb_field('objectiveid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'primaryobj');
00554         $dbman->change_field_type($table, $field);
00555         upgrade_mod_savepoint(true, 2011073100, 'scorm');
00556     }
00557 
00558     if ($oldversion < 2011080100) {
00559         //MDL-28295 the behaviour of pop-up windows has now changed - it now loads the full Player in the window
00560         //because of this, pop-up windows now include the TOC and the nav bar - disabling these for existing SCORMS
00561         //as it is a change that most users won't expect.
00562         //get all SCORMS that use a new window.
00563         require_once($CFG->dirroot."/mod/scorm/lib.php");
00564         $rs = $DB->get_recordset('scorm', array('popup' => 1), '', 'id,hidetoc,hidenav');
00565         foreach ($rs as $scorm) {
00566             $scorm->hidetoc = SCORM_TOC_DISABLED;
00567             $scorm->hidenav = 1;
00568             $DB->update_record('scorm', $scorm);
00569         }
00570         $rs->close();
00571 
00572         upgrade_mod_savepoint(true, 2011080100, 'scorm');
00573     }
00574     if ($oldversion < 2011110502) {
00575 
00576         // Define table scorm_aicc_session to be created
00577         $table = new xmldb_table('scorm_aicc_session');
00578 
00579         // Adding fields to table scorm_aicc_session
00580         $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
00581         $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
00582         $table->add_field('scormid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
00583         $table->add_field('hacpsession', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
00584         $table->add_field('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, '0');
00585         $table->add_field('scormmode', XMLDB_TYPE_CHAR, '50', null, null, null, null);
00586         $table->add_field('scormstatus', XMLDB_TYPE_CHAR, '255', null, null, null, null);
00587         $table->add_field('attempt', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
00588         $table->add_field('lessonstatus', XMLDB_TYPE_CHAR, '255', null, null, null, null);
00589         $table->add_field('sessiontime', XMLDB_TYPE_CHAR, '255', null, null, null, null);
00590         $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
00591         $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
00592 
00593         // Adding keys to table scorm_aicc_session
00594         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
00595         $table->add_key('scormid', XMLDB_KEY_FOREIGN, array('scormid'), 'scorm', array('id'));
00596         $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
00597 
00598         // Conditionally launch create table for scorm_aicc_session
00599         if (!$dbman->table_exists($table)) {
00600             $dbman->create_table($table);
00601         }
00602 
00603         // scorm savepoint reached
00604         upgrade_mod_savepoint(true, 2011110502, 'scorm');
00605     }
00606 
00607     // Moodle v2.2.0 release upgrade line
00608     // Put any upgrade step following this
00609 
00610     return true;
00611 }
00612 
00613 
 All Data Structures Namespaces Files Functions Variables Enumerations