CMS  Version 3.9
MultipleChoiceView Class Reference
+ Inheritance diagram for MultipleChoiceView:
+ Collaboration diagram for MultipleChoiceView:

Public Member Functions

 MultipleChoiceView ($parent, $question)
 
 writeHTML ()
 
 drawView ()
 
 getAnswer ()
 
 getRequiredValidator ()
 
 drawGraph ($mgr, $answers)
 Draws an interactive graphical view of answers to one question. More...
 
- Public Member Functions inherited from QuestionField
 QuestionField ($parent, $question)
 
 getID ()
 
 writeScript ()
 
 drawGraph ()
 
 drawSummaryView ()
 
 getSpreadsheetAnswer ()
 
 getOptionAnswer ()
 
 writeLimitScript ()
 
 renderLimitEnd ($limit, $field, $value)
 
 getRequired ()
 

Additional Inherited Members

- Static Public Member Functions inherited from QuestionField
static create ($parent, $question)
 
- Public Attributes inherited from QuestionField
 $parent
 The parent QuestionForm obj. More...
 
 $question
 The question renderer obj. More...
 
 $readonly
 Whether the questions should be drawn readonly. More...
 
 $answer
 The answer to the question obj. More...
 
 $answerSeparator = "<br>"
 for list of answers in checklist renderer More...
 

Detailed Description

Definition at line 254 of file question_renderer.inc.

Member Function Documentation

◆ drawGraph()

MultipleChoiceView::drawGraph (   $mgr,
  $answers 
)

Draws an interactive graphical view of answers to one question.

Parameters
obj$mgr- object of the Survey/Questionnaire Results manager class
Array$answers- all survey or questionnaire answers to this question

Definition at line 333 of file question_renderer.inc.

334  {
336  }
static drawSelectGraph($question, $resultsManager, $answers)
Draws an interactive graphical view of answers to one question.
$answers

◆ drawView()

MultipleChoiceView::drawView ( )

Definition at line 303 of file question_renderer.inc.

304  {
305  $this->writeHTML();
306  }

◆ getAnswer()

MultipleChoiceView::getAnswer ( )

Reimplemented from QuestionField.

Definition at line 311 of file question_renderer.inc.

312  {
313  return $this->getOptionAnswer();
314  }

◆ getRequiredValidator()

MultipleChoiceView::getRequiredValidator ( )

Reimplemented from QuestionField.

Definition at line 316 of file question_renderer.inc.

317  {
318  $pk = $this->question->getPrimaryKey();
319  // Empty question object signals to validator to validate from form and $_POST.
320  // Not empty means this is a view so we have the answer object that was saved.
321  $answer = ($this->parent->readOnlyForm) ? $this->answer : "";
322  $question_number = $this->question->question_number ? $this->question->question_number : $this->parent->mgr->getQuestionNumber($this->question);
323  return new RequiredRadioButtonQuestionValidator("question_{$this->question->$pk}", "Question {$question_number}", $answer);
324  }
$answer
The answer to the question obj.
RequiredRadioButtonQuestion Validator.
Definition: validation.inc:199

◆ MultipleChoiceView()

MultipleChoiceView::MultipleChoiceView (   $parent,
  $question 
)

Definition at line 256 of file question_renderer.inc.

257  {
259  }
QuestionField($parent, $question)
$question
The question renderer obj.
$parent
The parent QuestionForm obj.

◆ writeHTML()

MultipleChoiceView::writeHTML ( )

Reimplemented from QuestionField.

Definition at line 262 of file question_renderer.inc.

263  {
264  $pk = $this->question->getPrimaryKey();
265  $options = explode("\n", $this->question->options);
266  $tips = explode("\n", $this->question->context_help);
267 
268  $valueAnswer = $this->parent->getAnswer($this->question);
269 
270  $readonly = $this->parent->readOnlyForm ? " DISABLED" : "";
271 
272  echo "<table class=\"layout\">";
273 
274  $count = count($options);
275 
276  if($count > 0)
277  {
278  $idx = 1;
279  foreach($options as $value => $text)
280  {
281  $tip = $tips[$idx - 1];
282  if ($tip)
283  {
284  $tip = " onmouseover=\"showTextToolTip('question_{$this->question->$pk}', event, 'question_help', '".jsSafe($tip)."'); return false;\" onmouseout=\"hideToolTip('question_help');return false\" ";
285  }
286 
287  $selected = ($valueAnswer == $idx) ? " checked" : "";
288 
289  echo "<tr><td style=\"padding:1px\"$tip><input type='radio'
290  style='border: none' name='question_{$this->question->$pk}' id='question_{$this->question->$pk}_$idx'
291  value='$idx'$selected $readonly>&nbsp;$text</td></tr>";
292  $idx++;
293  }
294  }
295 
296  // Save this count to loop through checkboxes on required validation
297  echo "<input type=\"hidden\" name=\"count_question_{$this->question->$pk}\" value=\"$count\">";
298 
299  echo "</table>";
300 
301  }
$readonly
Whether the questions should be drawn readonly.

The documentation for this class was generated from the following file: