ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.assClozeTestGUI.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 
37 {
42  var $gapIndex;
43 
49 
58  function assClozeTestGUI(
59  $id = -1
60  )
61  {
62  $this->assQuestionGUI();
63  include_once "./Modules/TestQuestionPool/classes/class.assClozeTest.php";
64  $this->object = new assClozeTest();
65  if ($id >= 0)
66  {
67  $this->object->loadFromDb($id);
68  }
69  }
70 
71  function getCommand($cmd)
72  {
73  if (preg_match("/^(addGapText|addSelectGapText|addSuggestedSolution|removeSuggestedSolution)_(\d+)$/", $cmd, $matches))
74  {
75  $cmd = $matches[1];
76  $this->gapIndex = $matches[2];
77  }
78  else if (preg_match("/^(delete)_(\d+)_(\d+)$/", $cmd, $matches))
79  {
80  $cmd = $matches[1];
81  $this->gapIndex = $matches[2];
82  $this->answerIndex = $matches[3];
83  }
84  return $cmd;
85  }
86 
90  function createGaps()
91  {
92  $this->writePostData();
93  $this->editQuestion();
94  }
95 
99  function changeGapType()
100  {
101  $this->writePostData();
102  $this->editQuestion();
103  }
104 
108  function checkInput()
109  {
110  if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["clozetext"]))
111  {
112  return FALSE;
113  }
114  return TRUE;
115  }
116 
124  function setGapTypes()
125  {
126  foreach ($_POST as $key => $value)
127  {
128  // Set the cloze type of the gap
129  if (preg_match("/clozetype_(\d+)/", $key, $matches))
130  {
131  $this->object->setGapType($matches[1], $value);
132  }
133  }
134  }
135 
143  function setShuffleState()
144  {
145  foreach ($_POST as $key => $value)
146  {
147  // Set select gap shuffle state
148  if (preg_match("/^shuffle_(\d+)$/", $key, $matches))
149  {
150  $this->object->setGapShuffle($matches[1], $value);
151  }
152  }
153  }
154 
162  function setGapAnswers()
163  {
164  $error = FALSE;
165  $this->object->clearGapAnswers();
166  foreach ($_POST as $key => $value)
167  {
168  if (preg_match("/^(textgap|selectgap|numericgap)_(\d+)_(\d+)$/", $key, $matches))
169  {
170  // text gap answer
171  $gap = $matches[2];
172  $order = $matches[3];
173  $this->object->addGapAnswer($gap, $order, ilUtil::stripSlashes($value, FALSE));
174  $gapObj = $this->object->getGap($gap);
175  if (is_object($gapObj))
176  {
177  if ($gapObj->getType() == CLOZE_NUMERIC)
178  {
179  include_once "./Services/Math/classes/class.EvalMath.php";
180  $eval = new EvalMath();
181  $eval->suppress_errors = TRUE;
182  if ($eval->e(str_replace(",", ".", ilUtil::stripSlashes($value, FALSE))) === FALSE)
183  {
184  $error = TRUE;
185  $this->addErrorMessage($this->lng->txt("error_cloze_not_numeric"));
186  }
187  }
188  }
189  }
190  }
191  return $error;
192  }
193 
201  function setGapPoints()
202  {
203  foreach ($_POST as $key => $value)
204  {
205  if (preg_match("/points_(\d+)_(\d+)/", $key, $matches))
206  {
207  $gap = $matches[1];
208  $order = $matches[2];
209  $this->object->setGapAnswerPoints($gap, $order, ilUtil::stripSlashes($value));
210  }
211  }
212  }
213 
221  function setGapBounds()
222  {
223  $error = FALSE;
224  foreach ($_POST as $key => $value)
225  {
226  if (preg_match("/numericgap_(\d+)_(\d+)_lower/", $key, $matches))
227  {
228  $gap = $matches[1];
229  $order = $matches[2];
230  $gapObj = $this->object->getGap($gap);
231  if (is_object($gapObj))
232  {
233  if ($gapObj->getType() == CLOZE_NUMERIC)
234  {
235  include_once "./Services/Math/classes/class.EvalMath.php";
236  $eval = new EvalMath();
237  $eval->suppress_errors = TRUE;
238  if ($eval->e(str_replace(",", ".", ilUtil::stripSlashes($value, FALSE))) === FALSE)
239  {
240  if (is_object($gapObj->getItem($order)))
241  {
242  if ($eval->e($gapObj->getItem($order)->getAnswertext()) !== FALSE)
243  {
244  $value = $gapObj->getItem($order)->getAnswertext();
245  }
246  else
247  {
248  $error = TRUE;
249  }
250  }
251  else
252  {
253  $error = TRUE;
254  }
255  if ($error) $this->addErrorMessage($this->lng->txt("error_no_lower_limit"));
256  }
257  }
258  }
259  $this->object->setGapAnswerLowerBound($gap, $order, $value);
260  }
261  if (preg_match("/numericgap_(\d+)_(\d+)_upper/", $key, $matches))
262  {
263  $gap = $matches[1];
264  $order = $matches[2];
265  $gapObj = $this->object->getGap($gap);
266  if (is_object($gapObj))
267  {
268  if ($gapObj->getType() == CLOZE_NUMERIC)
269  {
270  include_once "./Services/Math/classes/class.EvalMath.php";
271  $eval = new EvalMath();
272  $eval->suppress_errors = TRUE;
273  if ($eval->e(str_replace(",", ".", ilUtil::stripSlashes($value, FALSE))) === FALSE)
274  {
275  if (is_object($gapObj->getItem($order)))
276  {
277  if ($eval->e($gapObj->getItem($order)->getAnswertext()) !== FALSE)
278  {
279  $value = $gapObj->getItem($order)->getAnswertext();
280  }
281  else
282  {
283  $error = TRUE;
284  }
285  }
286  else
287  {
288  $error = TRUE;
289  }
290  if ($error) $this->addErrorMessage($this->lng->txt("error_no_upper_limit"));
291  }
292  }
293  }
294  $this->object->setGapAnswerUpperBound($gap, $order, $value);
295  }
296  }
297  return $error;
298  }
299 
307  function addGapText()
308  {
309  $this->writePostData();
310  $this->object->addGapText($this->gapIndex);
311  $this->editQuestion();
312  }
313 
321  function addSelectGapText()
322  {
323  $this->writePostData();
324  $this->object->addGapText($this->gapIndex);
325  $this->editQuestion();
326  }
327 
335  function delete()
336  {
337  $this->writePostData();
338  $this->object->deleteAnswerText($this->gapIndex, $this->answerIndex);
339  $this->editQuestion();
340  }
341 
350  function writePostData()
351  {
352  $result = 0;
353  $saved = false;
354  // Delete all existing gaps and create new gaps from the form data
355  $this->object->flushGaps();
356  $this->setErrorMessage("");
357 
358  if (!$this->checkInput())
359  {
360  $this->setErrorMessage($this->lng->txt("fill_out_all_required_fields"));
361  $result = 1;
362  }
363 
364 /* if (($result) and ($_POST["cmd"]["add"]))
365  {
366  // You cannot create gaps before you enter the required data
367  ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_create_gaps"));
368  $_POST["cmd"]["add"] = "";
369  }
370 */
371  $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
372  $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
373  $this->object->setComment(ilUtil::stripSlashes($_POST["comment"]));
374  $this->object->setTextgapRating($_POST["textgap_rating"]);
375  $this->object->setIdenticalScoring($_POST["identical_scoring"]);
376  $this->object->setFixedTextLength($_POST["fixedTextLength"]);
377  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
378  $cloze_text = ilUtil::stripSlashes($_POST["clozetext"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
379  $this->object->setClozeText($cloze_text);
380  // adding estimated working time
381  $saved = $saved | $this->writeOtherPostData($result);
382  $this->object->suggested_solutions = array();
383  foreach ($_POST as $key => $value)
384  {
385  if (preg_match("/^solution_hint_(\d+)/", $key, $matches))
386  {
387  if ($value)
388  {
389  $this->object->setSuggestedSolution($value, $matches[1]);
390  }
391  }
392  }
393 
394  if (strcmp($this->ctrl->getCmd(), "createGaps") == 0)
395  {
396  // on createGaps the gaps are created from the entered cloze text
397  // but synchronized with existing gap form values if an answer
398  // already exists for a gap
399  $this->setGapTypes();
400  $this->setShuffleState();
401  $this->setGapPoints();
402  $this->setGapBounds();
403  }
404  else
405  {
406  $this->setGapTypes();
407  $this->setShuffleState();
408  $error = $this->setGapAnswers();
409  if ($error) $result = 1;
410  $this->setGapPoints();
411  $error = $this->setGapBounds();
412  if ($error) $result = 1;
413  $this->object->updateClozeTextFromGaps();
414  }
415  if ($saved)
416  {
417  // If the question was saved automatically before an upload, we have to make
418  // sure, that the state after the upload is saved. Otherwise the user could be
419  // irritated, if he presses cancel, because he only has the question state before
420  // the upload process.
421  $this->object->saveToDb();
422  $this->ctrl->setParameter($this, "q_id", $this->object->getId());
423  }
424  return $result;
425  }
426 
434  function editQuestion()
435  {
436  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
437  $internallinks = array(
438  "lm" => $this->lng->txt("obj_lm"),
439  "st" => $this->lng->txt("obj_st"),
440  "pg" => $this->lng->txt("obj_pg"),
441  "glo" => $this->lng->txt("glossary_term")
442  );
443  //$this->tpl->setVariable("HEADER", $this->object->getTitle());
444  $this->getQuestionTemplate();
445  $this->tpl->addBlockFile("QUESTION_DATA", "question_data", "tpl.il_as_qpl_cloze_question.html", "Modules/TestQuestionPool");
446  for ($i = 0; $i < $this->object->getGapCount(); $i++)
447  {
448  $gap = $this->object->getGap($i);
449  if ($gap->getType() == CLOZE_TEXT)
450  {
451  $this->tpl->setCurrentBlock("textgap_value");
452  foreach ($gap->getItemsRaw() as $item)
453  {
454  $this->tpl->setVariable("TEXT_VALUE", $this->lng->txt("value"));
455  $this->tpl->setVariable("VALUE_TEXT_GAP", $item->getAnswertext());
456  $this->tpl->setVariable("VALUE_GAP_COUNTER", "$i" . "_" . $item->getOrder());
457  $this->tpl->setVariable("VALUE_GAP", $i);
458  $this->tpl->setVariable("VALUE_INDEX", $item->getOrder());
459  $this->tpl->setVariable("VALUE_STATUS_COUNTER", $item->getOrder());
460  $this->tpl->setVariable("VALUE_GAP", $i);
461  $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
462  $this->tpl->setVariable("VALUE_TEXT_GAP_POINTS", $item->getPoints());
463  $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
464  $this->tpl->parseCurrentBlock();
465  }
466 
467  foreach ($internallinks as $key => $value)
468  {
469  $this->tpl->setCurrentBlock("textgap_internallink");
470  $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
471  $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
472  $this->tpl->parseCurrentBlock();
473  }
474 
475  $this->tpl->setCurrentBlock("textgap_suggested_solution");
476  $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
477  if (array_key_exists($i, $this->object->suggested_solutions))
478  {
479  $solution_array = $this->object->getSuggestedSolution($i);
480  $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
481  $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
482  $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
483  $this->tpl->setVariable("VALUE_GAP_COUNTER_REMOVE", $i);
484  $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
485  $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
486  }
487  else
488  {
489  $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
490  }
491  $this->tpl->setVariable("VALUE_GAP_COUNTER", $i);
492  $this->tpl->parseCurrentBlock();
493  $this->tpl->setCurrentBlock("textgap");
494  $this->tpl->setVariable("ADD_TEXT_GAP", $this->lng->txt("add_gap"));
495  $this->tpl->setVariable("VALUE_GAP_COUNTER", "$i");
496  $this->tpl->parseCurrentBlock();
497  }
498 
499  else if ($gap->getType() == CLOZE_NUMERIC)
500  {
501  $this->tpl->setCurrentBlock("numericgap_value");
502  foreach ($gap->getItemsRaw() as $item)
503  {
504  $this->tpl->setVariable("TEXT_VALUE", $this->lng->txt("value"));
505  $this->tpl->setVariable("TEXT_LOWER_LIMIT", $this->lng->txt("range_lower_limit"));
506  $this->tpl->setVariable("TEXT_UPPER_LIMIT", $this->lng->txt("range_upper_limit"));
507  $this->tpl->setVariable("VALUE_NUMERIC_GAP", $item->getAnswertext());
508  $this->tpl->setVariable("VALUE_GAP_COUNTER", "$i" . "_" . $item->getOrder());
509  $this->tpl->setVariable("VALUE_GAP", $i);
510  $this->tpl->setVariable("VALUE_INDEX", $item->getOrder());
511  $this->tpl->setVariable("VALUE_STATUS_COUNTER", $item->getOrder());
512  $this->tpl->setVariable("VALUE_GAP", $i);
513  $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
514  $this->tpl->setVariable("VALUE_NUMERIC_GAP_POINTS", $item->getPoints());
515  $this->tpl->setVariable("VALUE_LOWER_LIMIT", $item->getLowerBound());
516  $this->tpl->setVariable("VALUE_UPPER_LIMIT", $item->getUpperBound());
517  $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
518  $this->tpl->parseCurrentBlock();
519  }
520 
521  foreach ($internallinks as $key => $value)
522  {
523  $this->tpl->setCurrentBlock("numericgap_internallink");
524  $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
525  $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
526  $this->tpl->parseCurrentBlock();
527  }
528 
529  $this->tpl->setCurrentBlock("numericgap_suggested_solution");
530  $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
531  if (array_key_exists($i, $this->object->suggested_solutions))
532  {
533  $solution_array = $this->object->getSuggestedSolution($i);
534  $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
535  $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
536  $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
537  $this->tpl->setVariable("VALUE_GAP_COUNTER_REMOVE", $i);
538  $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
539  $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
540  }
541  else
542  {
543  $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
544  }
545  $this->tpl->setVariable("VALUE_GAP_COUNTER", $i);
546  $this->tpl->parseCurrentBlock();
547  $this->tpl->setCurrentBlock("numericgap");
548  $this->tpl->parseCurrentBlock();
549  }
550 
551  else if ($gap->getType() == CLOZE_SELECT)
552  {
553  $this->tpl->setCurrentBlock("selectgap_value");
554  foreach ($gap->getItemsRaw() as $item)
555  {
556  $this->tpl->setVariable("TEXT_VALUE", $this->lng->txt("value"));
557  $this->tpl->setVariable("VALUE_SELECT_GAP", $item->getAnswertext());
558  $this->tpl->setVariable("VALUE_GAP_COUNTER", "$i" . "_" . $item->getOrder());
559  $this->tpl->setVariable("VALUE_GAP", $i);
560  $this->tpl->setVariable("VALUE_INDEX", $item->getOrder());
561  $this->tpl->setVariable("VALUE_STATUS_COUNTER", $item->getOrder());
562  $this->tpl->setVariable("VALUE_GAP", $i);
563  $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
564  $this->tpl->setVariable("VALUE_SELECT_GAP_POINTS", $item->getPoints());
565  $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
566  $this->tpl->parseCurrentBlock();
567  }
568 
569  foreach ($internallinks as $key => $value)
570  {
571  $this->tpl->setCurrentBlock("selectgap_internallink");
572  $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
573  $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
574  $this->tpl->parseCurrentBlock();
575  }
576 
577  $this->tpl->setCurrentBlock("selectgap_suggested_solution");
578  $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
579  if (array_key_exists($i, $this->object->suggested_solutions))
580  {
581  $solution_array = $this->object->getSuggestedSolution($i);
582  $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
583  $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
584  $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
585  $this->tpl->setVariable("VALUE_GAP_COUNTER_REMOVE", $i);
586  $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
587  $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
588  }
589  else
590  {
591  $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
592  }
593  $this->tpl->setVariable("VALUE_GAP_COUNTER", $i);
594  $this->tpl->parseCurrentBlock();
595  $this->tpl->setCurrentBlock("selectgap");
596  $this->tpl->setVariable("ADD_SELECT_GAP", $this->lng->txt("add_gap"));
597  $this->tpl->setVariable("TEXT_SHUFFLE_ANSWERS", $this->lng->txt("shuffle_answers"));
598  $this->tpl->setVariable("VALUE_GAP_COUNTER", "$i");
599  if ($gap->getShuffle())
600  {
601  $this->tpl->setVariable("SELECTED_YES", " selected=\"selected\"");
602  }
603  else
604  {
605  $this->tpl->setVariable("SELECTED_NO", " selected=\"selected\"");
606  }
607  $this->tpl->setVariable("TXT_YES", $this->lng->txt("yes"));
608  $this->tpl->setVariable("TXT_NO", $this->lng->txt("no"));
609  $this->tpl->parseCurrentBlock();
610  }
611 
612  $this->tpl->setCurrentBlock("answer_row");
613  $name = $this->lng->txt("gap") . " " . ($i+1);
614  $this->tpl->setVariable("TEXT_GAP_NAME", $name);
615  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("type"));
616  $this->tpl->setVariable("TEXT_CHANGE", $this->lng->txt("change"));
617  switch ($gap->getType())
618  {
619  case CLOZE_TEXT:
620  $this->tpl->setVariable("SELECTED_TEXT_GAP", " selected=\"selected\"");
621  break;
622  case CLOZE_SELECT:
623  $this->tpl->setVariable("SELECTED_SELECT_GAP", " selected=\"selected\"");
624  break;
625  case CLOZE_NUMERIC:
626  $this->tpl->setVariable("SELECTED_NUMERIC_GAP", " selected=\"selected\"");
627  break;
628  }
629  $this->tpl->setVariable("TEXT_TEXT_GAP", $this->lng->txt("text_gap"));
630  $this->tpl->setVariable("TEXT_SELECT_GAP", $this->lng->txt("select_gap"));
631  $this->tpl->setVariable("TEXT_NUMERIC_GAP", $this->lng->txt("numeric_gap"));
632  $this->tpl->setVariable("VALUE_GAP_COUNTER", $i);
633  $this->tpl->parseCurrentBlock();
634  }
635 
636  // call to other question data i.e. estimated working time block
637  $this->outOtherQuestionData();
638 
639  // out automatical selection of the best text input field (javascript)
640  $this->tpl->setCurrentBlock("HeadContent");
641  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
642  $javascript = "<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
643  "function initialSelect() {\n%s\n}</script>";
644  if (preg_match("/addGapText_(\d+)/", $this->ctrl->getCmd(), $matches))
645  {
646  $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_cloze_test.textgap_" . $matches[1] . "_" .(is_object($this->object->getGap($matches[1])) ? $this->object->getGap($matches[1])->getItemCount() - 1 : 0) .".focus(); document.frm_cloze_test.textgap_" . $matches[1] . "_" . (is_object($this->object->getGap($matches[1])) ? $this->object->getGap($matches[1])->getItemCount() - 1 : 0) .".scrollIntoView(\"true\");"));
647  }
648  else if (preg_match("/addSelectGapText_(\d+)/", $this->ctrl->getCmd(), $matches))
649  {
650  $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_cloze_test.selectgap_" . $matches[1] . "_" .(is_object($this->object->getGap($matches[1])) ? $this->object->getGap($matches[1])->getItemCount() - 1 : 0) .".focus(); document.frm_cloze_test.selectgap_" . $matches[1] . "_" . (is_object($this->object->getGap($matches[1])) ? $this->object->getGap($matches[1])->getItemCount() - 1 : 0) .".scrollIntoView(\"true\");"));
651  }
652  else
653  {
654  $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_cloze_test.title.focus();"));
655  }
656  $this->tpl->parseCurrentBlock();
657 
658  // Add textgap rating options
659  $textgap_options = array(
660  array("ci", $this->lng->txt("cloze_textgap_case_insensitive")),
661  array("cs", $this->lng->txt("cloze_textgap_case_sensitive")),
662  array("l1", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1")),
663  array("l2", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2")),
664  array("l3", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3")),
665  array("l4", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4")),
666  array("l5", sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5"))
667  );
668  $textgap_rating = $this->object->getTextgapRating();
669  foreach ($textgap_options as $textgap_option)
670  {
671  $this->tpl->setCurrentBlock("textgap_rating");
672  $this->tpl->setVariable("TEXTGAP_VALUE", $textgap_option[0]);
673  $this->tpl->setVariable("TEXTGAP_TEXT", $textgap_option[1]);
674  if (strcmp($textgap_rating, $textgap_option[0]) == 0)
675  {
676  $this->tpl->setVariable("SELECTED_TEXTGAP_VALUE", " selected=\"selected\"");
677  }
678  $this->tpl->parseCurrentBlock();
679  }
680 
681  $this->tpl->setCurrentBlock("question_data");
682  $this->tpl->setVariable("FIXED_TEXTLENGTH", $this->lng->txt("cloze_fixed_textlength"));
683  $this->tpl->setVariable("FIXED_TEXTLENGTH_DESCRIPTION", $this->lng->txt("cloze_fixed_textlength_description"));
684  if ($this->object->getFixedTextLength())
685  {
686  $this->tpl->setVariable("VALUE_FIXED_TEXTLENGTH", " value=\"" . ilUtil::prepareFormOutput($this->object->getFixedTextLength()) . "\"");
687  }
688  $this->tpl->setVariable("VALUE_CLOZE_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
689  $this->tpl->setVariable("VALUE_CLOZE_COMMENT", ilUtil::prepareFormOutput($this->object->getComment()));
690  $this->tpl->setVariable("VALUE_CLOZE_AUTHOR", ilUtil::prepareFormOutput($this->object->getAuthor()));
691  $cloze_text = $this->object->getClozeText();
692  $this->tpl->setVariable("VALUE_CLOZE_TEXT", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($cloze_text)));
693  $this->tpl->setVariable("TEXT_CREATE_GAPS", $this->lng->txt("create_gaps"));
694  $identical_scoring = $this->object->getIdenticalScoring();
695  if ($identical_scoring) $this->tpl->setVariable("CHECKED_IDENTICAL_SCORING", " checked=\"checked\"");
696  $this->tpl->setVariable("TEXT_IDENTICAL_SCORING", $this->lng->txt("identical_scoring"));
697  $this->tpl->setVariable("TEXT_IDENTICAL_SCORING_DESCRIPTION", $this->lng->txt("identical_scoring_desc"));
698  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
699  $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
700  $this->tpl->setVariable("TEXT_COMMENT", $this->lng->txt("description"));
701  $this->tpl->setVariable("TEXT_CLOZE_TEXT", $this->lng->txt("cloze_text"));
702  $this->tpl->setVariable("TEXT_CLOSE_HINT", ilUtil::prepareFormOutput($this->lng->txt("close_text_hint")));
703  $this->tpl->setVariable("TEXTGAP_RATING", $this->lng->txt("cloze_textgap_rating"));
704  $this->tpl->setVariable("TEXT_GAP_DEFINITION", $this->lng->txt("gap_definition"));
705  $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
706  $this->tpl->setVariable("SAVE_EDIT", $this->lng->txt("save_edit"));
707  $this->tpl->setVariable("CANCEL",$this->lng->txt("cancel"));
708  $this->ctrl->setParameter($this, "sel_question_types", $this->object->getQuestionType());
709  $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->outQuestionType());
710  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
711  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
712  $this->tpl->parseCurrentBlock();
713 
714  include_once "./Services/RTE/classes/class.ilRTE.php";
715  $rtestring = ilRTE::_getRTEClassname();
716  include_once "./Services/RTE/classes/class.$rtestring.php";
717  $rte = new $rtestring();
718  $rte->addPlugin("latex");
719  $rte->addButton("latex"); $rte->addButton("pastelatex");
720  include_once "./classes/class.ilObject.php";
721  $obj_id = $_GET["q_id"];
722  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
723  $rte->addRTESupport($obj_id, $obj_type, "assessment");
724 
725  $this->tpl->setCurrentBlock("adm_content");
726  //$this->tpl->setVariable("BODY_ATTRIBUTES", " onload=\"initialSelect();\"");
727  $this->tpl->parseCurrentBlock();
728  }
729 
742  function outQuestionForTest($formaction, $active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
743  {
744  $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions);
745  $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
746  $this->tpl->setVariable("FORMACTION", $formaction);
747  }
748 
757  function getPreview($show_question_only = FALSE)
758  {
759  // generate the question output
760  include_once "./classes/class.ilTemplate.php";
761  $template = new ilTemplate("tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
762  $output = $this->object->getClozeText();
763  foreach ($this->object->getGaps() as $gap_index => $gap)
764  {
765  switch ($gap->getType())
766  {
767  case CLOZE_TEXT:
768  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE, "Modules/TestQuestionPool");
769  $gaptemplate->setVariable("TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->object->getFixedTextLength() : $gap->getMaxWidth());
770  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
771  $output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
772  break;
773  case CLOZE_SELECT:
774  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE, "Modules/TestQuestionPool");
775  foreach ($gap->getItems() as $item)
776  {
777  $gaptemplate->setCurrentBlock("select_gap_option");
778  $gaptemplate->setVariable("SELECT_GAP_VALUE", $item->getOrder());
779  $gaptemplate->setVariable("SELECT_GAP_TEXT", ilUtil::prepareFormOutput($item->getAnswerText()));
780  $gaptemplate->parseCurrentBlock();
781  }
782  $gaptemplate->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
783  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
784  $output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
785  break;
786  case CLOZE_NUMERIC:
787  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE, "Modules/TestQuestionPool");
788  $gaptemplate->setVariable("TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->object->getFixedTextLength() : $gap->getMaxWidth());
789  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
790  $output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
791  break;
792  }
793  }
794  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
795  $questionoutput = $template->get();
796  if (!$show_question_only)
797  {
798  // get page object output
799  $questionoutput = $this->getILIASPage($questionoutput);
800  }
801  return $questionoutput;
802  }
803 
816  function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE)
817  {
818  // get the solution of the user for the active pass or from the last pass if allowed
819  $user_solution = array();
820  if ($active_id)
821  {
822  // get the solutions of a user
823  $user_solution =& $this->object->getSolutionValues($active_id, $pass);
824  if (!is_array($user_solution))
825  {
826  $user_solution = array();
827  }
828  }
829 
830  include_once "./classes/class.ilTemplate.php";
831  $template = new ilTemplate("tpl.il_as_qpl_cloze_question_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
832  $output = $this->object->getClozeText();
833  $ssc = $this->object->_getSuggestedSolutionCount($this->object->getId());
834  foreach ($this->object->getGaps() as $gap_index => $gap)
835  {
836  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_output_solution_gap.html", TRUE, TRUE, "Modules/TestQuestionPool");
837  $found = array();
838  foreach ($user_solution as $solutionarray)
839  {
840  if ($solutionarray["value1"] == $gap_index) $found = $solutionarray;
841  }
842 
843  if ($active_id)
844  {
845  if ($graphicalOutput)
846  {
847  // output of ok/not ok icons for user entered solutions
848  $details = $this->object->calculateReachedPoints($active_id, $pass, TRUE);
849  $check = $details[$gap_index];
850  if ($check["best"])
851  {
852  $gaptemplate->setCurrentBlock("icon_ok");
853  $gaptemplate->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.gif"));
854  $gaptemplate->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
855  $gaptemplate->parseCurrentBlock();
856  }
857  else
858  {
859  $gaptemplate->setCurrentBlock("icon_not_ok");
860  if ($check["positive"])
861  {
862  $gaptemplate->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.gif"));
863  $gaptemplate->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
864  }
865  else
866  {
867  $gaptemplate->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.gif"));
868  $gaptemplate->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
869  }
870  $gaptemplate->parseCurrentBlock();
871  }
872  }
873  if ($ssc > 0)
874  {
875  $ss = $this->object->_getSuggestedSolution($this->object->getId(), $gap_index);
876  if (count($ss))
877  {
878  $gaptemplate->setCurrentBlock("solution_hint");
879  $gaptemplate->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
880  $gaptemplate->setVariable("URL_SOLUTION_HINT", $this->object->_getInternalLinkHref($ss["internal_link"]));
881  $gaptemplate->parseCurrentBlock();
882  }
883  }
884  }
885  if ($result_output)
886  {
887  $points = $this->object->getMaximumGapPoints($gap_index);
888  $resulttext = ($points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
889  $gaptemplate->setCurrentBlock("result_output");
890  $gaptemplate->setVariable("RESULT_OUTPUT", sprintf($resulttext, $points));
891  $gaptemplate->parseCurrentBlock();
892  }
893  switch ($gap->getType())
894  {
895  case CLOZE_TEXT:
896  $solutiontext = "";
897  if (($active_id > 0) && (!$show_correct_solution))
898  {
899  if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0))
900  {
901  for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
902  {
903  $solutiontext .= "&nbsp;";
904  }
905  }
906  else
907  {
908  $solutiontext = ilUtil::prepareFormOutput($found["value2"]);
909  }
910  }
911  else
912  {
913  $solutiontext = ilUtil::prepareFormOutput($gap->getBestSolutionOutput());
914  }
915  $gaptemplate->setVariable("SOLUTION", $solutiontext);
916  $output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
917  break;
918  case CLOZE_SELECT:
919  $solutiontext = "";
920  if (($active_id > 0) && (!$show_correct_solution))
921  {
922  if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0))
923  {
924  for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
925  {
926  $solutiontext .= "&nbsp;";
927  }
928  }
929  else
930  {
931  $item = $gap->getItem($found["value2"]);
932  if (is_object($item))
933  {
934  $solutiontext = ilUtil::prepareFormOutput($item->getAnswertext());
935  }
936  else
937  {
938  for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
939  {
940  $solutiontext .= "&nbsp;";
941  }
942  }
943  }
944  }
945  else
946  {
947  $solutiontext = ilUtil::prepareFormOutput($gap->getBestSolutionOutput());
948  }
949  $gaptemplate->setVariable("SOLUTION", $solutiontext);
950  $output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
951  break;
952  case CLOZE_NUMERIC:
953  $solutiontext = "";
954  if (($active_id > 0) && (!$show_correct_solution))
955  {
956  if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0))
957  {
958  for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
959  {
960  $solutiontext .= "&nbsp;";
961  }
962  }
963  else
964  {
965  $solutiontext = ilUtil::prepareFormOutput($found["value2"]);
966  }
967  }
968  else
969  {
970  $solutiontext = ilUtil::prepareFormOutput($gap->getBestSolutionOutput());
971  }
972  $gaptemplate->setVariable("SOLUTION", $solutiontext);
973  $output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
974  break;
975  }
976  }
977  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
978 
979  // generate the question output
980  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html",TRUE, TRUE, "Modules/TestQuestionPool");
981  $questionoutput = $template->get();
982  $feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : "";
983  if (strlen($feedback)) $solutiontemplate->setVariable("FEEDBACK", $feedback);
984  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
985 
986  $solutionoutput = $solutiontemplate->get();
987  if (!$show_question_only)
988  {
989  // get page object output
990  $solutionoutput = $this->getILIASPage($solutionoutput);
991  }
992  return $solutionoutput;
993  }
994 
995  function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
996  {
997  // get the solution of the user for the active pass or from the last pass if allowed
998  $user_solution = array();
999  if ($active_id)
1000  {
1001  include_once "./Modules/Test/classes/class.ilObjTest.php";
1002  if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
1003  {
1004  if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
1005  }
1006  $user_solution =& $this->object->getSolutionValues($active_id, $pass);
1007  if (!is_array($user_solution))
1008  {
1009  $user_solution = array();
1010  }
1011  }
1012 
1013  // generate the question output
1014  include_once "./classes/class.ilTemplate.php";
1015  $template = new ilTemplate("tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
1016  $output = $this->object->getClozeText();
1017  foreach ($this->object->getGaps() as $gap_index => $gap)
1018  {
1019  switch ($gap->getType())
1020  {
1021  case CLOZE_TEXT:
1022  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE, "Modules/TestQuestionPool");
1023  $gaptemplate->setVariable("TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->object->getFixedTextLength() : $gap->getMaxWidth());
1024  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
1025  foreach ($user_solution as $solution)
1026  {
1027  if (strcmp($solution["value1"], $gap_index) == 0)
1028  {
1029  $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilUtil::prepareFormOutput($solution["value2"]) . "\"");
1030  }
1031  }
1032  $output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1033  break;
1034  case CLOZE_SELECT:
1035  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE, "Modules/TestQuestionPool");
1036  foreach ($gap->getItems() as $item)
1037  {
1038  $gaptemplate->setCurrentBlock("select_gap_option");
1039  $gaptemplate->setVariable("SELECT_GAP_VALUE", $item->getOrder());
1040  $gaptemplate->setVariable("SELECT_GAP_TEXT", ilUtil::prepareFormOutput($item->getAnswerText()));
1041  foreach ($user_solution as $solution)
1042  {
1043  if (strcmp($solution["value1"], $gap_index) == 0)
1044  {
1045  if (strcmp($solution["value2"], $item->getOrder()) == 0)
1046  {
1047  $gaptemplate->setVariable("SELECT_GAP_SELECTED", " selected=\"selected\"");
1048  }
1049  }
1050  }
1051  $gaptemplate->parseCurrentBlock();
1052  }
1053  $gaptemplate->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
1054  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
1055  $output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1056  break;
1057  case CLOZE_NUMERIC:
1058  $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE, "Modules/TestQuestionPool");
1059  $gaptemplate->setVariable("TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->object->getFixedTextLength() : $gap->getMaxWidth());
1060  $gaptemplate->setVariable("GAP_COUNTER", $gap_index);
1061  foreach ($user_solution as $solution)
1062  {
1063  if (strcmp($solution["value1"], $gap_index) == 0)
1064  {
1065  $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilUtil::prepareFormOutput($solution["value2"]) . "\"");
1066  }
1067  }
1068  $output = preg_replace("/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1069  break;
1070  }
1071  }
1072  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
1073  $questionoutput = $template->get();
1074  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
1075  return $pageoutput;
1076  }
1077 
1079  {
1080  $addForGap = -1;
1081  if (array_key_exists("cmd", $_POST))
1082  {
1083  foreach ($_POST["cmd"] as $key => $value)
1084  {
1085  if (preg_match("/addSuggestedSolution_(\d+)/", $key, $matches))
1086  {
1087  $addForGap = $matches[1];
1088  }
1089  }
1090  }
1091  if ($addForGap > -1)
1092  {
1093  if ($this->writePostData())
1094  {
1096  $this->editQuestion();
1097  return;
1098  }
1099  if (!$this->checkInput())
1100  {
1101  ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
1102  $this->editQuestion();
1103  return;
1104  }
1105  $_POST["internalLinkType"] = $_POST["internalLinkType_$addForGap"];
1106  $this->ctrl->setParameter($this, "subquestion_index", $addForGap);
1107 // $_SESSION["subquestion_index"] = $addForGap;
1108  }
1109  $this->object->saveToDb();
1110  $this->ctrl->setParameter($this, "q_id", $this->object->getId());
1111  $this->tpl->setVariable("HEADER", $this->object->getTitle());
1112  $this->getQuestionTemplate();
1114  }
1115 
1117  {
1118  $removeFromGap = -1;
1119  foreach ($_POST["cmd"] as $key => $value)
1120  {
1121  if (preg_match("/removeSuggestedSolution_(\d+)/", $key, $matches))
1122  {
1123  $removeFromGap = $matches[1];
1124  }
1125  }
1126  if ($removeFromGap > -1)
1127  {
1128  unset($this->object->suggested_solutions[$removeFromGap]);
1129  }
1130  $this->object->saveToDb();
1131  $this->editQuestion();
1132  }
1133 
1141  function saveFeedback()
1142  {
1143  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1144  $this->object->saveFeedbackGeneric(0, ilUtil::stripSlashes($_POST["feedback_incomplete"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
1145  $this->object->saveFeedbackGeneric(1, ilUtil::stripSlashes($_POST["feedback_complete"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")));
1146  $this->object->cleanupMediaObjectUsage();
1148  }
1149 
1157  function feedback()
1158  {
1159  $this->tpl->addBlockFile("ADM_CONTENT", "feedback", "tpl.il_as_qpl_cloze_question_feedback.html", "Modules/TestQuestionPool");
1160  $this->tpl->setVariable("FEEDBACK_TEXT", $this->lng->txt("feedback"));
1161  $this->tpl->setVariable("FEEDBACK_COMPLETE", $this->lng->txt("feedback_complete_solution"));
1162  $this->tpl->setVariable("VALUE_FEEDBACK_COMPLETE", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
1163  $this->tpl->setVariable("FEEDBACK_INCOMPLETE", $this->lng->txt("feedback_incomplete_solution"));
1164  $this->tpl->setVariable("VALUE_FEEDBACK_INCOMPLETE", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
1165  global $rbacsystem;
1166  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
1167  {
1168  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
1169  }
1170  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1171 
1172  include_once "./Services/RTE/classes/class.ilRTE.php";
1173  $rtestring = ilRTE::_getRTEClassname();
1174  include_once "./Services/RTE/classes/class.$rtestring.php";
1175  $rte = new $rtestring();
1176  $rte->addPlugin("latex");
1177  $rte->addButton("latex"); $rte->addButton("pastelatex");
1178  include_once "./classes/class.ilObject.php";
1179  $obj_id = $_GET["q_id"];
1180  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
1181  $rte->addRTESupport($obj_id, $obj_type, "assessment");
1182  }
1183 
1191  function setQuestionTabs()
1192  {
1193  global $rbacsystem, $ilTabs;
1194 
1195  $this->ctrl->setParameterByClass("ilpageobjectgui", "q_id", $_GET["q_id"]);
1196  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1197  $q_type = $this->object->getQuestionType();
1198 
1199  if (strlen($q_type))
1200  {
1201  $classname = $q_type . "GUI";
1202  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
1203  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
1204  }
1205 
1206  if ($_GET["q_id"])
1207  {
1208  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
1209  {
1210  // edit page
1211  $ilTabs->addTarget("edit_content",
1212  $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "edit"),
1213  array("edit", "insert", "exec_pg"),
1214  "", "", $force_active);
1215  }
1216 
1217  // edit page
1218  $ilTabs->addTarget("preview",
1219  $this->ctrl->getLinkTargetByClass("ilPageObjectGUI", "preview"),
1220  array("preview"),
1221  "ilPageObjectGUI", "", $force_active);
1222  }
1223 
1224  $force_active = false;
1225  $commands = $_POST["cmd"];
1226  if (is_array($commands))
1227  {
1228  foreach ($commands as $key => $value)
1229  {
1230  if (preg_match("/^delete_.*/", $key, $matches) ||
1231  preg_match("/^addSelectGapText_.*/", $key, $matches) ||
1232  preg_match("/^addGapText_.*/", $key, $matches) ||
1233  preg_match("/^upload_.*/", $key, $matches) ||
1234  preg_match("/^addSuggestedSolution_.*/", $key, $matches) ||
1235  preg_match("/^removeSuggestedSolution_.*/", $key, $matches)
1236  )
1237  {
1238  $force_active = true;
1239  }
1240  }
1241  }
1242  if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
1243  {
1244  $url = "";
1245  if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
1246  // edit question properties
1247  $ilTabs->addTarget("edit_properties",
1248  $url,
1249  array("editQuestion", "save", "cancel", "addSuggestedSolution",
1250  "cancelExplorer", "linkChilds", "removeSuggestedSolution",
1251  "createGaps", "saveEdit", "changeGapType"),
1252  $classname, "", $force_active);
1253  }
1254 
1255  if ($_GET["q_id"])
1256  {
1257  $ilTabs->addTarget("feedback",
1258  $this->ctrl->getLinkTargetByClass($classname, "feedback"),
1259  array("feedback", "saveFeedback"),
1260  $classname, "");
1261  }
1262 
1263  // Assessment of questions sub menu entry
1264  if ($_GET["q_id"])
1265  {
1266  $ilTabs->addTarget("statistics",
1267  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
1268  array("assessment"),
1269  $classname, "");
1270  }
1271 
1272  if (($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
1273  {
1274  $ref_id = $_GET["calling_test"];
1275  if (strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
1276  $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1277  }
1278  else
1279  {
1280  $ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
1281  }
1282  }
1283 }
1284 ?>