MDL-66536 analytics: Indicators can add extra data for targets
This commit is contained in:
@@ -951,6 +951,8 @@ class model {
|
||||
$predictionrecords = $this->add_prediction_ids($predictionrecords);
|
||||
|
||||
$samplesdata = $this->predictions_sample_data($predictionrecords);
|
||||
$samplesdata = $this->append_calculations_info($predictionrecords, $samplesdata);
|
||||
|
||||
$predictions = array_map(function($predictionobj) use ($samplesdata) {
|
||||
$prediction = new \core_analytics\prediction($predictionobj, $samplesdata[$predictionobj->sampleid]);
|
||||
return $prediction;
|
||||
@@ -1426,6 +1428,24 @@ class model {
|
||||
return $samplesdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the calculation info to the samples data.
|
||||
*
|
||||
* @param \stdClass[] $predictionrecords
|
||||
* @param array $samplesdata
|
||||
* @return array
|
||||
*/
|
||||
public function append_calculations_info(array $predictionrecords, array $samplesdata): array {
|
||||
|
||||
if ($extrainfo = calculation_info::pull_info($predictionrecords)) {
|
||||
foreach ($samplesdata as $sampleid => $data) {
|
||||
// The extra info come prefixed by extra: so we will not have overwrites here.
|
||||
$samplesdata[$sampleid] = $samplesdata[$sampleid] + $extrainfo[$sampleid];
|
||||
}
|
||||
}
|
||||
return $samplesdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of a sample
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user