protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $scheduler = new backup_nested_element('scheduler', array('id'), array('name', 'intro', 'introformat', 'schedulermode', 'maxbookings', 'guardtime', 'defaultslotduration', 'allownotifications', 'staffrolename', 'scale', 'gradingstrategy', 'bookingrouping', 'timemodified'));
     $slots = new backup_nested_element('slots');
     $slot = new backup_nested_element('slot', array('id'), array('starttime', 'duration', 'teacherid', 'appointmentlocation', 'timemodified', 'notes', 'exclusivity', 'appointmentnote', 'emaildate', 'hideuntil'));
     $appointments = new backup_nested_element('appointments');
     $appointment = new backup_nested_element('appointment', array('id'), array('studentid', 'attended', 'grade', 'appointmentnote', 'timecreated', 'timemodified'));
     // Build the tree
     $scheduler->add_child($slots);
     $slots->add_child($slot);
     $slot->add_child($appointments);
     $appointments->add_child($appointment);
     // Define sources
     $scheduler->set_source_table('scheduler', array('id' => backup::VAR_ACTIVITYID));
     $scheduler->annotate_ids('grouping', 'bookingrouping');
     // Include appointments only if we back up user information
     if ($userinfo) {
         $slot->set_source_table('scheduler_slots', array('schedulerid' => backup::VAR_PARENTID));
         $appointment->set_source_table('scheduler_appointment', array('slotid' => backup::VAR_PARENTID));
     }
     // Define id annotations
     $scheduler->annotate_ids('scale', 'scale');
     if ($userinfo) {
         $slot->annotate_ids('user', 'teacherid');
         $appointment->annotate_ids('user', 'studentid');
     }
     // Define file annotations
     $scheduler->annotate_files('mod_scheduler', 'intro', null);
     // This file area has no itemid
     // Return the root element (scheduler), wrapped into standard activity structure
     return $this->prepare_activity_structure($scheduler);
 }
 protected function define_structure()
 {
     global $CFG;
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $certificate = new backup_nested_element('simplecertificate', array('id'), array('name', 'intro', 'introformat', 'timemodified', 'width', 'height', 'certificateimage', 'certificatetext', 'certificatetextformat', 'certificatetextx', 'certificatetexty', 'coursename', 'coursehours', 'outcome', 'certdate', 'certdatefmt', 'certgrade', 'gradefmt', 'emailfrom', 'emailothers', 'emailteachers', 'reportcert', 'delivery', 'requiredtime', 'printqrcode', 'qrcodefirstpage', 'codex', 'codey', 'enablesecondpage', 'secondpagex', 'secondpagey', 'secondpagetext', 'secondpagetextformat', 'secondimage', 'timestartdatefmt'));
     $issues = new backup_nested_element('issues');
     $issue = new backup_nested_element('issue', array('id'), array('userid', 'certificatename', 'timecreated', 'code', 'timedeleted'));
     // Build the tree
     $certificate->add_child($issues);
     $issues->add_child($issue);
     // Define sources
     $certificate->set_source_table('simplecertificate', array('id' => backup::VAR_ACTIVITYID));
     // All the rest of elements only happen if we are including user info
     if ($userinfo) {
         $issue->set_source_table('simplecertificate_issues', array('certificateid' => backup::VAR_PARENTID));
     }
     // Annotate the user id's where required.
     $certificate->annotate_ids('outcome', 'outcome');
     $certificate->annotate_ids('certdate', 'certdate');
     $certificate->annotate_ids('certgrade', 'certgrade');
     $issue->annotate_ids('user', 'userid');
     // Define file annotations
     //$certificate->annotate_files('mod_simplecertificate', 'intro', null);
     $certificate->annotate_files(simplecertificate::CERTIFICATE_COMPONENT_NAME, simplecertificate::CERTIFICATE_IMAGE_FILE_AREA, null);
     $issue->annotate_files(simplecertificate::CERTIFICATE_COMPONENT_NAME, simplecertificate::CERTIFICATE_ISSUES_FILE_AREA, 'id');
     // Return the root element (certificate), wrapped into standard activity structure
     return $this->prepare_activity_structure($certificate);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $voiceshadow = new backup_nested_element('voiceshadow', array('id'), array('course', 'name', 'intro', 'introformat', 'timeopen', 'timeclose', 'teacher', 'embedvideo', 'recordtype', 'timemodified'));
     $files = new backup_nested_element('files', array('id'), array('instance', 'userid', 'summary', 'itemoldid', 'itemid', 'itemimgid', 'filename', 'time'));
     $ratings = new backup_nested_element('ratings', array('id'), array('fileid', 'userid', 'rating', 'ratingrhythm', 'ratingclear', 'ratingintonation', 'ratingspeed', 'ratingreproduction', 'summary', 'time'));
     $comments = new backup_nested_element('comments', array('id'), array('instance', 'fileid', 'userid', 'summary', 'itemoldid', 'itemid', 'itemimgid', 'filename', 'time'));
     $process = new backup_nested_element('process', array('id'), array('itemid', 'type'));
     // Build the tree
     $voiceshadow->add_child($files);
     $voiceshadow->add_child($ratings);
     $voiceshadow->add_child($comments);
     $voiceshadow->add_child($process);
     // Define sources
     $voiceshadow->set_source_table('voiceshadow', array('id' => backup::VAR_ACTIVITYID, 'course' => backup::VAR_COURSEID));
     $files->set_source_table('voiceshadow_files', array('instance' => backup::VAR_ACTIVITYID));
     $comments->set_source_table('voiceshadow_comments', array('instance' => backup::VAR_ACTIVITYID));
     // Define id annotations
     $voiceshadow->annotate_ids('teacher', 'userid');
     $files->annotate_ids('userid', 'userid');
     $ratings->annotate_ids('userid', 'userid');
     $comments->annotate_ids('userid', 'userid');
     // Return the root element (voiceshadow), wrapped into standard activity structure
     return $this->prepare_activity_structure($voiceshadow);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $groupselect = new backup_nested_element('groupselect', array('id'), array('name', 'intro', 'introformat', 'targetgrouping', 'maxmembers', 'timeavailable', 'timedue', 'timecreated', 'timemodified', 'hidefullgroups', 'deleteemptygroups', 'studentcancreate', 'minmembers', 'assignteachers', 'studentcansetdesc', 'showassignedteacher', 'studentcansetenrolmentkey', 'studentcansetgroupname', 'notifyexpiredselection'));
     $passwords = new backup_nested_element('passwords');
     $password = new backup_nested_element('password', array('id'), array('groupid', 'password'));
     $groupteachers = new backup_nested_element('groupteachers');
     $groupteacher = new backup_nested_element('groupteacher', array('id'), array('groupid', 'teacherid'));
     // Build the tree
     $groupselect->add_child($passwords);
     $passwords->add_child($password);
     $groupselect->add_child($groupteachers);
     $groupteachers->add_child($groupteacher);
     // Define sources
     $groupselect->set_source_table('groupselect', array('id' => backup::VAR_ACTIVITYID));
     $password->set_source_table('groupselect_passwords', array('instance_id' => backup::VAR_ACTIVITYID));
     if ($userinfo) {
         $groupteacher->set_source_table('groupselect_groups_teachers', array('instance_id' => backup::VAR_ACTIVITYID));
     }
     // Define id annotations
     $groupselect->annotate_ids('grouping', 'targetgrouping');
     $password->annotate_ids('group', 'groupid');
     $groupteacher->annotate_ids('group', 'groupid');
     $groupteacher->annotate_ids('user', 'teacherid');
     // Define file annotations
     $groupselect->annotate_files('mod_groupselect', 'intro', null);
     // This file areas haven't itemid
     // Return the root element (groupselect), wrapped into standard activity structure
     return $this->prepare_activity_structure($groupselect);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $jclic = new backup_nested_element('jclic', array('id'), array('name', 'intro', 'introformat', 'url', 'skin', 'maxattempts', 'width', 'height', 'avaluation', 'maxgrade', 'grade', 'lang', 'exiturl', 'timeavailable', 'timedue'));
     $sessions = new backup_nested_element('sessions');
     $session = new backup_nested_element('session', array('id'), array('session_id', 'user_id', 'session_datetime', 'project_name', 'session_key', 'session_code', 'session_context'));
     $activities = new backup_nested_element('sessionactivities');
     $activity = new backup_nested_element('sessionactivity', array('id'), array('session_id', 'activity_id', 'activity_name', 'num_actions', 'score', 'activity_solved', 'qualification', 'total_time', 'activity_code'));
     // Build the tree
     $jclic->add_child($sessions);
     $sessions->add_child($session);
     $session->add_child($activities);
     $activities->add_child($activity);
     // Define sources
     $jclic->set_source_table('jclic', array('id' => backup::VAR_ACTIVITYID));
     // All the rest of elements only happen if we are including user info
     if ($userinfo) {
         $session->set_source_table('jclic_sessions', array('jclicid' => backup::VAR_PARENTID));
         $activity->set_source_table('jclic_activities', array('session_id' => '../../session_id'));
     }
     // Define id annotations
     $jclic->annotate_ids('scale', 'grade');
     $session->annotate_ids('user', 'user_id');
     // Define file annotations
     $jclic->annotate_files('mod_jclic', 'intro', null);
     // This file area hasn't itemid
     $jclic->annotate_files('mod_jclic', 'content', null);
     // This file area hasn't itemid
     // Return the root element (jclic), wrapped into standard activity structure
     return $this->prepare_activity_structure($jclic);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo.
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated.
     $teambuilder = new backup_nested_element('teambuilder', array('id'), array('course', 'name', 'intro', 'introformat', 'open', 'close', 'groupid', 'allowupdate'));
     $questions = new backup_nested_element('questions');
     $question = new backup_nested_element('question', array('id'), array('builder', 'question', 'type', 'display', 'ordinal'));
     $answers = new backup_nested_element('answers');
     $answer = new backup_nested_element('answer', array('id'), array('question', 'answer', 'ordinal'));
     $responses = new backup_nested_element('responses');
     $response = new backup_nested_element('response', array('id'), array('userid', 'answerid'));
     // Build the tree.
     $teambuilder->add_child($questions);
     $questions->add_child($question);
     $question->add_child($answers);
     $answers->add_child($answer);
     $answer->add_child($responses);
     $responses->add_child($response);
     // Define sources.
     $teambuilder->set_source_table('teambuilder', array('id' => backup::VAR_ACTIVITYID));
     $question->set_source_table('teambuilder_question', array('builder' => backup::VAR_PARENTID));
     $answer->set_source_table('teambuilder_answer', array('question' => backup::VAR_PARENTID));
     // All the rest of elements only happen if we are including user info.
     if ($userinfo) {
         $response->set_source_table('teambuilder_response', array('answerid' => backup::VAR_PARENTID));
     }
     $teambuilder->annotate_ids('group', 'groupid');
     $response->annotate_ids('user', 'userid');
     // Define file annotations.
     $teambuilder->annotate_files('mod_teambuilder', 'intro', null);
     // Return the root element (teambuilder), wrapped into standard activity structure.
     return $this->prepare_activity_structure($teambuilder);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $groupselect = new backup_nested_element('groupselect', array('id'), array('course', 'name', 'intro', 'introformat', 'targetgrouping', 'signuptype', 'password', 'maxmembers', 'individual_limits', 'timeavailable', 'timedue', 'timecreated', 'timemodified'));
     $limits = new backup_nested_element('limits');
     $limit = new backup_nested_element('limit', array('id'), array('groupselect', 'groupid', 'lim'));
     // Build the tree
     $groupselect->add_child($limits);
     $limits->add_child($limit);
     // Define sources
     $groupselect->set_source_table('groupselect', array('id' => backup::VAR_ACTIVITYID));
     $limit->set_source_sql('
         SELECT *
           FROM {groupselect_limits}
           WHERE groupselect = ?', array(backup::VAR_PARENTID));
     // Define id annotations
     $groupselect->annotate_ids('grouping', 'targetgrouping');
     $limit->annotate_ids('group', 'groupid');
     // Define file annotations
     $groupselect->annotate_files('mod_groupselect', 'intro', null);
     // This file area hasn't itemid
     // Return the root element (groupselect), wrapped into standard activity structure
     return $this->prepare_activity_structure($groupselect);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $geogebra = new backup_nested_element('geogebra', array('id'), array('name', 'intro', 'introformat', 'url', 'attributes', 'width', 'height', 'showsubmit', 'grade', 'autograde', 'maxattempts', 'grademethod', 'timeavailable', 'timedue', 'timecreated', 'timemodified'));
     $attempts = new backup_nested_element('attempts');
     $attempt = new backup_nested_element('attempt', array('id'), array('geogebra', 'userid', 'vars', 'gradecomment', 'finished', 'dateteacher', 'datestudent'));
     // Build the tree
     $geogebra->add_child($attempts);
     $attempts->add_child($attempt);
     // Define sources
     $geogebra->set_source_table('geogebra', array('id' => backup::VAR_ACTIVITYID));
     // All the rest of elements only happen if we are including user info
     if ($userinfo) {
         $attempt->set_source_table('geogebra_attempts', array('geogebra' => backup::VAR_PARENTID));
     }
     // Define id annotations
     $geogebra->annotate_ids('scale', 'grade');
     $attempt->annotate_ids('user', 'userid');
     // Define file annotations
     $geogebra->annotate_files('mod_geogebra', 'intro', null);
     // This file area hasn't itemid
     $geogebra->annotate_files('mod_geogebra', 'content', null);
     // This file area hasn't itemid
     // Return the root element (geogebra), wrapped into standard activity structure
     return $this->prepare_activity_structure($geogebra);
 }
 protected function define_structure()
 {
     global $DB;
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('users');
     if ($userinfo) {
         // Define each element separated
         $jmail = new backup_nested_element('jmail', array('id'), array('sender', 'courseid', 'subject', 'body', 'attachment', 'approved', 'timesent', 'timecreated'));
         $sents = new backup_nested_element('sents');
         $sent = new backup_nested_element('sent', array('id'), array('userid', 'messageid', 'type', 'mread', 'answered', 'deleted', 'labeled'));
         $labels = new backup_nested_element('labels');
         $label = new backup_nested_element('label', array('id'), array('name', 'userid', 'courseid', 'timecreated'));
         $mlabels = new backup_nested_element('mlabels');
         $mlabel = new backup_nested_element('mlabel', array('id'), array('labelid', 'messagesentid', 'timecreated'));
         $preferences = new backup_nested_element('preferences');
         $preference = new backup_nested_element('preference', array('id'), array('userid', 'courseid', 'name', 'value'));
         // Build the tree
         $jmail->add_child($sents);
         $sents->add_child($sent);
         $jmail->add_child($preferences);
         $preferences->add_child($preference);
         $jmail->add_child($labels);
         $labels->add_child($label);
         $label->add_child($mlabels);
         $mlabels->add_child($mlabel);
         // Define sources
         $jmail->set_source_table('block_jmail', array('courseid' => backup::VAR_COURSEID));
         $sent->set_source_table('block_jmail_sent', array('messageid' => backup::VAR_PARENTID));
         $preference->set_source_table('block_jmail_preferences', array('courseid' => backup::VAR_COURSEID));
         $label->set_source_table('block_jmail_label', array('courseid' => backup::VAR_COURSEID));
         $mlabel->set_source_table('block_jmail_m_label', array('labelid' => backup::VAR_PARENTID));
         // Define id annotations
         $jmail->annotate_ids('course', 'courseid');
         $jmail->annotate_ids('user', 'sender');
         $sent->annotate_ids('user', 'userid');
         // Define file annotations
         $jmail->annotate_files('block_jmail', 'attachment', 'id');
         $jmail->annotate_files('block_jmail', 'body', 'id');
     } else {
         return null;
     }
     // Return the root element (jmail), wrapped into standard block structure
     return $this->prepare_block_structure($jmail);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo.
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated.
     $activequiz = new backup_nested_element('activequiz', array('id'), array('name', 'intro', 'introformat', 'graded', 'scale', 'grademethod', 'workedingroups', 'grouping', 'groupattendance', 'reviewoptions', 'timecreated', 'timemodified', 'defaultquestiontime', 'waitforquestiontime', 'questionorder'));
     $questions = new backup_nested_element('questions');
     $question = new backup_nested_element('question', array('id'), array('questionid', 'notime', 'questiontime', 'tries', 'points', 'showhistoryduringquiz'));
     $grades = new backup_nested_element('grades');
     $grade = new backup_nested_element('grade', array('id'), array('userid', 'gradeval', 'timemodified'));
     $sessions = new backup_nested_element('sessions');
     $session = new backup_nested_element('session', array('id'), array('name', 'sessionopen', 'status', 'currentquestion', 'currentqnum', 'currentquestiontime', 'classresult', 'nextstarttime', 'created'));
     $attempts = new backup_nested_element('attempts');
     $attempt = new backup_nested_element('attempt', array('id'), array('userid', 'attemptnum', 'questionengid', 'status', 'preview', 'responded', 'forgroupid', 'timestart', 'timefinish', 'timemodified', 'qubalayout'));
     // This module is using questions, so produce the related question states and sessions
     // attaching them to the $attempt element based in 'questionengid' matching.
     $this->add_question_usages($attempt, 'questionengid');
     $groupattendances = new backup_nested_element('groupattendances');
     $groupattendance = new backup_nested_element('groupattendance', array('id'), array('activequizid', 'sessionid', 'groupid', 'userid'));
     // Build the tree.
     $activequiz->add_child($questions);
     $questions->add_child($question);
     $activequiz->add_child($grades);
     $grades->add_child($grade);
     $activequiz->add_child($sessions);
     $sessions->add_child($session);
     $session->add_child($attempts);
     $attempts->add_child($attempt);
     $attempt->add_child($groupattendances);
     $groupattendances->add_child($groupattendance);
     // Define sources.
     $activequiz->set_source_table('activequiz', array('id' => backup::VAR_ACTIVITYID));
     $question->set_source_table('activequiz_questions', array('activequizid' => backup::VAR_PARENTID));
     // If user info backup grades table.
     if ($userinfo) {
         $grade->set_source_table('activequiz_grades', array('activequizid' => backup::VAR_PARENTID));
         $session->set_source_table('activequiz_sessions', array('activequizid' => backup::VAR_PARENTID));
         $attempt->set_source_table('activequiz_attempts', array('sessionid' => backup::VAR_PARENTID));
         $groupattendance->set_source_table('activequiz_groupattendance', array('attemptid' => backup::VAR_PARENTID));
     }
     // Define source alias.
     $grade->set_source_alias('grade', 'gradeval');
     // Define id annotations.
     $activequiz->annotate_ids('grouping', 'grouping');
     $grade->annotate_ids('user', 'userid');
     $attempt->annotate_ids('user', 'userid');
     $attempt->annotate_ids('group', 'forgroupid');
     $question->annotate_ids('question', 'questionid');
     $groupattendance->annotate_ids('group', 'groupid');
     $groupattendance->annotate_ids('user', 'userid');
     // Define file annotations.
     $activequiz->annotate_files('mod_activequiz', 'intro', null);
     // This file area hasn't itemid.
     // Return the root element (activequiz), wrapped into standard activity structure.
     return $this->prepare_activity_structure($activequiz);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $glossary = new backup_nested_element('glossary', array('id'), array('name', 'intro', 'introformat', 'allowduplicatedentries', 'displayformat', 'mainglossary', 'showspecial', 'showalphabet', 'showall', 'allowcomments', 'allowprintview', 'usedynalink', 'defaultapproval', 'globalglossary', 'entbypage', 'editalways', 'rsstype', 'rssarticles', 'assessed', 'assesstimestart', 'assesstimefinish', 'scale', 'timecreated', 'timemodified', 'completionentries'));
     $entries = new backup_nested_element('entries');
     $entry = new backup_nested_element('entry', array('id'), array('userid', 'concept', 'definition', 'definitionformat', 'definitiontrust', 'attachment', 'timecreated', 'timemodified', 'teacherentry', 'sourceglossaryid', 'usedynalink', 'casesensitive', 'fullmatch', 'approved'));
     $aliases = new backup_nested_element('aliases');
     $alias = new backup_nested_element('alias', array('id'), array('alias_text'));
     $ratings = new backup_nested_element('ratings');
     $rating = new backup_nested_element('rating', array('id'), array('scaleid', 'value', 'userid', 'timecreated', 'timemodified'));
     $categories = new backup_nested_element('categories');
     $category = new backup_nested_element('category', array('id'), array('name', 'usedynalink'));
     $categoryentries = new backup_nested_element('category_entries');
     $categoryentry = new backup_nested_element('category_entry', array('id'), array('entryid'));
     // Build the tree
     $glossary->add_child($entries);
     $entries->add_child($entry);
     $entry->add_child($aliases);
     $aliases->add_child($alias);
     $entry->add_child($ratings);
     $ratings->add_child($rating);
     $glossary->add_child($categories);
     $categories->add_child($category);
     $category->add_child($categoryentries);
     $categoryentries->add_child($categoryentry);
     // Define sources
     $glossary->set_source_table('glossary', array('id' => backup::VAR_ACTIVITYID));
     $category->set_source_table('glossary_categories', array('glossaryid' => backup::VAR_PARENTID));
     // All the rest of elements only happen if we are including user info
     if ($userinfo) {
         $entry->set_source_table('glossary_entries', array('glossaryid' => backup::VAR_PARENTID));
         $alias->set_source_table('glossary_alias', array('entryid' => backup::VAR_PARENTID));
         $alias->set_source_alias('alias', 'alias_text');
         $rating->set_source_table('rating', array('contextid' => backup::VAR_CONTEXTID, 'itemid' => backup::VAR_PARENTID));
         $rating->set_source_alias('rating', 'value');
         $categoryentry->set_source_table('glossary_entries_categories', array('categoryid' => backup::VAR_PARENTID));
     }
     // Define id annotations
     $glossary->annotate_ids('scale', 'scale');
     $entry->annotate_ids('user', 'userid');
     $rating->annotate_ids('scale', 'scaleid');
     $rating->annotate_ids('user', 'userid');
     // Define file annotations
     $glossary->annotate_files('mod_glossary', 'intro', null);
     // This file area hasn't itemid
     $entry->annotate_files('mod_glossary', 'entry', 'id');
     $entry->annotate_files('mod_glossary', 'attachment', 'id');
     // Return the root element (glossary), wrapped into standard activity structure
     return $this->prepare_activity_structure($glossary);
 }
Ejemplo n.º 12
0
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $data = new backup_nested_element('data', array('id'), array('name', 'intro', 'introformat', 'comments', 'timeavailablefrom', 'timeavailableto', 'timeviewfrom', 'timeviewto', 'requiredentries', 'requiredentriestoview', 'maxentries', 'rssarticles', 'singletemplate', 'listtemplate', 'listtemplateheader', 'listtemplatefooter', 'addtemplate', 'rsstemplate', 'rsstitletemplate', 'csstemplate', 'jstemplate', 'asearchtemplate', 'approval', 'manageapproved', 'scale', 'assessed', 'assesstimestart', 'assesstimefinish', 'defaultsort', 'defaultsortdir', 'editany', 'notification'));
     $fields = new backup_nested_element('fields');
     $field = new backup_nested_element('field', array('id'), array('type', 'name', 'description', 'required', 'param1', 'param2', 'param3', 'param4', 'param5', 'param6', 'param7', 'param8', 'param9', 'param10'));
     $records = new backup_nested_element('records');
     $record = new backup_nested_element('record', array('id'), array('userid', 'groupid', 'timecreated', 'timemodified', 'approved'));
     $contents = new backup_nested_element('contents');
     $content = new backup_nested_element('content', array('id'), array('fieldid', 'content', 'content1', 'content2', 'content3', 'content4'));
     $ratings = new backup_nested_element('ratings');
     $rating = new backup_nested_element('rating', array('id'), array('component', 'ratingarea', 'scaleid', 'value', 'userid', 'timecreated', 'timemodified'));
     // Build the tree
     $data->add_child($fields);
     $fields->add_child($field);
     $data->add_child($records);
     $records->add_child($record);
     $record->add_child($contents);
     $contents->add_child($content);
     $record->add_child($ratings);
     $ratings->add_child($rating);
     // Define sources
     $data->set_source_table('data', array('id' => backup::VAR_ACTIVITYID));
     $field->set_source_sql('
         SELECT *
           FROM {data_fields}
          WHERE dataid = ?', array(backup::VAR_PARENTID));
     // All the rest of elements only happen if we are including user info
     if ($userinfo) {
         $record->set_source_table('data_records', array('dataid' => backup::VAR_PARENTID));
         $content->set_source_table('data_content', array('recordid' => backup::VAR_PARENTID));
         $rating->set_source_table('rating', array('contextid' => backup::VAR_CONTEXTID, 'itemid' => backup::VAR_PARENTID, 'component' => backup_helper::is_sqlparam('mod_data'), 'ratingarea' => backup_helper::is_sqlparam('entry')));
         $rating->set_source_alias('rating', 'value');
     }
     // Define id annotations
     $data->annotate_ids('scale', 'scale');
     $record->annotate_ids('user', 'userid');
     $record->annotate_ids('group', 'groupid');
     $rating->annotate_ids('scale', 'scaleid');
     $rating->annotate_ids('user', 'userid');
     // Define file annotations
     $data->annotate_files('mod_data', 'intro', null);
     // This file area hasn't itemid
     $content->annotate_files('mod_data', 'content', 'id');
     // By content->id
     // Return the root element (data), wrapped into standard activity structure
     return $this->prepare_activity_structure($data);
 }
 /**
  * Define the structure for the setask activity
  * @return void
  */
 protected function define_structure()
 {
     // To know if we are including userinfo.
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated.
     $setask = new backup_nested_element('setask', array('id'), array('name', 'intro', 'introformat', 'alwaysshowdescription', 'submissiondrafts', 'sendnotifications', 'sendlatenotifications', 'sendstudentnotifications', 'duedate', 'cutoffdate', 'allowsubmissionsfromdate', 'grade', 'timemodified', 'completionsubmit', 'requiresubmissionstatement', 'teamsubmission', 'requireallteammemberssubmit', 'teamsubmissiongroupingid', 'blindmarking', 'revealidentities', 'attemptreopenmethod', 'maxattempts', 'markingworkflow', 'markingallocation', 'preventsubmissionnotingroup'));
     $userflags = new backup_nested_element('userflags');
     $userflag = new backup_nested_element('userflag', array('id'), array('userid', 'setaskment', 'mailed', 'locked', 'extensionduedate', 'workflowstate', 'allocatedmarker'));
     $submissions = new backup_nested_element('submissions');
     $submission = new backup_nested_element('submission', array('id'), array('userid', 'timecreated', 'timemodified', 'status', 'groupid', 'attemptnumber', 'latest'));
     $grades = new backup_nested_element('grades');
     $grade = new backup_nested_element('grade', array('id'), array('userid', 'timecreated', 'timemodified', 'grader', 'grade', 'attemptnumber'));
     $pluginconfigs = new backup_nested_element('plugin_configs');
     $pluginconfig = new backup_nested_element('plugin_config', array('id'), array('plugin', 'subtype', 'name', 'value'));
     // Build the tree.
     $setask->add_child($userflags);
     $userflags->add_child($userflag);
     $setask->add_child($submissions);
     $submissions->add_child($submission);
     $setask->add_child($grades);
     $grades->add_child($grade);
     $setask->add_child($pluginconfigs);
     $pluginconfigs->add_child($pluginconfig);
     // Define sources.
     $setask->set_source_table('setask', array('id' => backup::VAR_ACTIVITYID));
     $pluginconfig->set_source_table('setask_plugin_config', array('setaskment' => backup::VAR_PARENTID));
     if ($userinfo) {
         $userflag->set_source_table('setask_user_flags', array('setaskment' => backup::VAR_PARENTID));
         $submission->set_source_table('setask_submission', array('setaskment' => backup::VAR_PARENTID));
         $grade->set_source_table('setask_grades', array('setaskment' => backup::VAR_PARENTID));
         // Support 2 types of subplugins.
         $this->add_subplugin_structure('setasksubmission', $submission, true);
         $this->add_subplugin_structure('setaskfeedback', $grade, true);
     }
     // Define id annotations.
     $userflag->annotate_ids('user', 'userid');
     $userflag->annotate_ids('user', 'allocatedmarker');
     $submission->annotate_ids('user', 'userid');
     $submission->annotate_ids('group', 'groupid');
     $grade->annotate_ids('user', 'userid');
     $grade->annotate_ids('user', 'grader');
     $setask->annotate_ids('grouping', 'teamsubmissiongroupingid');
     // Define file annotations.
     // These file areas don't have an itemid.
     $setask->annotate_files('mod_setask', 'intro', null);
     $setask->annotate_files('mod_setask', 'introattachment', null);
     // Return the root element (choice), wrapped into standard activity structure.
     return $this->prepare_activity_structure($setask);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $pcast = new backup_nested_element('pcast', array('id'), array('userid', 'name', 'intro', 'introformat', 'userscancomment', 'userscancategorize', 'userscanpost', 'requireapproval', 'displayauthor', 'displayviews', 'image', 'imageheight', 'imagewidth', 'rssepisodes', 'rsssortorder', 'enablerssfeed', 'enableitunes', 'visible', 'explicit', 'subtitle', 'keywords', 'topcategory', 'nestedcategory', 'assessed', 'assesstimestart', 'assesstimefinish', 'scale', 'timecreated', 'timemodified'));
     $episodes = new backup_nested_element('episodes');
     $episode = new backup_nested_element('episode', array('id'), array('userid', 'name', 'summary', 'mediafile', 'duration', 'explicit', 'subtitle', 'keywords', 'topcategory', 'nestedcategory', 'timecreated', 'timemodified', 'approved', 'sequencenumber'));
     $views = new backup_nested_element('views');
     $view = new backup_nested_element('view', array('id'), array('episodeid', 'userid', 'views', 'lastview'));
     $ratings = new backup_nested_element('ratings');
     $rating = new backup_nested_element('rating', array('id'), array('component', 'ratingarea', 'scaleid', 'value', 'userid', 'timecreated', 'timemodified'));
     // Build the tree
     $pcast->add_child($episodes);
     $episodes->add_child($episode);
     $episode->add_child($views);
     $views->add_child($view);
     $episode->add_child($ratings);
     $ratings->add_child($rating);
     // Define sources
     $pcast->set_source_table('pcast', array('id' => backup::VAR_ACTIVITYID));
     // All the rest of elements only happen if we are including user info
     if ($userinfo) {
         $episode->set_source_sql('
         SELECT *
           FROM {pcast_episodes}
          WHERE pcastid = ?', array(backup::VAR_PARENTID));
         $view->set_source_sql('
         SELECT *
           FROM {pcast_views}
          WHERE episodeid = ?', array(backup::VAR_PARENTID));
         $rating->set_source_table('rating', array('contextid' => backup::VAR_CONTEXTID, 'itemid' => backup::VAR_PARENTID, 'component' => 'mod_pcast', 'ratingarea' => 'episode'));
         $rating->set_source_alias('rating', 'value');
     }
     // Define id annotations
     $pcast->annotate_ids('user', 'userid');
     $episode->annotate_ids('user', 'userid');
     $view->annotate_ids('user', 'userid');
     $rating->annotate_ids('scale', 'scaleid');
     $rating->annotate_ids('user', 'userid');
     // Define file annotations
     $pcast->annotate_files('mod_pcast', 'intro', null);
     // This file area hasn't itemid
     $pcast->annotate_files('mod_pcast', 'logo', null);
     $episode->annotate_files('mod_pcast', 'episode', 'id');
     // Return the root element (pcast), wrapped into standard activity structure
     return $this->prepare_activity_structure($pcast);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $studyplan = new backup_nested_element('studyplan', array('id'), array("quiz", "name", "intro", "introformat", "standardblock", "timecreated", "timemodified"));
     $blocks = new backup_nested_element('blocks');
     $block = new backup_nested_element('block', array('id'), array("studyplan", "sequence", "type", "lookuptype", "keyname", "operator", "value", "label", "content", "contentformat", "activity", "completionactivity", "timecreated", "timemodified"));
     $overrides = new backup_nested_element('overrides');
     $override = new backup_nested_element('override', array('id'), array("studyplan", "block", "user", "timecreated", "timemodified"));
     $progresses = new backup_nested_element('progresses');
     $progress = new backup_nested_element('progress', array('id'), array("studyplan", "user", "percent", "timecreated", "timemodified"));
     // Build the tree
     $studyplan->add_child($blocks);
     $blocks->add_child($block);
     $studyplan->add_child($overrides);
     $overrides->add_child($override);
     $studyplan->add_child($progresses);
     $progresses->add_child($progress);
     // Define sources
     $studyplan->set_source_table('studyplan', array('id' => backup::VAR_ACTIVITYID));
     $block->set_source_sql('
         SELECT *
           FROM {studyplan_blocks}
          WHERE studyplan = ?', array(backup::VAR_PARENTID));
     // All the rest of elements only happen if we are including user info
     if ($userinfo) {
         $override->set_source_table('studyplan_overrides', array('studyplan' => '../../id'));
         $override->annotate_ids('studyplan', 'studyplan');
         $override->annotate_ids('studyplan_block', 'block');
         $override->annotate_ids('user', 'user');
         $progress->set_source_table('studyplan_progress', array('studyplan' => '../../id'));
         $progress->annotate_ids('studyplan', 'studyplan');
         $progress->annotate_ids('user', 'user');
     }
     // Define id annotations
     $studyplan->annotate_ids('quiz', 'quiz');
     $block->annotate_ids('studyplan', 'studyplan');
     $block->annotate_ids('course_module', 'activity');
     $block->annotate_ids('course_module', 'completionactivity');
     // Define file annotations
     // Return the root element (studyplan), wrapped into standard activity structure
     return $this->prepare_activity_structure($studyplan);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $congrea = new backup_nested_element('congrea', array('id'), array('name', 'intro', 'introformat', 'moderatorid', 'opentime', 'closetime', 'themecolor', 'audio', 'pushtotalk', 'timecreated', 'timemodified'));
     $files = new backup_nested_element('files');
     $file = new backup_nested_element('file', array('id'), array('userid', 'vcsessionkey', 'vcsessionname', 'numoffiles', 'timecreated'));
     $congrea->add_child($files);
     $files->add_child($file);
     // Define sources
     $congrea->set_source_table('congrea', array('id' => backup::VAR_ACTIVITYID));
     if ($userinfo) {
         $file->set_source_table('congrea_files', array('vcid' => backup::VAR_PARENTID));
     }
     // Define id annotations.
     $file->annotate_ids('user', 'userid');
     $congrea->annotate_ids('user', 'moderatorid');
     // Define file annotations.
     $congrea->annotate_files('mod_congrea', 'intro', null);
     // This file area hasn't itemid
     // Return the root element (congrea), wrapped into standard activity structure.
     return $this->prepare_activity_structure($congrea);
 }
    /**
     * Define the structure for the assign activity
     * @return void
     */
    protected function define_structure() {

        // To know if we are including userinfo
        $userinfo = $this->get_setting_value('userinfo');

        // Define each element separated
        $assign = new backup_nested_element('assign', array('id'),
                                            array('name',
                                                  'intro',
                                                  'introformat',
                                                  'alwaysshowdescription',
                                                  'submissiondrafts',
                                                  'sendnotifications',
                                                  'sendlatenotifications',
                                                  'duedate',
                                                  'cutoffdate',
                                                  'allowsubmissionsfromdate',
                                                  'grade',
                                                  'timemodified',
                                                  'completionsubmit',
                                                  'requiresubmissionstatement',
                                                  'teamsubmission',
                                                  'requireallteammemberssubmit',
                                                  'teamsubmissiongroupingid',
                                                  'blindmarking',
                                                  'revealidentities'));

        $submissions = new backup_nested_element('submissions');

        $submission = new backup_nested_element('submission', array('id'),
                                                array('userid',
                                                      'timecreated',
                                                      'timemodified',
                                                      'status',
                                                      'groupid'));

        $grades = new backup_nested_element('grades');

        $grade = new backup_nested_element('grade', array('id'),
                                           array('userid',
                                                 'timecreated',
                                                 'timemodified',
                                                 'grader',
                                                 'grade',
                                                 'locked',
                                                 'mailed',
                                                 'extensionduedate'));

        $pluginconfigs = new backup_nested_element('plugin_configs');

        $pluginconfig = new backup_nested_element('plugin_config', array('id'),
                                                   array('plugin',
                                                         'subtype',
                                                         'name',
                                                         'value'));

        // Build the tree

        $assign->add_child($submissions);
        $submissions->add_child($submission);
        $assign->add_child($grades);
        $grades->add_child($grade);
        $assign->add_child($pluginconfigs);
        $pluginconfigs->add_child($pluginconfig);


        // Define sources
        $assign->set_source_table('assign', array('id' => backup::VAR_ACTIVITYID));

        if ($userinfo) {
            $submission->set_source_table('assign_submission',
                                     array('assignment' => backup::VAR_PARENTID));

            $grade->set_source_table('assign_grades',
                                     array('assignment' => backup::VAR_PARENTID));
            $pluginconfig->set_source_table('assign_plugin_config',
                                     array('assignment' => backup::VAR_PARENTID));

            // support 2 types of subplugins
            $this->add_subplugin_structure('assignsubmission', $submission, true);
            $this->add_subplugin_structure('assignfeedback', $grade, true);
        }


        // Define id annotations
        $submission->annotate_ids('user', 'userid');
        $submission->annotate_ids('group', 'groupid');
        $grade->annotate_ids('user', 'userid');
        $grade->annotate_ids('user', 'grader');
        $assign->annotate_ids('grouping', 'teamsubmissiongroupingid');

        // Define file annotations
        $assign->annotate_files('mod_assign', 'intro', null); // This file area hasn't itemid

        // Return the root element (choice), wrapped into standard activity structure

        return $this->prepare_activity_structure($assign);
    }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $oublog = new backup_nested_element('oublog', array('id'), array('name', 'course', 'accesstoken', 'intro', 'introformat', 'allowcomments', 'individual', 'maxbytes', 'maxattachments', 'maxvisibility', 'global', 'views', 'completionposts', 'completioncomments', 'reportingemail', 'displayname', 'statblockon', 'allowimport', 'introonpost', 'tags', 'assessed', 'assesstimestart', 'assesstimefinish', 'scale', 'grading', 'restricttags', 'postfrom', 'postuntil', 'commentfrom', 'commentuntil'));
     $instances = new backup_nested_element('instances');
     $instance = new backup_nested_element('instance', array('id'), array('userid', 'name', 'summary', 'accesstoken', 'views'));
     $links = new backup_nested_element('links');
     $link = new backup_nested_element('link', array('id'), array('title', 'url', 'sortorder'));
     $posts = new backup_nested_element('posts');
     $post = new backup_nested_element('post', array('id'), array('groupid', 'title', 'message', 'timeposted', 'allowcomments', 'timeupdated', 'lasteditedby', 'deletedby', 'timedeleted', 'visibility'));
     $ratings = new backup_nested_element('ratings');
     $rating = new backup_nested_element('rating', array('id'), array('component', 'ratingarea', 'scaleid', 'value', 'userid', 'timecreated', 'timemodified'));
     $comments = new backup_nested_element('comments');
     $comment = new backup_nested_element('comment', array('id'), array('userid', 'title', 'message', 'timeposted', 'deletedby', 'timedeleted', 'authorname', 'authorip', 'timeapproved'));
     $edits = new backup_nested_element('edits');
     $edit = new backup_nested_element('edit', array('id'), array('userid', 'oldtitle', 'oldmessage', 'timeupdated'));
     $taginstances = new backup_nested_element('tags');
     $taginstance = new backup_nested_element('tag', array('id'), array('tag'));
     // Build the tree
     $oublog->add_child($instances);
     $instances->add_child($instance);
     $oublog->add_child($links);
     $links->add_child($link);
     $instance->add_child($posts);
     $posts->add_child($post);
     $post->add_child($ratings);
     $ratings->add_child($rating);
     $post->add_child($comments);
     $comments->add_child($comment);
     $post->add_child($edits);
     $edits->add_child($edit);
     $post->add_child($taginstances);
     $taginstances->add_child($taginstance);
     // Define sources
     $oublog->set_source_table('oublog', array('id' => backup::VAR_ACTIVITYID));
     // All the rest of elements only happen if we are including user info
     if ($userinfo) {
         $instance->set_source_table('oublog_instances', array('oublogid' => backup::VAR_PARENTID));
         $link->set_source_table('oublog_links', array('oubloginstancesid' => backup::VAR_PARENTID));
         $post->set_source_table('oublog_posts', array('oubloginstancesid' => backup::VAR_PARENTID));
         $comment->set_source_table('oublog_comments', array('postid' => backup::VAR_PARENTID));
         $edit->set_source_table('oublog_edits', array('postid' => backup::VAR_PARENTID));
         $taginstance->set_source_sql("SELECT t.id, t.tag\n                                          FROM {oublog_tags} t\n                                          JOIN {oublog_taginstances} ti\n                                           ON t.id=ti.tagid\n                                          WHERE ti.postid=?", array(backup::VAR_PARENTID));
         $rating->set_source_table('rating', array('contextid' => backup::VAR_CONTEXTID, 'component' => backup_helper::is_sqlparam('mod_oublog'), 'ratingarea' => backup_helper::is_sqlparam('post')));
         $rating->set_source_alias('rating', 'value');
     }
     // Define id annotations
     $instance->annotate_ids('user', 'userid');
     $post->annotate_ids('group', 'groupid');
     $post->annotate_ids('user', 'lasteditedby');
     $post->annotate_ids('user', 'deletedby');
     $comment->annotate_ids('user', 'userid');
     $edit->annotate_ids('user', 'userid');
     $link->annotate_ids('oublog_instances', 'id');
     $oublog->annotate_ids('scale', 'scale');
     $rating->annotate_ids('scale', 'scaleid');
     $rating->annotate_ids('user', 'userid');
     // Define file annotations
     $oublog->annotate_files('mod_oublog', 'intro', null);
     // This file area hasn't itemid
     $instance->annotate_files('mod_oublog', 'summary', 'id');
     $post->annotate_files('mod_oublog', 'attachment', 'id');
     $post->annotate_files('mod_oublog', 'message', 'id');
     $edit->annotate_files('mod_oublog', 'edit', 'id');
     $comment->annotate_files('mod_oublog', 'messagecomment', 'id');
     // Return the root element (oublog), wrapped into standard activity structure
     return $this->prepare_activity_structure($oublog);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $forum = new backup_nested_element('forum', array('id'), array('type', 'name', 'intro', 'introformat', 'assessed', 'assesstimestart', 'assesstimefinish', 'scale', 'maxbytes', 'maxattachments', 'forcesubscribe', 'trackingtype', 'rsstype', 'rssarticles', 'timemodified', 'warnafter', 'blockafter', 'blockperiod', 'completiondiscussions', 'completionreplies', 'completionposts', 'displaywordcount'));
     $discussions = new backup_nested_element('discussions');
     $discussion = new backup_nested_element('discussion', array('id'), array('name', 'firstpost', 'userid', 'groupid', 'assessed', 'timemodified', 'usermodified', 'timestart', 'timeend'));
     $posts = new backup_nested_element('posts');
     $post = new backup_nested_element('post', array('id'), array('parent', 'userid', 'created', 'modified', 'mailed', 'subject', 'message', 'messageformat', 'messagetrust', 'attachment', 'totalscore', 'mailnow'));
     $ratings = new backup_nested_element('ratings');
     $rating = new backup_nested_element('rating', array('id'), array('component', 'ratingarea', 'scaleid', 'value', 'userid', 'timecreated', 'timemodified'));
     $subscriptions = new backup_nested_element('subscriptions');
     $subscription = new backup_nested_element('subscription', array('id'), array('userid'));
     $digests = new backup_nested_element('digests');
     $digest = new backup_nested_element('digest', array('id'), array('userid', 'maildigest'));
     $readposts = new backup_nested_element('readposts');
     $read = new backup_nested_element('read', array('id'), array('userid', 'discussionid', 'postid', 'firstread', 'lastread'));
     $trackedprefs = new backup_nested_element('trackedprefs');
     $track = new backup_nested_element('track', array('id'), array('userid'));
     // Build the tree
     $forum->add_child($discussions);
     $discussions->add_child($discussion);
     $forum->add_child($subscriptions);
     $subscriptions->add_child($subscription);
     $forum->add_child($digests);
     $digests->add_child($digest);
     $forum->add_child($readposts);
     $readposts->add_child($read);
     $forum->add_child($trackedprefs);
     $trackedprefs->add_child($track);
     $discussion->add_child($posts);
     $posts->add_child($post);
     $post->add_child($ratings);
     $ratings->add_child($rating);
     // Define sources
     $forum->set_source_table('forum', array('id' => backup::VAR_ACTIVITYID));
     // All these source definitions only happen if we are including user info
     if ($userinfo) {
         $discussion->set_source_sql('
             SELECT *
               FROM {forum_discussions}
              WHERE forum = ?', array(backup::VAR_PARENTID));
         // Need posts ordered by id so parents are always before childs on restore
         $post->set_source_table('forum_posts', array('discussion' => backup::VAR_PARENTID), 'id ASC');
         $subscription->set_source_table('forum_subscriptions', array('forum' => backup::VAR_PARENTID));
         $digest->set_source_table('forum_digests', array('forum' => backup::VAR_PARENTID));
         $read->set_source_table('forum_read', array('forumid' => backup::VAR_PARENTID));
         $track->set_source_table('forum_track_prefs', array('forumid' => backup::VAR_PARENTID));
         $rating->set_source_table('rating', array('contextid' => backup::VAR_CONTEXTID, 'component' => backup_helper::is_sqlparam('mod_forum'), 'ratingarea' => backup_helper::is_sqlparam('post'), 'itemid' => backup::VAR_PARENTID));
         $rating->set_source_alias('rating', 'value');
     }
     // Define id annotations
     $forum->annotate_ids('scale', 'scale');
     $discussion->annotate_ids('group', 'groupid');
     $post->annotate_ids('user', 'userid');
     $rating->annotate_ids('scale', 'scaleid');
     $rating->annotate_ids('user', 'userid');
     $subscription->annotate_ids('user', 'userid');
     $digest->annotate_ids('user', 'userid');
     $read->annotate_ids('user', 'userid');
     $track->annotate_ids('user', 'userid');
     // Define file annotations
     $forum->annotate_files('mod_forum', 'intro', null);
     // This file area hasn't itemid
     $post->annotate_files('mod_forum', 'post', 'id');
     $post->annotate_files('mod_forum', 'attachment', 'id');
     // Return the root element (forum), wrapped into standard activity structure
     return $this->prepare_activity_structure($forum);
 }
 /**
  * define_structure
  *
  * @return xxx
  */
 protected function define_structure()
 {
     // are we including userinfo?
     $userinfo = $this->get_setting_value('userinfo');
     ////////////////////////////////////////////////////////////////////////
     // XML nodes declaration - non-user data
     ////////////////////////////////////////////////////////////////////////
     // root element describing hotpot instance
     $fieldnames = $this->get_fieldnames('hotpot', array('id', 'course'));
     $hotpot = new backup_nested_element('hotpot', array('id'), $fieldnames);
     ////////////////////////////////////////////////////////////////////////
     // XML nodes declaration - user data
     ////////////////////////////////////////////////////////////////////////
     if ($userinfo) {
         // attempts at hotpots
         $attempts = new backup_nested_element('attempts');
         $fieldnames = $this->get_fieldnames('hotpot_attempts', array('id', 'hotpotid'));
         $attempt = new backup_nested_element('attempt', array('id'), $fieldnames);
         // questions in hotpots
         $questions = new backup_nested_element('questions');
         $fieldnames = $this->get_fieldnames('hotpot_questions', array('id', 'hotpotid', 'md5key'));
         $question = new backup_nested_element('question', array('id'), $fieldnames);
         // responses to questions
         $responses = new backup_nested_element('responses');
         $fieldnames = $this->get_fieldnames('hotpot_responses', array('id', 'questionid'));
         $response = new backup_nested_element('response', array('id'), $fieldnames);
         // strings used in questions and responses
         $strings = new backup_nested_element('strings');
         $fieldnames = $this->get_fieldnames('hotpot_strings', array('id', 'md5key'));
         $string = new backup_nested_element('string', array('id'), $fieldnames);
     }
     ////////////////////////////////////////////////////////////////////////
     // build the tree in the order needed for restore
     ////////////////////////////////////////////////////////////////////////
     if ($userinfo) {
         // strings
         $hotpot->add_child($strings);
         $strings->add_child($string);
         // attempts
         $hotpot->add_child($attempts);
         $attempts->add_child($attempt);
         // questions
         $hotpot->add_child($questions);
         $questions->add_child($question);
         // responses
         $question->add_child($responses);
         $responses->add_child($response);
     }
     ////////////////////////////////////////////////////////////////////////
     // data sources - non-user data
     ////////////////////////////////////////////////////////////////////////
     $hotpot->set_source_table('hotpot', array('id' => backup::VAR_ACTIVITYID));
     ////////////////////////////////////////////////////////////////////////
     // data sources - user related data
     ////////////////////////////////////////////////////////////////////////
     if ($userinfo) {
         // attempts
         $attempt->set_source_table('hotpot_attempts', array('hotpotid' => backup::VAR_PARENTID));
         // questions
         $question->set_source_table('hotpot_questions', array('hotpotid' => backup::VAR_PARENTID));
         // responses
         $response->set_source_table('hotpot_responses', array('questionid' => backup::VAR_PARENTID));
         // strings
         list($filter, $params) = $this->get_strings_sql();
         $string->set_source_sql("SELECT * FROM {hotpot_strings} WHERE id {$filter}", $params);
     }
     ////////////////////////////////////////////////////////////////////////
     // id annotations (foreign keys on non-parent tables)
     ////////////////////////////////////////////////////////////////////////
     $hotpot->annotate_ids('course_modules', 'entrycm');
     $hotpot->annotate_ids('course_modules', 'exitcm');
     if ($userinfo) {
         $attempt->annotate_ids('user', 'userid');
         $response->annotate_ids('hotpot_attempts', 'attemptid');
     }
     ////////////////////////////////////////////////////////////////////////
     // file annotations
     ////////////////////////////////////////////////////////////////////////
     $hotpot->annotate_files('mod_hotpot', 'sourcefile', null);
     $hotpot->annotate_files('mod_hotpot', 'entrytext', null);
     $hotpot->annotate_files('mod_hotpot', 'exittext', null);
     // return the root element (hotpot), wrapped into standard activity structure
     return $this->prepare_activity_structure($hotpot);
 }
Ejemplo n.º 21
0
 protected function define_structure()
 {
     // To know if we are including userinfo.
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated.
     $vpl = new backup_nested_element('vpl', array('id'), array('name', 'shortdescription', 'intro', 'introformat', 'startdate', 'duedate', 'maxfiles', 'maxfilesize', 'requirednet', 'password', 'grade', 'visiblegrade', 'usevariations', 'variationtitle', 'basedon', 'run', 'debug', 'evaluate', 'evaluateonsubmission', 'automaticgrading', 'maxexetime', 'restrictededitor', 'example', 'maxexememory', 'maxexefilesize', 'maxexeprocesses', 'jailservers', 'emailteachers', 'worktype'));
     $requiredfiles = new backup_nested_element('required_files');
     $requiredfile = new backup_nested_filegroup('required_file', array('id'), array('name', 'content'));
     $executionfiles = new backup_nested_element('execution_files');
     $executionfile = new backup_nested_filegroup('execution_file', array('id'), array('name', 'content'));
     $variations = new backup_nested_element('variations');
     $variation = new backup_nested_element('variation', array('id'), array('vpl', 'identification', 'description'));
     $asignedvariations = new backup_nested_element('asigned_variations');
     $asignedvariation = new backup_nested_element('asigned_variation', array('id'), array('userid', 'vpl', 'variation'));
     $submissions = new backup_nested_element('submissions');
     $submission = new backup_nested_element('submission', array('id'), array('vpl', 'userid', 'datesubmitted', 'comments', 'grader', 'dategraded', 'grade', 'mailed', 'highlight'));
     $submissionfiles = new backup_nested_element('submission_files');
     $submissionfile = new backup_nested_filegroup('submission_file', array('id'), array('name', 'content'));
     // Build the tree.
     $vpl->add_child($requiredfiles);
     $vpl->add_child($executionfiles);
     $vpl->add_child($variations);
     $vpl->add_child($submissions);
     $requiredfiles->add_child($requiredfile);
     $executionfiles->add_child($executionfile);
     $variations->add_child($variation);
     $variation->add_child($asignedvariations);
     $asignedvariations->add_child($asignedvariation);
     $submissions->add_child($submission);
     $submission->add_child($submissionfiles);
     $submissionfiles->add_child($submissionfile);
     // Define sources.
     $vpl->set_source_table('vpl', array('id' => backup::VAR_ACTIVITYID));
     $variation->set_source_table('vpl_variations', array('vpl' => backup::VAR_ACTIVITYID));
     if ($userinfo) {
         $asignedvariation->set_source_table('vpl_assigned_variations', array('vpl' => backup::VAR_ACTIVITYID, 'variation' => backup::VAR_ACTIVITYID));
         /*
          * Uncomment next line and comment nexts to backup all student's submissions, not only last one.
          * $submission->set_source_table('vpl_submissions', array('vpl' => backup::VAR_ACTIVITYID));
          */
         $query = 'SELECT s.* FROM {vpl_submissions} AS s';
         $query .= ' inner join';
         $query .= ' (SELECT max(id) as maxid FROM {vpl_submissions}';
         $query .= '   WHERE {vpl_submissions}.vpl = ? GROUP BY {vpl_submissions}.userid) AS ls';
         $query .= ' on ls.maxid = s.id';
         $submission->set_source_sql($query, array(backup::VAR_ACTIVITYID));
     }
     // Define id annotations.
     $vpl->annotate_ids('scale', 'grade');
     $vpl->annotate_ids('vpl', 'basedon');
     $asignedvariation->annotate_ids('user', 'userid');
     $submission->annotate_ids('user', 'userid');
     $submission->annotate_ids('user', 'grader');
     // Define file annotations.
     $vpl->annotate_files('mod_vpl', 'intro', null);
     return $this->prepare_activity_structure($vpl);
 }
 protected function define_structure()
 {
     // To know if we are including userinfo
     $userinfo = $this->get_setting_value('userinfo');
     // Define each element separated
     $forumng = new backup_nested_element('forumng', array('id'), array('name', 'intro', 'introformat', 'type', 'ratingscale', 'ratingfrom', 'ratinguntil', 'ratingthreshold', 'grading', 'attachmentmaxbytes', 'reportingemail', 'subscription', 'feedtype', 'feeditems', 'maxpostsperiod', 'maxpostsblock', 'postingfrom', 'postinguntil', 'typedata', 'magicnumber', 'completiondiscussions', 'completionreplies', 'completionposts', 'removeafter', 'removeto', 'shared', 'originalcmid', 'gradingscale', 'canpostanon', 'tags', 'enableratings'));
     $discussions = new backup_nested_element('discussions');
     $discussion = new backup_nested_element('discussion', array('id'), array('groupid', 'timestart', 'timeend', 'deleted', 'locked', 'sticky'));
     $posts = new backup_nested_element('posts');
     $post = new backup_nested_element('post', array('id'), array('parentpostid', 'userid', 'created', 'modified', 'deleted', 'deleteuserid', 'important', 'mailstate', 'oldversion', 'edituserid', 'subject', 'message', 'messageformat', 'attachments', 'asmoderator'));
     $newratings = new backup_nested_element('newratings');
     $newrating = new backup_nested_element('newrating', array('id'), array('component', 'ratingarea', 'scaleid', 'value', 'userid', 'timecreated', 'timemodified'));
     $ratings = new backup_nested_element('ratings');
     $rating = new backup_nested_element('rating', array('id'), array('userid', 'time', 'rating'));
     $subscriptions = new backup_nested_element('subscriptions');
     $subscription = new backup_nested_element('subscription', array('id'), array('userid', 'subscribed', 'discussionid', 'clonecmid', 'groupid'));
     $readdiscussions = new backup_nested_element('readdiscussions');
     $read = new backup_nested_element('read', array('id'), array('userid', 'time'));
     $readposts = new backup_nested_element('readposts');
     $readp = new backup_nested_element('readpost', array('id'), array('userid', 'time'));
     $drafts = new backup_nested_element('drafts');
     $draft = new backup_nested_element('draft', array('id'), array('userid', 'groupid', 'parentpostid', 'subject', 'message', 'messageformat', 'attachments', 'saved', 'options', 'asmoderator'));
     $flags = new backup_nested_element('flags');
     $flag = new backup_nested_element('flag', array('id'), array('userid', 'flagged'));
     $flagsd = new backup_nested_element('flagsd');
     $flagd = new backup_nested_element('flagd', array('id'), array('userid', 'flagged'));
     $tags = new backup_nested_element('tags');
     $tag = new backup_nested_element('tag', array('id'), array('name', 'rawname'));
     $forumtaginstances = new backup_nested_element('forumtaginstances');
     $forumtaginstance = new backup_nested_element('forumtaginstance', array('id'), array('name', 'rawname', 'tagid', 'itemtype', 'tiuserid', 'ordering', 'component'));
     $forumgrouptaginstances = new backup_nested_element('forumgrouptaginstances');
     $forumgrouptaginstance = new backup_nested_element('forumgrouptaginstance', array('id'), array('name', 'rawname', 'tagid', 'itemtype', 'itemid', 'tiuserid', 'ordering', 'component'));
     // Build the tree
     $forumng->add_child($discussions);
     $discussions->add_child($discussion);
     $forumng->add_child($subscriptions);
     $subscriptions->add_child($subscription);
     $forumng->add_child($drafts);
     $drafts->add_child($draft);
     $discussion->add_child($posts);
     $posts->add_child($post);
     $discussion->add_child($readdiscussions);
     $readdiscussions->add_child($read);
     $discussion->add_child($flagsd);
     $flagsd->add_child($flagd);
     $post->add_child($newratings);
     $newratings->add_child($newrating);
     $post->add_child($ratings);
     $ratings->add_child($rating);
     $post->add_child($flags);
     $flags->add_child($flag);
     $post->add_child($readposts);
     $readposts->add_child($readp);
     $discussion->add_child($tags);
     $tags->add_child($tag);
     $forumng->add_child($forumtaginstances);
     $forumtaginstances->add_child($forumtaginstance);
     $forumng->add_child($forumgrouptaginstances);
     $forumgrouptaginstances->add_child($forumgrouptaginstance);
     // Define sources
     $forumng->set_source_table('forumng', array('id' => backup::VAR_ACTIVITYID));
     // All these source definitions only happen if we are including user info
     if ($userinfo) {
         $discussion->set_source_table('forumng_discussions', array('forumngid' => backup::VAR_PARENTID));
         $subscription->set_source_table('forumng_subscriptions', array('forumngid' => backup::VAR_PARENTID));
         $draft->set_source_table('forumng_drafts', array('forumngid' => backup::VAR_PARENTID));
         // Need posts ordered by id so parents are always before childs on restore
         $post->set_source_sql("SELECT * FROM {forumng_posts} WHERE discussionid = ?" . "ORDER BY id", array(backup::VAR_PARENTID));
         $read->set_source_table('forumng_read', array('discussionid' => backup::VAR_PARENTID));
         $readp->set_source_table('forumng_read_posts', array('postid' => backup::VAR_PARENTID));
         $newrating->set_source_table('rating', array('contextid' => backup::VAR_CONTEXTID, 'itemid' => backup::VAR_PARENTID, 'component' => backup_helper::is_sqlparam('mod_forumng'), 'ratingarea' => backup_helper::is_sqlparam('post')));
         $newrating->set_source_alias('rating', 'value');
         $rating->set_source_table('forumng_ratings', array('postid' => backup::VAR_PARENTID));
         $flag->set_source_table('forumng_flags', array('postid' => backup::VAR_PARENTID));
         $flagd->set_source_table('forumng_flags', array('discussionid' => backup::VAR_PARENTID));
         $tag->set_source_sql('SELECT t.id, t.name, t.rawname
                                 FROM {tag} t
                                 JOIN {tag_instance} ti ON ti.tagid = t.id
                                WHERE ti.itemtype = ?
                                  AND ti.component = ?
                                  AND ti.itemid = ?', array(backup_helper::is_sqlparam('forumng_discussions'), backup_helper::is_sqlparam('mod_forumng'), backup::VAR_PARENTID));
     }
     $forumtaginstance->set_source_sql('SELECT t.name, t.rawname, ti.*
             FROM {tag} t
             JOIN {tag_instance} ti ON ti.tagid = t.id
             WHERE ti.contextid = ?
             AND ti.itemid = ?
             AND ti.itemtype = ?
             AND ti.component = ?', array(backup::VAR_CONTEXTID, backup::VAR_PARENTID, backup_helper::is_sqlparam('forumng'), backup_helper::is_sqlparam('mod_forumng')));
     $forumgrouptaginstance->set_source_sql('SELECT t.name, t.rawname, ti.*
             FROM {tag} t
             JOIN {tag_instance} ti ON ti.tagid = t.id
            WHERE ti.contextid = ?
             AND ti.itemtype = ?
             AND ti.component = ?', array(backup::VAR_CONTEXTID, backup_helper::is_sqlparam('groups'), backup_helper::is_sqlparam('mod_forumng')));
     // Define id annotations
     $forumng->annotate_ids('course_modules', 'originalcmid');
     $forumng->annotate_ids('scale', 'ratingscale');
     $discussion->annotate_ids('group', 'groupid');
     $post->annotate_ids('user', 'userid');
     $post->annotate_ids('user', 'deleteuserid');
     $post->annotate_ids('user', 'edituserid');
     $newrating->annotate_ids('user', 'userid');
     $newrating->annotate_ids('scale', 'scaleid');
     $rating->annotate_ids('user', 'userid');
     $subscription->annotate_ids('user', 'userid');
     $subscription->annotate_ids('group', 'groupid');
     $subscription->annotate_ids('course_modules', 'clonecmid');
     $read->annotate_ids('user', 'userid');
     $readp->annotate_ids('user', 'userid');
     $draft->annotate_ids('user', 'userid');
     $draft->annotate_ids('group', 'groupid');
     $flag->annotate_ids('user', 'userid');
     $forumgrouptaginstance->annotate_ids('group', 'itemid');
     // Define file annotations
     $forumng->annotate_files('mod_forumng', 'intro', null);
     // This file area hasn't itemid
     $post->annotate_files('mod_forumng', 'message', 'id');
     $post->annotate_files('mod_forumng', 'attachment', 'id');
     $draft->annotate_files('mod_forumng', 'draft', 'id');
     // Return the root element (forumng), wrapped into standard activity structure
     return $this->prepare_activity_structure($forumng);
 }
Ejemplo n.º 23
0
 protected function define_structure()
 {
     global $DB;
     // Define each element separated
     $course = new backup_nested_element('course', array('id', 'contextid'), array('shortname', 'fullname', 'idnumber', 'summary', 'summaryformat', 'format', 'showgrades', 'newsitems', 'startdate', 'numsections', 'marker', 'maxbytes', 'legacyfiles', 'showreports', 'visible', 'hiddensections', 'groupmode', 'groupmodeforce', 'defaultgroupingid', 'lang', 'theme', 'timecreated', 'timemodified', 'requested', 'restrictmodules', 'enablecompletion', 'completionstartonenrol', 'completionnotify'));
     $category = new backup_nested_element('category', array('id'), array('name', 'description'));
     $tags = new backup_nested_element('tags');
     $tag = new backup_nested_element('tag', array('id'), array('name', 'rawname'));
     $allowedmodules = new backup_nested_element('allowed_modules');
     $module = new backup_nested_element('module', array(), array('modulename'));
     // Build the tree
     $course->add_child($category);
     $course->add_child($tags);
     $tags->add_child($tag);
     $course->add_child($allowedmodules);
     $allowedmodules->add_child($module);
     // Set the sources
     $courserec = $DB->get_record('course', array('id' => $this->task->get_courseid()));
     $courserec->contextid = $this->task->get_contextid();
     $course->set_source_array(array($courserec));
     $categoryrec = $DB->get_record('course_categories', array('id' => $courserec->category));
     $category->set_source_array(array($categoryrec));
     $tag->set_source_sql('SELECT t.id, t.name, t.rawname
                             FROM {tag} t
                             JOIN {tag_instance} ti ON ti.tagid = t.id
                            WHERE ti.itemtype = ?
                              AND ti.itemid = ?', array(backup_helper::is_sqlparam('course'), backup::VAR_PARENTID));
     $module->set_source_sql('SELECT m.name AS modulename
                                FROM {modules} m
                                JOIN {course_allowed_modules} cam ON m.id = cam.module
                               WHERE course = ?', array(backup::VAR_COURSEID));
     // Some annotations
     $course->annotate_ids('grouping', 'defaultgroupingid');
     $course->annotate_files('course', 'summary', null);
     $course->annotate_files('course', 'legacy', null);
     // Return root element ($course)
     return $course;
 }