MDL-23479 backup - various fixes in feedback backup & restore + delete old code ...
authorEloy Lafuente <stronk7@moodle.org>
Mon, 2 Aug 2010 23:31:29 +0000 (23:31 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Mon, 2 Aug 2010 23:31:29 +0000 (23:31 +0000)
mod/feedback/backup/moodle2/backup_feedback_activity_task.class.php
mod/feedback/backup/moodle2/backup_feedback_stepslib.php
mod/feedback/backup/moodle2/restore_feedback_activity_task.class.php
mod/feedback/backup/moodle2/restore_feedback_stepslib.php
mod/feedback/backuplib.php [deleted file]
mod/feedback/restorelib.php

index f94d147..acdc227 100644 (file)
@@ -68,7 +68,7 @@ class backup_feedback_activity_task extends backup_activity_task {
         $content= preg_replace($search, '$@FEEDBACKANALYSISBYID*$2@$', $content);
 
         // Link to feedback entries by moduleid
-        $search="/(".$base."\/mod\/feedback\/analysis.php\?id\=)([0-9]+)/";
+        $search="/(".$base."\/mod\/feedback\/show_entries.php\?id\=)([0-9]+)/";
         $content= preg_replace($search, '$@FEEDBACKSHOWENTRIESBYID*$2@$', $content);
 
         return $content;
index 0991256..21ec793 100644 (file)
@@ -91,21 +91,23 @@ class backup_feedback_activity_structure_step extends backup_activity_structure_
 
 
         // Build the tree
+        $feedback->add_child($items);
+        $items->add_child($item);
+
         $feedback->add_child($completeds);
         $completeds->add_child($completed);
 
         $completed->add_child($values);
         $values->add_child($value);
 
-        $feedback->add_child($items);
-        $items->add_child($item);
-
         $feedback->add_child($trackings);
         $trackings->add_child($tracking);
 
         // Define sources
         $feedback->set_source_table('feedback', array('id' => backup::VAR_ACTIVITYID));
 
+        $item->set_source_table('feedback_item', array('feedback' => backup::VAR_PARENTID));
+
         // All these source definitions only happen if we are including user info
         if ($userinfo) {
             $completed->set_source_sql('
@@ -114,8 +116,6 @@ class backup_feedback_activity_structure_step extends backup_activity_structure_
                  WHERE feedback = ?',
                 array(backup::VAR_PARENTID));
 
-            $item->set_source_table('feedback_item', array('feedback' => backup::VAR_PARENTID));
-
             $value->set_source_table('feedback_value', array('completed' => backup::VAR_PARENTID));
 
             $tracking->set_source_table('feedback_tracking', array('feedback' => backup::VAR_PARENTID));
index f7d0aa2..fe085a6 100644 (file)
@@ -55,6 +55,8 @@ class restore_feedback_activity_task extends restore_activity_task {
         $contents = array();
 
         $contents[] = new restore_decode_content('feedback', array('intro'), 'feedback');
+        $contents[] = new restore_decode_content('feedback_item', array('presentation'), 'feedback_item');
+        $contents[] = new restore_decode_content('feedback_value', array('value'), 'feedback_value');
 
         return $contents;
     }
@@ -66,8 +68,10 @@ class restore_feedback_activity_task extends restore_activity_task {
     static public function define_decode_rules() {
         $rules = array();
 
-        $rules[] = new restore_decode_rule('FEEDBACKVIEWBYID', '/mod/feedback/view.php?id=$1', 'course_module');
         $rules[] = new restore_decode_rule('FEEDBACKINDEX', '/mod/feedback/index.php?id=$1', 'course');
+        $rules[] = new restore_decode_rule('FEEDBACKVIEWBYID', '/mod/feedback/view.php?id=$1', 'course_module');
+        $rules[] = new restore_decode_rule('FEEDBACKANALYSISBYID', '/mod/feedback/analysis.php?id=$1', 'course_module');
+        $rules[] = new restore_decode_rule('FEEDBACKSHOWENTRIESBYID', '/mod/feedback/show_entries.php?id=$1', 'course_module');
 
         return $rules;
 
index e8e5109..a16ece6 100644 (file)
@@ -40,7 +40,7 @@ class restore_feedback_activity_structure_step extends restore_activity_structur
         $paths[] = new restore_path_element('feedback_item', '/activity/feedback/items/item');
         if ($userinfo) {
             $paths[] = new restore_path_element('feedback_completed', '/activity/feedback/completeds/completed');
-            $paths[] = new restore_path_element('feedback_value', '/activity/feedback/values/value');
+            $paths[] = new restore_path_element('feedback_value', '/activity/feedback/completeds/completed/values/value');
             $paths[] = new restore_path_element('feedback_tracking', '/activity/feedback/trackings/tracking');
         }
 
@@ -73,7 +73,7 @@ class restore_feedback_activity_structure_step extends restore_activity_structur
         $data->feedback = $this->get_new_parentid('feedback');
 
         $newitemid = $DB->insert_record('feedback_item', $data);
-        $this->set_mapping('feedback_item', $oldid, $newitemid);
+        $this->set_mapping('feedback_item', $oldid, $newitemid, true); // Can have files
     }
 
     protected function process_feedback_completed($data) {
@@ -94,8 +94,8 @@ class restore_feedback_activity_structure_step extends restore_activity_structur
 
         $data = (object)$data;
         $oldid = $data->id;
-        $data->item = $this->get_new_parentid('feedback_item');
         $data->completed = $this->get_new_parentid('feedback_completed');
+        $data->item = $this->get_mappingid('feedback_item', $data->item);
         $data->course_id = $this->get_courseid();
 
         $newitemid = $DB->insert_record('feedback_value', $data);
@@ -108,16 +108,16 @@ class restore_feedback_activity_structure_step extends restore_activity_structur
         $data = (object)$data;
         $oldid = $data->id;
         $data->feedback = $this->get_new_parentid('feedback');
+        $data->completed = $this->get_mappingid('feedback_completed', $data->completed);
         $data->userid = $this->get_mappingid('user', $data->userid);
 
         $newitemid = $DB->insert_record('feedback_tracking', $data);
-        $this->set_mapping('feedback_tracking', $oldid, $newitemid);
     }
-    
+
 
     protected function after_execute() {
         // Add feedback related files, no need to match by itemname (just internally handled context)
         $this->add_related_files('mod_feedback', 'intro', null);
-        $this->add_related_files('mod_feedback', 'item', 'id'); //TODO: Verify that this is working.
+        $this->add_related_files('mod_feedback', 'item', 'feedback_item');
     }
 }
diff --git a/mod/feedback/backuplib.php b/mod/feedback/backuplib.php
deleted file mode 100644 (file)
index 091d772..0000000
+++ /dev/null
@@ -1,277 +0,0 @@
-<?php
-    //This php script contains all the stuff to backup/restore
-    //feedback mods
-
-    //This is the "graphical" structure of the feedback mod:
-    //
-    //                     feedback---------------------------------feedback_tracking
-    //                    (CL,pk->id)                            (UL, pk->id, fk->feedback,completed)
-    //                        |                                           |
-    //                        |                                           |
-    //                        |                                           |
-    //                 feedback_template                            feedback_completed
-    //                   (CL,pk->id)                           (UL, pk->id, fk->feedback)
-    //                        |                                           |
-    //                        |                                           |
-    //                        |                                           |
-    //                 feedback_item---------------------------------feedback_value
-    //        (ML,pk->id, fk->feedback, fk->template)       (UL, pk->id, fk->item, fk->completed)
-    //
-    // Meaning: pk->primary key field of the table
-    //          fk->foreign key to link with parent
-    //          CL->course level info
-    //          ML->modul level info
-    //          UL->userid level info
-    //          message->text of each feedback_posting
-    //
-    //-----------------------------------------------------------
-
-    //This function executes all the backup procedure about this mod
-   function feedback_backup_mods($bf,$preferences) {
-      global $CFG, $DB;
-
-      $status = true;
-
-      //Iterate over feedback table
-      $feedbacks = $DB->get_records ("feedback", array("course"=>$preferences->backup_course), "id");
-      if ($feedbacks) {
-         foreach ($feedbacks as $feedback) {
-            if (backup_mod_selected($preferences,'feedback',$feedback->id)) {
-               $status = feedback_backup_one_mod($bf,$preferences,$feedback);
-            }
-         }
-      }
-      return $status;
-   }
-
-   function feedback_backup_one_mod($bf,$preferences,$feedback) {
-      global $CFG, $DB;
-
-      if (is_numeric($feedback)) {
-         $feedback = $DB->get_record('feedback', array('id'=>$feedback));
-      }
-
-      $status = true;
-      fwrite ($bf,start_tag("MOD",3,true));
-      //Print feedback data
-      fwrite ($bf,full_tag("ID",4,false,$feedback->id));
-      fwrite ($bf,full_tag("MODTYPE",4,false,"feedback"));
-      fwrite ($bf,full_tag("VERSION",4,false,1)); //version 1 steht fuer die neue Version
-      fwrite ($bf,full_tag("NAME",4,false,$feedback->name));
-      fwrite ($bf,full_tag("SUMMARY",4,false,$feedback->intro));
-      fwrite ($bf,full_tag("ANONYMOUS",4,false,$feedback->anonymous));
-      fwrite ($bf,full_tag("EMAILNOTIFICATION",4,false,$feedback->email_notification));
-      fwrite ($bf,full_tag("MULTIPLESUBMIT",4,false,$feedback->multiple_submit));
-      fwrite ($bf,full_tag("AUTONUMBERING",4,false,$feedback->autonumbering));
-      fwrite ($bf,full_tag("SITEAFTERSUB",4,false,$feedback->site_after_submit));
-      fwrite ($bf,full_tag("PAGEAFTERSUB",4,false,$feedback->page_after_submit));
-      fwrite ($bf,full_tag("PUBLISHSTATS",4,false,$feedback->publish_stats));
-      fwrite ($bf,full_tag("TIMEOPEN",4,false,$feedback->timeopen));
-      fwrite ($bf,full_tag("TIMECLOSE",4,false,$feedback->timeclose));
-      fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$feedback->timemodified));
-
-      //backup the items of each feedback
-      feedback_backup_data($bf, $preferences, $feedback->id);
-
-      //End mod
-      $status =fwrite ($bf,end_tag("MOD",3,true));
-      return $status;
-   }
-
-   function feedback_backup_data($bf, $preferences, $feedbackid) {
-      global $CFG, $DB;
-
-      $status = true;
-      $feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedbackid));
-      if(function_exists('backup_userdata_selected')) { //compatibility-hack for moodle 1.5.x
-         $backup_userdata = backup_userdata_selected($preferences,'feedback',$feedbackid);
-      }else {
-         $backup_userdata = $preferences->mods["feedback"]->userinfo;
-      }
-
-      if ($feedbackitems) {
-         $status =fwrite ($bf,start_tag("ITEMS",4,true));
-         foreach ($feedbackitems as $feedbackitem) {
-            //Start item
-            fwrite ($bf,start_tag("ITEM",5,true));
-            //Print item data
-            fwrite ($bf,full_tag("ID",6,false,$feedbackitem->id));
-            fwrite ($bf,full_tag("NAME",6,false,$feedbackitem->name));
-            fwrite ($bf,full_tag("PRESENTATION",6,false,$feedbackitem->presentation));
-            fwrite ($bf,full_tag("TYP",6,false,$feedbackitem->typ));
-            fwrite ($bf,full_tag("HASVALUE",6,false,$feedbackitem->hasvalue));
-            fwrite ($bf,full_tag("POSITION",6,false,$feedbackitem->position));
-            fwrite ($bf,full_tag("REQUIRED",6,false,$feedbackitem->required));
-
-            if ($backup_userdata) {
-               //backup the values of items
-               $feedbackvalues = $DB->get_records('feedback_value', array('item'=>$feedbackitem->id));
-               if($feedbackvalues) {
-                  $status =fwrite ($bf,start_tag("FBVALUES",6,true));
-                  foreach($feedbackvalues as $feedbackvalue) {
-                     //start value
-                     fwrite ($bf,start_tag("FBVALUE",7,true));
-                     //print value data
-                     fwrite ($bf,full_tag("ID",8,false,$feedbackvalue->id));
-                     fwrite ($bf,full_tag("ITEM",8,false,$feedbackvalue->item));
-                     fwrite ($bf,full_tag("COMPLETED",8,false,$feedbackvalue->completed));
-                     fwrite ($bf,full_tag("VAL",8,false,$feedbackvalue->value));
-                     fwrite ($bf,full_tag("COURSE_ID",8,false,$feedbackvalue->course_id));
-                     //End value
-                     $status =fwrite ($bf,end_tag("FBVALUE",7,true));
-                  }
-                  $status =fwrite ($bf,end_tag("FBVALUES",6,true));
-               }
-            }
-            //End item
-            $status =fwrite ($bf,end_tag("ITEM",5,true));
-         }
-         $status =fwrite ($bf,end_tag("ITEMS",4,true));
-      }
-
-      if($backup_userdata) {
-         //backup of feedback-completeds
-         $feedbackcompleteds = $DB->get_records('feedback_completed', array('feedback'=>$feedbackid));
-         if($feedbackcompleteds) {
-            fwrite ($bf,start_tag("COMPLETEDS",4,true));
-            foreach ($feedbackcompleteds as $feedbackcompleted) {
-               //Start completed
-               fwrite ($bf,start_tag("COMPLETED",5,true));
-               //Print completed data
-               fwrite ($bf,full_tag("ID",6,false,$feedbackcompleted->id));
-               fwrite ($bf,full_tag("FEEDBACK",6,false,$feedbackcompleted->feedback));
-               fwrite ($bf,full_tag("USERID",6,false,$feedbackcompleted->userid));
-               fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$feedbackcompleted->timemodified));
-               fwrite ($bf,full_tag("RANDOMRESPONSE",6,false,$feedbackcompleted->random_response));
-               fwrite ($bf,full_tag("ANONYMOUSRESPONSE",6,false,$feedbackcompleted->anonymous_response));
-
-               //End completed
-               $status =fwrite ($bf,end_tag("COMPLETED",5,true));
-            }
-            $status =fwrite ($bf,end_tag("COMPLETEDS",4,true));
-         }
-
-         //backup of tracking-data
-         $feedbacktrackings = $DB->get_records('feedback_tracking', array('feedback'=>$feedbackid));
-         if($feedbacktrackings) {
-            fwrite ($bf,start_tag("TRACKINGS",4,true));
-            foreach ($feedbacktrackings as $feedbacktracking) {
-               //Start tracking
-               fwrite ($bf,start_tag("TRACKING",5,true));
-               //Print tracking data
-               fwrite ($bf,full_tag("ID",6,false,$feedbacktracking->id));
-               fwrite ($bf,full_tag("USERID",6,false,$feedbacktracking->userid));
-               fwrite ($bf,full_tag("FEEDBACK",6,false,$feedbacktracking->feedback));
-               fwrite ($bf,full_tag("COMPLETED",6,false,$feedbacktracking->completed));
-
-               //End completed
-               $status =fwrite ($bf,end_tag("TRACKING",5,true));
-            }
-            $status =fwrite ($bf,end_tag("TRACKINGS",4,true));
-         }
-
-      }
-
-   }
-
-
-   function feedback_backup_template_data($bf, $templateid, $userinfo) {
-      global $CFG, $DB;
-
-      $status = true;
-      $templateitems = $DB->get_records('feedback_item', array('template'=>$templateid));
-
-      if ($templateitems) {
-         $status =fwrite ($bf,start_tag("ITEMS",5,true));
-         foreach ($templateitems as $templateitem) {
-            //Start item
-            fwrite ($bf,start_tag("ITEM",6,true));
-            //Print item data
-            fwrite ($bf,full_tag("ID",7,false,$templateitem->id));
-            fwrite ($bf,full_tag("NAME",7,false,$templateitem->name));
-            fwrite ($bf,full_tag("PRESENTATION",7,false,$templateitem->presentation));
-            fwrite ($bf,full_tag("TYP",7,false,$templateitem->typ));
-            fwrite ($bf,full_tag("HASVALUE",7,false,$templateitem->hasvalue));
-            fwrite ($bf,full_tag("POSITION",7,false,$templateitem->position));
-            fwrite ($bf,full_tag("REQUIRED",7,false,$templateitem->required));
-
-            //End item
-            $status =fwrite ($bf,end_tag("ITEM",6,true));
-         }
-         $status =fwrite ($bf,end_tag("ITEMS",5,true));
-      }
-   }
-
-
-
-
-   //Return an array of info (name,value)
-   function feedback_check_backup_mods($course,$user_data=false,$backup_unique_code, $instances=null) {
-      if (!empty($instances) && is_array($instances) && count($instances)) {
-         $info = array();
-         foreach ($instances as $id => $instance) {
-            $info += feedback_check_backup_mods_instances($instance,$backup_unique_code);
-         }
-         return $info;
-      }
-      //First the course data
-      $info[0][0] = get_string("modulenameplural","feedback");
-      $info[0][1] = feedback_count($course);
-
-      //Now, if requested, the user_data
-
-      if ($user_data) {
-         $info[1][0] = get_string('ready_feedbacks','feedback');
-         $info[1][1] = feedback_completed_count($course);
-      }
-
-      return $info;
-   }
-
-   ////Return an array of info (name,value)
-   function feedback_check_backup_mods_instances($instance,$backup_unique_code) {
-      global $DB;
-
-      //First the course data
-      $info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
-      $info[$instance->id.'0'][1] = '';
-
-      //Now, if requested, the user_data
-      if (!empty($instance->userdata)) {
-         $info[$instance->id.'1'][0] = get_string("responses","feedback");
-         if ($responses_count = $DB->count_records ('feedback_completed', array('feedback'=>$instance->id))) {
-               $info[$instance->id.'1'][1] = $responses_count;
-         } else {
-               $info[$instance->id.'1'][1] = 0;
-         }
-      }
-      return $info;
-   }
-
-///////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////
-//// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
-
-   //Returns an array of feedbacks ids
-   function feedback_count ($course) {
-      global $DB;
-
-      return $DB->count_records('feedback', array('course'=>$course));
-   }
-
-   function feedback_completed_count($course) {
-      global $DB;
-
-      $count = 0;
-      //get all feedbacks
-      $feedbacks = $DB->get_records('feedback', array('course'=>$course));
-      if($feedbacks) {
-         foreach($feedbacks as $feedback) {
-            $count += $DB->count_records('feedback_completed', array('feedback'=>$feedback->id));
-         }
-      }
-      return $count;
-   }
-
-
index bb99df0..c7d7b5b 100644 (file)
     //
     //-----------------------------------------------------------
 
-    require_once($CFG->dirroot.'/calendar/lib.php');
-    define('FEEDBACK_MULTICHOICERESTORE_TYPE_SEP', '>>>>>');
-
-    function feedback_restore_mods($mod,$restore) {
-        global $CFG, $DB;
-
-        // $allValues = array();
-        // $allTrackings = array();
-
-        $status = true;
-        $restore_userdata = restore_userdata_selected($restore,'feedback',$mod->id);
-
-        //Get record from backup_ids
-        $data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
-        if ($data) {
-            //Now get completed xmlized object
-            $info = $data->info;
-
-            //check of older backupversion of feedback
-            $version = intval(backup_todb($info['MOD']['#']['VERSION']['0']['#']));
-
-            //Now, build the feedback record structure
-            $feedback->course = $restore->course_id;
-            $feedback->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
-            $feedback->intro = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
-            $feedback->anonymous = backup_todb($info['MOD']['#']['ANONYMOUS']['0']['#']);
-            $feedback->email_notification = backup_todb($info['MOD']['#']['EMAILNOTIFICATION']['0']['#']);
-            $feedback->multiple_submit = backup_todb($info['MOD']['#']['MULTIPLESUBMIT']['0']['#']);
-            $feedback->autonumbering = backup_todb($info['MOD']['#']['AUTONUMBERING']['0']['#']);
-            $feedback->page_after_submit = backup_todb($info['MOD']['#']['PAGEAFTERSUB']['0']['#']);
-            $feedback->site_after_submit = backup_todb($info['MOD']['#']['SITEAFTERSUB']['0']['#']);
-            $feedback->publish_stats = backup_todb($info['MOD']['#']['PUBLISHSTATS']['0']['#']);
-            $feedback->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']);
-            $feedback->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']);
-            $feedback->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
-
-            //The structure is equal to the db, so insert the feedback
-            $newid = $DB->insert_record ("feedback",$feedback);
-
-            //create events
-            // the open-event
-            if($feedback->timeopen > 0) {
-                $event = NULL;
-                $event->name          = get_string('start', 'feedback').' '.$feedback->name;
-                $event->description = $feedback->intro;
-                $event->courseid     = $feedback->course;
-                $event->groupid      = 0;
-                $event->userid        = 0;
-                $event->modulename  = 'feedback';
-                $event->instance     = $newid;
-                $event->eventtype    = 'open';
-                $event->timestart    = $feedback->timeopen;
-                $event->visible      = instance_is_visible('feedback', $feedback);
-                if($feedback->timeclose > 0) {
-                  $event->timeduration = ($feedback->timeclose - $feedback->timeopen);
-                } else {
-                  $event->timeduration = 0;
-                }
-
-                calendar_event::create($event);
-            }
-
-            // the close-event
-            if($feedback->timeclose > 0) {
-                $event = NULL;
-                $event->name          = get_string('stop', 'feedback').' '.$feedback->name;
-                $event->description = $feedback->intro;
-                $event->courseid     = $feedback->course;
-                $event->groupid      = 0;
-                $event->userid        = 0;
-                $event->modulename  = 'feedback';
-                $event->instance     = $newid;
-                $event->eventtype    = 'close';
-                $event->timestart    = $feedback->timeclose;
-                $event->visible      = instance_is_visible('feedback', $feedback);
-                $event->timeduration = 0;
-
-                calendar_event::create($event);
-             }
-
-            //Do some output
-            echo "<ul><li>".get_string("modulename","feedback")." \"".$feedback->name."\"<br />";
-            backup_flush(300);
-
-            if ($newid) {
-                //Now, build the feedback_item record structure
-                if(isset($info['MOD']['#']['ITEMS']['0']['#']['ITEM'])) {
-                    $items = $info['MOD']['#']['ITEMS']['0']['#']['ITEM'];
-                    for($i = 0; $i < sizeof($items); $i++) {
-                        $item_info = $items[$i];
-                        $item->feedback = $newid;
-                        $item->template = 0;
-                        $item->name = backup_todb($item_info['#']['NAME']['0']['#']);
-                        $item->presentation = backup_todb($item_info['#']['PRESENTATION']['0']['#']);
-                        $item->presentation = str_replace("\n", '', $item->presentation);
-                        if($version >= 1) {
-                            $item->typ = backup_todb($item_info['#']['TYP']['0']['#']);
-                            $item->hasvalue = backup_todb($item_info['#']['HASVALUE']['0']['#']);
-                            switch($item->typ) {
-                                case 'radio':
-                                    $item->typ = 'multichoice';
-                                    $item->presentation = 'r'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
-                                    break;
-                                case 'check':
-                                    $item->typ = 'multichoice';
-                                    $item->presentation = 'c'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
-                                    break;
-                                case 'dropdown':
-                                    $item->typ = 'multichoice';
-                                    $item->presentation = 'd'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
-                                    break;
-                                case 'radiorated':
-                                    $item->typ = 'multichoicerated';
-                                    $item->presentation = 'r'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
-                                    break;
-                                case 'dropdownrated':
-                                    $item->typ = 'multichoicerated';
-                                    $item->presentation = 'd'.FEEDBACK_MULTICHOICERESTORE_TYPE_SEP.$item->presentation;
-                                    break;
-                            }
-                        } else {
-                            $oldtyp = intval(backup_todb($item_info['#']['TYP']['0']['#']));
-                            switch($oldtyp) {
-                                case 0:
-                                    $item->typ = 'label';
-                                    $item->hasvalue = 0;
-                                    break;
-                                case 1:
-                                    $item->typ = 'textfield';
-                                    $item->hasvalue = 1;
-                                    break;
-                                case 2:
-                                    $item->typ = 'textarea';
-                                    $item->hasvalue = 1;
-                                    break;
-                                case 3:
-                                    $item->typ = 'radio';
-                                    $item->hasvalue = 1;
-                                    break;
-                                case 4:
-                                    $item->typ = 'check';
-                                    $item->hasvalue = 1;
-                                    break;
-                                case 5:
-                                    $item->typ = 'dropdown';
-                                    $item->hasvalue = 1;
-                                    break;
-                            }
-                        }
-                        $item->position = backup_todb($item_info['#']['POSITION']['0']['#']);
-                        $item->required = backup_todb($item_info['#']['REQUIRED']['0']['#']);
-                        //put this new item into the database
-                        $newitemid = $DB->insert_record('feedback_item', $item);
-
-                        //Now check if want to restore user data and do it.
-                        if ($restore_userdata) {
-                            if(isset($item_info['#']['FBVALUES']['0']['#']['FBVALUE'])) {
-                                $values = $item_info['#']['FBVALUES']['0']['#']['FBVALUE'];
-                                for($ii = 0; $ii < sizeof($values); $ii++) {
-                                    $value_info = $values[$ii];
-                                    $value = new object();
-                                    $value->id = '';
-                                    $value->item = $newitemid;
-                                    $value->completed = 0;
-                                    $value->tmp_completed = backup_todb($value_info['#']['COMPLETED']['0']['#']);
-                                    $value->value = backup_todb($value_info['#']['VAL']['0']['#']);
-                                    $value->value = $value->value;
-                                    $value->course_id = backup_todb($value_info['#']['COURSE_ID']['0']['#']);
-                                    //put this new value into the database
-                                    $newvalueid = $DB->insert_record('feedback_value', $value);
-                                    $value->id = $newvalueid;
-                                    // $allValues[] = $value;
-                                }
-                            }
-                        }
-                    }
-                }
-                //Now check if want to restore user data again and do it.
-                if ($restore_userdata) {
-                    //restore tracking-data
-                    if(isset($info['MOD']['#']['TRACKINGS']['0']['#']['TRACKING'])) {
-                        $trackings = $info['MOD']['#']['TRACKINGS']['0']['#']['TRACKING'];
-                        for($i = 0; $i < sizeof($trackings); $i++) {
-                            $tracking_info = $trackings[$i];
-                            $tracking = new object();
-                            $tracking->id = '';
-                            $tracking->userid = backup_todb($tracking_info['#']['USERID']['0']['#']); //have to change later
-                            $tracking->feedback = $newid;
-                            $tracking->completed = backup_todb($tracking_info['#']['COMPLETED']['0']['#']); //have to change later
-                            if($tracking->userid > 0) {
-                                //We have to recode the userid field
-                                $user = backup_getid($restore->backup_unique_code,"user",$tracking->userid);
-                                if ($user) {
-                                    $tracking->userid = $user->new_id;
-                                }
-                            }
-
-                            //save the tracking
-                            $newtrackingid = $DB->insert_record('feedback_tracking', $tracking);
-                            $tracking->id = $newtrackingid;
-                            // $allTrackings[] = $tracking;
-                        }
-                    }
-
-                    //restore completeds
-                    if(isset($info['MOD']['#']['COMPLETEDS']['0']['#']['COMPLETED'])) {
-                        $completeds = $info['MOD']['#']['COMPLETEDS']['0']['#']['COMPLETED'];
-                        for($i = 0; $i < sizeof($completeds); $i++) {
-                            $completed_info = $completeds[$i];
-                            $completed = new object();
-                            $completed->feedback = $newid;
-                            $completed->userid = backup_todb($completed_info['#']['USERID']['0']['#']);
-                            $completed->timemodified = backup_todb($completed_info['#']['TIMEMODIFIED']['0']['#']);
-                            $completed->random_response = backup_todb($completed_info['#']['RANDOMRESPONSE']['0']['#']);
-                            if(!$anonymous_response = backup_todb($completed_info['#']['ANONYMOUSRESPONSE']['0']['#'])) {
-                                $anonymous_response = 1;
-                            }
-                            $completed->anonymous_response = $anonymous_response;
-                            if($completed->userid > 0) {
-                                //We have to recode the userid field
-                                $user = backup_getid($restore->backup_unique_code,"user",$completed->userid);
-                                if ($user) {
-                                    $completed->userid = $user->new_id;
-                                }
-                            }
-                            //later this have to be changed
-                            $oldcompletedid = backup_todb($completed_info['#']['ID']['0']['#']);
-
-                            //save the completed
-                            $newcompletedid = $DB->insert_record('feedback_completed', $completed);
-
-                            //the newcompletedid have to be changed at every values
-                            $tochangevals = $DB->get_records('feedback_value', array('tmp_completed'=>$oldcompletedid));
-                            if($tochangevals) {
-                                foreach($tochangevals as $tmpVal) {
-                                    $tmpVal->completed = $newcompletedid;
-                                    $tmpVal->tmp_completed = 0;
-                                    $DB->update_record('feedback_value', $tmpVal);
-                                }
-                            }
-
-                            //the newcompletedid have to be changed at every tracking
-                            $tochangetracks = $DB->get_records('feedback_tracking', array('completed'=>$oldcompletedid));
-                            if($tochangetracks) {
-                                foreach($tochangetracks as $tmpTrack) {
-                                    $tmpTrack->completed = $newcompletedid;
-                                    $tmpTrack->tmp_completed = 0;
-                                    $DB->update_record('feedback_tracking', $tmpTrack);
-                                }
-                            }
-                        }
-                    }
-                }
-
-                //We have the newid, update backup_ids
-                backup_putid($restore->backup_unique_code,$mod->modtype, $mod->id, $newid);
-            } else {
-                $status = false;
-            }
-
-            //Finalize ul
-            echo "</ul>";
-
-        } else {
-            $status = false;
-        }
-
-      return $status;
-    }
 
     //This function returns a log record with all the necessay transformations
     //done. It's used by restore_log_module() to restore modules log.