Permalink
Browse files

MDL-32614 lti: on restore, clean any typeid to convert the tool to se…

…lfcontained.

This is known to be imperfect, awaiting for MDL-34161 to fix the whole thing. Also,
unrelated, there are some basiclti => lti replacements.
  • Loading branch information...
1 parent f2b7928 commit ccef7fe8d0db11a40472219bb8a9ef8a107ad2ce @stronk7 stronk7 committed Jul 4, 2012
Showing with 14 additions and 7 deletions.
  1. +7 −5 mod/lti/backup/moodle2/backup_lti_stepslib.php
  2. +7 −2 mod/lti/backup/moodle2/restore_lti_stepslib.php
View
12 mod/lti/backup/moodle2/backup_lti_stepslib.php
@@ -56,11 +56,13 @@ class backup_lti_activity_structure_step extends backup_activity_structure_step
protected function define_structure() {
+ // TODO: MDL-34161 - Fix restore to support course/site tools & submissions.
+
// To know if we are including userinfo
$userinfo = $this->get_setting_value('userinfo');
// Define each element separated
- $basiclti = new backup_nested_element('lti', array('id'), array(
+ $lti = new backup_nested_element('lti', array('id'), array(
'name',
'intro',
'introformat',
@@ -86,15 +88,15 @@ protected function define_structure() {
// (none)
// Define sources
- $basiclti->set_source_table('lti', array('id' => backup::VAR_ACTIVITYID));
+ $lti->set_source_table('lti', array('id' => backup::VAR_ACTIVITYID));
// Define id annotations
// (none)
// Define file annotations
- $basiclti->annotate_files('mod_lti', 'intro', null); // This file areas haven't itemid
+ $lti->annotate_files('mod_lti', 'intro', null); // This file areas haven't itemid
- // Return the root element (basiclti), wrapped into standard activity structure
- return $this->prepare_activity_structure($basiclti);
+ // Return the root element (lti), wrapped into standard activity structure
+ return $this->prepare_activity_structure($lti);
}
}
View
9 mod/lti/backup/moodle2/restore_lti_stepslib.php
@@ -50,7 +50,7 @@
defined('MOODLE_INTERNAL') || die;
/**
- * Structure step to restore one basiclti activity
+ * Structure step to restore one lti activity
*/
class restore_lti_activity_structure_step extends restore_activity_structure_step {
@@ -71,6 +71,11 @@ protected function process_lti($data) {
$data->course = $this->get_courseid();
require_once($CFG->dirroot.'/mod/lti/lib.php');
+ // Clean any course or site typeid. All modules
+ // are restored as self-contained. Note this is
+ // an interim solution until the issue below is implemented.
+ // TODO: MDL-34161 - Fix restore to support course/site tools & submissions.
+ $data->typeid = 0;
$newitemid = lti_add_instance($data, null);
@@ -79,7 +84,7 @@ protected function process_lti($data) {
}
protected function after_execute() {
- // Add basiclti related files, no need to match by itemname (just internally handled context)
+ // Add lti related files, no need to match by itemname (just internally handled context)
$this->add_related_files('mod_lti', 'intro', null);
}
}

0 comments on commit ccef7fe

Please sign in to comment.