CMS  Version 3.9
questionnaire_graphical_view.inc
Go to the documentation of this file.
1 <?php
7 Fakoli::using("questionnaire", "svg_charts");
8 
14 {
15  var $mgr;
16  var $emptyMessage = "There are no results to display.";
17 
26  {
27  $this->mgr = $mgr;
28  }
29 
30  function writeScript()
31  {
32  return "";
33  }
34 
35  function drawView()
36  {
37  $questions = $this->mgr->getQuestions();
38  $answers = $this->mgr->getAnswers();
39 
40  if(count($questions) == 0 || $this->mgr->getResponseCount() == 0)
41  {
42  echo "<p><em>{$this->emptyMessage}</em></p>";
43  return;
44  }
45 
46  $pk = $this->mgr->getQuestionKey();
47  $answers = count($answers) ? regroupList($answers, $pk) : array();
48 
49  foreach($questions as $question)
50  {
51  $qAnswers = array();
52 
53  if(array_key_exists($question->$pk, $answers))
54  {
55  $qAnswers = $answers[$question->$pk];
56  if(!is_array($qAnswers)) $qAnswers = array($qAnswers);
57  }
58  $renderer = QuestionField::create($this->mgr->item, $question);
59  echo "<h4>{$question->question_number}. {$question->question}</h4>\n";
60  $renderer->drawGraph($this->mgr, $qAnswers);
61  }
62  }
63 }
64 
65 ?>
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static create($parent, $question)
Draws a graphical view of questionnaire/survey responses.
$question
$renderer
$answers