24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
41 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyTextQuestion.php";
60 $maxchars->setSize(5);
61 $maxchars->setDecimals(0);
67 $textwidth->setSize(3);
68 $textwidth->setDecimals(0);
69 $textwidth->setMinValue(10,
true);
75 $textheight->setSize(3);
77 $textheight->setDecimals(0);
78 $textheight->setMinValue(1);
82 if ($this->object->getMaxChars() > 0)
84 $maxchars->setValue($this->object->getMaxChars());
86 $textwidth->setValue($this->object->getTextWidth());
87 $textheight->setValue($this->object->getTextHeight());
92 $max = $a_form->
getInput(
"maxchars");
93 $this->
object->setMaxChars(strlen($max) ? $max : null);
94 $this->
object->setTextWidth($a_form->
getInput(
"textwidth"));
95 $this->
object->setTextHeight($a_form->
getInput(
"textheight"));
98 public function getParsedAnswers(array $a_working_data = null, $a_only_user_anwers =
false)
102 if(is_array($a_working_data))
104 $res[] = array(
"textanswer"=>trim($a_working_data[0][
"textanswer"]));
110 public function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null, array $a_working_data = null)
116 $user_answer = $user_answer[0][
"textanswer"];
119 $template =
new ilTemplate(
"tpl.il_svy_qpl_text_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
120 if ($show_questiontext)
126 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
128 $template->setVariable(
"QUESTION_ID", $this->object->getId());
129 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
130 if(is_array($a_working_data) && trim($user_answer))
132 $template->setVariable(
"TEXT", nl2br($user_answer));
137 $template->setVariable(
"TEXTBOX", $this->lng->txt(
"textbox"));
138 $template->setVariable(
"TEXTBOX_WIDTH", $this->object->getTextWidth()*16);
139 $template->setVariable(
"TEXTBOX_HEIGHT", $this->object->getTextHeight()*16);
141 if ($this->object->getMaxChars())
143 $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
145 return $template->get();
156 public function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
158 $template =
new ilTemplate(
"tpl.il_svy_out_text.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
159 $template->setCurrentBlock(
"material_text");
161 $template->parseCurrentBlock();
163 if ($this->object->getTextHeight() == 1)
165 $template->setCurrentBlock(
"textinput");
166 if (is_array($working_data))
168 if (strlen($working_data[0][
"textanswer"]))
173 $template->setVariable(
"QUESTION_ID", $this->object->getId());
174 $template->setVariable(
"WIDTH", $this->object->getTextWidth());
175 if ($this->object->getMaxChars())
177 $template->setVariable(
"MAXLENGTH",
" maxlength=\"" . $this->object->getMaxChars() .
"\"");
179 $template->parseCurrentBlock();
183 $template->setCurrentBlock(
"textarea");
184 if (is_array($working_data))
188 $template->setVariable(
"QUESTION_ID", $this->object->getId());
189 $template->setVariable(
"WIDTH", $this->object->getTextWidth());
190 $template->setVariable(
"HEIGHT", $this->object->getTextHeight());
191 $template->parseCurrentBlock();
193 $template->setCurrentBlock(
"question_data_text");
194 if ($show_questiontext)
200 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
202 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
203 $template->setVariable(
"LABEL_QUESTION_ID", $this->object->getId());
204 if (strcmp($error_message,
"") != 0)
206 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
208 if ($this->object->getMaxChars())
210 $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
212 $template->parseCurrentBlock();
213 return $template->get();
231 if (count($this->cumulated) == 0)
235 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
240 $nr_of_users =
sizeof($finished_ids);
242 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
246 include_once
"./Services/UICore/classes/class.ilTemplate.php";
247 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
249 $template->setCurrentBlock(
"detail_row");
250 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
251 $questiontext = $this->
object->getQuestiontext();
252 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
253 $template->parseCurrentBlock();
254 $template->setCurrentBlock(
"detail_row");
255 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
256 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
257 $template->parseCurrentBlock();
258 $template->setCurrentBlock(
"detail_row");
259 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
260 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
261 $template->parseCurrentBlock();
262 $template->setCurrentBlock(
"detail_row");
263 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
264 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
265 $template->parseCurrentBlock();
267 $template->setCurrentBlock(
"detail_row");
268 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"given_answers"));
270 if (is_array($this->cumulated[
"textvalues"]))
272 foreach ($this->cumulated[
"textvalues"] as $textvalue)
274 $textvalues .=
"<li>" . preg_replace(
"/\n/",
"<br>", $textvalue) .
"</li>";
277 $textvalues =
"<ul>$textvalues</ul>";
278 $template->setVariable(
"TEXT_OPTION_VALUE", $textvalues);
279 $template->parseCurrentBlock();
281 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
282 return $template->get();