Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/quiz/backup/moodle2/backup_quiz_activity_task.class.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 
00025 defined('MOODLE_INTERNAL') || die();
00026 
00027 require_once($CFG->dirroot . '/mod/quiz/backup/moodle2/backup_quiz_stepslib.php');
00028 
00029 
00037 class backup_quiz_activity_task extends backup_activity_task {
00038 
00042     protected function define_my_settings() {
00043         // No particular settings for this activity
00044     }
00045 
00049     protected function define_my_steps() {
00050         // Generate the quiz.xml file containing all the quiz information
00051         // and annotating used questions
00052         $this->add_step(new backup_quiz_activity_structure_step('quiz_structure', 'quiz.xml'));
00053 
00054         // Note: Following  steps must be present
00055         // in all the activities using question banks (only quiz for now)
00056         // TODO: Specialise these step to a new subclass of backup_activity_task
00057 
00058         // Process all the annotated questions to calculate the question
00059         // categories needing to be included in backup for this activity
00060         // plus the categories belonging to the activity context itself
00061         $this->add_step(new backup_calculate_question_categories('activity_question_categories'));
00062 
00063         // Clean backup_temp_ids table from questions. We already
00064         // have used them to detect question_categories and aren't
00065         // needed anymore
00066         $this->add_step(new backup_delete_temp_questions('clean_temp_questions'));
00067     }
00068 
00073     public static function encode_content_links($content) {
00074         global $CFG;
00075 
00076         $base = preg_quote($CFG->wwwroot, '/');
00077 
00078         // Link to the list of quizzes
00079         $search="/(".$base."\/mod\/quiz\/index.php\?id\=)([0-9]+)/";
00080         $content= preg_replace($search, '$@QUIZINDEX*$2@$', $content);
00081 
00082         // Link to quiz view by moduleid
00083         $search="/(".$base."\/mod\/quiz\/view.php\?id\=)([0-9]+)/";
00084         $content= preg_replace($search, '$@QUIZVIEWBYID*$2@$', $content);
00085 
00086         // Link to quiz view by quizid
00087         $search="/(".$base."\/mod\/quiz\/view.php\?q\=)([0-9]+)/";
00088         $content= preg_replace($search, '$@QUIZVIEWBYQ*$2@$', $content);
00089 
00090         return $content;
00091     }
00092 }
 All Data Structures Namespaces Files Functions Variables Enumerations