MDL-62535 mod_assign: Update to providers to include adv grading.
authorAdrian Greeve <adrian@moodle.com>
Thu, 14 Jun 2018 05:11:18 +0000 (13:11 +0800)
committerAdrian Greeve <abgreeve@gmail.com>
Mon, 20 Aug 2018 03:32:01 +0000 (11:32 +0800)
mod/assign/classes/privacy/provider.php

index 8150d63..56a7736 100644 (file)
@@ -238,7 +238,7 @@ class provider implements metadataprovider, pluginprovider, preference_provider
     /**
      * Delete all use data which matches the specified context.
      *
-     * @param context $context The module context.
+     * @param \context $context The module context.
      */
     public static function delete_data_for_all_users_in_context(\context $context) {
         global $DB;
@@ -257,6 +257,13 @@ class provider implements metadataprovider, pluginprovider, preference_provider
                     'delete_feedback_for_context', [$requestdata]);
                 $DB->delete_records('assign_grades', ['assignment' => $assign->get_instance()->id]);
 
+                // Delete advanced grading information.
+                $gradingmanager = get_grading_manager($context, 'mod_assign', 'submissions');
+                $controller = $gradingmanager->get_active_controller();
+                if (isset($controller)) {
+                    \core_grading\privacy\provider::delete_instance_data($context);
+                }
+
                 // Time to roll my own method for deleting overrides.
                 static::delete_user_overrides($assign);
                 $DB->delete_records('assign_submission', ['assignment' => $assign->get_instance()->id]);
@@ -292,10 +299,16 @@ class provider implements metadataprovider, pluginprovider, preference_provider
             }
 
             $grades = $DB->get_records('assign_grades', ['assignment' => $assignid, 'userid' => $user->id]);
+            $gradingmanager = get_grading_manager($context, 'mod_assign', 'submissions');
+            $controller = $gradingmanager->get_active_controller();
             foreach ($grades as $grade) {
                 $requestdata = new assign_plugin_request_data($context, $assign, $grade, [], $user);
                 manager::plugintype_class_callback('assignfeedback', self::ASSIGNFEEDBACK_INTERFACE,
                         'delete_feedback_for_grade', [$requestdata]);
+                // Delete advanced grading information.
+                if (isset($controller)) {
+                    \core_grading\privacy\provider::delete_instance_data($context, $grade->id);
+                }
             }
 
             static::delete_user_overrides($assign, $user);
@@ -497,6 +510,8 @@ class provider implements metadataprovider, pluginprovider, preference_provider
             bool $exportforteacher = false) {
         $submissions = $assign->get_all_submissions($user->id);
         $teacher = ($exportforteacher) ? $user : null;
+        $gradingmanager = get_grading_manager($context, 'mod_assign', 'submissions');
+        $controller = $gradingmanager->get_active_controller();
         foreach ($submissions as $submission) {
             // Attempt numbers start at zero, which is fine for programming, but doesn't make as much sense
             // for users.
@@ -516,6 +531,10 @@ class provider implements metadataprovider, pluginprovider, preference_provider
                         [$params]);
 
                 self::export_grade_data($grade, $context, $submissionpath);
+                // Check for advanced grading and retrieve that information.
+                if (isset($controller)) {
+                    \core_grading\privacy\provider::export_item_data($context, $grade->id, $submissionpath);
+                }
             }
         }
     }