diff --git a/lang/en_utf8/rating.php b/lang/en_utf8/rating.php index 8ce1f888129..0e98df3927c 100644 --- a/lang/en_utf8/rating.php +++ b/lang/en_utf8/rating.php @@ -9,4 +9,3 @@ $string['noviewrate'] = 'You do not have the capability to view post ratings'; $string['noviewanyrate'] = 'You can only look at results for posts that you made'; $string['ratepermissiondenied'] = 'You do not have permission to rate this item'; $string['ratingsuse'] = 'Use ratings'; -$string['sessionexpired'] = 'Your session has expired. Please log in again.'; diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 9e5d2b9c4ad..e3fc138ee97 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -1234,11 +1234,11 @@ class core_renderer extends renderer_base { * @param $page the page object on which this rating will appear */ function render_rating(rating $rating) { - global $CFG, $USER, $PAGE; + global $CFG, $USER; static $havesetupjavascript = false; if( !$havesetupjavascript && !empty($CFG->enableajax) ) { - $PAGE->requires->js_init_call('M.core_ratings.init'); + $this->page->requires->js_init_call('M.core_ratings.init'); $havesetupjavascript = true; } diff --git a/rating/index.php b/rating/index.php index 4ff941f7b0a..88e03b725cc 100644 --- a/rating/index.php +++ b/rating/index.php @@ -34,7 +34,7 @@ $sort = optional_param('sort', '', PARAM_ALPHA); list($context, $course, $cm) = get_context_info_array($contextid); require_login($course, false, $cm); -$url = new moodle_url('/rating/index.php', array('contextid'=>$contextid,'itemid'=>$itemid)); +$url = new moodle_url('/rating/index.php', array('contextid'=>$contextid,'itemid'=>$itemid,'scaleid'=>$scaleid)); if ($sort !== 0) { $url->param('sort', $sort); } @@ -80,7 +80,7 @@ if (!$ratings) { echo "$strtime"; echo ""; foreach ($ratings as $rating) { - echo ''; + echo ''; echo ""; if($courseid) { echo $OUTPUT->user_picture($rating, array('courseid'=>$courseid)); diff --git a/rating/lib.php b/rating/lib.php index 1022d2641f6..93e3cca05e3 100644 --- a/rating/lib.php +++ b/rating/lib.php @@ -44,9 +44,34 @@ define ('RATING_AGGREGATE_SUM', 5); * @since Moodle 2.0 */ class rating implements renderable { + + /** + * The context in which this rating exists + * @var context + */ + public $context; + + /** + * The id of the item (forum post, glossary item etc) being rated + * @var int + */ + public $itemid; + + /** + * The id scale (1-5, 0-100) that was in use when the rating was submitted + * @var int + */ + public $scaleid; + + /** + * The id of the user who submitted the rating + * @var int + */ + public $userid; + /** * Constructor. - * @param int $contextid the current context + * @param context $context the current context object * @param int $itemid the id of the associated item (forum post, glossary item etc) * @param int $scaleid the scale to use * @param int $userid the user submitting the rating @@ -120,7 +145,7 @@ class rating implements renderable { * 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. */ - public static function rating_get_aggregation_method($aggregate) { + public static function get_aggregation_method($aggregate) { $aggregatestr = null; switch($aggregate){ case RATING_AGGREGATE_AVERAGE: @@ -168,7 +193,7 @@ class rating implements renderable { /** * Static method that adds rating objects to an array of items (forum posts, glossary entries etc) * Rating objects are available at $item->rating - * @param int $contextid the current context + * @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 $scaleid the scale from which the user can select a rating @@ -186,7 +211,7 @@ class rating implements renderable { $userid = $USER->id; } - $aggregatestr = rating::rating_get_aggregation_method($aggregate); + $aggregatestr = rating::get_aggregation_method($aggregate); //create an array of item ids $itemids = array(); diff --git a/rating/rate.php b/rating/rate.php index f626e25d794..64805e5e432 100644 --- a/rating/rate.php +++ b/rating/rate.php @@ -40,7 +40,7 @@ $returnurl = optional_param('returnurl', null, PARAM_LOCALURL);//will only be su $result = new stdClass; if( !isloggedin() && !$returnurl ){ //session has expired and its an ajax request - $result->error = get_string('sessionexpired', 'ratings'); + $result->error = get_string('sessionerroruser', 'error'); echo json_encode($result); die(); }