MDL-32614 lti: on restore, clean any typeid to convert the tool to selfcontained.

This is known to be imperfect, awaiting for MDL-34161 to fix the whole thing. Also,
unrelated, there are some basiclti => lti replacements.
This commit is contained in:
Eloy Lafuente (stronk7) 2012-07-04 02:01:21 +02:00
parent 420e6740e9
commit b666885397
2 changed files with 14 additions and 7 deletions

View File

@ -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 @@ class backup_lti_activity_structure_step extends backup_activity_structure_step
// (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 File

@ -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 @@ class restore_lti_activity_structure_step extends restore_activity_structure_ste
$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 @@ class restore_lti_activity_structure_step extends restore_activity_structure_ste
}
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);
}
}