MDL-29793 Advanced grading - do not execute the restore step if the grading.xml is...
authorDavid Mudrak <david@moodle.com>
Mon, 14 Nov 2011 20:09:52 +0000 (21:09 +0100)
committerDavid Mudrak <david@moodle.com>
Mon, 14 Nov 2011 20:11:41 +0000 (21:11 +0100)
backup/moodle2/restore_stepslib.php

index 68bfb2c..3044c7f 100644 (file)
@@ -1877,6 +1877,21 @@ class restore_activity_logs_structure_step extends restore_course_logs_structure
  */
 class restore_activity_grading_structure_step extends restore_structure_step {
 
+    /**
+     * This step is executed only if the grading file is present
+     */
+     protected function execute_condition() {
+
+        $fullpath = $this->task->get_taskbasepath();
+        $fullpath = rtrim($fullpath, '/') . '/' . $this->filename;
+        if (!file_exists($fullpath)) {
+            return false;
+        }
+
+        return true;
+    }
+
+
     /**
      * Declares paths in the grading.xml file we are interested in
      */