Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]
A class representing a single rating and containing some static methods for manipulating ratings
Copyright: | 2010 Andrew Davis |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 1249 lines (53 kb) |
Included or required: | 1 time |
Referenced: | 38 times |
Includes or requires: | 0 files |
rating:: (8 methods):
__construct()
update_rating()
get_rating()
get_aggregate_string()
user_can_rate()
user_can_view_aggregate()
get_view_ratings_url()
get_rate_url()
rating_manager:: (15 methods):
delete_ratings()
get_all_ratings_for_item()
get_ratings()
generate_rating_settings_object()
generate_rating_scale_object()
get_item_time_created()
get_user_grades()
get_aggregate_types()
get_aggregation_method()
get_plugin_permissions_array()
check_rating_is_valid()
initialise_rating_javascript()
get_aggregate_label()
add_rating()
get_component_ratings_since()
rating_exception:: (1 method):
__construct()
__construct($options) X-Ref |
Constructor. param: stdClass $options { |
update_rating($rating) X-Ref |
Update this rating in the database param: int $rating the integer value of this rating |
get_rating() X-Ref |
Retreive the integer value of this rating return: int the integer value of this rating object |
get_aggregate_string() X-Ref |
Returns this ratings aggregate value as a string. return: string ratings aggregate value |
user_can_rate($userid = null) X-Ref |
Returns true if the user is able to rate this rating object return: bool true if the user is able to rate this rating object param: int $userid Current user assumed if left empty |
user_can_view_aggregate($userid = null) X-Ref |
Returns true if the user is able to view the aggregate for this rating object. return: bool true if the user is able to view the aggregate for this rating object param: int|null $userid If left empty the current user is assumed. |
get_view_ratings_url($popup = false) X-Ref |
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). return: moodle_url URL to view all of the ratings for the item this rating is for. param: bool $popup whether of not the URL should be loaded in a popup |
get_rate_url($rating = null, $returnurl = null) X-Ref |
Returns a URL that can be used to rate the associated item. return: moodle_url can be used to rate the associated item. param: int|null $rating The rating to give the item, if null then no rating param is added. param: moodle_url|string $returnurl The URL to return to. |
Class: rating_manager - X-Ref
The rating_manager class provides the ability to retrieve sets of ratings from the databasedelete_ratings($options) X-Ref |
Delete one or more ratings. Specify either a rating id, an item id or just the context id. param: stdClass $options { |
get_all_ratings_for_item($options) X-Ref |
Returns an array of ratings for a given item (forum post, glossary entry etc). This returns all users ratings for a single item return: array an array of ratings param: stdClass $options { |
get_ratings($options) X-Ref |
Adds rating objects to an array of items (forum posts, glossary entries etc). Rating objects are available at $item->rating return: array the array of items with their ratings attached at $items[0]->rating param: stdClass $options { |
generate_rating_settings_object($options) X-Ref |
Generates a rating settings object based upon the options it is provided. return: stdClass rating settings object param: stdClass $options { |
generate_rating_scale_object($scaleid) X-Ref |
Generates a scale object that can be returned return: stdClass scale for ratings param: int $scaleid scale-type identifier |
get_item_time_created($item) X-Ref |
Gets the time the given item was created TODO: MDL-31511 - Find a better solution for this, its not ideal to test for fields really we should be asking the component the item belongs to what field to look for or even the value we are looking for. return: int|null return null if the created time is unavailable, otherwise return a timestamp param: stdClass $item |
get_user_grades($options) X-Ref |
Returns an array of grades calculated by aggregating item ratings. return: array the array of the user's grades param: stdClass $options { |
get_aggregate_types() X-Ref |
Returns array of aggregate types. Used by ratings. return: array aggregate types |
get_aggregation_method($aggregate) X-Ref |
Converts an aggregation method constant into something that can be included in SQL return: string an SQL aggregation method param: int $aggregate An aggregation constant. For example, RATING_AGGREGATE_AVERAGE. |
get_plugin_permissions_array($contextid, $component, $ratingarea) X-Ref |
Looks for a callback like forum_rating_permissions() to retrieve permissions from the plugin whose items are being rated return: array rating related permissions param: int $contextid The current context id param: string $component the name of the component that is using ratings ie 'mod_forum' param: string $ratingarea The area the rating is associated with |
check_rating_is_valid($params) X-Ref |
Validates a submitted rating return: boolean true if the rating is valid, false if callback not found, throws rating_exception if rating is invalid param: array $params submitted data |
initialise_rating_javascript(moodle_page $page) X-Ref |
Initialises JavaScript to enable AJAX ratings on the provided page return: true always returns true param: moodle_page $page |
get_aggregate_label($aggregationmethod) X-Ref |
Returns a string that describes the aggregation method that was provided. return: string describes the aggregation method that was provided param: string $aggregationmethod |
add_rating($cm, $context, $component, $ratingarea, $itemid, $scaleid, $userrating, $rateduserid,$aggregationmethod) X-Ref |
Adds a new rating param: stdClass $cm course module object param: stdClass $context context object param: string $component component name param: string $ratingarea rating area param: int $itemid the item id param: int $scaleid the scale id param: int $userrating the user rating param: int $rateduserid the rated user id param: int $aggregationmethod the aggregation method |
get_component_ratings_since($context, $component, $since) X-Ref |
Get ratings created since a given time. return: array list of ratings db records since the given timelimit param: stdClass $context context object param: string $component component name param: int $since the time to check |
Class: rating_exception - X-Ref
The rating_exception class for exceptions specific to the ratings system__construct($errorcode) X-Ref |
Generate exceptions that can be easily identified as coming from the ratings system param: string $errorcode the error code to generate |