How to add ratings to Moodle

Use shortcodes to display and manage ratings with the Star Rating plugin

Written By Stefan-Alexander Scholz

Last updated About 6 hours ago

About

Shortcodes control how Star Rating displays rating elements and related information. They are processed by the Star Rating filter and can be used in activity, course, or user context.


Where to add shortcodes

  • You can add shortcodes anywhere in Moodle where text content is supported. Officially supported contexts are activity, course, and user context.

  • Ratings added to sections or blocks within a course are treated as part of the course context. A course context supports only one rating instance. These ratings are therefore not independent and will always display the same data.

  • Activities within a course have their own independent context, and each activity supports only one rating instance. You can create multiple independent ratings within a course by adding the shortcode to different activities. Repeating the shortcode within the same activity only duplicates the display and does not create additional independent ratings.


Available shortcodes

  • [rating]

    Displays the interface for submitting a star rating.

    • A rating can be changed at any time. Once a rating has been submitted, it cannot be withdrawn.

    • After submission, the stars turn turquoise.

    • The number of available stars is defined in the global settings.

  • [currentrating]

    Displays the current average rating as a numeric value.

  • [getrating]

    Displays the current average rating as stars.

  • [ratingcount]

    Displays the total number of submitted ratings.

  • [ratingcomment]

    Displays the interface to submit a rating and add a comment.

    • Depending on configured capabilities, comments can be edited or deleted.

    • Users can be actively prompted to leave a comment based on the submitted rating value. This behaviour is configured in the global settings.

  • [ratinglist]

    Displays submitted comments together with their ratings.

    • Depending on capabilities, users can edit or delete comments.

    • A maximum of 10 comments is displayed. For additional entries, use the Star Rating report.

Note: The ratings in [rating] and [ratingcomments] always have the same value if the shortcodes are used in the same context.


Tip: Add the Star Rating block as a sticky block so it appears on all course pages. Making it accessible everywhere can encourage participation.