original_string: public static function export_item_data(\context $context, int $itemid, array $subcontext) {
          global $DB;
  
          $sql = "SELECT gi.id AS instanceid, gd.id AS definitionid, gd.method
                    FROM {grading_areas} ga
                    JOIN {grading_definitions} gd ON gd.areaid = ga.id
                    JOIN {grading_instances} gi ON gi.definitionid = gd.id AND gi.itemid = :itemid
                   WHERE ga.contextid = :contextid";
          $params = [
              'itemid' => $itemid,
              'contextid' => $context->id,
          ];
          $records = $DB->get_recordset_sql($sql, $params);
          foreach ($records as $record) {
              $instancedata = manager::component_class_callback(
                  "gradingform_{$record->method}",
                  gradingform_provider_v2::class,
                  'export_gradingform_instance_data',
                  [$context, $record->instanceid, $subcontext]
              );
          }
          $records->close();
      }
code: public static function export_item_data(\context $context, int $itemid, array $subcontext) {
          global $DB;
  
          $sql = "SELECT gi.id AS instanceid, gd.id AS definitionid, gd.method
                    FROM {grading_areas} ga
                    JOIN {grading_definitions} gd ON gd.areaid = ga.id
                    JOIN {grading_instances} gi ON gi.definitionid = gd.id AND gi.itemid = :itemid
                   WHERE ga.contextid = :contextid";
          $params = [
              'itemid' => $itemid,
              'contextid' => $context->id,
          ];
          $records = $DB->get_recordset_sql($sql, $params);
          foreach ($records as $record) {
              $instancedata = manager::component_class_callback(
                  "gradingform_{$record->method}",
                  gradingform_provider_v2::class,
                  'export_gradingform_instance_data',
                  [$context, $record->instanceid, $subcontext]
              );
          }
          $records->close();
      }
code_tokens: public static function export_item_data ( \ context $ context , int $ itemid , array $ subcontext ) { global $ DB ; $ sql = "SELECT gi.id AS instanceid, gd.id AS definitionid, gd.method
                    FROM {grading_areas} ga
                    JOIN {grading_definitions} gd ON gd.areaid = ga.id
                    JOIN {grading_instances} gi ON gi.definitionid = gd.id AND gi.itemid = :itemid
                   WHERE ga.contextid = :contextid" ; $ params = [ 'itemid' => $ itemid , 'contextid' => $ context -> id , ] ; $ records = $ DB -> get_recordset_sql ( $ sql , $ params ) ; foreach ( $ records as $ record ) { $ instancedata = manager :: component_class_callback ( "gradingform_{$record->method}" , gradingform_provider_v2 :: class , 'export_gradingform_instance_data' , [ $ context , $ record -> instanceid , $ subcontext ] ) ; } $ records -> close ( ) ; }
docstring: Export all user data related to a context and itemid.
  
  @param  \context $context    Context to export on.
  @param  int      $itemid     Item ID to export on.
  @param  array    $subcontext Directory location to export to.
docstring_tokens: Export all user data related to a context and itemid .