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);
    }