original_string: public static function export_area_ratings(
          int $userid,
          \context $context,
          array $subcontext,
          string $component,
          string $ratingarea,
          int $itemid,
          bool $onlyuser = true
      ) {
          global $DB;
  
          $rm = new \rating_manager();
          $ratings = $rm->get_all_ratings_for_item((object) [
              'context' => $context,
              'component' => $component,
              'ratingarea' => $ratingarea,
              'itemid' => $itemid,
          ]);
  
          if ($onlyuser) {
              $ratings = array_filter($ratings, function($rating) use ($userid){
                  return ($rating->userid == $userid);
              });
          }
  
          if (empty($ratings)) {
              return;
          }
  
          $toexport = array_map(function($rating) {
              return (object) [
                  'rating' => $rating->rating,
                  'author' => $rating->userid,
              ];
          }, $ratings);
  
          $writer = \core_privacy\local\request\writer::with_context($context)
              ->export_related_data($subcontext, 'rating', $toexport);
      }
code: public static function export_area_ratings(
          int $userid,
          \context $context,
          array $subcontext,
          string $component,
          string $ratingarea,
          int $itemid,
          bool $onlyuser = true
      ) {
          global $DB;
  
          $rm = new \rating_manager();
          $ratings = $rm->get_all_ratings_for_item((object) [
              'context' => $context,
              'component' => $component,
              'ratingarea' => $ratingarea,
              'itemid' => $itemid,
          ]);
  
          if ($onlyuser) {
              $ratings = array_filter($ratings, function($rating) use ($userid){
                  return ($rating->userid == $userid);
              });
          }
  
          if (empty($ratings)) {
              return;
          }
  
          $toexport = array_map(function($rating) {
              return (object) [
                  'rating' => $rating->rating,
                  'author' => $rating->userid,
              ];
          }, $ratings);
  
          $writer = \core_privacy\local\request\writer::with_context($context)
              ->export_related_data($subcontext, 'rating', $toexport);
      }
code_tokens: public static function export_area_ratings ( int $ userid , \ context $ context , array $ subcontext , string $ component , string $ ratingarea , int $ itemid , bool $ onlyuser = true ) { global $ DB ; $ rm = new \ rating_manager ( ) ; $ ratings = $ rm -> get_all_ratings_for_item ( ( object ) [ 'context' => $ context , 'component' => $ component , 'ratingarea' => $ ratingarea , 'itemid' => $ itemid , ] ) ; if ( $ onlyuser ) { $ ratings = array_filter ( $ ratings , function ( $ rating ) use ( $ userid ) { return ( $ rating -> userid == $ userid ) ; } ) ; } if ( empty ( $ ratings ) ) { return ; } $ toexport = array_map ( function ( $ rating ) { return ( object ) [ 'rating' => $ rating -> rating , 'author' => $ rating -> userid , ] ; } , $ ratings ) ; $ writer = \ core_privacy \ local \ request \ writer :: with_context ( $ context ) -> export_related_data ( $ subcontext , 'rating' , $ toexport ) ; }
docstring: Export all ratings which match the specified component, areaid, and itemid.
  
  If requesting ratings for a users own content, and you wish to include all ratings of that content, specify
  $onlyuser as false.
  
  When requesting ratings for another users content, you should only export the ratings that the specified user
  made themselves.
  
  @param   int         $userid The user whose information is to be exported
  @param   \context    $context The context being stored.
  @param   array       $subcontext The subcontext within the context to export this information
  @param   string      $component The component to fetch data from
  @param   string      $ratingarea The ratingarea that the data was stored in within the component
  @param   int         $itemid The itemid within that ratingarea
  @param   bool        $onlyuser Whether to only export ratings that the current user has made, or all ratings
docstring_tokens: Export all ratings which match the specified component areaid and itemid .