Skip to content

Commit

Permalink
Merge branch 'MDL-59279_master' of git://github.com/dmonllao/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski authored and David Monllao committed Sep 7, 2017
2 parents 4cc3f4f + 10658a1 commit 8357572
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions analytics/classes/local/analyser/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ protected function process_time_splitting($timesplitting, $analysable, $includet
return $result;
}

// Add target metadata.
$this->add_target_metadata($data);
// Add extra metadata.
$this->add_model_metadata($data);

// Write all calculated data to a file.
$file = $dataset->store($data);
Expand Down Expand Up @@ -646,21 +646,25 @@ protected function save_prediction_samples($sampleids, $ranges, $timesplitting)
* @param array $data
* @return void
*/
protected function add_target_metadata(&$data) {
$data[0][] = 'targetcolumn';
$data[1][] = $this->analysabletarget->get_id();
protected function add_model_metadata(&$data) {
global $CFG;

$metadata = array(
'moodleversion' => $CFG->version,
'targetcolumn' => $this->analysabletarget->get_id()
);
if ($this->analysabletarget->is_linear()) {
$data[0][] = 'targettype';
$data[1][] = 'linear';
$data[0][] = 'targetmin';
$data[1][] = $this->analysabletarget::get_min_value();
$data[0][] = 'targetmax';
$data[1][] = $this->analysabletarget::get_max_value();
$metadata['targettype'] = 'linear';
$metadata['targetmin'] = $this->analysabletarget::get_min_value();
$metadata['targetmax'] = $this->analysabletarget::get_max_value();
} else {
$data[0][] = 'targettype';
$data[1][] = 'discrete';
$data[0][] = 'targetclasses';
$data[1][] = json_encode($this->analysabletarget::get_classes());
$metadata['targettype'] = 'discrete';
$metadata['targetclasses'] = json_encode($this->analysabletarget::get_classes());
}

foreach ($metadata as $varname => $value) {
$data[0][] = $varname;
$data[1][] = $value;
}
}
}

0 comments on commit 8357572

Please sign in to comment.