From c6708db889f1d906140d12a5ece4327ea2818669 Mon Sep 17 00:00:00 2001 From: Anupama Sarjoshi Date: Thu, 20 Apr 2023 18:22:03 +0100 Subject: [PATCH] MDL-77987 Backup: add progress tracking to some slow steps --- backup/moodle2/backup_stepslib.php | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/backup/moodle2/backup_stepslib.php b/backup/moodle2/backup_stepslib.php index 8f82b94d3fc..354e07d16c9 100644 --- a/backup/moodle2/backup_stepslib.php +++ b/backup/moodle2/backup_stepslib.php @@ -2383,28 +2383,40 @@ class backup_annotate_all_question_files extends backup_execution_step { AND bi.itemname = 'question_categoryfinal'", array($this->get_backupid())); // To know about qtype specific components/fileareas $components = backup_qtype_plugin::get_components_and_fileareas(); + $progress = $this->task->get_progress(); + $progress->start_progress($this->get_name()); // Let's loop foreach($rs as $record) { // 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); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'questiontext', null, + $progress); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'generalfeedback', null, + $progress); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'answer', null, + $progress); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'answerfeedback', null, + $progress); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'hint', null, + $progress); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'correctfeedback', null, + $progress); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', + 'partiallycorrectfeedback', null, $progress); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, 'question', 'incorrectfeedback', null, + $progress); // 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); + backup_structure_dbops::annotate_files($this->get_backupid(), $record->contextid, $component, null, null, + $progress); } } + $progress->end_progress(); $rs->close(); } }