Skip to content

Commit

Permalink
Merge branch 'MDL-65839_37' of git://github.com/dmonllao/moodle into …
Browse files Browse the repository at this point in the history
…MOODLE_37_STABLE
  • Loading branch information
sarjona committed Jul 2, 2019
2 parents 43ab5e7 + cd59d03 commit 2a6ee58
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion analytics/classes/analysis.php
Expand Up @@ -313,7 +313,8 @@ protected function process_time_splitting(\core_analytics\local\time_splitting\b
}

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.
Expand Down
12 changes: 12 additions & 0 deletions analytics/classes/local/analyser/base.php
Expand Up @@ -237,6 +237,18 @@ public function get_indicators(): array {
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.
*
Expand Down

0 comments on commit 2a6ee58

Please sign in to comment.