How content rating work?

Ashutosh Pandey asked on August 23, 2020 16:08

I have gone through the code and webparts but couldn't figure out how rating works.

I want to show rating history through an API. I also need to allow users to rate using API.

I can get rating value of a document with the query:

select DocumentRatings, DocumentRatingValue from CMS_Document WHERE [DocumentNodeID] = 123

But how to see rating history? How rating is calculated internally? Which are the other tables involved?

Recent Answers


Liam Goldfinch answered on August 23, 2020 20:20

Hi Ashutosh,

In Kentico, there are two different types of content ratings, both count towards the document's content rating:

  • Ratings without message
    • increments the rating value and count directly in the Document table.
  • Ratings with message (uses Message Board functionality)
    • adds a message with rating to [Board_Message] table, grouped together by a board representing the page stored in [Board_Board]
    • also increments the rating value and count directly in the Document table.

If you're wanting to have full rating history, and be able to expose it via an API, you're probably best looking at using Message Board functionality. To do this, you can check the API documentation here or investigate how Kentico's Message Board webparts work, try checking:

  • CMS\CMSModules\MessageBoards\Controls\MessageBoard.ascx.cs
  • CMS\CMSModules\MessageBoards\Controls\Messages\MessageEdit.ascx.cs (btnOk_Click event)

Hope this helps.

2 votesVote for this answer Mark as a Correct answer

Ashutosh Pandey answered on August 24, 2020 07:56

Thanks Liam,

We are using rating without message. There are no entries in any of the Board_* tables.

Once a rating is done, the rating control is disabled for the current user for that page. How does the web part know this user has rated for this page?

I checked the code for CMSAdminControls/ContentRating/RatingControl but couldn't find anything.

0 votesVote for this answer Mark as a Correct answer

Liam Goldfinch answered on August 24, 2020 09:02

Hi Ashutosh,

Kentico stores a cookie in the browser called CMSRatedDocuments which contains all of the rated Document IDs. If you delete this from your browser, you will be able to submit another rating.

Regards,

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.