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);
72 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_text.html",
"Modules/SurveyQuestionPool");
73 $this->tpl->addBlockFile(
"OTHER_QUESTION_DATA",
"other_question_data",
"tpl.il_svy_qpl_other_question_data.html",
"Modules/SurveyQuestionPool");
75 $internallinks = array(
76 "lm" => $this->lng->txt(
"obj_lm"),
77 "st" => $this->lng->txt(
"obj_st"),
78 "pg" => $this->lng->txt(
"obj_pg"),
79 "glo" => $this->lng->txt(
"glossary_term")
81 foreach ($internallinks as $key => $value)
83 $this->tpl->setCurrentBlock(
"internallink");
84 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
85 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
86 $this->tpl->parseCurrentBlock();
89 $this->tpl->setCurrentBlock(
"adm_content");
90 $this->tpl->setVariable(
"TEXT_MATERIAL", $this->lng->txt(
"material"));
91 if (count($this->object->material))
93 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
95 $this->tpl->setVariable(
"TEXT_VALUE_MATERIAL",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"material").
"</a> ");
96 $this->tpl->setVariable(
"BUTTON_REMOVE_MATERIAL", $this->lng->txt(
"remove"));
97 $this->tpl->setVariable(
"BUTTON_ADD_MATERIAL", $this->lng->txt(
"change"));
98 $this->tpl->setVariable(
"VALUE_MATERIAL", $this->object->material[
"internal_link"]);
99 $this->tpl->setVariable(
"VALUE_MATERIAL_TITLE", $this->object->material[
"title"]);
100 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
104 $this->tpl->setVariable(
"BUTTON_ADD_MATERIAL", $this->lng->txt(
"add"));
106 $this->tpl->setVariable(
"QUESTION_ID", $this->object->getId());
107 $this->tpl->setVariable(
"VALUE_TITLE", $this->object->getTitle());
108 $this->tpl->setVariable(
"VALUE_DESCRIPTION", $this->object->getDescription());
109 $this->tpl->setVariable(
"VALUE_AUTHOR", $this->object->getAuthor());
110 if ($this->object->getMaxChars() > 0)
112 $this->tpl->setVariable(
"VALUE_MAXCHARS", $this->object->getMaxChars());
114 $questiontext = $this->
object->getQuestiontext();
115 $this->tpl->setVariable(
"VALUE_QUESTION",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
116 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
117 $this->tpl->setVariable(
"TEXT_AUTHOR", $this->lng->txt(
"author"));
118 $this->tpl->setVariable(
"TEXT_DESCRIPTION", $this->lng->txt(
"description"));
119 $this->tpl->setVariable(
"TEXT_MAXCHARS", $this->lng->txt(
"maxchars"));
120 $this->tpl->setVariable(
"TEXT_WIDTH", $this->lng->txt(
"width"));
121 $this->tpl->setVariable(
"TEXT_HEIGHT", $this->lng->txt(
"height"));
122 $this->tpl->setVariable(
"DESCRIPTION_TEXTWIDTH", $this->lng->txt(
"survey_text_textwidth_desc"));
123 $this->tpl->setVariable(
"DESCRIPTION_TEXTHEIGHT", $this->lng->txt(
"survey_text_textheight_desc"));
124 if ($this->object->getTextWidth())
126 $this->tpl->setVariable(
"VALUE_TEXTWIDTH",
" value=\"" . $this->object->getTextWidth() .
"\"");
128 if ($this->object->getTextHeight())
130 $this->tpl->setVariable(
"VALUE_TEXTHEIGHT",
" value=\"" . $this->object->getTextHeight() .
"\"");
132 $this->tpl->setVariable(
"DESCRIPTION_MAXCHARS", $this->lng->txt(
"description_maxchars"));
133 $this->tpl->setVariable(
"TEXT_QUESTION", $this->lng->txt(
"question"));
134 $this->tpl->setVariable(
"TEXT_OBLIGATORY", $this->lng->txt(
"obligatory"));
135 if ($this->object->getObligatory())
137 $this->tpl->setVariable(
"CHECKED_OBLIGATORY",
" checked=\"checked\"");
139 $this->tpl->setVariable(
"SAVE",$this->lng->txt(
"save"));
140 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
141 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
142 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->lng->txt($this->getQuestionType()));
143 $this->tpl->parseCurrentBlock();
144 include_once
"./Services/RTE/classes/class.ilRTE.php";
146 include_once
"./Services/RTE/classes/class.$rtestring.php";
147 $rte =
new $rtestring();
148 $rte->addPlugin(
"latex");
149 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
150 $rte->removePlugin(
"ibrowser");
151 include_once
"./classes/class.ilObject.php";
152 $obj_id =
$_GET[
"q_id"];
154 $rte->addRTESupport($obj_id, $obj_type,
"survey");
166 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
168 $template =
new ilTemplate(
"tpl.il_svy_out_text.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
169 if (count($this->object->material))
171 $template->setCurrentBlock(
"material_text");
172 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
174 $template->setVariable(
"TEXT_MATERIAL", $this->lng->txt(
"material") .
": <a href=\"$href\" target=\"content\">" . $this->
object->material[
"title"].
"</a> ");
175 $template->parseCurrentBlock();
178 if ($this->object->getTextHeight() == 1)
180 $template->setCurrentBlock(
"textinput");
181 if (is_array($working_data))
183 if (strlen($working_data[0][
"textanswer"]))
188 $template->setVariable(
"QUESTION_ID", $this->object->getId());
189 $template->setVariable(
"WIDTH", $this->object->getTextWidth());
190 if ($this->object->getMaxChars())
192 $template->setVariable(
"MAXLENGTH",
" maxlength=\"" . $this->object->getMaxChars() .
"\"");
194 $template->parseCurrentBlock();
198 $template->setCurrentBlock(
"textarea");
199 if (is_array($working_data))
203 $template->setVariable(
"QUESTION_ID", $this->object->getId());
204 $template->setVariable(
"WIDTH", $this->object->getTextWidth());
205 $template->setVariable(
"HEIGHT", $this->object->getTextHeight());
206 $template->parseCurrentBlock();
208 $template->setCurrentBlock(
"question_data_text");
209 if ($show_questiontext)
211 $questiontext = $this->
object->getQuestiontext();
212 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
214 if (! $this->object->getObligatory($survey_id))
216 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
220 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
222 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
223 $template->setVariable(
"LABEL_QUESTION_ID", $this->object->getId());
224 if (strcmp($error_message,
"") != 0)
226 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
228 if ($this->object->getMaxChars())
230 $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
232 $template->parseCurrentBlock();
233 return $template->get();
243 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
245 $template =
new ilTemplate(
"tpl.il_svy_qpl_text_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
246 if ($show_questiontext)
248 $questiontext = $this->
object->getQuestiontext();
249 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
251 if (! $this->object->getObligatory($survey_id))
253 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
257 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
259 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
261 $template->setVariable(
"TEXTBOX", $this->lng->txt(
"textbox"));
262 $template->setVariable(
"TEXTBOX_WIDTH", $this->object->getTextWidth()*16);
263 $template->setVariable(
"TEXTBOX_HEIGHT", $this->object->getTextHeight()*16);
264 $template->setVariable(
"QUESTION_ID", $this->object->getId());
265 if ($this->object->getMaxChars())
267 $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
269 return $template->get();
281 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_preview.html",
"Modules/SurveyQuestionPool");
283 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
297 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]))
$result = 1;
301 if ($_POST[
"id"] > 0) $this->
object->setId($_POST[
"id"]);
302 include_once
"./Services/Utilities/classes/class.ilUtil.php";
309 if (strlen($_POST[
"material"]))
311 $this->
object->setMaterial($_POST[
"material"], 0,
ilUtil::stripSlashes($_POST[
"material_title"]));
313 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
315 $this->
object->setQuestiontext($questiontext);
316 if ($_POST[
"obligatory"])
318 $this->
object->setObligatory(1);
322 $this->
object->setObligatory(0);
331 $this->
object->saveToDb();
351 include_once
"./classes/class.ilTemplate.php";
352 if (count($this->cumulated) == 0)
354 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
356 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
358 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_row.html", TRUE, TRUE,
"Modules/Survey");
359 $template->setVariable(
"QUESTION_TITLE", ($counter+1) .
". ".$this->object->getTitle());
361 $questiontext = preg_replace(
"/<[^>]+?>/ims",
"", $this->object->getQuestiontext());
362 if (strlen($questiontext) > $maxlen + 3)
364 $questiontext = substr($questiontext, 0, $maxlen) .
"...";
366 $template->setVariable(
"QUESTION_TEXT", $questiontext);
367 $template->setVariable(
"USERS_ANSWERED", $this->cumulated[
"USERS_ANSWERED"]);
368 $template->setVariable(
"USERS_SKIPPED", $this->cumulated[
"USERS_SKIPPED"]);
369 $template->setVariable(
"QUESTION_TYPE", $this->lng->txt($this->cumulated[
"QUESTION_TYPE"]));
370 $template->setVariable(
"MODE", $this->cumulated[
"MODE"]);
371 $template->setVariable(
"MODE_NR_OF_SELECTIONS", $this->cumulated[
"MODE_NR_OF_SELECTIONS"]);
372 $template->setVariable(
"MEDIAN", $this->cumulated[
"MEDIAN"]);
373 $template->setVariable(
"ARITHMETIC_MEAN", $this->cumulated[
"ARITHMETIC_MEAN"]);
374 $template->setVariable(
"COLOR_CLASS", $css_class);
375 return $template->get();
390 if (count($this->cumulated) == 0)
392 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
394 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
398 include_once
"./classes/class.ilTemplate.php";
399 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
401 $template->setCurrentBlock(
"detail_row");
402 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
403 $questiontext = $this->
object->getQuestiontext();
404 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
405 $template->parseCurrentBlock();
406 $template->setCurrentBlock(
"detail_row");
407 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
408 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
409 $template->parseCurrentBlock();
410 $template->setCurrentBlock(
"detail_row");
411 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
412 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
413 $template->parseCurrentBlock();
414 $template->setCurrentBlock(
"detail_row");
415 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
416 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
417 $template->parseCurrentBlock();
419 $template->setCurrentBlock(
"detail_row");
420 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"given_answers"));
422 if (is_array($this->cumulated[
"textvalues"]))
424 foreach ($this->cumulated[
"textvalues"] as $textvalue)
426 $textvalues .=
"<li>" . preg_replace(
"/\n/",
"<br>", $textvalue) .
"</li>";
429 $textvalues =
"<ul>$textvalues</ul>";
430 $template->setVariable(
"TEXT_OPTION_VALUE", $textvalues);
431 $template->parseCurrentBlock();
433 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
434 return $template->get();