74 $this->answer = $this->parent->answers[$this->question->$qPk];
79 return $this->question->get($this->question->getPrimaryKey());
103 echo
"<p>" . $this->
getAnswer() .
"</p>";
113 return $this->parent->getAnswer($this->question);
125 $pk = $this->question->getPrimaryKey();
126 $options = explode(
"\n", $this->question->options);
128 $valueAnswer = $this->parent->getAnswer($this->question);
136 if($valueAnswer == $idx)
150 if ($this->question->char_limit)
153 $pk = $this->question->getPrimaryKey();
154 $field =
"question_{$this->question->$pk}";
159 function {
$field}_keyup(event)
161 var form = document.getElementById(
'Questionnaire_form');
162 var ctrl = form[
'{$field}'];
163 var len = ctrl.value.length;
164 if (len >= {$this->question->char_limit})
166 ctrl.value = ctrl.value.substring(0, {$this->question->char_limit});
167 len = {$this->question->char_limit};
170 var count = document.getElementById(
'{$field}_length');
171 count.innerHTML = len;
186 echo strlen(trim($value));
187 echo
"</span> of {$limit} characters";
194 return ($this->question->required) ?
"*" :
"";
200 $pk = $this->question->getPrimaryKey();
202 $answer = ($this->parent->readOnlyForm) ? $this->answer :
"";
203 $question_number = ($this->question->question_number) ? $this->question->question_number : $this->parent->mgr->getQuestionNumber($this->question);
216 trace(
"QuestionField::create(): Unknown question type", 2);
217 die(
"Unknown question type {$question->question_type_id}");
264 $pk = $this->question->getPrimaryKey();
265 $options = explode(
"\n", $this->question->options);
266 $tips = explode(
"\n", $this->question->context_help);
268 $valueAnswer = $this->parent->getAnswer($this->question);
270 $readonly = $this->parent->readOnlyForm ?
" DISABLED" :
"";
272 echo
"<table class=\"layout\">";
281 $tip = $tips[$idx - 1];
284 $tip =
" onmouseover=\"showTextToolTip('question_{$this->question->$pk}', event, 'question_help', '".jsSafe($tip).
"'); return false;\" onmouseout=\"hideToolTip('question_help');return false\" ";
287 $selected = ($valueAnswer == $idx) ?
" checked" :
"";
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> $text</td></tr>";
297 echo
"<input type=\"hidden\" name=\"count_question_{$this->question->$pk}\" value=\"$count\">";
318 $pk = $this->question->getPrimaryKey();
321 $answer = ($this->parent->readOnlyForm) ? $this->answer :
"";
322 $question_number = $this->question->question_number ? $this->question->question_number : $this->parent->mgr->getQuestionNumber($this->question);
357 $options = explode(
"\n", $this->question->options);
360 $value = $this->parent->getAnswer($this->question);
362 $readonly = $this->parent->readOnlyForm ?
" DISABLED" :
"";
366 echo
"<table class=\"layout\">";
367 $pk = $this->question->getPrimaryKey();
368 echo
"<select name='question_{$this->question->$pk}'>\n";
371 echo
"<option value=''></option>";
376 $selected = ($value == $num) ?
" selected" :
"";
377 echo
"<option value='$num'$readonly$selected>$option</option>";
420 list(
$from,
$to, $steps) = explode(
"\n", $this->question->options);
422 if (!
$to)
$to =
"Highest";
423 if (!$steps) $steps = 5;
426 $readonly = $this->parent->readOnlyForm ?
" disabled='disabled'" :
"";
427 $valueAnswer = $this->parent->getAnswer($this->question);
429 $qPk = $this->question->getPrimaryKey();
431 $tip = $this->question->context_help;
434 $tip =
" onmouseover=\"showTextToolTip('question_{$this->question->$qPk}', event, 'question_help', '".jsSafe($tip).
"'); return false;\" onmouseout=\"hideToolTip('question_help');return false\" ";
436 echo
"<div$tip>$from ";
438 for($i = 1; $i <= $steps; ++$i)
440 $selected = ($valueAnswer == $i) ?
" checked" :
"";
442 echo
"<input type='radio' style='border: none' name='question_{$this->question->$qPk}'
443 id='question_{$this->question->$qPk}_$i'
444 value='$i'$selected $readonly /> ";
448 echo
"<input type=\"hidden\" name=\"count_question_{$this->question->$qPk}\" value=\"$steps\">";
457 $valueAnswer = $this->parent->getAnswer($this->question);
459 $answer =
"{$valueAnswer} rating on scale of $steps $from – $to";
467 $valueAnswer = $this->parent->getAnswer($this->question);
476 if (!
$to)
$to =
"Highest";
477 if (!$steps) $steps = 5;
489 $pk = $this->question->getPrimaryKey();
490 $answer = ($this->parent->readOnlyForm) ? $this->answer :
"";
491 $question_number = $this->question->question_number ? $this->question->question_number : $this->parent->mgr->getQuestionNumber($this->question);
518 $value = $this->parent->getAnswer($this->question);
519 $readonly = $this->parent->readOnlyForm ?
" readonly='readonly'":
"";
520 $autocomplete =
"autocomplete='off'";
522 $pk = $this->question->getPrimaryKey();
524 $field =
"question_" . $this->question->$pk;
526 if ($this->question->char_limit)
528 $onkeypress =
" onkeyup='{$field}_keyup(event);'";
531 $tip = $this->question->context_help;
534 $tip =
" onmouseover=\"showTextToolTip('question_{$this->question->$pk}', event, 'question_help', '".jsSafe($tip).
"'); return false;\" onmouseout=\"hideToolTip('question_help');return false\" ";
537 echo
"<input id='$field' type='text' name='$field' $readonly $autocomplete value='".htmlspecialchars($value, ENT_QUOTES,
'UTF-8').
"' size='50' $disable $onkeypress $tip/>";
538 echo
"<br/><div style='clear: left; float: right'><span id='{$field}_length'>";
540 parent::renderLimitEnd($this->question->char_limit,
$field, $value);
547 $value = $this->parent->getAnswer($this->question);
548 echo
"<em>".htmlsafe($value).
"</em>";
553 return parent::writeLimitScript();
566 $pk = $this->question->getPrimaryKey();
573 echo
"<li>" . formatAsHTML(stripHTML(
$answer->value)) .
"</li>\n";
590 return parent::writeLimitScript();
596 $pk = $this->question->getPrimaryKey();
597 $field =
"question_{$this->question->$pk}";
599 $rows = ($this->question->num_rows) ? $this->question->num_rows : 6;
602 if ($this->question->char_limit)
604 $onkeypress =
" onkeyup='{$field}_keyup(event);'";
607 $value = $this->parent->getAnswer($this->question);
609 $readonly = $this->parent->readOnlyForm ?
" readonly='readonly'":
"";
610 $autocomplete =
"autocomplete='off'";
612 $tip = $this->question->context_help;
615 $tip =
" onmouseover=\"showTextToolTip('question_{$this->question->$pk}', event, 'question_help', '".jsSafe($tip).
"'); return false;\" onmouseout=\"hideToolTip('question_help');return false\" ";
618 echo
"<textarea name='{$field}' cols='75' rows='$rows' $onkeypress $readonly $autocomplete $tip>".htmlsafe($value).
"</textarea>";
620 echo
"<br/><div style='clear: left; float: right'><span id='{$field}_length'>";
622 parent::renderLimitEnd($this->question->char_limit,
$field, $value);
630 $value = $this->parent->getAnswer($this->question);
636 $answerVal = htmlsafe($value);
638 $answerVal = formatAsHTML($value);
640 echo
"<em>".$answerVal.
"</em>";
654 $pk = $this->question->getPrimaryKey();
661 echo
"<li>" . formatAsHTML(stripHTML(
$answer->value)) .
"</li>\n";
678 $values = $this->parent->getAnswer($this->question);
681 if(strlen($values)==1 AND is_numeric($values))
682 $values = array($values);
683 elseif(strlen($values)==0)
686 $values = explode(
",", $values);
693 $optionArr = explode(
"\n", $this->question->options);
694 $options = $this->parent->incrementArray($optionArr);
695 $tips = explode(
"\n", $this->question->context_help);
699 $readonly = $this->parent->readOnlyForm ?
" DISABLED" :
"";
702 echo
"<table class=\"layout\">";
706 $pk = $this->question->getPrimaryKey();
712 if(is_array($values))
714 $checked = (array_search($value, $values) !== FALSE) ?
" checked" :
"";
717 $tip = $tips[$idx - 1];
720 $tip =
" onmouseover=\"showTextToolTip('question_{$this->question->$pk}', event, 'question_help', '".jsSafe($tip).
"'); return false;\" onmouseout=\"hideToolTip('question_help');return false\" ";
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/> $text</td></tr>";
730 echo
"<input type=\"hidden\" name=\"count_question_{$this->question->$pk}\" value=\"$count\">";
746 if($this->question->required > 0)
748 $optionArr = explode(
"\n", $this->question->options);
749 if(count($optionArr) > 1)
751 $label = ($this->question->required > 1) ?
"checkboxes" :
"checkbox";
752 $required =
"* at least " . $this->question->required .
" $label must be checked";
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);
778 $optionArr = explode(
"\n", $this->question->options);
779 $options = $this->parent->incrementArray($optionArr);
790 if(is_array($values))
792 if(array_search($value, $values) !== FALSE)
800 return implode($this->answerSeparator,
$answers);
CheckListView($parent, $question)
drawGraph($mgr, $answers)
Draws an interactive graphical view of answers to one question.
static using()
Import the datamodels, views and manifest for the specified component(s).
static usingFile()
Uses the specified framework file(s) from the framework directory.
FreeTextView($parent, $question)
drawGraph($mgr, $answers)
There is no graphical display for free text questions so just display the answers as a list.
MultipleChoiceView($parent, $question)
drawGraph($mgr, $answers)
Draws an interactive graphical view of answers to one question.
MultipleChoiceView($parent, $question)
QuestionField($parent, $question)
static create($parent, $question)
$answer
The answer to the question obj.
$readonly
Whether the questions should be drawn readonly.
$question
The question renderer obj.
$answerSeparator
for list of answers in checklist renderer
renderLimitEnd($limit, $field, $value)
$parent
The parent QuestionForm obj.
static drawChecklistGraph($question, $resultsManager, $answers)
Draws an interactive graphical view of answers to one question.
static drawSelectGraph($question, $resultsManager, $answers)
Draws an interactive graphical view of answers to one question.
static drawRatingsGraph($question, $resultsManager, $answers)
Draws an interactive graphical view of answers to one question.
RatingView($parent, $question)
drawGraph($mgr, $answers)
Draws an interactive graphical view of answers to one question.
static getOptions($options, &$from, &$to, &$steps)
RequiredCheckListQuestion Validator.
RequiredQuestion Validator.
SelectFieldView($parent, $question)
drawGraph($mgr, $answers)
Draws an interactive graphical view of answers to one question.
drawGraph($mgr, $answers)
There is no graphical display for free text questions so just display the answers as a list.
ShortTextView($parent, $question)