Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/lti/backup/moodle1/lib.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029 class moodle1_mod_lti_handler extends moodle1_mod_handler {
00030 
00032     protected $fileman = null;
00033 
00035     protected $moduleid = null;
00036 
00050     public function get_paths() {
00051 
00052         return array(
00053             new convert_path(
00054                 'basiclti', '/MOODLE_BACKUP/COURSE/MODULES/MOD/LTI'
00055             )
00056         );
00057 
00058     }
00059 
00064     public function process_basiclti($data) {
00065         global $DB;
00066 
00067         // get the course module id and context id
00068         $instanceid     = $data['id'];
00069         $cminfo         = $this->get_cminfo($instanceid);
00070         $this->moduleid = $cminfo['id'];
00071         $contextid      = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
00072 
00073         // get a fresh new file manager for this instance
00074         $this->fileman = $this->converter->get_file_manager($contextid, 'mod_lti');
00075 
00076         // convert course files embedded into the intro
00077         $this->fileman->filearea = 'intro';
00078         $this->fileman->itemid   = 0;
00079         $data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
00080 
00081         // start writing assignment.xml
00082         $this->open_xml_writer("activities/lti_{$this->moduleid}/lti.xml");
00083         $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid,
00084                 'modulename' => 'lti', 'contextid' => $contextid));
00085         $this->xmlwriter->begin_tag('lti', array('id' => $instanceid));
00086 
00087         $ignore_fields = array('id', 'modtype');
00088         if (!$DB->record_exists('lti_types', array('id' => $data['typeid']))) {
00089             $ntypeid = $DB->get_field('lti_types_config',
00090                                       'typeid',
00091                                       array('name' => 'toolurl', 'value' => $data['toolurl']),
00092                                       IGNORE_MULTIPLE);
00093             if ($ntypeid === false) {
00094                 $ntypeid = $DB->get_field('lti_types_config',
00095                                           'typeid',
00096                                           array(),
00097                                           IGNORE_MULTIPLE);
00098 
00099             }
00100             if ($ntypeid === false) {
00101                 $ntypeid = 0;
00102             }
00103             $data['typeid'] = $ntypeid;
00104         }
00105         if (empty($data['servicesalt'])) {
00106             $data['servicesalt'] = uniqid('', true);
00107         }
00108         foreach ($data as $field => $value) {
00109             if (!in_array($field, $ignore_fields)) {
00110                 $this->xmlwriter->full_tag($field, $value);
00111             }
00112         }
00113 
00114         return $data;
00115     }
00116 
00120     public function on_basiclti_end() {
00121         // finish writing basiclti.xml
00122         $this->xmlwriter->end_tag('lti');
00123         $this->xmlwriter->end_tag('activity');
00124         $this->close_xml_writer();
00125 
00126         // write inforef.xml
00127         $this->open_xml_writer("activities/lti_{$this->moduleid}/inforef.xml");
00128         $this->xmlwriter->begin_tag('inforef');
00129         $this->xmlwriter->begin_tag('fileref');
00130         foreach ($this->fileman->get_fileids() as $fileid) {
00131             $this->write_xml('file', array('id' => $fileid));
00132         }
00133         $this->xmlwriter->end_tag('fileref');
00134         $this->xmlwriter->end_tag('inforef');
00135         $this->close_xml_writer();
00136     }
00137 
00138 }
00139 
 All Data Structures Namespaces Files Functions Variables Enumerations