Implement result viewer for experiments

This commit is contained in:
Eike Foken
2011-09-20 01:55:09 +02:00
parent 2c24c46cd1
commit 6bd0b517d3
6 changed files with 167 additions and 3 deletions

View File

@@ -25,6 +25,7 @@
* Result browser.
*
* @author Karsten Heiken <karsten@disposed.de>
* @author Eike Foken <kontakt@eikefoken.de>
*/
class Results extends MY_Controller {
@@ -36,6 +37,7 @@ class Results extends MY_Controller {
$this->load->model('program');
$this->load->model('job');
$this->load->model('server');
$this->load->model('experiment');
}
/**
@@ -58,6 +60,19 @@ class Results extends MY_Controller {
* @param string $experimentId The experiment for which to get the results
*/
public function experiment($experimentId) {
$experiment = $this->experiment->getById($experimentId);
// execute program runner
$program = $this->program->getById($experiment['program_id']);
$this->load->library('program_runner', array('program_driver' => $program['driver']));
$results = $this->program_runner->getResults($experiment['id']);
$data = array(); // empty data array
$data['experiment'] = $experiment;
$data['project'] = $this->project->getById($experiment['project_id']);
$data['results'] = $results;
$this->load->view('results/experiment', $data);
}
/**

View File

@@ -24,6 +24,7 @@
/**
*
* @package ScattPort
* @subpackage Libraries
* @author Eike Foken <kontakt@eikefoken.de>
*/
class Program_runner {
@@ -74,6 +75,14 @@ class Program_runner {
return true;
}
/**
*
* @param string $experimentId
*/
public function getResults($experimentId) {
return $this->driver->_getResults($experimentId);
}
}
/* End of file Program_runner.php */

View File

@@ -1,7 +1,30 @@
<?php
<?php defined('BASEPATH') || exit('No direct script access allowed');
/*
* Copyright (c) 2011 Karsten Heiken, Eike Foken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
*
* @package ScattPort
* @subpackage Libraries
* @author Eike Foken <kontakt@eikefoken.de>
*/
class Scatt extends Program_runner {
@@ -17,7 +40,7 @@ class Scatt extends Program_runner {
$this->CI->load->model('program');
$this->program = $this->CI->program->getByDriver(strtolower(__CLASS__));
log_message('debug', "Scatt Class Initialized");
log_message('debug', "ScaTT Class Initialized");
}
/**
@@ -39,4 +62,43 @@ class Scatt extends Program_runner {
return true;
}
/**
*
* @param string $experimentId
*/
public function _getResults($experimentId) {
$this->CI->load->helper('array');
$experiment = $this->CI->experiment->getById($experimentId);
$path = FCPATH . 'uploads/' . $experiment['project_id'] . '/' . $experiment['id'] . '/';
if (!file_exists($path . 'default.out')) {
return array();
}
$handler = fopen($path . 'default.out', "r");
$results = array();
while (($line = fgets($handler)) !== false) {
$values = array();
$i = 0;
foreach (preg_split("/\s+/", $line) as $value) {
if ($value != '') {
$values[] = trim($value);
}
$i++;
}
$results[] = $values;
}
return $results;
}
}
/* End of file Scatt.php */
/* Location: ./application/libraries/programs/Scatt.php */

View File

@@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@@ -0,0 +1,58 @@
<?php $this->load->view('header');?>
<div id="content">
<div class="title">
<h2><?=anchor('projects', _('Projects'));?> &raquo; <?=anchor('projects/detail/' . $project['id'], $project['name']);?> &raquo; <?=anchor('experiments/detail/' . $experiment['id'], $experiment['name']);?> &raquo; <?=_('Results');?></h2>
</div>
<div class="box">
<h3><?=_('Results');?></h3>
<table class="tableList">
<?php
$i = 0;
foreach ($results as $result):
if ($i == 0):
?>
<thead>
<tr>
<?php
foreach ($result as $headline):
?>
<th scope="col"><?=$headline;?></th>
<?php
endforeach;
?>
</tr>
</thead>
<?php
else:
if ($i == 1):
?>
<tbody>
<?php
endif;
?>
<tr>
<?php
foreach ($result as $value):
?>
<td><?=$value;?></td>
<?php
endforeach;
?>
</tr>
<?php
if ($i == sizeof($results)):
?>
</tbody>
<?php
endif;
endif;
$i++;
endforeach;
?>
</table>
</div>
</div>
<?php $this->load->view('footer');?>

View File

@@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>