]> git.mjollnir.org Git - moodle.git/commitdiff
lesson_default table had become out of synch with the lesson table. Needed to add...
authormichaelpenne <michaelpenne>
Mon, 1 May 2006 19:02:38 +0000 (19:02 +0000)
committermichaelpenne <michaelpenne>
Mon, 1 May 2006 19:02:38 +0000 (19:02 +0000)
Updated backup and restore to include the new values

Fixed a bug in restore where it would restore 1 lesson_default per lesson.  Now only stores one per course.

Went through all the backuplib.php, restorelib.php, mysql.sql and postgres7.sql to make sure everything was in synch and being backed up and restored.

mod/lesson/backuplib.php
mod/lesson/db/mysql.php
mod/lesson/db/mysql.sql
mod/lesson/db/postgres7.php
mod/lesson/db/postgres7.sql
mod/lesson/restorelib.php
mod/lesson/version.php

index fa753813334b52ed0e3da76f3f2d96de47703aaf..7804debbb876f341376044a3fc740207b78a861c 100644 (file)
@@ -71,8 +71,8 @@
         fwrite ($bf,full_tag("NAME",4,false,$lesson->name));
         fwrite ($bf,full_tag("PRACTICE",4,false,$lesson->practice));
         fwrite ($bf,full_tag("MODATTEMPTS",4,false,$lesson->modattempts));
-        fwrite ($bf,full_tag("PASSWORD",4,false,$lesson->password));
         fwrite ($bf,full_tag("USEPASSWORD",4,false,$lesson->usepassword));
+        fwrite ($bf,full_tag("PASSWORD",4,false,$lesson->password));
         fwrite ($bf,full_tag("DEPENDENCY",4,false,$lesson->dependency));
         fwrite ($bf,full_tag("CONDITIONS",4,false,$lesson->conditions));
         fwrite ($bf,full_tag("GRADE",4,false,$lesson->grade));
         fwrite ($bf,full_tag("TIMED",4,false,$lesson->timed));
         fwrite ($bf,full_tag("MAXTIME",4,false,$lesson->maxtime));
         fwrite ($bf,full_tag("RETAKE",4,false,$lesson->retake));
+        fwrite ($bf,full_tag("ACTIVITYLINK",4,false,$lesson->activitylink));
         fwrite ($bf,full_tag("MEDIAFILE",4,false,$lesson->mediafile));
+        fwrite ($bf,full_tag("MEDIAHEIGHT",4,false,$lesson->mediaheight));
+        fwrite ($bf,full_tag("MEDIAWIDTH",4,false,$lesson->mediawidth));
+        fwrite ($bf,full_tag("MEDIACLOSE",4,false,$lesson->mediaclose));
         fwrite ($bf,full_tag("SLIDESHOW",4,false,$lesson->slideshow));
         fwrite ($bf,full_tag("WIDTH",4,false,$lesson->width));
         fwrite ($bf,full_tag("HEIGHT",4,false,$lesson->height));
         fwrite ($bf,full_tag("BGCOLOR",4,false,$lesson->bgcolor));
         fwrite ($bf,full_tag("DISPLAYLEFT",4,false,$lesson->displayleft));
+        fwrite ($bf,full_tag("DISPLAYLEFTIF",4,false,$lesson->displayleftif));
+        fwrite ($bf,full_tag("PROGRESSBAR",4,false,$lesson->progressbar));
         fwrite ($bf,full_tag("SHOWHIGHSCORES",4,false,$lesson->highscores));
         fwrite ($bf,full_tag("MAXHIGHSCORES",4,false,$lesson->maxhighscores));
         fwrite ($bf,full_tag("AVAILABLE",4,false,$lesson->available));
             //Print default data
             fwrite ($bf,full_tag("PRACTICE",5,false,$default->practice));
             fwrite ($bf,full_tag("MODATTEMPTS",5,false,$default->modattempts));
-            fwrite ($bf,full_tag("PASSWORD",5,false,$default->password));
             fwrite ($bf,full_tag("USEPASSWORD",5,false,$default->usepassword));
+            fwrite ($bf,full_tag("PASSWORD",5,false,$default->password));
+            fwrite ($bf,full_tag("CONDITIONS",5,false,$default->conditions));
             fwrite ($bf,full_tag("GRADE",5,false,$default->grade));
             fwrite ($bf,full_tag("CUSTOM",5,false,$default->custom));
             fwrite ($bf,full_tag("ONGOING",5,false,$default->ongoing));
             fwrite ($bf,full_tag("TIMED",5,false,$default->timed));
             fwrite ($bf,full_tag("MAXTIME",5,false,$default->maxtime));
             fwrite ($bf,full_tag("RETAKE",5,false,$default->retake));
+            fwrite ($bf,full_tag("MEDIAHEIGHT",5,false,$default->mediaheight));
+            fwrite ($bf,full_tag("MEDIAWIDTH",5,false,$default->mediawidth));
+            fwrite ($bf,full_tag("MEDIACLOSE",5,false,$default->mediaclose));
             fwrite ($bf,full_tag("SLIDESHOW",5,false,$default->slideshow));
             fwrite ($bf,full_tag("WIDTH",5,false,$default->width));
             fwrite ($bf,full_tag("HEIGHT",5,false,$default->height));
             fwrite ($bf,full_tag("BGCOLOR",5,false,$default->bgcolor));
             fwrite ($bf,full_tag("DISPLAYLEFT",5,false,$default->displayleft));
+            fwrite ($bf,full_tag("DISPLAYLEFTIF",5,false,$default->displayleftif));
+            fwrite ($bf,full_tag("PROGRESSBAR",5,false,$default->progressbar));
             fwrite ($bf,full_tag("HIGHSCORES",5,false,$default->highscores));
             fwrite ($bf,full_tag("MAXHIGHSCORES",5,false,$default->maxhighscores));
             $status =fwrite ($bf,end_tag("DEFAULTS",4,true));
index 5102d0daf054a87f121185c6c0af45f867046840..bbdd616faf70701a697670199a8427b9b451d3cc 100644 (file)
@@ -213,15 +213,24 @@ function lesson_upgrade($oldversion) {
         table_column('lesson', '', 'mediawidth', 'int', '10', 'unsigned', '650', 'not null', 'mediafile');
     }
 
-       if ($oldversion < 2005110200) {
+    if ($oldversion < 2005110200) {
         table_column('lesson', '', 'activitylink', 'int', '10', 'unsigned', '0', 'not null', 'tree');
-       }
-       
-       if ($oldversion < 2006031900) {
-           execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson DROP COLUMN tree');
-           execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson_default DROP COLUMN tree');
-       }
-         
+    }
+    
+    if ($oldversion < 2006031900) {
+        execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson DROP COLUMN tree');
+        execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson_default DROP COLUMN tree');
+    }
+    
+    if ($oldversion < 2006050100) {   
+        table_column('lesson_default', '', 'conditions', 'text', '', '', '', 'not null', 'password');
+        table_column('lesson_default', '', 'progressbar', 'tinyint', '3', 'unsigned', '0', 'not null', 'displayleft');
+        table_column('lesson_default', '', 'displayleftif', 'int', '3', 'unsigned', '0', 'not null', 'displayleft'); 
+        table_column('lesson_default', '', 'mediaclose', 'tinyint', '3', 'unsigned', '0', 'not null', 'retake');
+        table_column('lesson_default', '', 'mediaheight', 'int', '10', 'unsigned', '100', 'not null', 'retake');
+        table_column('lesson_default', '', 'mediawidth', 'int', '10', 'unsigned', '650', 'not null', 'retake');
+    }
+    
     return true;
 }
 
index 342ec8d88d05c27f97f3edf016cc0530d968e9b5..ebfd4b2f2f0c5fa6286937ed2dab77e02aa920df 100644 (file)
@@ -120,8 +120,9 @@ CREATE TABLE `prefix_lesson_default`
           `course` int(10) unsigned NOT NULL default '0',
           `practice` tinyint(3) unsigned NOT NULL default '0',
           `modattempts` tinyint(3) unsigned NOT NULL default '0',
-          `password` varchar(32) NOT NULL default '',
           `usepassword` int(3) unsigned NOT NULL default '0',
+          `password` varchar(32) NOT NULL default '',
+          `conditions` text NOT NULL default '',
           `grade` tinyint(3) NOT NULL default '0',
           `custom` int(3) unsigned NOT NULL default '0',
           `ongoing` int(3) unsigned NOT NULL default '0',
@@ -135,11 +136,16 @@ CREATE TABLE `prefix_lesson_default`
           `timed` int(3) unsigned NOT NULL default '0',
           `maxtime` int(10) unsigned NOT NULL default '0',
           `retake` int(3) unsigned NOT NULL default '1',
+          `mediaheight` INT(10) UNSIGNED NOT NULL DEFAULT '100',
+          `mediawidth` INT(10) UNSIGNED NOT NULL DEFAULT '650',
+          `mediaclose` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
           `slideshow` int(3) unsigned NOT NULL default '0',
           `width` int(10) unsigned NOT NULL default '640',
           `height` int(10) unsigned NOT NULL default '480',
           `bgcolor` varchar(7) default '#FFFFFF',
           `displayleft` int(3) unsigned NOT NULL default '0',
+          `displayleftif` INT(3) UNSIGNED NOT NULL DEFAULT '0',
+          `progressbar` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
           `highscores` int(3) unsigned NOT NULL default '0',
           `maxhighscores` int(10) NOT NULL default '0',
           PRIMARY KEY  (`id`)
index 6f402c0aaf09ed625b61d34f3f450b9c972c36d7..a5220bed3536775f5ffad4c97c333bc722f91875 100644 (file)
@@ -294,14 +294,23 @@ function lesson_upgrade($oldversion) {
         table_column('lesson', '', 'mediawidth', 'INT', '10', 'unsigned', '650', 'not null', 'mediafile');
     }
 
-       if ($oldversion < 2005110200) {
+    if ($oldversion < 2005110200) {
         table_column('lesson', '', 'activitylink', 'INT', '10', 'unsigned', '0', 'not null', 'tree');
-       }
-       
-       if ($oldversion < 2006031900) {
-           execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson DROP COLUMN tree');
-           execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson_default DROP COLUMN tree');
-       }
+    }
+    
+    if ($oldversion < 2006031900) {
+        execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson DROP COLUMN tree');
+        execute_sql('ALTER TABLE  '. $CFG->prefix . 'lesson_default DROP COLUMN tree');
+    }
+    
+    if ($oldversion < 2006050100) {   
+        table_column('lesson_default', '', 'conditions', 'text', '', '', '', 'not null', 'password');
+        table_column('lesson_default', '', 'progressbar', 'tinyint', '3', 'unsigned', '0', 'not null', 'displayleft');
+        table_column('lesson_default', '', 'displayleftif', 'int', '3', 'unsigned', '0', 'not null', 'displayleft'); 
+        table_column('lesson_default', '', 'mediaclose', 'tinyint', '3', 'unsigned', '0', 'not null', 'retake');
+        table_column('lesson_default', '', 'mediaheight', 'int', '10', 'unsigned', '100', 'not null', 'retake');
+        table_column('lesson_default', '', 'mediawidth', 'int', '10', 'unsigned', '650', 'not null', 'retake');
+    }
 
    return true;
 }
index d0a6382cfdb2dacc54652c5f081e6072aeeee5c0..280cb1723c3224c38e8f3da956b60e52fbef67d6 100644 (file)
@@ -108,8 +108,9 @@ CREATE TABLE prefix_lesson_default
           course INT8  NOT NULL default '0',
           practice INT  NOT NULL default '0',
           modattempts INT4 NOT NULL default '0',
-          password varchar(32) NOT NULL default '',
           usepassword INT  NOT NULL default '0',
+          password varchar(32) NOT NULL default '',
+          conditions text NOT NULL DEFAULT '',
           grade INT NOT NULL default '0',
           custom INT  NOT NULL default '0',
           ongoing INT  NOT NULL default '0',
@@ -123,11 +124,16 @@ CREATE TABLE prefix_lesson_default
           timed INT  NOT NULL default '0',
           maxtime INT8  NOT NULL default '0',
           retake INT  NOT NULL default '1',
+          mediaheight INT  NOT NULL DEFAULT '100',
+          mediawidth INT  NOT NULL DEFAULT '650',
+          mediaclose INT  NOT NULL DEFAULT '0',
           slideshow INT  NOT NULL default '0',
           width INT8  NOT NULL default '640',
           height INT8  NOT NULL default '480',
           bgcolor varchar(7) default '#FFFFFF',
           displayleft INT  NOT NULL default '0',
+          displayleftif INT  NOT NULL DEFAULT '0',
+          progressbar INT  NOT NULL DEFAULT '0',
           highscores INT  NOT NULL default '0',
           maxhighscores INT8 NOT NULL default '0'
         ) ;
index cac89b57321fb14272f9e7f7cccc3cf2b2b70e6b..89adcb3652b209d3e4b3aa30194cfe0603f6e1be 100644 (file)
@@ -56,8 +56,8 @@
             $lesson->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
             $lesson->practice = backup_todb($info['MOD']['#']['PRACTICE']['0']['#']);
             $lesson->modattempts = backup_todb($info['MOD']['#']['MODATTEMPTS']['0']['#']);
-            $lesson->password = backup_todb($info['MOD']['#']['PASSWORD']['0']['#']);
             $lesson->usepassword = backup_todb($info['MOD']['#']['USEPASSWORD']['0']['#']);
+            $lesson->password = backup_todb($info['MOD']['#']['PASSWORD']['0']['#']);            
             $lesson->dependency = backup_todb($info['MOD']['#']['DEPENDENCY']['0']['#']);
             $lesson->conditions = backup_todb($info['MOD']['#']['CONDITIONS']['0']['#']);
             $lesson->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
             $lesson->timed = backup_todb($info['MOD']['#']['TIMED']['0']['#']);
             $lesson->maxtime = backup_todb($info['MOD']['#']['MAXTIME']['0']['#']);
             $lesson->retake = backup_todb($info['MOD']['#']['RETAKE']['0']['#']);
+            $lesson->activitylink = backup_todb($info['MOD']['#']['ACTIVITYLINK']['0']['#']);
             $lesson->mediafile = backup_todb($info['MOD']['#']['MEDIAFILE']['0']['#']);
+            $lesson->mediaheight = backup_todb($info['MOD']['#']['MEDIAHEIGHT']['0']['#']);
+            $lesson->mediawidth = backup_todb($info['MOD']['#']['MEDIAWIDTH']['0']['#']);
+            $lesson->mediaclose = backup_todb($info['MOD']['#']['MEDIACLOSE']['0']['#']);
             $lesson->slideshow = backup_todb($info['MOD']['#']['SLIDESHOW']['0']['#']);
             $lesson->width = backup_todb($info['MOD']['#']['WIDTH']['0']['#']);
             $lesson->height = backup_todb($info['MOD']['#']['HEIGHT']['0']['#']);
             $lesson->bgcolor = backup_todb($info['MOD']['#']['BGCOLOR']['0']['#']);
             $lesson->displayleft = backup_todb($info['MOD']['#']['DISPLAYLEFT']['0']['#']);
+            $lesson->displayleftif = backup_todb($info['MOD']['#']['DISPLAYLEFTIF']['0']['#']);
+            $lesson->progressbar = backup_todb($info['MOD']['#']['PROGRESSBAR']['0']['#']);
             $lesson->highscores = backup_todb($info['MOD']['#']['SHOWHIGHSCORES']['0']['#']);
             $lesson->maxhighscores = backup_todb($info['MOD']['#']['MAXHIGHSCORES']['0']['#']);
             $lesson->available = backup_todb($info['MOD']['#']['AVAILABLE']['0']['#']);
                             return false;
                         }
                     }
-                    // restore the default for the course.  There might not be one, but if there
-                    //  is, there will only be one.
-                    $status = lesson_default_restore_mods($info,$restore);
+                    // restore the default for the course.  Only do this once by checking for an id for lesson_default
+                    $lessondefault = backup_getid($restore->backup_unique_code,'lesson_default',$restore->course_id);
+                    if (!$lessondefault) {
+                        $status = lesson_default_restore_mods($info,$restore);
+                    }
+                    
                 }
             } else {
                 $status = false;
                 $default->course = $restore->course_id;
                 $default->practice = backup_todb($default_info['#']['PRACTICE']['0']['#']);
                 $default->modattempts = backup_todb($default_info['#']['MODATTEMPTS']['0']['#']);
-                $default->password = backup_todb($default_info['#']['PASSWORD']['0']['#']);
                 $default->usepassword = backup_todb($default_info['#']['USEPASSWORD']['0']['#']);
+                $default->password = backup_todb($default_info['#']['PASSWORD']['0']['#']);
+                $default->conditions = backup_todb($default_info['#']['CONDITIONS']['0']['#']);
                 $default->grade = backup_todb($default_info['#']['GRADE']['0']['#']);
                 $default->custom = backup_todb($default_info['#']['CUSTOM']['0']['#']);
                 $default->ongoing = backup_todb($default_info['#']['ONGOING']['0']['#']);
                 $default->timed = backup_todb($default_info['#']['TIMED']['0']['#']);
                 $default->maxtime = backup_todb($default_info['#']['MAXTIME']['0']['#']);
                 $default->retake = backup_todb($default_info['#']['RETAKE']['0']['#']);
+                $default->mediaheight = backup_todb($default_info['#']['MEDIAHEIGHT']['0']['#']);
+                $default->mediawidth = backup_todb($default_info['#']['MEDIAWIDTH']['0']['#']);
+                $default->mediaclose = backup_todb($default_info['#']['MEDIACLOSE']['0']['#']);
                 $default->slideshow = backup_todb($default_info['#']['SLIDESHOW']['0']['#']);
                 $default->width = backup_todb($default_info['#']['WIDTH']['0']['#']);
                 $default->height = backup_todb($default_info['#']['HEIGHT']['0']['#']);
                 $default->bgcolor = backup_todb($default_info['#']['BGCOLOR']['0']['#']);
                 $default->displayleft = backup_todb($default_info['#']['DISPLAYLEFT']['0']['#']);
+                $default->displayleftif = backup_todb($default_info['#']['DISPLAYLEFTIF']['0']['#']);
+                $default->progressbar = backup_todb($default_info['#']['PROGRESSBAR']['0']['#']);
                 $default->highscores = backup_todb($default_info['#']['HIGHSCORES']['0']['#']);
                 $default->maxhighscores = backup_todb($default_info['#']['MAXHIGHSCORES']['0']['#']);
 
                 //The structure is equal to the db, so insert the lesson_grade
                 $newid = insert_record ("lesson_default",$default);
-
+                
+                if ($newid) {
+                    backup_putid($restore->backup_unique_code,'lesson_default',
+                                 $restore->course_id, $newid);
+                }
+                
                 //Do some output
                 if (($i+1) % 50 == 0) {
                     if (!defined('RESTORE_SILENTLY')) {
index 9e09a356c70385ad314788ce3c9df1d1439ddade..7e4101fbccb6d12a47fe833f0550240645d1cf51 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2006031900;  // The current module version (Date: YYYYMMDDXX)
+$module->version  = 2006050100;  // The current module version (Date: YYYYMMDDXX)
 $module->requires = 2005021600;  // Requires this Moodle version
 $module->cron     = 0;           // Period for cron to check this module (secs)