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->setAuthor(
$_POST[
"author"]);
76 $this->
object->setDescription(
$_POST[
"description"]);
77 $questiontext =
$_POST[
"question"];
78 $this->
object->setQuestiontext($questiontext);
79 $this->
object->setObligatory((
$_POST[
"obligatory"]) ? 1 : 0);
81 $this->
object->setMaxChars((strlen(
$_POST[
"maxchars"])) ?
$_POST[
"maxchars"] : null);
82 $this->
object->setTextWidth(
$_POST[
"textwidth"]);
83 $this->
object->setTextHeight(
$_POST[
"textheight"]);
98 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) || (strcmp($this->ctrl->getCmd(),
"saveEdit") == 0)) ? TRUE : FALSE;
100 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
102 $form->setFormAction($this->ctrl->getFormAction($this));
103 $form->setTitle($this->lng->txt($this->getQuestionType()));
104 $form->setMultipart(FALSE);
105 $form->setTableWidth(
"100%");
106 $form->setId(
"essay");
110 $title->setValue($this->object->getTitle());
111 $title->setRequired(TRUE);
115 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
116 $author->
setValue($this->object->getAuthor());
117 $author->setRequired(TRUE);
118 $form->addItem($author);
121 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"description");
122 $description->
setValue($this->object->getDescription());
123 $description->setRequired(FALSE);
124 $form->addItem($description);
128 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
129 $question->setRequired(TRUE);
130 $question->setRows(10);
131 $question->setCols(80);
132 $question->setUseRte(TRUE);
133 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
135 $question->addPlugin(
"latex");
136 $question->addButton(
"latex");
137 $question->addButton(
"pastelatex");
138 $question->removePlugin(
"ibrowser");
139 $question->setRTESupport($this->object->getId(),
"spl",
"survey");
140 $form->addItem($question);
145 $maxchars->setSize(5);
146 if ($this->object->getMaxChars() > 0)
148 $maxchars->setValue($this->object->getMaxChars());
150 $maxchars->setDecimals(0);
151 $form->addItem($maxchars);
156 $textwidth->setSize(3);
157 $textwidth->setValue($this->object->getTextWidth());
158 $textwidth->setDecimals(0);
159 $textwidth->setMinValue(10);
160 $form->addItem($textwidth);
163 $textheight =
new ilNumberInputGUI($this->lng->txt(
"height"),
"textheight");
165 $textheight->setSize(3);
166 $textheight->setValue($this->object->getTextHeight());
167 $textheight->setDecimals(0);
168 $textheight->setMinValue(1);
169 $form->addItem($textheight);
174 $shuffle->setChecked($this->object->getObligatory());
175 $shuffle->setRequired(FALSE);
176 $form->addItem($shuffle);
178 $form->addCommandButton(
"save", $this->lng->txt(
"save"));
184 $form->setValuesByPost();
185 $errors = !$form->checkInput();
186 $form->setValuesByPost();
187 if (
$errors) $checkonly =
false;
190 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
197 public function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
199 $template =
new ilTemplate(
"tpl.il_svy_out_text.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
200 $template->setCurrentBlock(
"material_text");
202 $template->parseCurrentBlock();
204 if ($this->object->getTextHeight() == 1)
206 $template->setCurrentBlock(
"textinput");
207 if (is_array($working_data))
209 if (strlen($working_data[0][
"textanswer"]))
214 $template->setVariable(
"QUESTION_ID", $this->object->getId());
215 $template->setVariable(
"WIDTH", $this->object->getTextWidth());
216 if ($this->object->getMaxChars())
218 $template->setVariable(
"MAXLENGTH",
" maxlength=\"" . $this->object->getMaxChars() .
"\"");
220 $template->parseCurrentBlock();
224 $template->setCurrentBlock(
"textarea");
225 if (is_array($working_data))
229 $template->setVariable(
"QUESTION_ID", $this->object->getId());
230 $template->setVariable(
"WIDTH", $this->object->getTextWidth());
231 $template->setVariable(
"HEIGHT", $this->object->getTextHeight());
232 $template->parseCurrentBlock();
234 $template->setCurrentBlock(
"question_data_text");
235 if ($show_questiontext)
237 $questiontext = $this->
object->getQuestiontext();
238 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
240 if (! $this->object->getObligatory($survey_id))
242 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
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)
270 $questiontext = $this->
object->getQuestiontext();
271 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
273 if (! $this->object->getObligatory($survey_id))
275 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
279 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
281 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
283 $template->setVariable(
"TEXTBOX", $this->lng->txt(
"textbox"));
284 $template->setVariable(
"TEXTBOX_WIDTH", $this->object->getTextWidth()*16);
285 $template->setVariable(
"TEXTBOX_HEIGHT", $this->object->getTextHeight()*16);
286 $template->setVariable(
"QUESTION_ID", $this->object->getId());
287 if ($this->object->getMaxChars())
289 $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
291 return $template->get();
303 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_preview.html",
"Modules/SurveyQuestionPool");
305 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
323 if (count($this->cumulated) == 0)
325 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
327 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
331 include_once
"./classes/class.ilTemplate.php";
332 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
334 $template->setCurrentBlock(
"detail_row");
335 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
336 $questiontext = $this->
object->getQuestiontext();
337 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
338 $template->parseCurrentBlock();
339 $template->setCurrentBlock(
"detail_row");
340 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
341 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
342 $template->parseCurrentBlock();
343 $template->setCurrentBlock(
"detail_row");
344 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
345 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
346 $template->parseCurrentBlock();
347 $template->setCurrentBlock(
"detail_row");
348 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
349 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
350 $template->parseCurrentBlock();
352 $template->setCurrentBlock(
"detail_row");
353 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"given_answers"));
355 if (is_array($this->cumulated[
"textvalues"]))
357 foreach ($this->cumulated[
"textvalues"] as $textvalue)
359 $textvalues .=
"<li>" . preg_replace(
"/\n/",
"<br>", $textvalue) .
"</li>";
362 $textvalues =
"<ul>$textvalues</ul>";
363 $template->setVariable(
"TEXT_OPTION_VALUE", $textvalues);
364 $template->parseCurrentBlock();
366 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
367 return $template->get();