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

Public Member Functions

 CheckListView ($parent, $question)
 
 getValues ()
 
 writeHTML ()
 
 getRequired ()
 
 getRequiredValidator ()
 
 drawView ()
 
 getAnswer ()
 
 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)
 

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 669 of file question_renderer.inc.

Member Function Documentation

◆ CheckListView()

CheckListView::CheckListView (   $parent,
  $question 
)

Definition at line 671 of file question_renderer.inc.

672  {
674  }
QuestionField($parent, $question)
$question
The question renderer obj.
$parent
The parent QuestionForm obj.

◆ drawGraph()

CheckListView::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 810 of file question_renderer.inc.

811  {
813  }
static drawChecklistGraph($question, $resultsManager, $answers)
Draws an interactive graphical view of answers to one question.
$answers

◆ drawView()

CheckListView::drawView ( )

Definition at line 770 of file question_renderer.inc.

771  {
772  $this->writeHTML();
773  }

◆ getAnswer()

CheckListView::getAnswer ( )

Reimplemented from QuestionField.

Definition at line 776 of file question_renderer.inc.

777  {
778  $optionArr = explode("\n", $this->question->options);
779  $options = $this->parent->incrementArray($optionArr);
780 
781  $answers = array();
782  $values = $this->getValues();
783 
784  $count = count($options);
785  if($count > 0)
786  {
787  $idx = 1;
788  foreach($options as $value => $text)
789  {
790  if(is_array($values))
791  {
792  if(array_search($value, $values) !== FALSE)
793  {
794  $answers[] = $text;
795  }
796  }
797  $idx++;
798  }
799  }
800  return implode($this->answerSeparator, $answers);
801  }

◆ getRequired()

CheckListView::getRequired ( )

Reimplemented from QuestionField.

Definition at line 744 of file question_renderer.inc.

745  {
746  if($this->question->required > 0)
747  {
748  $optionArr = explode("\n", $this->question->options);
749  if(count($optionArr) > 1)
750  {
751  $label = ($this->question->required > 1) ? "checkboxes" : "checkbox";
752  $required = "* at least " . $this->question->required . " $label must be checked";
753  }
754  else
755  $required = "*";
756  }
757  return $required;
758  }

◆ getRequiredValidator()

CheckListView::getRequiredValidator ( )

Reimplemented from QuestionField.

Definition at line 760 of file question_renderer.inc.

761  {
762  // Empty question object signals to validator to validate from form and $_POST.
763  // Not empty means this is a view so we have the answer object that was saved.
764  $pk = $this->question->getPrimaryKey();
765  $answer = ($this->parent->readOnlyForm) ? $this->answer : "";
766  $question_number = $this->question->question_number ? $this->question->question_number : $this->parent->mgr->getQuestionNumber($this->question);
767  return new RequiredCheckListQuestionValidator("question_{$this->question->$pk}", "Question {$question_number}", $this->question->required, $answer);
768  }
$answer
The answer to the question obj.
RequiredCheckListQuestion Validator.
Definition: validation.inc:117

◆ getValues()

CheckListView::getValues ( )

Definition at line 676 of file question_renderer.inc.

677  {
678  $values = $this->parent->getAnswer($this->question);
679 
680  // include 0 value, first checkbox
681  if(strlen($values)==1 AND is_numeric($values))
682  $values = array($values);
683  elseif(strlen($values)==0)
684  $values = "";
685  else
686  $values = explode(",", $values);
687 
688  return $values;
689  }
return
Definition: add_member.inc:70
if(! $process) else

◆ writeHTML()

CheckListView::writeHTML ( )

Reimplemented from QuestionField.

Definition at line 691 of file question_renderer.inc.

692  {
693  $optionArr = explode("\n", $this->question->options);
694  $options = $this->parent->incrementArray($optionArr);
695  $tips = explode("\n", $this->question->context_help);
696 
697  $values = $this->getValues();
698 
699  $readonly = $this->parent->readOnlyForm ? " DISABLED" : "";
700 
701  // to do - put the font style into css
702  echo "<table class=\"layout\">";
703  $idx = 1;
704 
705  $count = count($options);
706  $pk = $this->question->getPrimaryKey();
707 
708  if($count > 0)
709  {
710  foreach($options as $value => $text)
711  {
712  if(is_array($values))
713  {
714  $checked = (array_search($value, $values) !== FALSE) ? " checked" : "";
715  }
716 
717  $tip = $tips[$idx - 1];
718  if ($tip)
719  {
720  $tip = " onmouseover=\"showTextToolTip('question_{$this->question->$pk}', event, 'question_help', '".jsSafe($tip)."'); return false;\" onmouseout=\"hideToolTip('question_help');return false\" ";
721  }
722 
723  echo "<tr><td style=\"padding:1px\"$tip><input type='checkbox'
724  class='checkbox' name='question_{$this->question->$pk}[$idx]'
725  value='$value'$readonly$checked/>&nbsp;$text</td></tr>";
726  $idx++;
727  }
728 
729  // Save this count to loop through checkboxes on required validation
730  echo "<input type=\"hidden\" name=\"count_question_{$this->question->$pk}\" value=\"$count\">";
731  }
732 
733  echo "</table>";
734 
735  }
$readonly
Whether the questions should be drawn readonly.

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