Rating macro

Release 1.1 - ...

The Rating smartlet allows users of the site to rate pages.

Example

The image below displays an example of the Rating smartlet when the user hasn't rated the current item yet.

Rating example

By clicking on one of the "stars" (or any other icon that's in use), the user's rating will be submitted and the result will be displayed, as shown in the example below.

Rating result example

When hovering over the "stars", the average rating will be displayed within a tooltip.

Parameters

The table below gives an overview of the available parameters for the Rating Smartlet.

Name Type Default Description
title string Rate this page The caption displayed by the smartlet
scale integer 5 The top end of the scale on which user can rate. Must be between 3 and 10 inclusive.
allowAnonymous boolean false Determines if anonymous visitors can rate items
getHighestRated integer 0 If set to a positive number, the smartlet will return a list of highest rated items containing (at most) the given number of items.
getHighestRatedFor integer N/A If getHighestRated is set, a user id can be passed to getHighestRatedFor to get the list of items the given user has rated highest.
ratingItem integer The current page Set ratingItem to apply the rating to a different item than the page currently being rendered.

Technical details

The rating is stored as a percentage, independant of the scale. This allows the getHighestRated mode to show a reasonable list even if different scales are used in different situations.

The rating results are stored within the table swtUserItemFeedback. This table is shared among other Web Toolkit macros, however records related to rating can be distinguished on the Source column (they will have the value "rating").

The Rating macro has no SXML macro counterpart, but the implementation does rely on several viper calls, such as useritemfeedback.setuserfeedback() and useritemfeedback.getuserfeedback().