Merge branch 'MDL-65839_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Sara Arjona 2019-07-02 10:41:35 +02:00
commit aa6a50cccc
2 changed files with 14 additions and 1 deletions

View File

@ -313,7 +313,8 @@ class analysis {
}
try {
$indicators = $this->analyser->get_indicators();
// Instantiate empty indicators to ensure that no garbage is dragged from previous analyses.
$indicators = $this->analyser->instantiate_indicators();
foreach ($indicators as $key => $indicator) {
// The analyser attaches the main entities the sample depends on and are provided to the
// indicator to calculate the sample.

View File

@ -237,6 +237,18 @@ abstract class base {
return $this->indicators;
}
/**
* Instantiate the indicators.
*
* @return \core_analytics\local\indicator\base[]
*/
public function instantiate_indicators() {
foreach ($this->indicators as $key => $indicator) {
$this->indicators[$key] = call_user_func(array($indicator, 'instance'));
}
return $this->indicators;
}
/**
* Samples data this analyser provides.
*