MDL-29333 rating: prevent the ratings JS from being intialized multiple times

This commit is contained in:
Andrew Davis (andyjdavis) 2011-09-21 15:49:24 +08:00
parent 5c0452c6f8
commit 5e36e1045a

View File

@ -396,13 +396,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.
*
@ -1019,15 +1012,17 @@ class rating_manager {
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;
}