Permalink
Browse files

MDL-29333 rating: prevent the ratings JS from being intialized multip…

…le times
  • Loading branch information...
1 parent 81fa243 commit cfb909d013d1dad6c116fa3e6b31725d7c07fd81 @andyjdavis andyjdavis committed Sep 21, 2011
Showing with 4 additions and 9 deletions.
  1. +4 −9 rating/lib.php
View
13 rating/lib.php
@@ -397,13 +397,6 @@ class rating_manager {
protected $scales = array();
/**
- * Gets set to true when the JavaScript that controls AJAX rating has been
- * initialised (so that it only gets initialised once.
- * @var int
- */
- protected $javascriptinitialised = false;
-
- /**
* Delete one or more ratings. Specify either a rating id, an item id or just the context id.
*
* @global moodle_database $DB
@@ -1019,15 +1012,17 @@ public function check_rating_is_valid($params) {
public function initialise_rating_javascript(moodle_page $page) {
global $CFG;
- if ($this->javascriptinitialised) {
+ //only needs to be initialized once
+ static $done = false;
+ if ($done) {
return true;
}
if (!empty($CFG->enableajax)) {
$page->requires->js_init_call('M.core_rating.init');
}
+ $done = true;
- $this->javascriptinitialised = true;
return true;
}

0 comments on commit cfb909d

Please sign in to comment.