mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-29333 rating: prevent the ratings JS from being intialized multiple times
This commit is contained in:
parent
5c0452c6f8
commit
5e36e1045a
1 changed files with 4 additions and 9 deletions
|
@ -396,13 +396,6 @@ class rating_manager {
|
||||||
*/
|
*/
|
||||||
protected $scales = array();
|
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.
|
* 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) {
|
public function initialise_rating_javascript(moodle_page $page) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
if ($this->javascriptinitialised) {
|
//only needs to be initialized once
|
||||||
|
static $done = false;
|
||||||
|
if ($done) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($CFG->enableajax)) {
|
if (!empty($CFG->enableajax)) {
|
||||||
$page->requires->js_init_call('M.core_rating.init');
|
$page->requires->js_init_call('M.core_rating.init');
|
||||||
}
|
}
|
||||||
|
$done = true;
|
||||||
|
|
||||||
$this->javascriptinitialised = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue