public static function external_ratings_structure() {

        return new external_single_structure (
            [
                'contextid' => new external_value(PARAM_INT, 'Context id.'),
                'component' => new external_value(PARAM_COMPONENT, 'Context name.'),
                'ratingarea' => new external_value(PARAM_AREA, 'Rating area name.'),
                'canviewall' => new external_value(PARAM_BOOL, 'Whether the user can view all the individual ratings.',
                    VALUE_OPTIONAL),
                'canviewany' => new external_value(PARAM_BOOL, 'Whether the user can view aggregate of ratings of others.',
                    VALUE_OPTIONAL),
                'scales' => new external_multiple_structure(
                    new external_single_structure (
                        [
                            'id' => new external_value(PARAM_INT, 'Scale id.'),
                            'courseid' => new external_value(PARAM_INT, 'Course id.', VALUE_OPTIONAL),
                            'name' => new external_value(PARAM_TEXT, 'Scale name (when a real scale is used).', VALUE_OPTIONAL),
                            'max' => new external_value(PARAM_INT, 'Max value for the scale.'),
                            'isnumeric' => new external_value(PARAM_BOOL, 'Whether is a numeric scale.'),
                            'items' => new external_multiple_structure(
                                new external_single_structure (
                                    [
                                        'value' => new external_value(PARAM_INT, 'Scale value/option id.'),
                                        'name' => new external_value(PARAM_NOTAGS, 'Scale name.'),
                                    ]
                                ), 'Scale items. Only returned for not numerical scales.', VALUE_OPTIONAL
                            )
                        ], 'Scale information'
                    ), 'Different scales used information', VALUE_OPTIONAL
                ),
                'ratings' => new external_multiple_structure(
                    new external_single_structure (
                        [
                            'itemid' => new external_value(PARAM_INT, 'Item id.'),
                            'scaleid' => new external_value(PARAM_INT, 'Scale id.', VALUE_OPTIONAL),
                            'userid' => new external_value(PARAM_INT, 'User who rated id.', VALUE_OPTIONAL),
                            'aggregate' => new external_value(PARAM_FLOAT, 'Aggregated ratings grade.', VALUE_OPTIONAL),
                            'aggregatestr' => new external_value(PARAM_NOTAGS, 'Aggregated ratings as string.', VALUE_OPTIONAL),
                            'aggregatelabel' => new external_value(PARAM_NOTAGS, 'The aggregation label.', VALUE_OPTIONAL),
                            'count' => new external_value(PARAM_INT, 'Ratings count (used when aggregating).', VALUE_OPTIONAL),
                            'rating' => new external_value(PARAM_INT, 'The rating the user gave.', VALUE_OPTIONAL),
                            'canrate' => new external_value(PARAM_BOOL, 'Whether the user can rate the item.', VALUE_OPTIONAL),
                            'canviewaggregate' => new external_value(PARAM_BOOL, 'Whether the user can view the aggregated grade.',
                                VALUE_OPTIONAL),
                        ]
                    ), 'The ratings', VALUE_OPTIONAL
                ),
            ], 'Rating information', VALUE_OPTIONAL
        );
    }