From bc575d2bea86619fca3f4647a4b509b99f175850 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Tue, 11 Nov 2014 19:18:01 +0000 Subject: [PATCH] MDL-47590 question backup: include response file only with userdata --- backup/moodle2/backup_stepslib.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/backup/moodle2/backup_stepslib.php b/backup/moodle2/backup_stepslib.php index 651b8d13a6e..00174677711 100644 --- a/backup/moodle2/backup_stepslib.php +++ b/backup/moodle2/backup_stepslib.php @@ -1925,13 +1925,22 @@ class backup_annotate_all_question_files extends backup_execution_step { $components = backup_qtype_plugin::get_components_and_fileareas(); // Let's loop foreach($rs as $record) { - // We don't need to specify filearea nor itemid as far as by - // component and context it's enough to annotate the whole bank files - // This backups "questiontext", "generalfeedback" and "answerfeedback" fileareas (all them - // belonging to the "question" component - backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', null, null); - // Again, it is enough to pick files only by context and component - // Do it for qtype specific components + // Backup all the file areas the are managed by the core question component. + // That is, by the question_type base class. In particular, we don't want + // to include files belonging to responses here. + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'questiontext', null); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'generalfeedback', null); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'answer', null); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'answerfeedback', null); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'hint', null); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'correctfeedback', null); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'partiallycorrectfeedback', null); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'incorrectfeedback', null); + + // For files belonging to question types, we make the leap of faith that + // all the files belonging to the question type are part of the question definition, + // so we can just backup all the files in bulk, without specifying each + // file area name separately. foreach ($components as $component => $fileareas) { backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, $component, null, null); }