mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-29333 rating: prevent the ratings JS from being intialized multiple times
This commit is contained in:
parent
5c0452c6f8
commit
5e36e1045a
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user