Skip to content

Commit

Permalink
rating MDL-21657 improved the phpdoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Davis committed Mar 18, 2010
1 parent 66a0612 commit 4e5c048
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions rating/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function __construct($context, $itemid, $scaleid, $userid) {
/**
* Update this rating in the database
* @param int $rating the integer value of this rating
* @return void
*/
public function update_rating($rating) {
global $DB;
Expand All @@ -118,11 +119,7 @@ public function update_rating($rating) {
$DB->insert_record($table, $data);
}
else {
//$data->id = $this->id;
$data->id = $items[0]->rating->id;
/*$data->contextid = $this->context->id;
$data->scaleid = $this->scaleid;
$data->userid = $this->userid;*/
$data->rating = $rating;

$time = time();
Expand All @@ -134,22 +131,24 @@ public function update_rating($rating) {

/**
* Retreive the integer value of this rating
* @return the integer value of this rating object
* @return int the integer value of this rating object
*/
public function get_rating() {
return $this->rating;
}

/**
* Remove this rating from the database
* @return void
*/
public function delete_rating() {
//todo implement this if its actually needed
}

/**
* Static method that converts an aggregation method constant into something that can be included in SQL
* @param $aggregate An aggregation constant. For example, RATING_AGGREGATE_AVERAGE.
* @param int $aggregate An aggregation constant. For example, RATING_AGGREGATE_AVERAGE.
* @return string an SQL aggregation method
*/
public static function get_aggregation_method($aggregate) {
$aggregatestr = null;
Expand Down Expand Up @@ -178,6 +177,8 @@ public static function get_aggregation_method($aggregate) {
* This returns all users ratings for a single item
* @param context $context the context in which the rating exists
* @param int $itemid The id of the forum posts, glossary items or whatever
* @param string SQL sort by clause
* @return array an array of ratings
*/
public static function load_ratings_for_item($context, $itemid, $sort) {
global $DB;
Expand All @@ -202,10 +203,11 @@ public static function load_ratings_for_item($context, $itemid, $sort) {
* Rating objects are available at $item->rating
* @param context $context the current context object
* @param array $items an array of items such as forum posts or glossary items. They must have an 'id' member ie $items[0]->id
* @param $aggregate what aggregation method should be applied. AVG, MAX etc
* @param int $aggregate what aggregation method should be applied. AVG, MAX etc
* @param int $scaleid the scale from which the user can select a rating
* @param int $userid the id of the current user
* @return returns the array of items with their ratings attached at $items[0]->rating
* @param string $returnurl the url to return the user to after submitting a rating. Can be left null for ajax requests.
* @return array the array of items with their ratings attached at $items[0]->rating
*/
public static function load_ratings($context, $items, $aggregate=RATING_AGGREGATE_AVERAGE, $scaleid=5, $userid = null, $returnurl = null) {
global $DB, $USER, $PAGE, $CFG;
Expand Down

0 comments on commit 4e5c048

Please sign in to comment.