|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00030 require_once($CFG->dirroot . '/mod/lesson/backup/moodle2/backup_lesson_stepslib.php'); 00031 00037 class backup_lesson_activity_task extends backup_activity_task { 00038 00039 protected function define_my_settings() { 00040 // There are no settings 00041 } 00042 00043 protected function define_my_steps() { 00044 $this->add_step(new backup_lesson_activity_structure_step('lesson structure', 'lesson.xml')); 00045 } 00046 00054 static public function encode_content_links($content) { 00055 global $CFG; 00056 00057 $base = preg_quote($CFG->wwwroot.'/mod/lesson','#'); 00058 00059 // Provides the interface for overall authoring of lessons 00060 $pattern = '#'.$base.'/edit\.php\?id=([0-9]+)#'; 00061 $replacement = '$@LESSONEDIT*$1@$'; 00062 $content = preg_replace($pattern, $replacement, $content); 00063 00064 // Action for adding a question page. Prints an HTML form. 00065 $pattern = '#'.$base.'/editpage\.php\?id=([0-9]+)&(amp;)?pageid=([0-9]+)#'; 00066 $replacement = '$@LESSONEDITPAGE*$1*$3@$'; 00067 $content = preg_replace($pattern, $replacement, $content); 00068 00069 // Provides the interface for grading essay questions 00070 $pattern = '#'.$base.'/essay\.php\?id=([0-9]+)#'; 00071 $replacement = '$@LESSONESSAY*$1@$'; 00072 $content = preg_replace($pattern, $replacement, $content); 00073 00074 // Provides the interface for viewing and adding high scores 00075 $pattern = '#'.$base.'/highscores\.php\?id=([0-9]+)#'; 00076 $replacement = '$@LESSONHIGHSCORES*$1@$'; 00077 $content = preg_replace($pattern, $replacement, $content); 00078 00079 // Provides the interface for viewing the report 00080 $pattern = '#'.$base.'/report\.php\?id=([0-9]+)#'; 00081 $replacement = '$@LESSONREPORT*$1@$'; 00082 $content = preg_replace($pattern, $replacement, $content); 00083 00084 // This file plays the mediafile set in lesson settings. 00085 $pattern = '#'.$base.'/mediafile\.php\?id=([0-9]+)#'; 00086 $replacement = '$@LESSONMEDIAFILE*$1@$'; 00087 $content = preg_replace($pattern, $replacement, $content); 00088 00089 // This page lists all the instances of lesson in a particular course 00090 $pattern = '#'.$base.'/index\.php\?id=([0-9]+)#'; 00091 $replacement = '$@LESSONINDEX*$1@$'; 00092 $content = preg_replace($pattern, $replacement, $content); 00093 00094 // This page prints a particular page of lesson 00095 $pattern = '#'.$base.'/view\.php\?id=([0-9]+)&(amp;)?pageid=([0-9]+)#'; 00096 $replacement = '$@LESSONVIEWPAGE*$1*$3@$'; 00097 $content = preg_replace($pattern, $replacement, $content); 00098 00099 // Link to one lesson by cmid 00100 $pattern = '#'.$base.'/view\.php\?id=([0-9]+)#'; 00101 $replacement = '$@LESSONVIEWBYID*$1@$'; 00102 $content = preg_replace($pattern, $replacement, $content); 00103 00104 // Return the now encoded content 00105 return $content; 00106 } 00107 00108 }