Skip to content

Commit

Permalink
Selective options - Only type 3 results can choose evaluation plots w…
Browse files Browse the repository at this point in the history
…ith aggregation functions
  • Loading branch information
PatrikBuetler committed Sep 2, 2024
1 parent c135177 commit f170e53
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
2 changes: 2 additions & 0 deletions controllers/results.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function build() {
$this->view->assign('type', intval($this->get['type']));
$plots = Util::getDefaultResultPlots();
$system->getResultPlots($plots);
$plots = Util::filterAllowedPlots($plots, $this->get['type']);
$this->view->assign('plots', $plots);
} else if (!empty($this->get['experimentId']) && !empty($this->get['type']) && !empty($this->get['resultId'])) {
$experiment = Factory::getExperimentFactory()->get($this->get['experimentId']);
Expand All @@ -62,6 +63,7 @@ public function build() {

$plots = Util::getDefaultResultPlots();
$system->getResultPlots($plots);
$plots = Util::filterAllowedPlots($plots, $this->get['type']);
$this->view->assign('plots', $plots);
} else {
throw new Exception("No system/experiment id / type provided!");
Expand Down
31 changes: 23 additions & 8 deletions core/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,7 @@ public static function scanForPlots($path, $type = "") {
// TODO: check if override happens
$plot = new Plot($path . $entry);
if ($plot->isValid()) {
# Return only evaluation plots
if($type == 'eval' && strpos(gettype($plot), 'For Evaluations') != false) {
$plots[] = $plot;
}
# Return non-evaluation plots
if(strpos(gettype($plot), 'For Evaluations') === false) {
$plots[] = $plot;
}
$plots[] = $plot;
}
}
return $plots;
Expand All @@ -222,6 +215,28 @@ public static function getDefaultResultPlots() {
return self::scanForPlots(SERVER_ROOT . "/libraries/graphs/");
}

/**
* Filters the plots that are either for evaluations or not
* @return Plot[]
*/
public static function filterAllowedPlots($plots, $type=0) {
$validPlots = [];
if($type==3) {
foreach ($plots as $plot) {
if(strpos(gettype($plot), 'Evaluations') != false) {
$validPlots[] = $plot;
}
}
}
else {
foreach ($plots as $plot) {
if(strpos(gettype($plot), 'Evaluations') === false) {
$validPlots[] = $plot;
}
}
}
return $validPlots;
}
/**
* @return Element[]
* @throws Exception
Expand Down

0 comments on commit f170e53

Please sign in to comment.