Example #1
0
 public function process_turnitintool_submission($data)
 {
     $this->fileman->itemid = $data['id'];
     $this->fileman->userid = $data['userid'];
     $this->fileman->migrate_directory('moddata/turnitintool/' . $data['id']);
     $this->write_xml('submission', $data, array('/submission/id'));
 }
Example #2
0
 /**
  * This is executed when we reach the closing </MOD> tag of our 'wiki' path
  */
 public function on_wiki_end()
 {
     global $USER;
     //check if the initial content needs to be created (and if a page is already there for it)
     if ($this->initialcontentfilename && $this->needinitpage) {
         //contruct (synthetic - not for cooking) a full path for creating entries/entry/pages/page
         $data_entry = array('id' => $this->converter->get_nextid(), 'groupid' => 0, 'userid' => 0, 'synonyms' => '', 'links' => '');
         $data_page = array('id' => $this->converter->get_nextid(), 'title' => $this->initialcontentfilename, 'content' => $this->initialcontent, 'userid' => $USER->id, 'timecreated' => time(), 'timemodified' => 0, 'pageviews' => 0, 'cachedcontent' => '**reparse needed**', 'timerendered' => 0, 'readonly' => 0, 'tags' => '');
         //create xml with constructed page data (from initial_content file).
         $this->on_wiki_entries_start();
         $this->process_wiki_entry($data_entry);
         $this->on_wiki_pages_start();
         $this->process_wiki_entry_page($data_page);
         $this->on_wiki_entry_page_end();
         $this->on_wiki_pages_end();
         $this->on_wiki_entry_end();
         $this->on_wiki_entries_end();
     }
     //close wiki.xml
     $this->xmlwriter->end_tag('wiki');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     // write inforef.xml
     $this->open_xml_writer("activities/wiki_{$this->moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
 }
Example #3
0
 /**
  * This is executed when we reach the closing </MOD> tag of our 'referentiel' path
  */
 public function on_referentiel_end()
 {
     // finish writing referentiel.xml
     $this->xmlwriter->end_tag('referentiel');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     /*
             // write inforef.xml
             $this->open_xml_writer("activities/referentiel_{$this->moduleid}/inforef.xml");
             $this->xmlwriter->begin_tag('inforef');
             $this->xmlwriter->begin_tag('fileref');
             foreach ($this->fileman->get_fileids() as $fileid) {
                 $this->write_xml('file', array('id' => $fileid));
             }
             $this->xmlwriter->end_tag('fileref');
             $this->xmlwriter->end_tag('inforef');
             $this->close_xml_writer();
     */
     // write inforef.xml
     $this->inforefman->add_refs('file', $this->fileman->get_fileids());
     $this->open_xml_writer("activities/referentiel_{$this->moduleid}/inforef.xml");
     $this->inforefman->write_refs($this->xmlwriter);
     $this->close_xml_writer();
     // get ready for the next instance
     $this->cminfo = null;
     $this->moduleid = null;
 }
 /**
  * This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/CUSTOMLABEL
  * data available
  */
 public function process_customlabel($data)
 {
     // get the course module id and context id
     $instanceid = $data['id'];
     $cminfo = $this->get_cminfo($instanceid);
     $moduleid = $cminfo['id'];
     $contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);
     // shifts content from name (moodle 1.9 label hacking location) to processed content and
     // computes a new explicit name
     $storedcontent = base64_decode($data['content']);
     $customlabel = json_decode($storedcontent);
     $data['processedcontent'] = $data['name'];
     $data['name'] = $customlabel->labelclass . $data['id'];
     // get a fresh new file manager for this instance
     $this->fileman = $this->converter->get_file_manager($contextid, 'mod_customlabel');
     // convert course files embedded into the content
     $this->fileman->filearea = 'content';
     $this->fileman->itemid = 0;
     // try get files and reencode from stored content stub.
     $storedcontent = moodle1_converter::migrate_referenced_files($storedcontent, $this->fileman);
     $data['content'] = base64_encode($storedcontent);
     $data['processedcontent'] = moodle1_converter::migrate_referenced_files($data['processedcontent'], $this->fileman);
     // write inforef.xml
     $this->open_xml_writer("activities/customlabel_{$moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
     // write customlabel.xml
     $this->open_xml_writer("activities/customlabel_{$moduleid}/customlabel.xml");
     $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid, 'modulename' => 'customlabel', 'contextid' => $contextid));
     $this->xmlwriter->begin_tag('customlabel', array('id' => $instanceid));
     foreach ($data as $field => $value) {
         if ($field != 'id') {
             $this->xmlwriter->full_tag($field, $value);
         }
     }
     // finish writing customlabel.xml
     $this->xmlwriter->end_tag('customlabel');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     return $data;
 }
Example #5
0
 /**
  * This is executed when we reach the closing </MOD> tag of our 'lti' path
  */
 public function on_basiclti_end()
 {
     // Finish writing basiclti.xml.
     $this->xmlwriter->end_tag('lti');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     // Write inforef.xml.
     $this->open_xml_writer("activities/lti_{$this->moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
 }
Example #6
0
 /**
  * This is executed when we reach the closing </MOD> tag of our 'glossary' path
  */
 public function on_glossary_end()
 {
     // finalize glossary.xml
     $this->xmlwriter->end_tag('glossary');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     // write inforef.xml
     $this->open_xml_writer("activities/glossary_{$this->moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
 }
 /**
  * This is executed when we reach the closing </MOD> tag of our 'giportfolio' path
  */
 public function on_giportfolio_end()
 {
     // Finalize giportfolio.xml.
     $this->xmlwriter->end_tag('giportfolio');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     // Write inforef.xml.
     $this->open_xml_writer("activities/giportfolio_{$this->moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
 }
Example #8
0
 /**
  * This is executed when we reach the closing </MOD> tag of our 'lesson' path
  */
 public function on_lesson_end()
 {
     // finish writing lesson.xml
     $this->xmlwriter->end_tag('lesson');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     // write inforef.xml
     $this->open_xml_writer("activities/lesson_{$this->moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
 }
Example #9
0
 /**
  * This is executed when we reach the closing </MOD> tag of our 'scorm' path
  */
 public function on_scorm_end()
 {
     // close scorm.xml
     $this->xmlwriter->end_tag('scoes');
     $this->xmlwriter->end_tag('scorm');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     // write inforef.xml
     $this->open_xml_writer("activities/scorm_{$this->moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
 }
Example #10
0
 /**
  * This is executed when we reach the closing </MOD> tag of our 'flashcard' path
  */
 public function on_flashcard_end()
 {
     // finish writing flashcard.xml
     $this->xmlwriter->end_tag('group_deck');
     $this->xmlwriter->end_tag('flashcard');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     // write inforef.xml
     $this->open_xml_writer("activities/flashcard_{$this->moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
 }
Example #11
0
    /**
     * This is executed when we reach the closing </MOD> tag of our 'assignment' path
     */
    public function on_assignment_end() {
        // finish writing assignment.xml
        $this->xmlwriter->end_tag('submissions');
        $this->xmlwriter->end_tag('assignment');
        $this->xmlwriter->end_tag('activity');
        $this->close_xml_writer();

        // write inforef.xml
        $this->open_xml_writer("activities/assignment_{$this->moduleid}/inforef.xml");
        $this->xmlwriter->begin_tag('inforef');
        $this->xmlwriter->begin_tag('fileref');
        foreach ($this->fileman->get_fileids() as $fileid) {
            $this->write_xml('file', array('id' => $fileid));
        }
        $this->xmlwriter->end_tag('fileref');
        $this->xmlwriter->end_tag('inforef');
        $this->close_xml_writer();
    }
Example #12
0
 /**
  * This is executed when we reach the closing </MOD> tag of our 'chat' path
  */
 public function on_chat_end()
 {
     // Close chat.xml.
     $this->xmlwriter->end_tag('messages');
     $this->xmlwriter->end_tag('chat');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     // Write inforef.xml.
     $this->open_xml_writer("activities/chat_{$this->moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
 }
Example #13
0
 /**
  * This is executed when we reach the closing </MOD> tag of our 'rcontent' path
  */
 public function on_rcontent_end()
 {
     // close rcontent.xml
     $this->xmlwriter->end_tag('grades');
     //Changed structure from rcommon->grade and  rcommon->grades_details to  rcommon->grade->grades_details
     $this->xmlwriter->end_tag('rcontent');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     // write inforef.xml
     $this->open_xml_writer("activities/rcontent_{$this->moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
 }
 /**
  * This is executed when we reach the closing </MOD> tag of our 'quiz' path
  */
 public function on_quiz_end()
 {
     // append empty <overrides> subpath element
     $this->write_xml('overrides', array());
     // finish writing quiz.xml
     $this->xmlwriter->end_tag('quiz');
     $this->xmlwriter->end_tag('activity');
     $this->close_xml_writer();
     // write inforef.xml
     $this->open_xml_writer("activities/quiz_{$this->moduleid}/inforef.xml");
     $this->xmlwriter->begin_tag('inforef');
     $this->xmlwriter->begin_tag('fileref');
     foreach ($this->fileman->get_fileids() as $fileid) {
         $this->write_xml('file', array('id' => $fileid));
     }
     $this->xmlwriter->end_tag('fileref');
     $this->xmlwriter->end_tag('inforef');
     $this->close_xml_writer();
 }
Example #15
0
    /**
     * Migrates all course files referenced from the hypertext using the given filemanager
     *
     * This is typically used to convert images embedded into the intro fields.
     *
     * @param string $text hypertext containing $@FILEPHP@$ referenced
     * @param moodle1_file_manager $fileman file manager to use for the file migration
     * @return string the original $text with $@FILEPHP@$ references replaced with the new @@PLUGINFILE@@
     */
    public static function migrate_referenced_files($text, moodle1_file_manager $fileman) {

        $files = self::find_referenced_files($text);
        if (!empty($files)) {
            foreach ($files as $file) {
                try {
                    $fileman->migrate_file('course_files'.$file, dirname($file));
                } catch (moodle1_convert_exception $e) {
                    // file probably does not exist
                    $fileman->log('error migrating file', backup::LOG_WARNING, 'course_files'.$file);
                }
            }
            $text = self::rewrite_filephp_usage($text, $files);
        }

        return $text;
    }