/** * Maakt de testpagina, of de pagina met resultaten als de test al ingevuld * is. * * @param string $test_name de naam van deze test, voor gebruik in MySQL */ function create($test_name) { $this->pageCreator->path_to_root = $this->path_to_root; $this->pageCreator->title = $this->title; $this->pageCreator->includeMenu = true; $this->pageCreator->head = self::$head . $this->extra_head; try { /* Kijk of er correcte vragen opgestuurd zijn. Als dat niet zo is, komt er een InvalidTestResultsException. */ $results = $this->validatePostResults(count($this->questions)); if ($test_name != 'personeel') { /* Zet de resultaten van de test in de database */ require_once '../resources/includes/TestsSQL.php'; $tests_sql = new TestsSQL($this->pageCreator->mysql); $tests_sql->storeResults($test_name, $results); } /* Laat de pagina zien. Dit kan de test zelf of de pagina met resultaten zijn. */ $this->createResultsPage($results); } catch (InvalidTestResultsException $ex) { if ($ex->getCode() != 1) { $this->test_body .= <<<EOF <br> <p> Er is iets misgegaan tijdens het verwerken van uw testresultaten. Vult u alstublieft alle vragen in. </p> EOF; } $this->createTestPage(); } $this->pageCreator->create(); }
<?php include '../resources/includes/PageCreator.php'; $page = new PageCreator(); $page->path_to_root = '../'; if (isset($_GET['test'])) { include_once '../resources/includes/TestsSQL.php'; $tests_sql = new TestsSQL($page->mysql); $content = '<table class="contact">'; $i = 0; foreach ($tests_sql->getAverageResults($_GET['test']) as $question_average) { $content .= "<tr><th>{$i}</th><td>{$question_average}</td></tr>"; $i++; } $content .= '</table>'; } else { $self = htmlentities($_SERVER['PHP_SELF']); $content = <<<EOF <p> \t Op deze pagina kunt u de testresultaten inzien.<br> \t Kies een test: \t </p> <ul> <li><a href="{$self}?test=snel">Snelle test</a></li> <li><a href="{$self}?test=uitgebreid">Uitgebreide test</a></li> <li><a href="{$self}?test=risicoanalyse">Risicoanalyse</a></li> </ul> EOF; } $page->head = '<link rel="stylesheet" href="resources/css/specific/information.css"