|
Moodle
2.2.1
http://www.collinsharper.com
|

Public Member Functions | |
| delete_ratings ($options) | |
| get_all_ratings_for_item ($options) | |
| get_ratings ($options) | |
| get_user_grades ($options) | |
| get_aggregate_types () | |
| get_aggregation_method ($aggregate) | |
| get_plugin_permissions_array ($contextid, $component, $ratingarea) | |
| check_rating_is_valid ($params) | |
| initialise_rating_javascript (moodle_page $page) | |
| get_aggregate_label ($aggregationmethod) | |
Protected Member Functions | |
| generate_rating_settings_object ($options) | |
| generate_rating_scale_object ($scaleid) | |
| get_item_time_created ($item) | |
Protected Attributes | |
| $scales = array() | |
The rating_manager class provides the ability to retrieve sets of ratings from the database
| check_rating_is_valid | ( | $ | params | ) |
Validates a submitted rating
| array | $params | submitted data context => object the context in which the rated items exists [required] component => The component the rating belongs to [required] ratingarea => The ratingarea the rating is associated with [required] itemid => int the ID of the object being rated [required] scaleid => int the scale from which the user can select a rating. Used for bounds checking. [required] rating => int the submitted rating rateduserid => int the id of the user whose items have been rated. NOT the user who submitted the ratings. 0 to update all. [required] aggregation => int the aggregation method to apply when calculating grades ie RATING_AGGREGATE_AVERAGE [optional] |
Definition at line 971 of file lib.php.

| delete_ratings | ( | $ | options | ) |
Delete one or more ratings. Specify either a rating id, an item id or just the context id.
moodle_database $DB
| stdClass | $options | { contextid => int the context in which the ratings exist [required] ratingid => int the id of an individual rating to delete [optional] userid => int delete the ratings submitted by this user. May be used in conjuction with itemid [optional] itemid => int delete all ratings attached to this item [optional] component => string The component to delete ratings from [optional] ratingarea => string The ratingarea to delete ratings from [optional] } |
| generate_rating_scale_object | ( | $ | scaleid | ) | [protected] |
Generates a scale object that can be returned
moodle_database $DB
| type | $scaleid |
| generate_rating_settings_object | ( | $ | options | ) | [protected] |
Generates a rating settings object based upon the options it is provided.
| stdClass | $options | { context => context the context in which the ratings exists [required] component => string The component the items belong to [required] ratingarea => string The ratingarea the items belong to [required] aggregate => int what aggregation method should be applied. RATING_AGGREGATE_AVERAGE, RATING_AGGREGATE_MAXIMUM etc [required] scaleid => int the scale from which the user can select a rating [required] returnurl => string the url to return the user to after submitting a rating. Can be left null for ajax requests [optional] assesstimestart => int only allow rating of items created after this timestamp [optional] assesstimefinish => int only allow rating of items created before this timestamp [optional] plugintype => string plugin type ie 'mod' Used to find the permissions callback [optional] pluginname => string plugin name ie 'forum' Used to find the permissions callback [optional] } |
Definition at line 650 of file lib.php.

| get_aggregate_label | ( | $ | aggregationmethod | ) |
| get_aggregation_method | ( | $ | aggregate | ) |
| get_all_ratings_for_item | ( | $ | options | ) |
Returns an array of ratings for a given item (forum post, glossary entry etc) This returns all users ratings for a single item
| stdClass | $options | { context => context the context in which the ratings exists [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] sort => string SQL sort by clause [optional] } |
Definition at line 448 of file lib.php.

| get_item_time_created | ( | $ | item | ) | [protected] |
Gets the time the given item was created
TODO: 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.
| stdClass | $item |
| get_plugin_permissions_array | ( | $ | contextid, |
| $ | component, | ||
| $ | ratingarea | ||
| ) |
Looks for a callback like forum_rating_permissions() to retrieve permissions from the plugin whose items are being rated
| int | $contextid | The current context id |
| string | component the name of the component that is using ratings ie 'mod_forum' | |
| string | ratingarea The area the rating is associated with |
Reimplemented in mockup_rating_manager.
Definition at line 946 of file lib.php.

| get_ratings | ( | $ | options | ) |
Adds rating objects to an array of items (forum posts, glossary entries etc) Rating objects are available at $item->rating
| stdClass | $options | { context => context the context in which the ratings exists [required] component => the component name ie mod_forum [required] ratingarea => the ratingarea we are interested in [required] items => array an array of items such as forum posts or glossary items. They must have an 'id' member ie $items[0]->id[required] aggregate => int what aggregation method should be applied. RATING_AGGREGATE_AVERAGE, RATING_AGGREGATE_MAXIMUM etc [required] scaleid => int the scale from which the user can select a rating [required] userid => int the id of the current user [optional] returnurl => string the url to return the user to after submitting a rating. Can be left null for ajax requests [optional] assesstimestart => int only allow rating of items created after this timestamp [optional] assesstimefinish => int only allow rating of items created before this timestamp [optional] |
Definition at line 504 of file lib.php.

| get_user_grades | ( | $ | options | ) |
Returns an array of grades calculated by aggregating item ratings.
| object | $options | { userid => int the id of the user whose items have been rated. NOT the user who submitted the ratings. 0 to update all. [required] aggregationmethod => int the aggregation method to apply when calculating grades ie RATING_AGGREGATE_AVERAGE [required] scaleid => int the scale from which the user can select a rating. Used for bounds checking. [required] itemtable => int the table containing the items [required] itemtableusercolum => int the column of the user table containing the item owner's user id [required] component => The component for the ratings [required] ratingarea => The ratingarea for the ratings [required] |
contextid => int the context in which the rated items exist [optional]
modulename => string the name of the module [optional] moduleid => int the id of the module instance [optional]
Definition at line 790 of file lib.php.

| initialise_rating_javascript | ( | moodle_page $ | page | ) |
Initialises JavaScript to enable AJAX ratings on the provided page
| moodle_page | $page |