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->removePlugin(
"ibrowser");
145 $question->setRTESupport($this->object->getId(),
"spl",
"survey", null,
false,
"3.4.7");
146 $form->addItem($question);
151 $maxchars->setSize(5);
152 if ($this->object->getMaxChars() > 0)
154 $maxchars->setValue($this->object->getMaxChars());
156 $maxchars->setDecimals(0);
157 $form->addItem($maxchars);
162 $textwidth->setSize(3);
163 $textwidth->setValue($this->object->getTextWidth());
164 $textwidth->setDecimals(0);
165 $textwidth->setMinValue(10);
166 $form->addItem($textwidth);
169 $textheight =
new ilNumberInputGUI($this->lng->txt(
"height"),
"textheight");
171 $textheight->setSize(3);
172 $textheight->setValue($this->object->getTextHeight());
173 $textheight->setDecimals(0);
174 $textheight->setMinValue(1);
175 $form->addItem($textheight);
180 $shuffle->setChecked($this->object->getObligatory());
181 $shuffle->setRequired(FALSE);
182 $form->addItem($shuffle);
190 $form->setValuesByPost();
191 $errors = !$form->checkInput();
192 $form->setValuesByPost();
193 if (
$errors) $checkonly =
false;
196 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
203 public function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
205 $template =
new ilTemplate(
"tpl.il_svy_out_text.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
206 $template->setCurrentBlock(
"material_text");
208 $template->parseCurrentBlock();
210 if ($this->object->getTextHeight() == 1)
212 $template->setCurrentBlock(
"textinput");
213 if (is_array($working_data))
215 if (strlen($working_data[0][
"textanswer"]))
220 $template->setVariable(
"QUESTION_ID", $this->object->getId());
221 $template->setVariable(
"WIDTH", $this->object->getTextWidth());
222 if ($this->object->getMaxChars())
224 $template->setVariable(
"MAXLENGTH",
" maxlength=\"" . $this->object->getMaxChars() .
"\"");
226 $template->parseCurrentBlock();
230 $template->setCurrentBlock(
"textarea");
231 if (is_array($working_data))
235 $template->setVariable(
"QUESTION_ID", $this->object->getId());
236 $template->setVariable(
"WIDTH", $this->object->getTextWidth());
237 $template->setVariable(
"HEIGHT", $this->object->getTextHeight());
238 $template->parseCurrentBlock();
240 $template->setCurrentBlock(
"question_data_text");
241 if ($show_questiontext)
247 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
249 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
250 $template->setVariable(
"LABEL_QUESTION_ID", $this->object->getId());
251 if (strcmp($error_message,
"") != 0)
253 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
255 if ($this->object->getMaxChars())
257 $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
259 $template->parseCurrentBlock();
260 return $template->get();
266 public function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
268 $template =
new ilTemplate(
"tpl.il_svy_qpl_text_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
269 if ($show_questiontext)
275 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
277 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
279 $template->setVariable(
"TEXTBOX", $this->lng->txt(
"textbox"));
280 $template->setVariable(
"TEXTBOX_WIDTH", $this->object->getTextWidth()*16);
281 $template->setVariable(
"TEXTBOX_HEIGHT", $this->object->getTextHeight()*16);
282 $template->setVariable(
"QUESTION_ID", $this->object->getId());
283 if ($this->object->getMaxChars())
285 $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
287 return $template->get();
305 if (count($this->cumulated) == 0)
307 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
309 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
313 include_once
"./classes/class.ilTemplate.php";
314 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
316 $template->setCurrentBlock(
"detail_row");
317 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
318 $questiontext = $this->
object->getQuestiontext();
319 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
320 $template->parseCurrentBlock();
321 $template->setCurrentBlock(
"detail_row");
322 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
323 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
324 $template->parseCurrentBlock();
325 $template->setCurrentBlock(
"detail_row");
326 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
327 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
328 $template->parseCurrentBlock();
329 $template->setCurrentBlock(
"detail_row");
330 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
331 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
332 $template->parseCurrentBlock();
334 $template->setCurrentBlock(
"detail_row");
335 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"given_answers"));
337 if (is_array($this->cumulated[
"textvalues"]))
339 foreach ($this->cumulated[
"textvalues"] as $textvalue)
341 $textvalues .=
"<li>" . preg_replace(
"/\n/",
"<br>", $textvalue) .
"</li>";
344 $textvalues =
"<ul>$textvalues</ul>";
345 $template->setVariable(
"TEXT_OPTION_VALUE", $textvalues);
346 $template->parseCurrentBlock();
348 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
349 return $template->get();