81 var
$requiredText =
"<b>You must answer all required questions.</b><br/>";
103 global $auto_form_defaults;
108 foreach($auto_form_defaults as
$field => $value)
112 $this->requiredFieldsText = preg_replace(
"/field/i",
"question", $this->requiredFieldsText);
131 $question->question->question_number = $num++;
136 array_push($this->validators,
$question->getRequiredValidator());
163 $this->buttons[] = array(
'text' =>
$text,
'url' =>
$url,
'confirm' => $confirm,
'isScript' =>
$isScript);
172 foreach($this->buttons as
$button)
178 $link =
"if (confirm('".jsSafe(
$button[
'confirm']).
"')) $url; return false;";
182 $link =
"$url; return false;";
185 echo
" <input type='button' class='{$this->buttonCSS}' onclick=\"$link\" value=\"{$button['text']}\"/>";
191 $qPk = $this->mgr->getQuestionKey();
200 if(count($this->questions) == 0)
209 $script .=
"function validate_Questionnaire_form(form)\n";
217 $script .=
"\n\n return true;\n}";
219 $script .=
"function onSubmitQuestionnaire_form(form)\n{\n";
221 if ($this->allowIncompleteSave)
225 $script .=
"\t validate_Questionnaire_form(form); return true\n}";
229 $script .=
"\t return validate_Questionnaire_form(form);\n}";
231 if (
$script)
$script =
"<script type='text/javascript'>\n$script\n</script>";
237 if(count($this->questions) == 0)
239 echo
"There are no questions.<br/>";
243 if($this->requiredText)
247 echo
"<tr>\n <td colspan='2'><span class='error'>{$this->msg}</span</td></tr>\n";
254 echo
"<b>{$this->requiredFieldsText}</b><br/><br/>";
270 $num = (
$question->question->question_number) ?
$question->question->question_number : $this->mgr->getQuestionNumber();
272 echo
" <dt><label for='question_{$qPk}'>";
276 echo
"<b>{$num}.</b> ";
279 echo
"{$question->question->question}{$required}</label></dt>\n";
298 $pk = $this->mgr->item->getPrimaryKey();
299 $qPk = $this->mgr->getQuestionKey();
300 $aPk = $this->mgr->getAnswerKey();
301 $answerClass = $this->mgr->getAnswerClass();
305 if (!strncmp(
"question_",
$name, 9))
308 $valueAnswer = (is_array($value)) ? implode(
",", array_values($value)) : $value;
320 $answer->$pk = $this->mgr->item->$pk;
333 $indexed = regroupList(
$questions,
"question_type_id");
334 $checkListQuestions = array();
336 if(array_key_exists(5, $indexed))
338 $checkListQuestions = $indexed[5];
339 if(!is_array($checkListQuestions))
341 $checkListQuestions = array($checkListQuestions);
345 if(count($checkListQuestions) > 0)
347 foreach($checkListQuestions as
$question)
352 $postAnswer =
$_POST[
"question_{$question->$qPk}"];
354 if(!$postAnswer && !is_array($postAnswer))
369 echo
"<div class='questionnaire_form'>";
375 if (!$this->subordinate)
377 echo
"<form id=\"{$id}\" method=\"POST\" action=\"\" ";
378 echo
"enctype='multipart/form-data' onsubmit='return onSubmitQuestionnaire_form(this);'>";
381 if ($this->buttons_at_top && !$this->subordinate)
390 if (!$this->subordinate)
404 echo
"<input type=\"submit\" style=\"float: left\" name=\"save\" class=\"{$this->buttonCSS}\" value=\" {$submitLabel} \"/>";
420 $answers = $this->mgr->getAnswers();
447 $aPk = $this->mgr->getAnswerKey();
448 $qPk = $this->mgr->getQuestionKey();
455 $answer->filter =
new InclusionFilter(
"value");
463 if ($this->msg !=
"")
483 if(count($array) > 0)
486 while($idx < (count($array)))
488 $newArray[$idx+1] = $array[$idx];
525 $num = (
$question->question->question_number) ?
$question->question->question_number : $this->mgr->getQuestionNumber();
527 echo
" <dt><label for='question_{$qPk}'>";
531 echo
"<b>{$num}.</b> ";
534 echo
"{$question->question->question}{$required}</label></dt>\n";
577 parent::QuestionnaireForm(
$mgr,
true);
583 $num = (
$question->question->question_number) ?
$question->question->question_number : $this->mgr->getQuestionNumber();
588 echo
"<b>{$num}.</b> ";
591 echo
"{$question->question->question}{$required}</dt>\n";
static using()
Import the datamodels, views and manifest for the specified component(s).
static create($parent, $question)
writeOneQuestion($question)
QuestionnairePreview($mgr)
writeOneQuestion($question)
QuestionnaireResponseView($mgr)