~ubuntu-branches/ubuntu/trusty/moodle/trusty-proposed

« back to all changes in this revision

Viewing changes to mod/lti/backup/moodle2/restore_lti_stepslib.php

  • Committer: Package Import Robot
  • Author(s): Tomasz Muras
  • Date: 2012-11-15 21:50:13 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20121115215013-hmzkwz3v5hvm2a0a
Tags: 2.2.6.dfsg-1
New upstream version: 2.2.6 (Build: 20121112)

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
defined('MOODLE_INTERNAL') || die;
51
51
 
52
52
/**
53
 
 * Structure step to restore one basiclti activity
 
53
 * Structure step to restore one lti activity
54
54
 */
55
55
class restore_lti_activity_structure_step extends restore_activity_structure_step {
56
56
 
71
71
        $data->course = $this->get_courseid();
72
72
 
73
73
        require_once($CFG->dirroot.'/mod/lti/lib.php');
 
74
        // Clean any course or site typeid. All modules
 
75
        // are restored as self-contained. Note this is
 
76
        // an interim solution until the issue below is implemented.
 
77
        // TODO: MDL-34161 - Fix restore to support course/site tools & submissions.
 
78
        $data->typeid = 0;
74
79
 
75
80
        $newitemid = lti_add_instance($data, null);
76
81
 
77
 
        // insert the basiclti record
78
 
        //$newitemid = $DB->insert_record('lti', $data);
79
82
        // immediately after inserting "activity" record, call this
80
83
        $this->apply_activity_instance($newitemid);
81
84
    }
82
85
 
83
86
    protected function after_execute() {
84
 
        global $DB;
85
 
 
86
 
        $basicltis = $DB->get_records('lti');
87
 
        foreach ($basicltis as $basiclti) {
88
 
            if (!$DB->get_record('lti_types_config',
89
 
                array('typeid' => $basiclti->typeid, 'name' => 'toolurl', 'value' => $basiclti->toolurl))) {
90
 
 
91
 
                $basiclti->typeid = 0;
92
 
            }
93
 
 
94
 
            $basiclti->placementsecret = uniqid('', true);
95
 
            $basiclti->timeplacementsecret = time();
96
 
 
97
 
            $DB->update_record('lti', $basiclti);
98
 
        }
99
 
 
100
 
        // Add basiclti related files, no need to match by itemname (just internally handled context)
 
87
        // Add lti related files, no need to match by itemname (just internally handled context)
101
88
        $this->add_related_files('mod_lti', 'intro', null);
102
89
    }
103
90
}