Updating LTI backup / restore
authorChris Scribner <scriby@gmail.com>
Mon, 3 Oct 2011 21:51:46 +0000 (17:51 -0400)
committerChris Scribner <scriby@gmail.com>
Mon, 7 Nov 2011 01:41:54 +0000 (20:41 -0500)
mod/lti/backup/moodle2/backup_lti_stepslib.php
mod/lti/backup/moodle2/restore_lti_stepslib.php
mod/lti/lib.php

index 7824727..429794f 100644 (file)
@@ -62,12 +62,26 @@ class backup_lti_activity_structure_step extends backup_activity_structure_step
 
         // Define each element separated
         $basiclti = new backup_nested_element('lti', array('id'), array(
-            'name', 'intro', 'introformat', 'timecreated', 'timemodified',
-            'typeid', 'toolurl', 'preferheight', 'instructorchoiccesendname',
-            'instructorchoicesendemailaddr', 'organizationid',
-            'organizationurl', 'organizationdescr', 'launchinpopup',
-            'debuglaunch', 'instructorchoiceacceptgrades', 'instructorchoiceallowroster',
-               'instructorchoiceallowsetting', 'grade', 'instructorcustomparameters'));
+            'name', 
+            'intro', 
+            'introformat', 
+            'timecreated', 
+            'timemodified',
+            'typeid', 
+            'toolurl', 
+            'preferheight', 
+            'launchcontainer',
+            'instructorchoicesendname',
+            'instructorchoicesendemailaddr',
+            'instructorchoiceacceptgrades', 
+            'instructorchoiceallowroster',
+            'instructorchoiceallowsetting', 
+            'grade', 
+            'instructorcustomparameters',
+            'showtitle',
+            'showdescription'
+            )
+        );
 
         // Build the tree
         // (none)
index 2fe5082..6114cbd 100644 (file)
@@ -66,14 +66,18 @@ class restore_lti_activity_structure_step extends restore_activity_structure_ste
     }
 
     protected function process_lti($data) {
-        global $DB;
+        global $DB, $CFG;
 
         $data = (object)$data;
         $oldid = $data->id;
         $data->course = $this->get_courseid();
 
+        require_once($CFG->dirroot.'/mod/lti/lib.php');
+        
+        $newitemid = lti_add_instance($data);
+        
         // insert the basiclti record
-        $newitemid = $DB->insert_record('lti', $data);
+        //$newitemid = $DB->insert_record('lti', $data);
         // immediately after inserting "activity" record, call this
         $this->apply_activity_instance($newitemid);
     }
index 30fc958..dfb48b5 100644 (file)
@@ -93,6 +93,11 @@ function lti_add_instance($formdata) {
 
     if ($formdata->instructorchoiceacceptgrades == 1) {
         $basiclti = $DB->get_record('lti', array('id'=>$id));
+        
+        if(!isset($formdata->cmidnumber)){
+            $formdata->cmidnumber = '';
+        }
+        
         $basiclti->cmidnumber = $formdata->cmidnumber;
         
         lti_grade_item_update($basiclti);