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                 $save = ((strcmp($this->ctrl->getCmd(), 
"save") == 0) || (strcmp($this->ctrl->getCmd(), 
"saveEdit") == 0)) ? TRUE : FALSE;
 
  101                 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  103                 $form->setFormAction($this->ctrl->getFormAction($this));
 
  104                 $form->setTitle($this->lng->txt($this->getQuestionType()));
 
  105                 $form->setMultipart(FALSE);
 
  106                 $form->setTableWidth(
"100%");
 
  107                 $form->setId(
"essay");
 
  111                 $title->setValue($this->object->getTitle());
 
  112                 $title->setRequired(TRUE);
 
  117                 $label->
setValue($this->object->label);
 
  118                 $label->setInfo($this->lng->txt(
"label_info"));
 
  119                 $label->setRequired(
false);
 
  120                 $form->addItem($label);
 
  123                 $author = 
new ilTextInputGUI($this->lng->txt(
"author"), 
"author");
 
  124                 $author->
setValue($this->object->getAuthor());
 
  125                 $author->setRequired(TRUE);
 
  126                 $form->addItem($author);
 
  129                 $description = 
new ilTextInputGUI($this->lng->txt(
"description"), 
"description");
 
  130                 $description->
setValue($this->object->getDescription());
 
  131                 $description->setRequired(FALSE);
 
  132                 $form->addItem($description);
 
  136                 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
 
  137                 $question->setRequired(TRUE);
 
  138                 $question->setRows(10);
 
  139                 $question->setCols(80);
 
  140                 $question->setUseRte(TRUE);
 
  141                 include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
  143                 $question->addPlugin(
"latex");
 
  144                 $question->addButton(
"latex");
 
  145                 $question->addButton(
"pastelatex");
 
  146                 $question->removePlugin(
"ibrowser");
 
  147                 $question->setRTESupport($this->object->getId(), 
"spl", 
"survey");
 
  148                 $form->addItem($question);
 
  153                 $maxchars->setSize(5);
 
  154                 if ($this->object->getMaxChars() > 0)
 
  156                         $maxchars->setValue($this->object->getMaxChars());
 
  158                 $maxchars->setDecimals(0);
 
  159                 $form->addItem($maxchars);
 
  164                 $textwidth->setSize(3);
 
  165                 $textwidth->setValue($this->object->getTextWidth());
 
  166                 $textwidth->setDecimals(0);
 
  167                 $textwidth->setMinValue(10);
 
  168                 $form->addItem($textwidth);
 
  171                 $textheight = 
new ilNumberInputGUI($this->lng->txt(
"height"), 
"textheight");
 
  173                 $textheight->setSize(3);
 
  174                 $textheight->setValue($this->object->getTextHeight());
 
  175                 $textheight->setDecimals(0);
 
  176                 $textheight->setMinValue(1);
 
  177                 $form->addItem($textheight);
 
  182                 $shuffle->setChecked($this->object->getObligatory());
 
  183                 $shuffle->setRequired(FALSE);
 
  184                 $form->addItem($shuffle);
 
  186                 $form->addCommandButton(
"save", $this->lng->txt(
"save"));
 
  192                         $form->setValuesByPost();
 
  193                         $errors = !$form->checkInput();
 
  194                         $form->setValuesByPost(); 
 
  195                         if (
$errors) $checkonly = 
false;
 
  198                 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
 
  205         public function getWorkingForm($working_data = 
"", $question_title = 1, $show_questiontext = 1, $error_message = 
"", $survey_id = null)
 
  207                 $template = 
new ilTemplate(
"tpl.il_svy_out_text.html", TRUE, TRUE, 
"Modules/SurveyQuestionPool");
 
  208                 $template->setCurrentBlock(
"material_text");
 
  210                 $template->parseCurrentBlock();
 
  212                 if ($this->object->getTextHeight() == 1)
 
  214                         $template->setCurrentBlock(
"textinput");
 
  215                         if (is_array($working_data))
 
  217                                 if (strlen($working_data[0][
"textanswer"]))
 
  222                         $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  223                         $template->setVariable(
"WIDTH", $this->object->getTextWidth());
 
  224                         if ($this->object->getMaxChars())
 
  226                                 $template->setVariable(
"MAXLENGTH", 
" maxlength=\"" . $this->object->getMaxChars() . 
"\"");
 
  228                         $template->parseCurrentBlock();
 
  232                         $template->setCurrentBlock(
"textarea");
 
  233                         if (is_array($working_data))
 
  237                         $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  238                         $template->setVariable(
"WIDTH", $this->object->getTextWidth());
 
  239                         $template->setVariable(
"HEIGHT", $this->object->getTextHeight());
 
  240                         $template->parseCurrentBlock();
 
  242                 $template->setCurrentBlock(
"question_data_text");
 
  243                 if ($show_questiontext)
 
  249                         $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
 
  251                 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
 
  252                 $template->setVariable(
"LABEL_QUESTION_ID", $this->object->getId());
 
  253                 if (strcmp($error_message, 
"") != 0)
 
  255                         $template->setVariable(
"ERROR_MESSAGE", 
"<p class=\"warning\">$error_message</p>");
 
  257                 if ($this->object->getMaxChars())
 
  259                         $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
 
  261                 $template->parseCurrentBlock();
 
  262                 return $template->get();
 
  268         public function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
 
  270                 $template = 
new ilTemplate(
"tpl.il_svy_qpl_text_printview.html", TRUE, TRUE, 
"Modules/SurveyQuestionPool");
 
  271                 if ($show_questiontext)
 
  277                         $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
 
  279                 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
 
  281                 $template->setVariable(
"TEXTBOX", $this->lng->txt(
"textbox"));
 
  282                 $template->setVariable(
"TEXTBOX_WIDTH", $this->object->getTextWidth()*16);
 
  283                 $template->setVariable(
"TEXTBOX_HEIGHT", $this->object->getTextHeight()*16);
 
  284                 $template->setVariable(
"QUESTION_ID", $this->object->getId());
 
  285                 if ($this->object->getMaxChars())
 
  287                         $template->setVariable(
"TEXT_MAXCHARS", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxChars()));
 
  289                 return $template->get();
 
  301                 $this->tpl->addBlockFile(
"ADM_CONTENT", 
"adm_content", 
"tpl.il_svy_qpl_preview.html", 
"Modules/SurveyQuestionPool");
 
  303                 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
 
  321                 if (count($this->cumulated) == 0)
 
  323                         include_once 
"./Modules/Survey/classes/class.ilObjSurvey.php";
 
  325                         $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
 
  329                 include_once 
"./classes/class.ilTemplate.php";
 
  330                 $template = 
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE, 
"Modules/Survey");
 
  332                 $template->setCurrentBlock(
"detail_row");
 
  333                 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
 
  334                 $questiontext = $this->
object->getQuestiontext();
 
  335                 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  336                 $template->parseCurrentBlock();
 
  337                 $template->setCurrentBlock(
"detail_row");
 
  338                 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
 
  339                 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
 
  340                 $template->parseCurrentBlock();
 
  341                 $template->setCurrentBlock(
"detail_row");
 
  342                 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
 
  343                 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
 
  344                 $template->parseCurrentBlock();
 
  345                 $template->setCurrentBlock(
"detail_row");
 
  346                 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
 
  347                 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
 
  348                 $template->parseCurrentBlock();
 
  350                 $template->setCurrentBlock(
"detail_row");
 
  351                 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"given_answers"));
 
  353                 if (is_array($this->cumulated[
"textvalues"]))
 
  355                         foreach ($this->cumulated[
"textvalues"] as $textvalue)
 
  357                                 $textvalues .= 
"<li>" . preg_replace(
"/\n/", 
"<br>", $textvalue) . 
"</li>";
 
  360                 $textvalues = 
"<ul>$textvalues</ul>";
 
  361                 $template->setVariable(
"TEXT_OPTION_VALUE", $textvalues);
 
  362                 $template->parseCurrentBlock();
 
  364                 $template->setVariable(
"QUESTION_TITLE", 
"$counter. ".$this->object->getTitle());
 
  365                 return $template->get();