Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Public Attributes | List of all members
rating Class Reference
Inheritance diagram for rating:
renderable

Public Member Functions

 __construct ($options)
 Constructor. More...
 
 get_aggregate_string ()
 Returns this ratings aggregate value as a string. More...
 
 get_rate_url ($rating=null, $returnurl=null)
 Returns a URL that can be used to rate the associated item. More...
 
 get_rating ()
 Retreive the integer value of this rating. More...
 
 get_view_ratings_url ($popup=false)
 Returns a URL to view all of the ratings for the item this rating is for. More...
 
 update_rating ($rating)
 Update this rating in the database. More...
 
 user_can_rate ($userid=null)
 Returns true if the user is able to rate this rating object. More...
 
 user_can_view_aggregate ($userid=null)
 Returns true if the user is able to view the aggregate for this rating object. More...
 

Public Attributes

int $aggregate = null
 The aggregate of the combined ratings for the associated item. More...
 
string $component
 The component using ratings. More...
 
stdClass $context
 The context in which this rating exists.
 
int $count = 0
 The total number of ratings for the associated item. More...
 
int $id = null
 The Id of this rating within the rating table. More...
 
int $itemid
 The id of the item (forum post, glossary item etc) being rated.
 
int $itemtimecreated = null
 The time the associated item was created.
 
int $itemuserid = null
 The id of the user who submitted the rating.
 
int $rating = null
 The rating the associated user gave the associated item. More...
 
string $ratingarea = null
 The rating area to associate this rating with This allows a plugin to rate more than one thing by specifying different rating areas.
 
int $scaleid
 The id scale (1-5, 0-100) that was in use when the rating was submitted.
 
stdclass $settings
 settings for this rating. More...
 
int $userid
 The id of the user who submitted the rating.
 

Constructor & Destructor Documentation

◆ __construct()

rating::__construct (   $options)

Constructor.

Parameters
stdClass$options{ context => context context to use for the rating [required] component => component using ratings ie mod_forum [required] ratingarea => ratingarea to associate this rating with [required] itemid => int the id of the associated item (forum post, glossary item etc) [required] scaleid => int The scale in use when the rating was submitted [required] userid => int The id of the user who submitted the rating [required] settings => Settings for the rating object [optional] id => The id of this rating (if the rating is from the db) [optional] aggregate => The aggregate for the rating [optional] count => The number of ratings [optional] rating => The rating given by the user [optional] }

Member Function Documentation

◆ get_aggregate_string()

rating::get_aggregate_string ( )

Returns this ratings aggregate value as a string.

Return values
stringratings aggregate value

◆ get_rate_url()

rating::get_rate_url (   $rating = null,
  $returnurl = null 
)

Returns a URL that can be used to rate the associated item.

Parameters
int | null$ratingThe rating to give the item, if null then no rating param is added.
moodle_url | string$returnurlThe URL to return to.
Return values
moodle_urlcan be used to rate the associated item.

◆ get_rating()

rating::get_rating ( )

Retreive the integer value of this rating.

Return values
intthe integer value of this rating object

◆ get_view_ratings_url()

rating::get_view_ratings_url (   $popup = false)

Returns a URL to view all of the ratings for the item this rating is for.

If this is a rating of a post then this URL will take the user to a page that shows all of the ratings for the post (this one included).

Parameters
bool$popupwhether of not the URL should be loaded in a popup
Return values
moodle_urlURL to view all of the ratings for the item this rating is for.

◆ update_rating()

rating::update_rating (   $rating)

Update this rating in the database.

Parameters
int$ratingthe integer value of this rating

◆ user_can_rate()

rating::user_can_rate (   $userid = null)

Returns true if the user is able to rate this rating object.

Parameters
int$useridCurrent user assumed if left empty
Return values
booltrue if the user is able to rate this rating object

◆ user_can_view_aggregate()

rating::user_can_view_aggregate (   $userid = null)

Returns true if the user is able to view the aggregate for this rating object.

Parameters
int | null$useridIf left empty the current user is assumed.
Return values
booltrue if the user is able to view the aggregate for this rating object

Member Data Documentation

◆ $aggregate

int rating::$aggregate = null

The aggregate of the combined ratings for the associated item.

This is only set if the rating already exists

◆ $component

string rating::$component

The component using ratings.

For example "mod_forum"

◆ $count

int rating::$count = 0

The total number of ratings for the associated item.

This is only set if the rating already exists

◆ $id

int rating::$id = null

The Id of this rating within the rating table.

This is only set if the rating already exists

◆ $rating

int rating::$rating = null

The rating the associated user gave the associated item.

This is only set if the rating already exists

◆ $settings

stdclass rating::$settings

settings for this rating.

Necessary to render the rating.


The documentation for this class was generated from the following file: