Skip to content
Permalink
Browse files

MDL-23479 backup - lesson revised & old code deleted (but restore logs)

  • Loading branch information...
stronk7 committed Aug 3, 2010
1 parent 8327224 commit 113065d2fa1ceb6674bc2d07abf980b6ea6e35cf
@@ -76,28 +76,33 @@ static public function encode_content_links($content) {
$replacement = '$@LESSONHIGHSCORES*$1@$';
$content = preg_replace($pattern, $replacement, $content);
// This page lists all the instances of lesson in a particular course
$pattern = '#'.$base.'/index\.php\?id=([0-9]+)#';
$replacement = '$@LESSONINDEX*$1@$';
// Provides the interface for viewing the report
$pattern = '#'.$base.'/report\.php\?id=([0-9]+)#';
$replacement = '$@LESSONREPORT*$1@$';
$content = preg_replace($pattern, $replacement, $content);
// This file plays the mediafile set in lesson settings.
$pattern = '#'.$base.'/mediafile\.php\?id=([0-9]+)#';
$replacement = '$@LESSONMEDIAFILE*$1@$';
$content = preg_replace($pattern, $replacement, $content);
// Displays the lesson statistics.
$pattern = '#'.$base.'/report\.php\?id=([0-9]+)(&(amp;)?pageid=([0-9]+))?#';
$replacement = '$@LESSONREPORT*$1*$4@$';
// This page lists all the instances of lesson in a particular course
$pattern = '#'.$base.'/index\.php\?id=([0-9]+)#';
$replacement = '$@LESSONINDEX*$1@$';
$content = preg_replace($pattern, $replacement, $content);
// This page prints a particular page of lesson
$pattern = '#'.$base.'/view\.php\?id=([0-9]+)&(amp;)?pageid=([0-9]+)#';
$replacement = '$@LESSONVIEWPAGE*$1*$3@$';
$content = preg_replace($pattern, $replacement, $content);
// This page prints a particular instance of lesson
$pattern = '#'.$base.'/view\.php\?id=([0-9]+)(&(amp;)?pageid=([0-9]+))?#';
$replacement = '$@LESSONVIEW*$1*$4@$';
// Link to one lesson by cmid
$pattern = '#'.$base.'/view\.php\?id=([0-9]+)#';
$replacement = '$@LESSONVIEWBYID*$1@$';
$content = preg_replace($pattern, $replacement, $content);
// Return the now encoded content
return $content;
}
}
}
@@ -86,7 +86,8 @@ protected function define_structure() {
$pages = new backup_nested_element('pages');
$page = new backup_nested_element('page', array('id'), array(
'prevpageid','nextpageid','qtype','qoption','layout',
'display','timecreated','timemodified','title','contents'
'display','timecreated','timemodified','title','contents',
'contentsformat'
));
// The lesson_answers table
@@ -96,7 +97,7 @@ protected function define_structure() {
$answers = new backup_nested_element('answers');
$answer = new backup_nested_element('answer', array('id'), array(
'jumpto','grade','score','flags','timecreated','timemodified','answer_text',
'response'
'response', 'answerformat', 'responseformat'
));
// Tell the answer element about the answer_text elements mapping to the answer
// database field.
@@ -187,10 +188,10 @@ protected function define_structure() {
$timer->annotate_ids('user', 'userid');
// Annotate the file areas in user by the lesson module.
$lesson->annotate_files('mod_lesson', 'mediafile', 'id');
$lesson->annotate_files('mod_lesson', 'mediafile', null);
$page->annotate_files('mod_lesson', 'page_contents', 'id');
// Prepare and return the structure we have just created for the lesson module.
return $this->prepare_activity_structure($lesson);
}
}
}
@@ -54,7 +54,7 @@ protected function define_my_steps() {
static public function define_decode_contents() {
$contents = array();
$contents[] = new restore_decode_content('lesson_pages', array('contents'), 'lesson');
$contents[] = new restore_decode_content('lesson_pages', array('contents'), 'lesson_page');
return $contents;
}
@@ -66,8 +66,15 @@ static public function define_decode_contents() {
static public function define_decode_rules() {
$rules = array();
$rules[] = new restore_decode_rule('LESSONEDIT', '/mod/lesson/edit.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONESAY', '/mod/lesson/essay.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONHIGHSCORES', '/mod/lesson/highscores.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONREPORT', '/mod/lesson/report.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONMEDIAFILE', '/mod/lesson/mediafile.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONVIEWBYID', '/mod/lesson/view.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('LESSONINDEX', '/mod/lesson/index.php?id=$1', 'course');
$rules[] = new restore_decode_rule('LESSONVIEWPAGE', '/mod/lesson/view.php?id=$1&pageid=$2', array('course_module', 'lesson_page'));
$rules[] = new restore_decode_rule('LESSONEDITPAGE', '/mod/lesson/edit.php?id=$1&pageid=$2', array('course_module', 'lesson_page'));
return $rules;
@@ -80,15 +80,11 @@ protected function process_lesson_page($data) {
$data->timecreated = $this->apply_date_offset($data->timecreated);
$newitemid = $DB->insert_record('lesson_pages', $data);
$this->set_mapping('lesson_page', $oldid, $newitemid);
$this->set_mapping('lesson_page', $oldid, $newitemid, true); // Has related fileareas
//now update previous page with newid as the nextpageid
//now update previous page with newitemid as the nextpageid
if (!empty($data->prevpageid)) {
$prevpage = $DB->get_record('lesson_pages', array('lessonid'=>$data->lessonid, 'id'=>$data->prevpageid));
if (!empty($prevpage)) {
$prevpage->nextpageid = $newitemid;
$DB->update_record('lesson_pages', $prevpage);
}
$DB->set_field('lesson_pages', 'nextpageid', $newitemid, array('id' => $data->prevpageid));
}
}
@@ -116,6 +112,7 @@ protected function process_lesson_attempt($data) {
$data->pageid = $this->get_new_parentid('lesson_page');
$data->answerid = $this->get_new_parentid('lesson_answer');
$data->userid = $this->get_mappingid('user', $data->userid);
$data->timeseen = $this->apply_date_offset($data->timeseen);
$newitemid = $DB->insert_record('lesson_attempts', $data);
}
@@ -127,6 +124,7 @@ protected function process_lesson_grade($data) {
$oldid = $data->id;
$data->lessonid = $this->get_new_parentid('lesson');
$data->userid = $this->get_mappingid('user', $data->userid);
$data->completed = $this->apply_date_offset($data->completed);
$newitemid = $DB->insert_record('lesson_grades', $data);
$this->set_mapping('lesson_grade', $oldid, $newitemid);
@@ -140,9 +138,9 @@ protected function process_lesson_branch($data) {
$data->lessonid = $this->get_new_parentid('lesson');
$data->pageid = $this->get_new_parentid('lesson_page');
$data->userid = $this->get_mappingid('user', $data->userid);
$data->timeseen = $this->apply_date_offset($data->timeseen);
$newitemid = $DB->insert_record('lesson_branch', $data);
$this->set_mapping('lesson_branch', $oldid, $newitemid);
}
protected function process_lesson_highscore($data) {
@@ -164,13 +162,20 @@ protected function process_lesson_timer($data) {
$oldid = $data->id;
$data->lessonid = $this->get_new_parentid('lesson');
$data->userid = $this->get_mappingid('user', $data->userid);
$data->starttime = $this->apply_date_offset($data->starttime);
$data->lessontime = $this->apply_date_offset($data->lessontime);
$newitemid = $DB->insert_record('lesson_timer', $data);
}
protected function after_execute() {
// Add lesson related files, no need to match by itemname (just internally handled context)
$this->add_related_files('mod_lesson', 'mediafile', 'id');
$this->add_related_files('mod_lesson', 'page_contents', 'id');
// Add lesson mediafile, no need to match by itemname (just internally handled context)
$this->add_related_files('mod_lesson', 'mediafile', null);
// Add lesson page files, by lesson_page itemname
$this->add_related_files('mod_lesson', 'page_contents', 'lesson_page');
// TODO: somewhere at the end of the restore... when all the activities have been restored
// TODO: we need to decode the lesson->activitylink that points to another activity in the course
// TODO: great functionality that breaks self-contained principles, grrr
}
}

0 comments on commit 113065d

Please sign in to comment.
You can’t perform that action at this time.