24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
25 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
55 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyTextQuestion.php";
59 $this->
object->loadFromDb($id);
71 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
74 $this->
object->setTitle(
$_POST[
"title"]);
75 $this->
object->label =
$_POST[
'label'];
76 $this->
object->setAuthor(
$_POST[
"author"]);
77 $this->
object->setDescription(
$_POST[
"description"]);
78 $questiontext =
$_POST[
"question"];
79 $this->
object->setQuestiontext($questiontext);
80 $this->
object->setObligatory((
$_POST[
"obligatory"]) ? 1 : 0);
82 $this->
object->setMaxChars((strlen(
$_POST[
"maxchars"])) ?
$_POST[
"maxchars"] : null);
83 $this->
object->setTextWidth(
$_POST[
"textwidth"]);
84 $this->
object->setTextHeight(
$_POST[
"textheight"]);
99 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
101 $form->setFormAction($this->ctrl->getFormAction($this));
102 $form->setTitle($this->lng->txt($this->getQuestionType()));
103 $form->setMultipart(FALSE);
104 $form->setTableWidth(
"100%");
105 $form->setId(
"essay");
109 $title->setValue($this->object->getTitle());
110 $title->setRequired(TRUE);
115 $label->
setValue($this->object->label);
116 $label->setInfo($this->lng->txt(
"label_info"));
117 $label->setRequired(
false);
118 $form->addItem($label);
121 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
122 $author->
setValue($this->object->getAuthor());
123 $author->setRequired(TRUE);
124 $form->addItem($author);
127 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"description");
128 $description->
setValue($this->object->getDescription());
129 $description->setRequired(FALSE);
130 $form->addItem($description);
134 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
135 $question->setRequired(TRUE);
136 $question->setRows(10);
137 $question->setCols(80);
138 $question->setUseRte(TRUE);
139 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
141 $question->addPlugin(
"latex");
142 $question->addButton(
"latex");
143 $question->addButton(
"pastelatex");
144 $question->setRTESupport($this->object->getId(),
"spl",
"survey", null,
false,
"3.4.7");
145 $form->addItem($question);
150 $maxchars->setSize(5);
151 if ($this->object->getMaxChars() > 0)
153 $maxchars->setValue($this->object->getMaxChars());
155 $maxchars->setDecimals(0);
156 $form->addItem($maxchars);
161 $textwidth->setSize(3);
162 $textwidth->setValue($this->object->getTextWidth());
163 $textwidth->setDecimals(0);
164 $textwidth->setMinValue(10);
165 $form->addItem($textwidth);
168 $textheight =
new ilNumberInputGUI($this->lng->txt(
"height"),
"textheight");
170 $textheight->setSize(3);
171 $textheight->setValue($this->object->getTextHeight());
172 $textheight->setDecimals(0);
173 $textheight->setMinValue(1);
174 $form->addItem($textheight);
179 $shuffle->setChecked($this->object->getObligatory());
180 $shuffle->setRequired(FALSE);
181 $form->addItem($shuffle);
189 $form->setValuesByPost();
190 $errors = !$form->checkInput();
191 $form->setValuesByPost();
192 if (
$errors) $checkonly =
false;
195 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
202 public function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
204 $template =
new ilTemplate(
"tpl.il_svy_out_text.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
205 $template->setCurrentBlock(
"material_text");
207 $template->parseCurrentBlock();
209 if ($this->object->getTextHeight() == 1)
211 $template->setCurrentBlock(
"textinput");
212 if (is_array($working_data))
214 if (strlen($working_data[0][
"textanswer"]))
219 $template->setVariable(
"QUESTION_ID", $this->object->getId());
220 $template->setVariable(
"WIDTH", $this->object->getTextWidth());
221 if ($this->object->getMaxChars())
223 $template->setVariable(
"MAXLENGTH",
" maxlength=\"" . $this->object->getMaxChars() .
"\"");
225 $template->parseCurrentBlock();
229 $template->setCurrentBlock(
"textarea");
230 if (is_array($working_data))
234 $template->setVariable(
"QUESTION_ID", $this->object->getId());
235 $template->setVariable(
"WIDTH", $this->object->getTextWidth());
236 $template->setVariable(
"HEIGHT", $this->object->getTextHeight());
237 $template->parseCurrentBlock();
239 $template->setCurrentBlock(
"question_data_text");
240 if ($show_questiontext)
246 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
248 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
249 $template->setVariable(
"LABEL_QUESTION_ID", $this->object->getId());
250 if (strcmp($error_message,
"") != 0)
252 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
254 if ($this->object->getMaxChars())
256 $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
258 $template->parseCurrentBlock();
259 return $template->get();
265 public function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
267 $template =
new ilTemplate(
"tpl.il_svy_qpl_text_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
268 if ($show_questiontext)
274 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
276 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
278 $template->setVariable(
"TEXTBOX", $this->lng->txt(
"textbox"));
279 $template->setVariable(
"TEXTBOX_WIDTH", $this->object->getTextWidth()*16);
280 $template->setVariable(
"TEXTBOX_HEIGHT", $this->object->getTextHeight()*16);
281 $template->setVariable(
"QUESTION_ID", $this->object->getId());
282 if ($this->object->getMaxChars())
284 $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
286 return $template->get();
304 if (count($this->cumulated) == 0)
306 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
308 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
312 include_once
"./Services/UICore/classes/class.ilTemplate.php";
313 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
315 $template->setCurrentBlock(
"detail_row");
316 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
317 $questiontext = $this->
object->getQuestiontext();
318 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
319 $template->parseCurrentBlock();
320 $template->setCurrentBlock(
"detail_row");
321 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
322 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
323 $template->parseCurrentBlock();
324 $template->setCurrentBlock(
"detail_row");
325 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
326 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
327 $template->parseCurrentBlock();
328 $template->setCurrentBlock(
"detail_row");
329 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
330 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
331 $template->parseCurrentBlock();
333 $template->setCurrentBlock(
"detail_row");
334 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"given_answers"));
336 if (is_array($this->cumulated[
"textvalues"]))
338 foreach ($this->cumulated[
"textvalues"] as $textvalue)
340 $textvalues .=
"<li>" . preg_replace(
"/\n/",
"<br>", $textvalue) .
"</li>";
343 $textvalues =
"<ul>$textvalues</ul>";
344 $template->setVariable(
"TEXT_OPTION_VALUE", $textvalues);
345 $template->parseCurrentBlock();
347 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
348 return $template->get();