Changeset 97 for Dev/trunk/classes


Ignore:
Timestamp:
09/01/11 14:24:04 (14 years ago)
Author:
fpvanagthoven
Message:

DashboardTool? structure stuff

Location:
Dev/trunk/classes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/DashboardTool.php

    r96 r97  
    66 * @author Frans
    77 */
    8 class DashboardTool
    9 {
    10         private $surveys;
    11         private $gamedata;
     8class DashboardTool {
    129
    13         public function __construct($surveys, $gamedata = null)
    14         {
    15                 $this->surveys = $surveys;
    16                 $this->gamedata = $gamedata;
     10    private $surveys;
     11    private $gamedata;
    1712
    18                 $this->init();
    19         }
     13    public function __construct($surveys, $gamedata = null) {
     14        $this->surveys = $surveys;
     15        $this->gamedata = $gamedata;
    2016
    21         private function init()
    22         {
    23                 foreach ($this->surveys as $survey)
    24                 {
    25                         $surveyResults = $survey->results;
    26                         $questionResults = $surveyResults->getQuestionResults();
    27                         ?>
    28                         <div class="resultsDiv borderRadius padding1em">
    29                                 <?php
    30                                 foreach ($questionResults as $questionResult)
    31                                 {
    32                                         $this->visualizeResult($questionResult);
    33                                 }
    34                                 ?>
    35                         </div>
    36                         <?php
    37                 }
    38         }
     17        $this->init();
     18    }
    3919
    40         private function visualizeResult($questionResult)
    41         {
    42                 ?><div class="resultDiv"><?php
    43                 $this->displayQuestion($questionResult);
    44                 $this->displayVisualization($questionResult);
    45                 $this->displayChangeVisualizationBar();
    46                 ?></div><?php
    47         }
    48        
    49         private function displayQuestion($questionResult)
    50         {
    51                 echo "allo?";
    52         }
    53        
    54         private function displayVisualization($questionResult)
    55         {
    56                
    57         }
    58        
    59         private function displayChangeVisualizationBar()
    60         {
    61                
    62         }
     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
    6397}
    64 ?>
     98    ?>
  • Dev/trunk/classes/SurveyResults.php

    r75 r97  
    4343{
    4444        private $type;
    45         private $answers; // array
     45        public $answers; // array
    4646
    4747        public function __construct($type, $answers)
     
    5050                $this->answers = $answers;
    5151        }
     52       
     53        public function getType()
     54        {
     55            return $this->type;
     56        }
    5257}
    5358
Note: See TracChangeset for help on using the changeset viewer.