ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.assTextSubsetGUI.php
Go to the documentation of this file.
1 <?php
2  /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
24 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
26 
38 {
47  function assTextSubsetGUI(
48  $id = -1
49  )
50  {
51  $this->assQuestionGUI();
52  include_once "./Modules/TestQuestionPool/classes/class.assTextSubset.php";
53  $this->object = new assTextSubset();
54  if ($id >= 0)
55  {
56  $this->object->loadFromDb($id);
57  }
58  }
59 
60  function getCommand($cmd)
61  {
62  return $cmd;
63  }
64 
72  function editQuestion()
73  {
74  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
75  $javascript = "<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
76  "function initialSelect() {\n%s\n}</script>";
77  // single response
78  $this->getQuestionTemplate();
79  $this->tpl->addBlockFile("QUESTION_DATA", "question_data", "tpl.il_as_qpl_textsubset.html", "Modules/TestQuestionPool");
80  // output of existing single response answers
81  for ($i = 0; $i < $this->object->getAnswerCount(); $i++)
82  {
83  $this->tpl->setCurrentBlock("answers");
84  $answer = $this->object->getAnswer($i);
85  $this->tpl->setVariable("VALUE_ANSWER_COUNTER", $answer->getOrder() + 1);
86  $this->tpl->setVariable("ANSWER_ORDER", $answer->getOrder());
87  $this->tpl->setVariable("VALUE_ANSWER", ilUtil::prepareFormOutput($answer->getAnswertext()));
88  $this->tpl->setVariable("VALUE_POINTS", ilUtil::prepareFormOutput($answer->getPoints()));
89  $this->tpl->parseCurrentBlock();
90  }
91  if ($this->object->getAnswerCount() > 0)
92  {
93  $this->tpl->setCurrentBlock("answersheading");
94  $this->tpl->setVariable("TEXT_ANSWER_TEXT", $this->lng->txt("answer_text"));
95  $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
96  $this->tpl->parseCurrentBlock();
97  }
98 
99  $internallinks = array(
100  "lm" => $this->lng->txt("obj_lm"),
101  "st" => $this->lng->txt("obj_st"),
102  "pg" => $this->lng->txt("obj_pg"),
103  "glo" => $this->lng->txt("glossary_term")
104  );
105  foreach ($internallinks as $key => $value)
106  {
107  $this->tpl->setCurrentBlock("internallink");
108  $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
109  $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
110  $this->tpl->parseCurrentBlock();
111  }
112 
113  $this->tpl->setCurrentBlock("HeadContent");
114  if ($this->object->getAnswerCount() == 0)
115  {
116  $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_textsubset.title.focus();"));
117  }
118  else
119  {
120  switch ($this->ctrl->getCmd())
121  {
122  case "add":
123  $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_textsubset.answer_".($this->object->getAnswerCount() - $_POST["nrOfAnswers"]).".focus(); document.getElementById('answer_".($this->object->getAnswerCount() - $_POST["nrOfAnswers"])."').scrollIntoView(\"true\");"));
124  break;
125  case "":
126  if ($this->object->getAnswerCount() == 0)
127  {
128  $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_textsubset.title.focus();"));
129  }
130  else
131  {
132  $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_textsubset.answer_".($this->object->getAnswerCount() - 1).".focus(); document.getElementById('answer_".($this->object->getAnswerCount() - 1)."').scrollIntoView(\"true\");"));
133  }
134  break;
135  default:
136  $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_textsubset.title.focus();"));
137  break;
138  }
139  }
140  $this->tpl->parseCurrentBlock();
141 
142  // Add text rating options
143  $text_options = array(
144  array("ci", $this->lng->txt("cloze_textgap_case_insensitive")),
145  array("cs", $this->lng->txt("cloze_textgap_case_sensitive")),
146  array("l1", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1")),
147  array("l2", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2")),
148  array("l3", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3")),
149  array("l4", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4")),
150  array("l5", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5"))
151  );
152  $text_rating = $this->object->getTextRating();
153  foreach ($text_options as $text_option)
154  {
155  $this->tpl->setCurrentBlock("text_rating");
156  $this->tpl->setVariable("RATING_VALUE", $text_option[0]);
157  $this->tpl->setVariable("RATING_TEXT", $text_option[1]);
158  if (strcmp($text_rating, $text_option[0]) == 0)
159  {
160  $this->tpl->setVariable("SELECTED_RATING_VALUE", " selected=\"selected\"");
161  }
162  $this->tpl->parseCurrentBlock();
163  }
164 
165  if ($this->object->getAnswerCount() > 0)
166  {
167  $this->tpl->setCurrentBlock("selectall");
168  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
169  $this->tpl->parseCurrentBlock();
170  $this->tpl->setCurrentBlock("existinganswers");
171  $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
172  $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
173  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
174  $this->tpl->parseCurrentBlock();
175  }
176 
177  for ($i = 1; $i < 10; $i++)
178  {
179  $this->tpl->setCurrentBlock("numbers");
180  $this->tpl->setVariable("VALUE_NUMBER", $i);
181  if ($i == 1)
182  {
183  $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("answer"));
184  }
185  else
186  {
187  $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("answers"));
188  }
189  $this->tpl->parseCurrentBlock();
190  }
191 
192  $this->tpl->setCurrentBlock("question_data");
193  $this->tpl->setVariable("TEXTSUBSET_ID", $this->object->getId());
194  $this->tpl->setVariable("VALUE_TEXTSUBSET_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
195  $this->tpl->setVariable("VALUE_TEXTSUBSET_COMMENT", ilUtil::prepareFormOutput($this->object->getComment()));
196  $this->tpl->setVariable("VALUE_TEXTSUBSET_AUTHOR", ilUtil::prepareFormOutput($this->object->getAuthor()));
197  $this->tpl->setVariable("VALUE_CORRECTANSWERS", $this->object->getCorrectAnswers());
198  $this->tpl->setVariable("VALUE_POINTS", $this->object->getMaximumPoints());
199  $questiontext = $this->object->getQuestion();
200  $this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
201  $this->tpl->setVariable("VALUE_ADD_ANSWER", $this->lng->txt("add"));
202  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
203  $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
204  $this->tpl->setVariable("TEXT_COMMENT", $this->lng->txt("description"));
205  $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
206  $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
207  $this->tpl->setVariable("TEXT_RATING", $this->lng->txt("text_rating"));
208  $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("maximum_points"));
209  $this->tpl->setVariable("TEXT_CORRECTANSWERS", $this->lng->txt("nr_of_correct_answers"));
210 
211  // estimated working time
212  $est_working_time = $this->object->getEstimatedWorkingTime();
213  $this->tpl->setVariable("TEXT_WORKING_TIME", $this->lng->txt("working_time"));
214  $this->tpl->setVariable("TIME_FORMAT", $this->lng->txt("time_format"));
215  $this->tpl->setVariable("VALUE_WORKING_TIME", ilUtil::makeTimeSelect("Estimated", false, $est_working_time[h], $est_working_time[m], $est_working_time[s]));
216 
217  if (count($this->object->suggested_solutions))
218  {
219  $solution_array = $this->object->getSuggestedSolution(0);
220  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
221  $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
222  $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
223  $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
224  $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
225  $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
226  }
227  else
228  {
229  $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
230  }
231  $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
232  $this->tpl->setVariable("SAVE_EDIT", $this->lng->txt("save_edit"));
233  $this->tpl->setVariable("CANCEL",$this->lng->txt("cancel"));
234  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
235  $this->ctrl->setParameter($this, "sel_question_types", "assTextSubset");
236  $this->tpl->setVariable("ACTION_TEXTSUBSET_TEST", $this->ctrl->getFormAction($this));
237  $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->outQuestionType());
238  $this->outOtherQuestionData();
239 
240  $this->tpl->parseCurrentBlock();
241  include_once "./Services/RTE/classes/class.ilRTE.php";
242  $rtestring = ilRTE::_getRTEClassname();
243  include_once "./Services/RTE/classes/class.$rtestring.php";
244  $rte = new $rtestring();
245  $rte->addPlugin("latex");
246  $rte->addButton("latex"); $rte->addButton("pastelatex");
247  include_once "./classes/class.ilObject.php";
248  $obj_id = $_GET["q_id"];
249  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
250  $rte->addRTESupport($obj_id, $obj_type, "assessment");
251 
252  $this->tpl->setCurrentBlock("adm_content");
253  //$this->tpl->setVariable("BODY_ATTRIBUTES", " onload=\"initialSelect();\"");
254  $this->tpl->parseCurrentBlock();
255  }
256 
260  function deleteAnswer()
261  {
262  $this->writePostData();
263  $answers = $_POST["chb_answers"];
264  if (is_array($answers))
265  {
266  arsort($answers);
267  foreach ($answers as $answer)
268  {
269  $this->object->deleteAnswer($answer);
270  }
271  }
272  $this->editQuestion();
273  }
274 
278  function add()
279  {
280  //$this->setObjectData();
281  $this->writePostData();
282 
283  for ($i = 0; $i < $_POST["nrOfAnswers"]; $i++)
284  {
285  $this->object->addAnswer(
286  "",
287  1,
288  count($this->object->answers)
289  );
290  }
291 
292  $this->editQuestion();
293  }
294 
295  function save()
296  {
297  $unfilled_answer = false;
298  foreach ($_POST as $key => $value)
299  {
300  if (preg_match("/answer_(\d+)/", $key, $matches))
301  {
302  if (!$value)
303  {
304  $unfilled_answer = true;
305  }
306  }
307  }
308  if ($unfilled_answer)
309  {
310  ilUtil::sendInfo($this->lng->txt("qpl_answertext_fields_not_filled"));
311  $this->writePostData();
312  $this->editQuestion();
313  }
314  else
315  {
316  parent::save();
317  }
318  }
319 
320  function saveEdit()
321  {
322  $unfilled_answer = false;
323  foreach ($_POST as $key => $value)
324  {
325  if (preg_match("/answer_(\d+)/", $key, $matches))
326  {
327  if (!$value)
328  {
329  $unfilled_answer = true;
330  }
331  }
332  }
333  if ($unfilled_answer)
334  {
335  ilUtil::sendInfo($this->lng->txt("qpl_answertext_fields_not_filled"));
336  $this->writePostData();
337  $this->editQuestion();
338  }
339  else
340  {
342  }
343  }
344 
348  function checkInput()
349  {
350  $cmd = $this->ctrl->getCmd();
351 
352  if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]) or (!$_POST["correctanswers"]))
353  {
354  return false;
355  }
356  return true;
357  }
358 
367  function writePostData()
368  {
369 //echo "here!"; exit;
370 //echo "<br>assTextSubsetGUI->writePostData()";
371  $result = 0;
372  if (!$this->checkInput())
373  {
374  $result = 1;
375  }
376 
377  if (($result) and (strcmp($this->ctrl->getCmd(), "add") == 0))
378  {
379  // You cannot add answers before you enter the required data
380  ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
381  }
382 
383  $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
384  $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
385  $this->object->setComment(ilUtil::stripSlashes($_POST["comment"]));
386  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
387  $questiontext = ilUtil::stripSlashes($_POST["question"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
388  $this->object->setQuestion($questiontext);
389  $this->object->setSuggestedSolution($_POST["solution_hint"], 0);
390  $this->object->setCorrectAnswers($_POST["correctanswers"]);
391  $this->object->setTextRating($_POST["text_rating"]);
392 
393  $saved = $this->writeOtherPostData($result);
394 
395  // Delete all existing answers and create new answers from the form data
396  $this->object->flushAnswers();
397 
398  // Add all answers from the form into the object
399  foreach ($_POST as $key => $value)
400  {
401  if (preg_match("/answer_(\d+)/", $key, $matches))
402  {
403  $this->object->addAnswer(
404  ilUtil::stripSlashes($_POST["$key"]),
405  ilUtil::stripSlashes($_POST["points_".$matches[1]]),
406  ilUtil::stripSlashes($matches[1])
407  );
408  }
409  }
410 
411  // Set the question id from a hidden form parameter
412  if ($_POST["textsubset_id"] > 0)
413  {
414  $this->object->setId($_POST["textsubset_id"]);
415  }
416 
417  $maximum_points = $this->object->getMaximumPoints();
418  if (($maximum_points <= 0) && (count($this->object->answers) > 0))
419  {
420  $result = 1;
421  $this->setErrorMessage($this->lng->txt("enter_enough_positive_points"));
422  }
423  $this->object->setPoints($maximum_points);
424 
425  if ($saved)
426  {
427  // If the question was saved automatically before an upload, we have to make
428  // sure, that the state after the upload is saved. Otherwise the user could be
429  // irritated, if he presses cancel, because he only has the question state before
430  // the upload process.
431  $this->object->saveToDb();
432  $this->ctrl->setParameter($this, "q_id", $this->object->getId());
433  }
434 
435  return $result;
436  }
437 
438  function outQuestionForTest($formaction, $active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
439  {
440  $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions);
441  $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
442  $this->tpl->setVariable("FORMACTION", $formaction);
443  }
444 
445  function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE)
446  {
447  // get the solution of the user for the active pass or from the last pass if allowed
448  $solutions = array();
449  if (($active_id > 0) && (!$show_correct_solution))
450  {
451  $solutions =& $this->object->getSolutionValues($active_id, $pass);
452  }
453  else
454  {
455  $rank = array();
456  foreach ($this->object->answers as $answer)
457  {
458  if ($answer->getPoints() > 0)
459  {
460  if (!is_array($rank[$answer->getPoints()]))
461  {
462  $rank[$answer->getPoints()] = array();
463  }
464  array_push($rank[$answer->getPoints()], $answer->getAnswertext());
465  }
466  }
467  krsort($rank, SORT_NUMERIC);
468  foreach ($rank as $index => $bestsolutions)
469  {
470  array_push($solutions, array("value1" => join(",", $bestsolutions), "points" => $index));
471  }
472  }
473 
474  // generate the question output
475  include_once "./classes/class.ilTemplate.php";
476  $template = new ilTemplate("tpl.il_as_qpl_textsubset_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
477  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
478  $available_answers =& $this->object->getAvailableAnswers();
479  for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++)
480  {
481  if ((!$test_id) && (strcmp($solutions[$i]["value1"], "") == 0))
482  {
483  }
484  else
485  {
486  if (($active_id > 0) && (!$show_correct_solution))
487  {
488  if ($graphicalOutput)
489  {
490  // output of ok/not ok icons for user entered solutions
491  $index = $this->object->isAnswerCorrect($available_answers, $solutions[$i]["value1"]);
492  $correct = FALSE;
493  if ($index !== FALSE)
494  {
495  unset($available_answers[$index]);
496  $correct = TRUE;
497  }
498  if ($correct)
499  {
500  $template->setCurrentBlock("icon_ok");
501  $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.gif"));
502  $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
503  $template->parseCurrentBlock();
504  }
505  else
506  {
507  $template->setCurrentBlock("icon_ok");
508  $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.gif"));
509  $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
510  $template->parseCurrentBlock();
511  }
512  }
513  }
514  $template->setCurrentBlock("textsubset_row");
515  $template->setVariable("SOLUTION", $solutions[$i]["value1"]);
516  $template->setVariable("COUNTER", $i+1);
517  if ($result_output)
518  {
519  $points = $solutions[$i]["points"];
520  $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
521  $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
522  }
523  $template->parseCurrentBlock();
524  }
525  }
526  $questiontext = $this->object->getQuestion();
527  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
528  $questionoutput = $template->get();
529  $feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
530  if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $feedback);
531  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
532 
533  $solutionoutput = $solutiontemplate->get();
534  if (!$show_question_only)
535  {
536  // get page object output
537  $solutionoutput = $this->getILIASPage($solutionoutput);
538  }
539  return $solutionoutput;
540  }
541 
542  function getPreview($show_question_only = FALSE)
543  {
544  // generate the question output
545  include_once "./classes/class.ilTemplate.php";
546  $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
547  $width = $this->object->getMaxTextboxWidth();
548  for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++)
549  {
550  $template->setCurrentBlock("textsubset_row");
551  $template->setVariable("COUNTER", $i+1);
552  $template->setVariable("TEXTFIELD_ID", sprintf("%02d", $i+1));
553  $template->setVariable("TEXTFIELD_SIZE", $width);
554  $template->parseCurrentBlock();
555  }
556  $questiontext = $this->object->getQuestion();
557  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
558  $questionoutput = $template->get();
559  if (!$show_question_only)
560  {
561  // get page object output
562  $questionoutput = $this->getILIASPage($questionoutput);
563  }
564  return $questionoutput;
565  }
566 
567  function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
568  {
569  // get the solution of the user for the active pass or from the last pass if allowed
570  $user_solution = "";
571  if ($active_id)
572  {
573  $solutions = NULL;
574  include_once "./Modules/Test/classes/class.ilObjTest.php";
575  if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
576  {
577  if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
578  }
579  $solutions =& $this->object->getSolutionValues($active_id, $pass);
580  }
581 
582  // generate the question output
583  include_once "./classes/class.ilTemplate.php";
584  $template = new ilTemplate("tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
585  $width = $this->object->getMaxTextboxWidth();
586  for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++)
587  {
588  $template->setCurrentBlock("textsubset_row");
589  foreach ($solutions as $idx => $solution_value)
590  {
591  if ($idx == $i)
592  {
593  $template->setVariable("TEXTFIELD_VALUE", " value=\"" . $solution_value["value1"]."\"");
594  }
595  }
596  $template->setVariable("COUNTER", $i+1);
597  $template->setVariable("TEXTFIELD_ID", sprintf("%02d", $i+1));
598  $template->setVariable("TEXTFIELD_SIZE", $width);
599  $template->parseCurrentBlock();
600  }
601  $questiontext = $this->object->getQuestion();
602  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
603  $questionoutput = $template->get();
604  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
605  return $pageoutput;
606  }
607 
609  {
610  $_SESSION["subquestion_index"] = 0;
611  if ($_POST["cmd"]["addSuggestedSolution"])
612  {
613  if ($this->writePostData())
614  {
616  $this->editQuestion();
617  return;
618  }
619  if (!$this->checkInput())
620  {
621  ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
622  $this->editQuestion();
623  return;
624  }
625  }
626  $this->object->saveToDb();
627  $this->ctrl->setParameter($this, "q_id", $this->object->getId());
628  $this->tpl->setVariable("HEADER", $this->object->getTitle());
629  $this->getQuestionTemplate();
631  }
632 
640  function saveFeedback()
641  {
642  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
643  $this->object->saveFeedbackGeneric(0, ilUtil::stripSlashes($_POST["feedback_incomplete"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
644  $this->object->saveFeedbackGeneric(1, ilUtil::stripSlashes($_POST["feedback_complete"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
645  $this->object->cleanupMediaObjectUsage();
647  }
648 
656  function feedback()
657  {
658  $this->tpl->addBlockFile("ADM_CONTENT", "feedback", "tpl.il_as_qpl_textsubset_feedback.html", "Modules/TestQuestionPool");
659  $this->tpl->setVariable("FEEDBACK_TEXT", $this->lng->txt("feedback"));
660  $this->tpl->setVariable("FEEDBACK_COMPLETE", $this->lng->txt("feedback_complete_solution"));
661  $this->tpl->setVariable("VALUE_FEEDBACK_COMPLETE", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
662  $this->tpl->setVariable("FEEDBACK_INCOMPLETE", $this->lng->txt("feedback_incomplete_solution"));
663  $this->tpl->setVariable("VALUE_FEEDBACK_INCOMPLETE", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
664  global $rbacsystem;
665  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
666  {
667  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
668  }
669  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
670 
671  include_once "./Services/RTE/classes/class.ilRTE.php";
672  $rtestring = ilRTE::_getRTEClassname();
673  include_once "./Services/RTE/classes/class.$rtestring.php";
674  $rte = new $rtestring();
675  $rte->addPlugin("latex");
676  $rte->addButton("latex"); $rte->addButton("pastelatex");
677  include_once "./classes/class.ilObject.php";
678  $obj_id = $_GET["q_id"];
679  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
680  $rte->addRTESupport($obj_id, $obj_type, "assessment");
681  }
682 
690  function setQuestionTabs()
691  {
692  global $rbacsystem, $ilTabs;
693 
694  $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
695  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
696  $q_type = $this->object->getQuestionType();
697 
698  if (strlen($q_type))
699  {
700  $classname = $q_type . "GUI";
701  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
702  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
703  }
704 
705  if ($_GET["q_id"])
706  {
707  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
708  {
709  // edit page
710  $ilTabs->addTarget("edit_content",
711  $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "edit"),
712  array("edit", "insert", "exec_pg"),
713  "", "", $force_active);
714  }
715 
716  // edit page
717  $ilTabs->addTarget("preview",
718  $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
719  array("preview"),
720  "ilPageObjectGUI", "", $force_active);
721  }
722 
723  $force_active = false;
724  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
725  {
726  $url = "";
727  if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
728  // edit question properties
729  $ilTabs->addTarget("edit_properties",
730  $url,
731  array("editQuestion", "save", "cancel", "addSuggestedSolution",
732  "cancelExplorer", "linkChilds", "removeSuggestedSolution", "add", "deleteAnswer",
733  "saveEdit"),
734  $classname, "", $force_active);
735  }
736 
737  if ($_GET["q_id"])
738  {
739  $ilTabs->addTarget("feedback",
740  $this->ctrl->getLinkTargetByClass($classname, "feedback"),
741  array("feedback", "saveFeedback"),
742  $classname, "");
743  }
744 
745  // Assessment of questions sub menu entry
746  if ($_GET["q_id"])
747  {
748  $ilTabs->addTarget("statistics",
749  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
750  array("assessment"),
751  $classname, "");
752  }
753 
754  if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
755  {
756  $ref_id = $_GET["calling_test"];
757  if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
758  $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
759  }
760  else
761  {
762  $ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
763  }
764  }
765 }
766 ?>