source: Dev/trunk/classes/DashboardTool.php @ 114

Last change on this file since 114 was 97, checked in by fpvanagthoven, 14 years ago

DashboardTool? structure stuff

File size: 2.3 KB
Line 
1<?php
2
3/**
4 * Description of DashboardTool
5 *
6 * @author Frans
7 */
8class DashboardTool {
9
10    private $surveys;
11    private $gamedata;
12
13    public function __construct($surveys, $gamedata = null) {
14        $this->surveys = $surveys;
15        $this->gamedata = $gamedata;
16
17        $this->init();
18    }
19
20    private function init() {
21        $this->visualizeSurvey();
22    }
23
24    private function visualizeSurvey() {
25        foreach ($this->surveys as $survey) {
26            $surveyResults = $survey->results;
27
28            /* iterate at the same time through these arrays */
29            $questions = $survey->questions;
30            $questionResults = $surveyResults->getQuestionResults();
31            ?>
32            <div class="resultsDiv borderRadius padding1em">
33                <?php
34                $i = 0;
35                while (isset($questions[$i])) {
36                    ?><div class="resultDiv"><?php       
37                    $this->displayQuestion($questions[$i]);
38                    $this->visualizeResult($questionResults[$i]);
39                    ?></div><?php
40                   
41                    $i++;
42                }
43                ?>
44            </div>
45                <?php
46            }
47        }
48
49        private function visualizeResult($questionResult) {
50           
51        $this->displayVisualization($questionResult);
52        $this->displayChangeVisualizationBar();
53           
54    }
55
56    private function displayQuestion($question) {
57        echo $question->title;
58        echo "<br />";
59        echo $question->description;
60    }
61
62    private function displayVisualization($questionResult) {
63        $type = $questionResult->getType();
64       
65        switch ($type) {
66            case 0:
67                $value = "TEXT";
68
69                break;
70            case 1:
71                $value = "INTEGER";
72                break;
73            case 2:
74                $value = "MULT. CHOICE";
75                break;
76            case 3:
77                $value = "CHECKBOXES";
78                break;
79            case 4:
80                $value = "SCALE";
81                break;
82            default:
83                break;
84        }
85        echo $value;
86       
87        foreach($questionResult->answers as $answer)
88        {
89            echo "<br />" . $answer;
90        }
91    }
92
93    private function displayChangeVisualizationBar() {
94       
95    }
96
97}
98    ?>
Note: See TracBrowser for help on using the repository browser.