ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.assQuestionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once './Modules/Test/classes/inc.AssessmentConstants.php';
5require_once 'Modules/Test/classes/class.ilTestExpressPage.php';
6
19abstract class assQuestionGUI
20{
21 const FORM_MODE_EDIT = 'edit';
22 const FORM_MODE_ADJUST = 'adjust';
23
24 const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded';
25 const FORM_ENCODING_MULTIPART = 'multipart/form-data';
26
27 const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers';
28
37
38 var $tpl;
39 var $lng;
40 var $error;
42
51
52 private $taxonomyIds = array();
53
54 private $targetGuiClass = null;
55
56 private $questionActionCmd = 'handleQuestionAction';
57
62
67
68 const PRESENTATION_CONTEXT_TEST = 'pContextTest';
69 const PRESENTATION_CONTEXT_RESULTS = 'pContextResults';
70
74 private $presentationContext = null;
75
76 const OUTPUT_MODE_SCREEN = 'outModeScreen';
77 const OUTPUT_MODE_PDF = 'outModePdf';
78 const OUTPUT_MODE_CONTENT_EDITING = 'outModeUsrSol';
79
84
85 // hey: prevPassSolutions - flag to indicate that a previous answer is shown
90 // hey.
91
95 function __construct()
96 {
97 global $lng, $tpl, $ilCtrl;
98
99 $this->lng =& $lng;
100 $this->tpl =& $tpl;
101 $this->ctrl =& $ilCtrl;
102 $this->ctrl->saveParameter($this, "q_id");
103 $this->ctrl->saveParameter($this, "prev_qid");
104 $this->ctrl->saveParameter($this, "calling_test");
105 $this->ctrl->saveParameter($this, "calling_consumer");
106 $this->ctrl->saveParameter($this, "consumer_context");
107 $this->ctrl->saveParameterByClass('ilAssQuestionPageGUI', 'test_express_mode');
108 $this->ctrl->saveParameterByClass('ilAssQuestionPageGUI', 'calling_consumer');
109 $this->ctrl->saveParameterByClass('ilAssQuestionPageGUI', 'consumer_context');
110 $this->ctrl->saveParameterByClass('ilobjquestionpoolgui', 'test_express_mode');
111 $this->ctrl->saveParameterByClass('ilobjquestionpoolgui', 'calling_consumer');
112 $this->ctrl->saveParameterByClass('ilobjquestionpoolgui', 'consumer_context');
113
114 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
115 $this->errormessage = $this->lng->txt("fill_out_all_required_fields");
116
117 $this->selfassessmenteditingmode = false;
118 $this->new_id_listeners = array();
119 $this->new_id_listener_cnt = 0;
120
121 $this->navigationGUI = null;
122 }
123
127 function &executeCommand()
128 {
129 $cmd = $this->ctrl->getCmd("editQuestion");
130 $next_class = $this->ctrl->getNextClass($this);
131
132 $cmd = $this->getCommand($cmd);
133
134 switch($next_class)
135 {
136 default:
137 $ret =& $this->$cmd();
138 break;
139 }
140 return $ret;
141 }
142
143 function getCommand($cmd)
144 {
145 return $cmd;
146 }
147
151 function getType()
152 {
153 return $this->getQuestionType();
154 }
155
159 public function getPresentationContext()
160 {
162 }
163
168 {
169 $this->presentationContext = $presentationContext;
170 }
171
173 {
175 }
176
177 // hey: previousPassSolutions - setter/getter for Previous Solution Prefilled flag
182 {
184 }
185
190 {
191 $this->previousSolutionPrefilled = $previousSolutionPrefilled;
192 }
193 // hey.
194
198 public function getOutputMode()
199 {
200 return $this->outputMode;
201 }
202
206 public function setOutputMode($outputMode)
207 {
208 $this->outputMode = $outputMode;
209 }
210
211 public function isPdfOutputMode()
212 {
213 return $this->getOutputMode() == self::OUTPUT_MODE_PDF;
214 }
215
217 {
219 }
220
224 public function getNavigationGUI()
225 {
227 }
228
233 {
234 $this->navigationGUI = $navigationGUI;
235 }
236
238 {
239 $this->taxonomyIds = $taxonomyIds;
240 }
241
242 public function getTaxonomyIds()
243 {
244 return $this->taxonomyIds;
245 }
246
247 public function setTargetGui($linkTargetGui)
248 {
249 $this->setTargetGuiClass( get_class($linkTargetGui) );
250 }
251
253 {
254 $this->targetGuiClass = $targetGuiClass;
255 }
256
257 public function getTargetGuiClass()
258 {
260 }
261
266 {
267 $this->questionHeaderBlockBuilder = $questionHeaderBlockBuilder;
268 }
269
271 {
272 $this->questionActionCmd = $questionActionCmd;
273
274 if( is_object($this->object) )
275 {
276 $this->object->questionActionCmd = $questionActionCmd;
277 }
278 }
279
280 public function getQuestionActionCmd()
281 {
283 }
284
291 protected function writePostData()
292 {
293 }
294
298 public function assessment()
299 {
303 global $tpl;
304
305 require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionCumulatedStatisticsTableGUI.php';
306 $stats_table = new ilQuestionCumulatedStatisticsTableGUI($this, 'assessment', '', $this->object);
307
308 require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionUsagesTableGUI.php';
309 $usage_table = new ilQuestionUsagesTableGUI($this, 'assessment', '', $this->object);
310
311 $tpl->setContent(implode('<br />', array(
312 $stats_table->getHTML(),
313 $usage_table->getHTML()
314 )));
315 }
316
326 public function &_getQuestionGUI($question_type, $question_id = -1)
327 {
328 global $ilCtrl, $ilDB, $lng;
329
330 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
331
332 if ((!$question_type) and ($question_id > 0))
333 {
334 $question_type = assQuestion::getQuestionTypeFromDb($question_id);
335 }
336
337 if (strlen($question_type) == 0) return NULL;
338
339 assQuestion::_includeClass($question_type, 1);
340
341 $question_type_gui = assQuestion::getGuiClassNameByQuestionType($question_type);
342 $question =& new $question_type_gui();
343
344 $feedbackObjectClassname = assQuestion::getFeedbackClassNameByQuestionType($question_type);
345 $question->object->feedbackOBJ = new $feedbackObjectClassname($question->object, $ilCtrl, $ilDB, $lng);
346
347 if ($question_id > 0)
348 {
349 $question->object->loadFromDb($question_id);
350 }
351
352 return $question;
353 }
354
358 function _getGUIClassNameForId($a_q_id)
359 {
360 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
361 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
362 $q_type = assQuestion::getQuestionTypeFromDb($a_q_id);
363 $class_name = assQuestionGUI::_getClassNameForQType($q_type);
364 return $class_name;
365 }
366
370 function _getClassNameForQType($q_type)
371 {
372 return $q_type . "GUI";
373 }
374
387 function &createQuestionGUI($question_type, $question_id = -1)
388 {
389 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
390 $this->question =& assQuestionGUI::_getQuestionGUI($question_type, $question_id);
391 }
392
397 {
398 $this->tpl->addBlockFile("CONTENT", "content", "tpl.il_as_qpl_content.html", "Modules/TestQuestionPool");
399 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
400 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_question.html", "Modules/TestQuestionPool");
401 }
402
409 function getILIASPage($html = "")
410 {
411 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
412 $page_gui = new ilAssQuestionPageGUI($this->object->getId());
413 $page_gui->setQuestionHTML(array($this->object->getId() => $html));
414 $page_gui->setOutputMode("presentation");
415 $presentation = $page_gui->presentation();
416 $presentation = preg_replace("/src=\"\\.\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $presentation);
417 return $presentation;
418 }
419
423 function outQuestionPage($a_temp_var, $a_postponed = false, $active_id = "", $html = "")
424 {
425 // hey: prevPassSolutions - send the "use previous answer" message
426 if ($this->isPreviousSolutionPrefilled())
427 {
429 }
430 // hey.
431
432 $this->lng->loadLanguageModule("content");
433
434 if( $this->getNavigationGUI() )
435 {
436 $html = $this->getNavigationGUI()->getHTML().$html;
437 }
438
439 $postponed = "";
440 if ($a_postponed)
441 {
442 $postponed = " (" . $this->lng->txt("postponed") . ")";
443 }
444
445 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
446 $page_gui = new ilAssQuestionPageGUI($this->object->getId());
447 $page_gui->setOutputMode("presentation");
448 $page_gui->setTemplateTargetVar($a_temp_var);
449
450 if( strlen($html) )
451 {
452 $page_gui->setQuestionHTML(array($this->object->getId() => $html));
453 }
454
455 $page_gui->setPresentationTitle($this->questionHeaderBlockBuilder->getHTML());
456
457 return $page_gui->presentation();
458 }
459
460 // hey: prevPassSolutions - build prev solution message / build "use previous answer checkbox" html
462 {
463 return $this->lng->txt('use_previous_solution_advice');
464 }
465 // hey.
466
470 function cancel()
471 {
472 if ($_GET["calling_test"])
473 {
474 $_GET["ref_id"] = $_GET["calling_test"];
475 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
476 }
477 elseif ($_GET["test_ref_id"])
478 {
479 $_GET["ref_id"] = $_GET["test_ref_id"];
480 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
481 }
482 else
483 {
484 if ($_GET["q_id"] > 0)
485 {
486 $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
487 $this->ctrl->redirectByClass("ilAssQuestionPageGUI", "edit");
488 }
489 else
490 {
491 $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
492 }
493 }
494 }
495
500 function originalSyncForm($return_to = "", $return_to_feedback = '')
501 {
502 if (strlen($return_to))
503 {
504 $this->ctrl->setParameter($this, "return_to", $return_to);
505 }
506 else if ($_REQUEST['return_to']) {
507 $this->ctrl->setParameter($this, "return_to", $_REQUEST['return_to']);
508 }
509 if(strlen($return_to_feedback))
510 {
511 $this->ctrl->setParameter($this, 'return_to_fb', 'true');
512 }
513
514 $this->ctrl->saveParameter($this, 'test_express_mode');
515
516 $template = new ilTemplate("tpl.il_as_qpl_sync_original.html",TRUE, TRUE, "Modules/TestQuestionPool");
517 $template->setVariable("BUTTON_YES", $this->lng->txt("yes"));
518 $template->setVariable("BUTTON_NO", $this->lng->txt("no"));
519 $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
520 $template->setVariable("TEXT_SYNC", $this->lng->txt("confirm_sync_questions"));
521 $this->tpl->setVariable("ADM_CONTENT", $template->get());
522 }
523
524 function sync()
525 {
526 $original_id = $this->object->original_id;
527 if ($original_id)
528 {
529 $this->object->syncWithOriginal();
530 }
531 if (strlen($_GET["return_to"]))
532 {
533 $this->ctrl->redirect($this, $_GET["return_to"]);
534 }
535 if (strlen($_REQUEST["return_to_fb"]))
536 {
537 $this->ctrl->redirectByClass('ilAssQuestionFeedbackEditingGUI', 'showFeedbackForm');
538 }
539 else
540 {
541 if(isset($_GET['calling_consumer']) && (int)$_GET['calling_consumer'])
542 {
543 $ref_id = (int)$_GET['calling_consumer'];
545 if($consumer instanceof ilQuestionEditingFormConsumer)
546 {
547 ilUtil::redirect($consumer->getQuestionEditingFormBackTarget($_GET['consumer_context']));
548 }
549 require_once 'Services/Link/classes/class.ilLink.php';
551 }
552 $_GET["ref_id"] = $_GET["calling_test"];
553
554 if($_REQUEST['test_express_mode'])
555 {
557 }
558 else
559 {
560 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
561 }
562 }
563 }
564
565 function cancelSync()
566 {
567 if (strlen($_GET["return_to"]))
568 {
569 $this->ctrl->redirect($this, $_GET["return_to"]);
570 }
571 if(strlen($_REQUEST['return_to_fb']))
572 {
573 $this->ctrl->redirectByClass('ilAssQuestionFeedbackEditingGUI', 'showFeedbackForm');
574 }
575 else
576 {
577 if(isset($_GET['calling_consumer']) && (int)$_GET['calling_consumer'])
578 {
579 $ref_id = (int)$_GET['calling_consumer'];
581 if($consumer instanceof ilQuestionEditingFormConsumer)
582 {
583 ilUtil::redirect($consumer->getQuestionEditingFormBackTarget($_GET['consumer_context']));
584 }
585 require_once 'Services/Link/classes/class.ilLink.php';
587 }
588 $_GET["ref_id"] = $_GET["calling_test"];
589
590 if($_REQUEST['test_express_mode'])
591 {
593 }
594 else
595 {
596 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
597 }
598 }
599 }
600
604 function saveEdit()
605 {
606 global $ilUser;
607
608 $result = $this->writePostData();
609 if ($result == 0)
610 {
611 $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
612 $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
613 $this->object->saveToDb();
614 $originalexists = $this->object->_questionExists($this->object->original_id);
615 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
616 if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
617 {
618 $this->ctrl->redirect($this, "originalSyncForm");
619 }
620 elseif ($_GET["calling_test"])
621 {
622 $_GET["ref_id"] = $_GET["calling_test"];
623 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["calling_test"]);
624 return;
625 }
626 elseif ($_GET["test_ref_id"])
627 {
628 global $tree, $ilDB, $ilPluginAdmin;
629
630 include_once ("./Modules/Test/classes/class.ilObjTest.php");
631 $_GET["ref_id"] = $_GET["test_ref_id"];
632 $test =& new ilObjTest($_GET["test_ref_id"], true);
633
634 require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
635 $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
636
637 $test->insertQuestion( $testQuestionSetConfigFactory->getQuestionSetConfig(), $this->object->getId() );
638
639 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=".$_GET["test_ref_id"]);
640 }
641 else
642 {
643 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
644 $this->editQuestion();
645 if (strcmp($_SESSION["info"], "") != 0)
646 {
647 ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), false);
648 }
649 else
650 {
651 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), false);
652 }
653 $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $this->object->getId());
654 $this->ctrl->redirectByClass("ilAssQuestionPageGUI", "edit");
655 }
656 }
657 }
658
662 function save()
663 {
664 global $ilUser;
665 $old_id = $_GET["q_id"];
666 $result = $this->writePostData();
667
668 if($result == 0)
669 {
670 $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
671 $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
672 $this->object->saveToDb();
673 $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
674
675
676 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
677 if(($_GET["calling_test"] || (isset($_GET['calling_consumer']) && (int)$_GET['calling_consumer'])) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
678 {
679 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
680 $this->ctrl->setParameter($this, 'return_to', 'editQuestion');
681 $this->ctrl->redirect($this, "originalSyncForm");
682 return;
683 }
684 elseif($_GET["calling_test"])
685 {
686 require_once 'Modules/Test/classes/class.ilObjTest.php';
687 $test = new ilObjTest($_GET["calling_test"]);
688 if(!assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()))
689 {
690 global $tree, $ilDB, $ilPluginAdmin;
691
692 include_once("./Modules/Test/classes/class.ilObjTest.php");
693 $_GET["ref_id"] = $_GET["calling_test"];
694 $test = new ilObjTest($_GET["calling_test"], true);
695
696 require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
697 $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
698
699 $new_id = $test->insertQuestion(
700 $testQuestionSetConfigFactory->getQuestionSetConfig(), $this->object->getId()
701 );
702
703 if(isset($_REQUEST['prev_qid']))
704 {
705 $test->moveQuestionAfter($this->object->getId() + 1, $_REQUEST['prev_qid']);
706 }
707
708 $this->ctrl->setParameter($this, 'q_id', $new_id);
709 $this->ctrl->setParameter($this, 'calling_test', $_GET['calling_test']);
710 #$this->ctrl->setParameter($this, 'test_ref_id', false);
711 }
712 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
713 $this->ctrl->redirect($this, 'editQuestion');
714
715 }
716 else
717 {
718 $this->callNewIdListeners($this->object->getId());
719
720 if($this->object->getId() != $old_id)
721 {
722 // first save
723 $this->ctrl->setParameterByClass($_GET["cmdClass"], "q_id", $this->object->getId());
724 $this->ctrl->setParameterByClass($_GET["cmdClass"], "sel_question_types", $_GET["sel_question_types"]);
725 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
726
727 //global $___test_express_mode;
731 if($_REQUEST['prev_qid'])
732 {
733 // @todo: bheyser/mbecker wtf? ..... thx@jposselt ....
734 // mbecker: Possible fix: Just instantiate the obj?
735 include_once("./Modules/Test/classes/class.ilObjTest.php");
736 $test =& new ilObjTest($_GET["ref_id"], true);
737 $test->moveQuestionAfter($_REQUEST['prev_qid'], $this->object->getId());
738 }
739 if( /*$___test_express_mode || */ $_REQUEST['express_mode'] )
740 {
741 global $tree, $ilDB, $ilPluginAdmin;
742
743 include_once("./Modules/Test/classes/class.ilObjTest.php");
744 $test = new ilObjTest($_GET["ref_id"], true);
745
746 require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
747 $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
748
749 $test->insertQuestion(
750 $testQuestionSetConfigFactory->getQuestionSetConfig(), $this->object->getId()
751 );
752
753 require_once 'Modules/Test/classes/class.ilTestExpressPage.php';
754 $_REQUEST['q_id'] = $this->object->getId();
756 }
757
758 $this->ctrl->redirectByClass($_GET["cmdClass"], "editQuestion");
759 }
760 if(strcmp($_SESSION["info"], "") != 0)
761 {
762 ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
763 }
764 else
765 {
766 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
767 }
768 $this->ctrl->redirect($this, 'editQuestion');
769 }
770 }
771 }
772
776 function saveReturn()
777 {
778 global $ilUser;
779 $old_id = $_GET["q_id"];
780 $result = $this->writePostData();
781 if($result == 0)
782 {
783 $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
784 $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
785 $this->object->saveToDb();
786 $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
787 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
788 if(($_GET["calling_test"] || (isset($_GET['calling_consumer']) && (int)$_GET['calling_consumer'])) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
789 {
790 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
791 $this->ctrl->setParameter($this, 'test_express_mode', $_REQUEST['test_express_mode']);
792 $this->ctrl->redirect($this, "originalSyncForm");
793 return;
794 }
795 elseif($_GET["calling_test"])
796 {
797 require_once 'Modules/Test/classes/class.ilObjTest.php';
798 $test = new ilObjTest($_GET["calling_test"]);
799 #var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()));
800 $q_id = $this->object->getId();
801 if(!assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()))
802 {
803 global $tree, $ilDB, $ilPluginAdmin;
804
805 include_once("./Modules/Test/classes/class.ilObjTest.php");
806 $_GET["ref_id"] = $_GET["calling_test"];
807 $test = new ilObjTest($_GET["calling_test"], true);
808
809 require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
810 $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
811
812 $new_id = $test->insertQuestion(
813 $testQuestionSetConfigFactory->getQuestionSetConfig(), $this->object->getId()
814 );
815
816 $q_id = $new_id;
817 if(isset($_REQUEST['prev_qid']))
818 {
819 $test->moveQuestionAfter($this->object->getId() + 1, $_REQUEST['prev_qid']);
820 }
821
822 $this->ctrl->setParameter($this, 'q_id', $new_id);
823 $this->ctrl->setParameter($this, 'calling_test', $_GET['calling_test']);
824 #$this->ctrl->setParameter($this, 'test_ref_id', false);
825
826 }
827 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
828 if( /*$___test_express_mode || */
829 $_REQUEST['test_express_mode']
830 )
831 {
833 }
834 else
835 {
836 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=" . $_GET["calling_test"]);
837 }
838 }
839 else
840 {
841 if($this->object->getId() != $old_id)
842 {
843 $this->callNewIdListeners($this->object->getId());
844 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
845 $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
846 }
847 if(strcmp($_SESSION["info"], "") != 0)
848 {
849 ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
850 }
851 else
852 {
853 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
854 }
855 $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
856 }
857 }
858 }
859
863 function apply()
864 {
865 $this->writePostData();
866 $this->object->saveToDb();
867 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
868 $this->editQuestion();
869 }
870
877 function getContextPath($cont_obj, $a_endnode_id, $a_startnode_id = 1)
878 {
879 $path = "";
880
881 $tmpPath = $cont_obj->getLMTree()->getPathFull($a_endnode_id, $a_startnode_id);
882
883 // count -1, to exclude the learning module itself
884 for ($i = 1; $i < (count($tmpPath) - 1); $i++)
885 {
886 if ($path != "")
887 {
888 $path .= " > ";
889 }
890
891 $path .= $tmpPath[$i]["title"];
892 }
893
894 return $path;
895 }
896
897 function setSequenceNumber($nr)
898 {
899 $this->sequence_no = $nr;
900 }
901
903 {
904 return $this->sequence_no;
905 }
906
907 function setQuestionCount($a_question_count)
908 {
909 $this->question_count = $a_question_count;
910 }
911
913 {
915 }
916
918 {
919 return $this->errormessage;
920 }
921
923 {
924 $this->errormessage = $errormessage;
925 }
926
928 {
929 $this->errormessage .= ((strlen($this->errormessage)) ? "<br />" : "") . $errormessage;
930 }
931
933 {
934 }
935
945 {
946 return $this->object->getQuestionType();
947 }
948
956 public function getAsValueAttribute($a_value)
957 {
958 $result = "";
959 if (strlen($a_value))
960 {
961 $result = " value=\"$a_value\" ";
962 }
963 return $result;
964 }
965
966 // scorm2004-start
971 function addNewIdListener(&$a_object, $a_method, $a_parameters = "")
972 {
973 $cnt = $this->new_id_listener_cnt;
974 $this->new_id_listeners[$cnt]["object"] =& $a_object;
975 $this->new_id_listeners[$cnt]["method"] = $a_method;
976 $this->new_id_listeners[$cnt]["parameters"] = $a_parameters;
977 $this->new_id_listener_cnt++;
978 }
979
983 function callNewIdListeners($a_new_id)
984 {
985
986 for ($i=0; $i<$this->new_id_listener_cnt; $i++)
987 {
988 $this->new_id_listeners[$i]["parameters"]["new_id"] = $a_new_id;
989 $object =& $this->new_id_listeners[$i]["object"];
990 $method = $this->new_id_listeners[$i]["method"];
991 $parameters = $this->new_id_listeners[$i]["parameters"];
992//var_dump($object);
993//var_dump($method);
994//var_dump($parameters);
995
996 $object->$method($parameters);
997 }
998 }
999
1004 {
1005 //if (!$this->object->getSelfAssessmentEditingMode() && !$_GET["calling_test"]) $form->addCommandButton("saveEdit", $this->lng->txt("save_edit"));
1006 if(!$this->object->getSelfAssessmentEditingMode())
1007 {
1008 $form->addCommandButton("saveReturn", $this->lng->txt("save_return"));
1009 }
1010 $form->addCommandButton("save", $this->lng->txt("save"));
1011 }
1012
1020 {
1021 // title
1022 $title = new ilTextInputGUI($this->lng->txt("title"), "title");
1023 $title->setMaxLength(100);
1024 $title->setValue($this->object->getTitle());
1025 $title->setRequired(TRUE);
1026 $form->addItem($title);
1027
1028 if (!$this->object->getSelfAssessmentEditingMode())
1029 {
1030 // author
1031 $author = new ilTextInputGUI($this->lng->txt("author"), "author");
1032 $author->setValue($this->object->getAuthor());
1033 $author->setRequired(TRUE);
1034 $form->addItem($author);
1035
1036 // description
1037 $description = new ilTextInputGUI($this->lng->txt("description"), "comment");
1038 $description->setValue($this->object->getComment());
1039 $description->setRequired(FALSE);
1040 $form->addItem($description);
1041 }
1042 else
1043 {
1044 // author as hidden field
1045 $hi = new ilHiddenInputGUI("author");
1046 $author = ilUtil::prepareFormOutput($this->object->getAuthor());
1047 if (trim($author) == "")
1048 {
1049 $author = "-";
1050 }
1051 $hi->setValue($author);
1052 $form->addItem($hi);
1053
1054 }
1055
1056 // questiontext
1057 $question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
1058 $question->setValue($this->object->getQuestion());
1059 $question->setRequired(TRUE);
1060 $question->setRows(10);
1061 $question->setCols(80);
1062
1063 if (!$this->object->getSelfAssessmentEditingMode())
1064 {
1065 if( $this->object->getAdditionalContentEditingMode() != assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT )
1066 {
1067 $question->setUseRte(TRUE);
1068 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1069 $question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
1070 $question->addPlugin("latex");
1071 $question->addButton("latex");
1072 $question->addButton("pastelatex");
1073 $question->setRTESupport($this->object->getId(), "qpl", "assessment");
1074 }
1075 }
1076 else
1077 {
1078 require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
1080 $question->setUseTagsForRteOnly(false);
1081 }
1082 $form->addItem($question);
1083
1084 if (!$this->object->getSelfAssessmentEditingMode())
1085 {
1086 // duration
1087 $duration = new ilDurationInputGUI($this->lng->txt("working_time"), "Estimated");
1088 $duration->setShowHours(TRUE);
1089 $duration->setShowMinutes(TRUE);
1090 $duration->setShowSeconds(TRUE);
1091 $ewt = $this->object->getEstimatedWorkingTime();
1092 $duration->setHours($ewt["h"]);
1093 $duration->setMinutes($ewt["m"]);
1094 $duration->setSeconds($ewt["s"]);
1095 $duration->setRequired(FALSE);
1096 $form->addItem($duration);
1097 }
1098 else
1099 {
1100 // number of tries
1101 if (strlen($this->object->getNrOfTries()))
1102 {
1103 $nr_tries = $this->object->getNrOfTries();
1104 }
1105 else
1106 {
1107 $nr_tries = $this->object->getDefaultNrOfTries();
1108 }
1109 if ($nr_tries < 1)
1110 {
1111 $nr_tries = "";
1112 }
1113
1114 $ni = new ilNumberInputGUI($this->lng->txt("qst_nr_of_tries"), "nr_of_tries");
1115 $ni->setValue($nr_tries);
1116 $ni->setMinValue(0);
1117 $ni->setSize(5);
1118 $ni->setMaxLength(5);
1119 $form->addItem($ni);
1120 }
1121 }
1122
1123 protected function saveTaxonomyAssignments()
1124 {
1125 if( count($this->getTaxonomyIds()) )
1126 {
1127 require_once 'Services/Taxonomy/classes/class.ilTaxAssignInputGUI.php';
1128
1129 foreach($this->getTaxonomyIds() as $taxonomyId)
1130 {
1131 $postvar = "tax_node_assign_$taxonomyId";
1132
1133 $tax_node_assign = new ilTaxAssignInputGUI($taxonomyId, true, '', $postvar);
1134 // TODO: determine tst/qpl when tax assigns become maintainable within tests
1135 $tax_node_assign->saveInput("qpl", $this->object->getObjId(), "quest", $this->object->getId());
1136 }
1137 }
1138 }
1139
1141 {
1142 if( count($this->getTaxonomyIds()) )
1143 {
1144 $sectHeader = new ilFormSectionHeaderGUI();
1145 $sectHeader->setTitle($this->lng->txt('qpl_qst_edit_form_taxonomy_section'));
1146 $form->addItem($sectHeader);
1147
1148 require_once 'Services/Taxonomy/classes/class.ilTaxAssignInputGUI.php';
1149
1150 foreach($this->getTaxonomyIds() as $taxonomyId)
1151 {
1152 $taxonomy = new ilObjTaxonomy($taxonomyId);
1153 $label = sprintf($this->lng->txt('qpl_qst_edit_form_taxonomy'), $taxonomy->getTitle());
1154 $postvar = "tax_node_assign_$taxonomyId";
1155
1156 $taxNodeAssign = new ilTaxAssignInputGUI($taxonomy->getId(), true, $label, $postvar);
1157 // TODO: determine tst/qpl when tax assigns become maintainable within tests
1158 $taxNodeAssign->setCurrentValues('qpl', $this->object->getObjId(), 'quest', $this->object->getId());
1159 $form->addItem($taxNodeAssign);
1160 }
1161 }
1162 }
1163
1170 protected function isLastSolutionSubmitAuthorized($active_id, $pass)
1171 {
1172 $userSolution = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
1173
1174 if( count($userSolution) )
1175 {
1176 $solutionRow = current($userSolution);
1177 return (bool)$solutionRow['authorized'];
1178 }
1179
1180 return null;
1181 }
1182
1192 function getAnswerFeedbackOutput($active_id, $pass)
1193 {
1194 return $this->getGenericFeedbackOutput($active_id, $pass);
1195 }
1196
1206 function getGenericFeedbackOutput($active_id, $pass)
1207 {
1208 $output = "";
1209 include_once "./Modules/Test/classes/class.ilObjTest.php";
1210 $manual_feedback = ilObjTest::getManualFeedback($active_id, $this->object->getId(), $pass);
1211 if (strlen($manual_feedback))
1212 {
1213 return $manual_feedback;
1214 }
1215 $correct_feedback = $this->object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), true);
1216 $incorrect_feedback = $this->object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), false);
1217 if (strlen($correct_feedback.$incorrect_feedback))
1218 {
1219 $useAuthorizedSolution = $this->isLastSolutionSubmitAuthorized($active_id, $pass);
1220 $reached_points = $this->object->calculateReachedPoints($active_id, $pass, (bool)$useAuthorizedSolution);
1221 $max_points = $this->object->getMaximumPoints();
1222 if ($reached_points == $max_points)
1223 {
1224 $output = $correct_feedback;
1225 }
1226 else
1227 {
1228 $output = $incorrect_feedback;
1229 }
1230 }
1231 return $this->object->prepareTextareaOutput($output, TRUE);
1232 }
1233
1235 {
1236 return $this->object->prepareTextareaOutput(
1237 $this->object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), true), true
1238 );
1239 }
1240
1242 {
1243 return $this->object->prepareTextareaOutput(
1244 $this->object->feedbackOBJ->getGenericFeedbackTestPresentation($this->object->getId(), false), true
1245 );
1246 }
1247
1259 abstract function getSpecificFeedbackOutput($active_id, $pass);
1260
1261 public function outQuestionType()
1262 {
1263 $count = $this->object->isInUse();
1264
1265 if (assQuestion::_questionExistsInPool($this->object->getId()) && $count)
1266 {
1267 global $rbacsystem;
1268 if ($rbacsystem->checkAccess("write", $_GET["ref_id"]))
1269 {
1270 ilUtil::sendInfo(sprintf($this->lng->txt("qpl_question_is_in_use"), $count));
1271 }
1272 }
1273
1274 return assQuestion::_getQuestionTypeName($this->object->getQuestionType());
1275 }
1276
1277 public function showSuggestedSolution()
1278 {
1279 $this->suggestedsolution();
1280 }
1281
1287 public function suggestedsolution()
1288 {
1289 global $ilUser;
1290 global $ilAccess;
1291
1292 $save = (is_array($_POST["cmd"]) && array_key_exists("suggestedsolution", $_POST["cmd"])) ? TRUE : FALSE;
1293
1294 if ($save && $_POST["deleteSuggestedSolution"] == 1)
1295 {
1296 $this->object->deleteSuggestedSolutions();
1297 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1298 $this->ctrl->redirect($this, "suggestedsolution");
1299 }
1300
1301 $output = "";
1302 $solution_array = $this->object->getSuggestedSolution(0);
1303 $options = array(
1304 "lm" => $this->lng->txt("obj_lm"),
1305 "st" => $this->lng->txt("obj_st"),
1306 "pg" => $this->lng->txt("obj_pg"),
1307 "git" => $this->lng->txt("glossary_term"),
1308 "file" => $this->lng->txt("fileDownload"),
1309 "text" => $this->lng->txt("solutionText")
1310 );
1311
1312 if ((strcmp($_POST["solutiontype"], "file") == 0) && (strcmp($solution_array["type"], "file") != 0))
1313 {
1314 $solution_array = array(
1315 "type" => "file"
1316 );
1317 }
1318 elseif ((strcmp($_POST["solutiontype"], "text") == 0) && (strcmp($solution_array["type"], "text") != 0))
1319 {
1320 $oldOutputMode = $this->getOutputMode();
1321 $this->setOutputMode(self::OUTPUT_MODE_CONTENT_EDITING);
1322
1323 $solution_array = array(
1324 "type" => "text",
1325 "value" => $this->getSolutionOutput(0, NULL, FALSE, FALSE, TRUE, FALSE, TRUE)
1326 );
1327 $this->setOutputMode($oldsaveSuggestedSolutionOutputMode);
1328 }
1329 if ($save && strlen($_POST["filename"]))
1330 {
1331 $solution_array["value"]["filename"] = $_POST["filename"];
1332 }
1333 if ($save && strlen($_POST["solutiontext"]))
1334 {
1335 $solution_array["value"] = $_POST["solutiontext"];
1336 }
1337 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1338 if (count($solution_array))
1339 {
1340 $form = new ilPropertyFormGUI();
1341 $form->setFormAction($this->ctrl->getFormAction($this));
1342 $form->setTitle($this->lng->txt("solution_hint"));
1343 $form->setMultipart(TRUE);
1344 $form->setTableWidth("100%");
1345 $form->setId("suggestedsolutiondisplay");
1346
1347 // suggested solution output
1348 include_once "./Modules/TestQuestionPool/classes/class.ilSolutionTitleInputGUI.php";
1349 $title = new ilSolutionTitleInputGUI($this->lng->txt("showSuggestedSolution"), "solutiontype");
1350 $template = new ilTemplate("tpl.il_as_qpl_suggested_solution_input_presentation.html", TRUE, TRUE, "Modules/TestQuestionPool");
1351 if (strlen($solution_array["internal_link"]))
1352 {
1353 $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
1354 $template->setCurrentBlock("preview");
1355 $template->setVariable("TEXT_SOLUTION", $this->lng->txt("suggested_solution"));
1356 $template->setVariable("VALUE_SOLUTION", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("view"). "</a> ");
1357 $template->parseCurrentBlock();
1358 }
1359 elseif ((strcmp($solution_array["type"], "file") == 0) && (is_array($solution_array["value"])))
1360 {
1361 $href = $this->object->getSuggestedSolutionPathWeb() . $solution_array["value"]["name"];
1362 $template->setCurrentBlock("preview");
1363 $template->setVariable("TEXT_SOLUTION", $this->lng->txt("suggested_solution"));
1364 $template->setVariable("VALUE_SOLUTION", " <a href=\"$href\" target=\"content\">" . ilUtil::prepareFormOutput((strlen($solution_array["value"]["filename"])) ? $solution_array["value"]["filename"] : $solution_array["value"]["name"]). "</a> ");
1365 $template->parseCurrentBlock();
1366 }
1367 $template->setVariable("TEXT_TYPE", $this->lng->txt("type"));
1368 $template->setVariable("VALUE_TYPE", $options[$solution_array["type"]]);
1369 $title->setHtml($template->get());
1370 $deletesolution = new ilCheckboxInputGUI("", "deleteSuggestedSolution");
1371 $deletesolution->setOptionTitle($this->lng->txt("deleteSuggestedSolution"));
1372 $title->addSubItem($deletesolution);
1373 $form->addItem($title);
1374
1375 if (strcmp($solution_array["type"], "file") == 0)
1376 {
1377 // file
1378 $file = new ilFileInputGUI($this->lng->txt("fileDownload"), "file");
1379 $file->setRequired(TRUE);
1380 $file->enableFileNameSelection("filename");
1381 //$file->setSuffixes(array("doc","xls","png","jpg","gif","pdf"));
1382 if( $_FILES["file"]["tmp_name"] && $file->checkInput() )
1383 {
1384 if (!file_exists($this->object->getSuggestedSolutionPath())) ilUtil::makeDirParents($this->object->getSuggestedSolutionPath());
1385
1386 $res = ilUtil::moveUploadedFile($_FILES["file"]["tmp_name"], $_FILES["file"]["name"], $this->object->getSuggestedSolutionPath() . $_FILES["file"]["name"]);
1387 if ($res)
1388 {
1389 ilUtil::renameExecutables($this->object->getSuggestedSolutionPath());
1390
1391 // remove an old file download
1392 if (is_array($solution_array["value"])) @unlink($this->object->getSuggestedSolutionPath() . $solution_array["value"]["name"]);
1393 $file->setValue($_FILES["file"]["name"]);
1394 $this->object->saveSuggestedSolution("file", "", 0, array("name" => $_FILES["file"]["name"], "type" => $_FILES["file"]["type"], "size" => $_FILES["file"]["size"], "filename" => $_POST["filename"]));
1395 $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
1396 if (($_GET["calling_test"] || (isset($_GET['calling_consumer']) && (int)$_GET['calling_consumer'])) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
1397 {
1398 return $this->originalSyncForm("suggestedsolution");
1399 }
1400 else
1401 {
1402 ilUtil::sendSuccess($this->lng->txt("suggested_solution_added_successfully"), TRUE);
1403 $this->ctrl->redirect($this, "suggestedsolution");
1404 }
1405 }
1406 else
1407 {
1408 // BH: $res as info string? wtf? it holds a bool or something else!!?
1410 }
1411 }
1412 else
1413 {
1414 if (is_array($solution_array["value"]))
1415 {
1416 $file->setValue($solution_array["value"]["name"]);
1417 $file->setFilename((strlen($solution_array["value"]["filename"])) ? $solution_array["value"]["filename"] : $solution_array["value"]["name"]);
1418 }
1419 }
1420 $form->addItem($file);
1421 $hidden = new ilHiddenInputGUI("solutiontype");
1422 $hidden->setValue("file");
1423 $form->addItem($hidden);
1424 }
1425 else if (strcmp($solution_array["type"], "text") == 0)
1426 {
1427 $solutionContent = $solution_array['value'];
1428 $solutionContent = $this->object->fixSvgToPng($solutionContent);
1429 $solutionContent = $this->object->fixUnavailableSkinImageSources($solutionContent);
1430 $question = new ilTextAreaInputGUI($this->lng->txt("solutionText"), "solutiontext");
1431 $question->setValue($this->object->prepareTextareaOutput($solutionContent));
1432 $question->setRequired(TRUE);
1433 $question->setRows(10);
1434 $question->setCols(80);
1435 $question->setUseRte(TRUE);
1436 $question->addPlugin("latex");
1437 $question->addButton("latex");
1438 $question->setRTESupport($this->object->getId(), "qpl", "assessment");
1439 $hidden = new ilHiddenInputGUI("solutiontype");
1440 $hidden->setValue("text");
1441 $form->addItem($hidden);
1442 $form->addItem($question);
1443 }
1444 if ($ilAccess->checkAccess("write", "", $_GET['ref_id']))
1445 {
1446 $form->addCommandButton('showSuggestedSolution', $this->lng->txt('cancel'));
1447 $form->addCommandButton('suggestedsolution', $this->lng->txt('save'));
1448 }
1449
1450 if ($save)
1451 {
1452 if ($form->checkInput())
1453 {
1454 switch ($solution_array["type"])
1455 {
1456 case "file":
1457 $this->object->saveSuggestedSolution("file", "", 0, array(
1458 "name" => $solution_array["value"]["name"],
1459 "type" => $solution_array["value"]["type"],
1460 "size" => $solution_array["value"]["size"],
1461 "filename" => $_POST["filename"]
1462 ));
1463 break;
1464 case "text":
1465 $this->object->saveSuggestedSolution("text", "", 0, $solution_array["value"]);
1466 break;
1467 }
1468 $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
1469 if (($_GET["calling_test"] || (isset($_GET['calling_consumer']) && (int)$_GET['calling_consumer'])) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
1470 {
1471 return $this->originalSyncForm("suggestedsolution");
1472 }
1473 else
1474 {
1475 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1476 $this->ctrl->redirect($this, "suggestedsolution");
1477 }
1478 }
1479 }
1480
1481 $output = $form->getHTML();
1482 }
1483
1484 $savechange = (strcmp($this->ctrl->getCmd(), "saveSuggestedSolution") == 0) ? TRUE : FALSE;
1485
1486 $changeoutput = "";
1487 if ($ilAccess->checkAccess("write", "", $_GET['ref_id']))
1488 {
1489 $formchange = new ilPropertyFormGUI();
1490 $formchange->setFormAction($this->ctrl->getFormAction($this));
1491 $formchange->setTitle((count($solution_array)) ? $this->lng->txt("changeSuggestedSolution") : $this->lng->txt("addSuggestedSolution"));
1492 $formchange->setMultipart(FALSE);
1493 $formchange->setTableWidth("100%");
1494 $formchange->setId("suggestedsolution");
1495
1496 $solutiontype = new ilRadioGroupInputGUI($this->lng->txt("suggestedSolutionType"), "solutiontype");
1497 foreach($options as $opt_value => $opt_caption)
1498 {
1499 $solutiontype->addOption(new ilRadioOption($opt_caption, $opt_value));
1500 }
1501 if (count($solution_array))
1502 {
1503 $solutiontype->setValue($solution_array["type"]);
1504 }
1505 $solutiontype->setRequired(TRUE);
1506 $formchange->addItem($solutiontype);
1507
1508 $formchange->addCommandButton("saveSuggestedSolution", $this->lng->txt("select"));
1509
1510 if ($savechange)
1511 {
1512 $formchange->checkInput();
1513 }
1514 $changeoutput = $formchange->getHTML();
1515 }
1516
1517 $this->tpl->setVariable("ADM_CONTENT", $changeoutput . $output);
1518 }
1519
1520 public function outSolutionExplorer()
1521 {
1522 global $tree;
1523
1524 include_once("./Modules/TestQuestionPool/classes/class.ilSolutionExplorer.php");
1525 $type = $_GET["link_new_type"];
1526 $search = $_GET["search_link_type"];
1527 $this->ctrl->setParameter($this, "link_new_type", $type);
1528 $this->ctrl->setParameter($this, "search_link_type", $search);
1529 $this->ctrl->saveParameter($this, array("subquestion_index", "link_new_type", "search_link_type"));
1530
1531 ilUtil::sendInfo($this->lng->txt("select_object_to_link"));
1532
1533 $parent_ref_id = $tree->getParentId($_GET["ref_id"]);
1534 $exp = new ilSolutionExplorer($this->ctrl->getLinkTarget($this, 'suggestedsolution'), get_class($this));
1535 $exp->setExpand($_GET['expand_sol'] ? $_GET['expand_sol'] : $parent_ref_id);
1536 $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'outSolutionExplorer'));
1537 $exp->setTargetGet("ref_id");
1538 $exp->setRefId($_GET["ref_id"]);
1539 $exp->addFilter($type);
1540 $exp->setSelectableType($type);
1541 if(isset($_GET['expandCurrentPath']) && $_GET['expandCurrentPath'])
1542 {
1543 $exp->expandPathByRefId($parent_ref_id);
1544 }
1545
1546 // build html-output
1547 $exp->setOutput(0);
1548
1549 $template = new ilTemplate("tpl.il_as_qpl_explorer.html", TRUE, TRUE, "Modules/TestQuestionPool");
1550 $template->setVariable("EXPLORER_TREE",$exp->getOutput());
1551 $template->setVariable("BUTTON_CANCEL",$this->lng->txt("cancel"));
1552 $template->setVariable("FORMACTION",$this->ctrl->getFormAction($this, "suggestedsolution"));
1553 $this->tpl->setVariable("ADM_CONTENT", $template->get());
1554 }
1555
1556 public function saveSuggestedSolution()
1557 {
1558 global $tree;
1559
1560 include_once("./Modules/TestQuestionPool/classes/class.ilSolutionExplorer.php");
1561 switch ($_POST["solutiontype"])
1562 {
1563 case "lm":
1564 $type = "lm";
1565 $search = "lm";
1566 break;
1567 case "git":
1568 $type = "glo";
1569 $search = "glo";
1570 break;
1571 case "st":
1572 $type = "lm";
1573 $search = "st";
1574 break;
1575 case "pg":
1576 $type = "lm";
1577 $search = "pg";
1578 break;
1579 case "file":
1580 case "text":
1581 return $this->suggestedsolution();
1582 break;
1583 default:
1584 return $this->suggestedsolution();
1585 break;
1586 }
1587 if(isset($_POST['solutiontype']))
1588 {
1589 $this->ctrl->setParameter($this, 'expandCurrentPath', 1);
1590 }
1591 $this->ctrl->setParameter($this, "link_new_type", $type);
1592 $this->ctrl->setParameter($this, "search_link_type", $search);
1593 $this->ctrl->redirect($this, "outSolutionExplorer");
1594 }
1595
1597 {
1598 $this->ctrl->redirect($this, "suggestedsolution");
1599 }
1600
1602 {
1603 require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionInternalLinkSelectionTableGUI.php';
1604 require_once 'Modules/LearningModule/classes/class.ilLMPageObject.php';
1605 require_once 'Modules/LearningModule/classes/class.ilObjContentObjectGUI.php';
1606
1607 $this->ctrl->setParameter($this, 'q_id', $this->object->getId());
1608
1609 $cont_obj_gui = new ilObjContentObjectGUI('', $_GET['source_id'], true);
1610 $cont_obj = $cont_obj_gui->object;
1611 $pages = ilLMPageObject::getPageList($cont_obj->getId());
1612 $shownpages = array();
1613 $tree = $cont_obj->getLMTree();
1614 $chapters = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
1615
1616 $rows = array();
1617
1618 foreach($chapters as $chapter)
1619 {
1620 $chapterpages = $tree->getChildsByType($chapter['obj_id'], 'pg');
1621 foreach($chapterpages as $page)
1622 {
1623 if($page['type'] == $_GET['search_link_type'])
1624 {
1625 array_push($shownpages, $page['obj_id']);
1626
1627 if($tree->isInTree($page['obj_id']))
1628 {
1629 $path_str = $this->getContextPath($cont_obj, $page['obj_id']);
1630 }
1631 else
1632 {
1633 $path_str = '---';
1634 }
1635
1636 $this->ctrl->setParameter($this, $page['type'], $page['obj_id']);
1637 $rows[] = array(
1638 'title' => $page['title'],
1639 'description' => ilUtil::prepareFormOutput($path_str),
1640 'text_add' => $this->lng->txt('add'),
1641 'href_add' => $this->ctrl->getLinkTarget($this, 'add' . strtoupper($page['type']))
1642 );
1643 }
1644 }
1645 }
1646 foreach($pages as $page)
1647 {
1648 if(!in_array($page['obj_id'], $shownpages))
1649 {
1650 $this->ctrl->setParameter($this, $page['type'], $page['obj_id']);
1651 $rows[] = array(
1652 'title' => $page['title'],
1653 'description' => '---',
1654 'text_add' => $this->lng->txt('add'),
1655 'href_add' => $this->ctrl->getLinkTarget($this, 'add' . strtoupper($page['type']))
1656 );
1657 }
1658 }
1659
1660 require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionInternalLinkSelectionTableGUI.php';
1661 $table = new ilQuestionInternalLinkSelectionTableGUI($this, 'cancelExplorer', __METHOD__);
1662 $table->setTitle($this->lng->txt('obj_' . ilUtil::stripSlashes($_GET['search_link_type'])));
1663 $table->setData($rows);
1664
1665 $this->tpl->setContent($table->getHTML());
1666 }
1667
1668 public function outChapterSelector()
1669 {
1670 require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionInternalLinkSelectionTableGUI.php';
1671 require_once 'Modules/LearningModule/classes/class.ilObjContentObjectGUI.php';
1672
1673 $this->ctrl->setParameter($this, 'q_id', $this->object->getId());
1674
1675 $cont_obj_gui = new ilObjContentObjectGUI('', $_GET['source_id'], true);
1676 $cont_obj = $cont_obj_gui->object;
1677 $ctree = $cont_obj->getLMTree();
1678 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
1679
1680 $rows = array();
1681
1682 foreach($nodes as $node)
1683 {
1684 if($node['type'] == $_GET['search_link_type'])
1685 {
1686 $this->ctrl->setParameter($this, $node['type'], $node['obj_id']);
1687 $rows[] = array(
1688 'title' => $node['title'],
1689 'description' => '',
1690 'text_add' => $this->lng->txt('add'),
1691 'href_add' => $this->ctrl->getLinkTarget($this, 'add' . strtoupper($node['type']))
1692 );
1693 }
1694 }
1695
1696 $table = new ilQuestionInternalLinkSelectionTableGUI($this, 'cancelExplorer', __METHOD__);
1697 $table->setTitle($this->lng->txt('obj_' . ilUtil::stripSlashes($_GET['search_link_type'])));
1698 $table->setData($rows);
1699
1700 $this->tpl->setContent($table->getHTML());
1701 }
1702
1703 public function outGlossarySelector()
1704 {
1705 require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionInternalLinkSelectionTableGUI.php';
1706 require_once 'Modules/Glossary/classes/class.ilObjGlossary.php';
1707
1708 $this->ctrl->setParameter($this, 'q_id', $this->object->getId());
1709
1710 $glossary = new ilObjGlossary($_GET['source_id'], true);
1711 $terms = $glossary->getTermList();
1712
1713 $rows = array();
1714
1715 foreach($terms as $term)
1716 {
1717 $this->ctrl->setParameter($this, 'git', $term['id']);
1718 $rows[] = array(
1719 'title' => $term['term'],
1720 'description' => '',
1721 'text_add' => $this->lng->txt('add'),
1722 'href_add' => $this->ctrl->getLinkTarget($this, 'addGIT')
1723 );
1724 }
1725
1726 $table = new ilQuestionInternalLinkSelectionTableGUI($this, 'cancelExplorer', __METHOD__);
1727 $table->setTitle($this->lng->txt('glossary_term'));
1728 $table->setData($rows);
1729
1730 $this->tpl->setContent($table->getHTML());
1731 }
1732
1733 function linkChilds()
1734 {
1735 $this->ctrl->saveParameter($this, array("subquestion_index", "link_new_type", "search_link_type"));
1736 switch ($_GET["search_link_type"])
1737 {
1738 case "pg":
1739 return $this->outPageSelector();
1740 break;
1741 case "st":
1742 return $this->outChapterSelector();
1743 break;
1744 case "glo":
1745 return $this->outGlossarySelector();
1746 break;
1747 case "lm":
1748 $subquestion_index = ($_GET["subquestion_index"] > 0) ? $_GET["subquestion_index"] : 0;
1749 $this->object->saveSuggestedSolution("lm", "il__lm_" . $_GET["source_id"], $subquestion_index);
1750 ilUtil::sendSuccess($this->lng->txt("suggested_solution_added_successfully"), TRUE);
1751 $this->ctrl->redirect($this, "suggestedsolution");
1752 break;
1753 }
1754 }
1755
1756 function addPG()
1757 {
1758 $subquestion_index = 0;
1759 if (strlen($_GET["subquestion_index"]) && $_GET["subquestion_index"] >= 0)
1760 {
1761 $subquestion_index = $_GET["subquestion_index"];
1762 }
1763 $this->object->saveSuggestedSolution("pg", "il__pg_" . $_GET["pg"], $subquestion_index);
1764 ilUtil::sendSuccess($this->lng->txt("suggested_solution_added_successfully"), TRUE);
1765 $this->ctrl->redirect($this, "suggestedsolution");
1766 }
1767
1768 function addST()
1769 {
1770 $subquestion_index = 0;
1771 if (strlen($_GET["subquestion_index"]) && $_GET["subquestion_index"] >= 0)
1772 {
1773 $subquestion_index = $_GET["subquestion_index"];
1774 }
1775 $this->object->saveSuggestedSolution("st", "il__st_" . $_GET["st"], $subquestion_index);
1776 ilUtil::sendSuccess($this->lng->txt("suggested_solution_added_successfully"), TRUE);
1777 $this->ctrl->redirect($this, "suggestedsolution");
1778 }
1779
1780 function addGIT()
1781 {
1782 $subquestion_index = 0;
1783 if (strlen($_GET["subquestion_index"]) && $_GET["subquestion_index"] >= 0)
1784 {
1785 $subquestion_index = $_GET["subquestion_index"];
1786 }
1787 $this->object->saveSuggestedSolution("git", "il__git_" . $_GET["git"], $subquestion_index);
1788 ilUtil::sendSuccess($this->lng->txt("suggested_solution_added_successfully"), TRUE);
1789 $this->ctrl->redirect($this, "suggestedsolution");
1790 }
1791
1792 function isSaveCommand()
1793 {
1794 return in_array($this->ctrl->getCmd(), array('save', 'saveEdit', 'saveReturn'));
1795 }
1796
1805 public static function getCommandsFromClassConstants($guiClassName, $cmdConstantNameBegin = 'CMD_')
1806 {
1807 $reflectionClass = new ReflectionClass($guiClassName);
1808
1809 $commands = null;
1810
1811 if( $reflectionClass instanceof ReflectionClass )
1812 {
1813 $commands = array();
1814
1815 foreach($reflectionClass->getConstants() as $constName => $constValue)
1816 {
1817 if( substr($constName, 0, strlen($cmdConstantNameBegin)) == $cmdConstantNameBegin )
1818 {
1819 $commands[] = $constValue;
1820 }
1821 }
1822 }
1823
1824 return $commands;
1825 }
1826
1827 public function setQuestionTabs()
1828 {
1829 global $rbacsystem, $ilTabs;
1830
1831 $ilTabs->clearTargets();
1832
1833 $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
1834 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1835 $q_type = $this->object->getQuestionType();
1836
1837 if (strlen($q_type))
1838 {
1839 $classname = $q_type . "GUI";
1840 $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
1841 $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
1842 }
1843
1844 if ($_GET["q_id"])
1845 {
1846 if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
1847 {
1848 // edit page
1849 $ilTabs->addTarget("edit_page",
1850 $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
1851 array("edit", "insert", "exec_pg"),
1852 "", "", $force_active);
1853 }
1854
1855 $this->addTab_QuestionPreview($ilTabs);
1856 }
1857 $force_active = false;
1858 if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
1859 {
1860 $url = "";
1861 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
1862 $force_active = false;
1863 // edit question properties
1864 $ilTabs->addTarget("edit_question",
1865 $url,
1867 $classname, "", $force_active);
1868 }
1869
1870 // add tab for question feedback within common class assQuestionGUI
1871 $this->addTab_QuestionFeedback($ilTabs);
1872
1873 // add tab for question hint within common class assQuestionGUI
1874 $this->addTab_QuestionHints($ilTabs);
1875
1876 // add tab for question's suggested solution within common class assQuestionGUI
1877 $this->addTab_SuggestedSolution($ilTabs, $classname);
1878
1879 // Assessment of questions sub menu entry
1880 if ($_GET["q_id"])
1881 {
1882 $ilTabs->addTarget("statistics",
1883 $this->ctrl->getLinkTargetByClass($classname, "assessment"),
1884 array("assessment"),
1885 $classname, "");
1886 }
1887
1888 $this->addBackTab($ilTabs);
1889 }
1890
1891 public function addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
1892 {
1893 if ($_GET["q_id"])
1894 {
1895 $tabs->addTarget("suggested_solution",
1896 $this->ctrl->getLinkTargetByClass($classname, "suggestedsolution"),
1897 array("suggestedsolution", "saveSuggestedSolution", "outSolutionExplorer", "cancel",
1898 "addSuggestedSolution","cancelExplorer", "linkChilds", "removeSuggestedSolution"
1899 ),
1900 $classname,
1901 ""
1902 );
1903 }
1904 }
1905
1906 final public function getEditQuestionTabCommands()
1907 {
1908 return array_merge($this->getBasicEditQuestionTabCommands(), $this->getAdditionalEditQuestionCommands());
1909 }
1910
1912 {
1913 return array('editQuestion', 'save', 'saveEdit', 'originalSyncForm');
1914 }
1915
1917 {
1918 return array();
1919 }
1920
1927 protected function addTab_QuestionFeedback(ilTabsGUI $tabs)
1928 {
1929 global $ilCtrl;
1930
1931 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
1932 $tabCommands = self::getCommandsFromClassConstants('ilAssQuestionFeedbackEditingGUI');
1933
1934 $tabLink = $ilCtrl->getLinkTargetByClass('ilAssQuestionFeedbackEditingGUI', ilAssQuestionFeedbackEditingGUI::CMD_SHOW);
1935
1936 $tabs->addTarget('tst_feedback', $tabLink, $tabCommands, $ilCtrl->getCmdClass(), '');
1937 }
1938
1942 protected function addTab_Units(ilTabsGUI $tabs)
1943 {
1947 global $ilCtrl;
1948
1949 $tabs->addTarget('units', $ilCtrl->getLinkTargetByClass('ilLocalUnitConfigurationGUI', ''), '', 'illocalunitconfigurationgui');
1950 }
1951
1958 protected function addTab_QuestionHints(ilTabsGUI $tabs)
1959 {
1960 global $ilCtrl;
1961
1962 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
1963
1964 switch( $ilCtrl->getCmdClass() )
1965 {
1966 case 'ilassquestionhintsgui':
1967
1968 $tabCommands = self::getCommandsFromClassConstants('ilAssQuestionHintsGUI');
1969 break;
1970
1971 case 'ilassquestionhintgui':
1972
1973 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintGUI.php';
1974 $tabCommands = self::getCommandsFromClassConstants('ilAssQuestionHintGUI');
1975 break;
1976
1977 default:
1978
1979 $tabCommands = array();
1980 }
1981
1982 $tabLink = $ilCtrl->getLinkTargetByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
1983
1984 $tabs->addTarget('tst_question_hints_tab', $tabLink, $tabCommands, $ilCtrl->getCmdClass(), '');
1985 }
1986
1987 protected function addTab_QuestionPreview(ilTabsGUI $tabsGUI)
1988 {
1989 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewGUI.php';
1990
1991 $tabsGUI->addTarget(
1993 $this->ctrl->getLinkTargetByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW),
1994 array(),
1995 array('ilAssQuestionPreviewGUI')
1996 );
1997 }
1998
1999 abstract public function getSolutionOutput(
2000 $active_id,
2001 $pass = NULL,
2002 $graphicalOutput = FALSE,
2003 $result_output = FALSE,
2004 $show_question_only = TRUE,
2005 $show_feedback = FALSE,
2006 $show_correct_solution = FALSE,
2007 $show_manual_scoring = FALSE,
2008 $show_question_text = TRUE
2009 );
2010
2011 protected function hasCorrectSolution($activeId, $passIndex)
2012 {
2013 $reachedPoints = $this->object->getAdjustedReachedPoints($activeId, $passIndex, true);
2014 $maximumPoints = $this->object->getMaximumPoints();
2015
2016 return $reachedPoints == $maximumPoints;
2017 }
2018
2019 public function isAutosaveable()
2020 {
2021 return $this->object->isAutosaveable();
2022 }
2023
2024 protected function writeQuestionGenericPostData()
2025 {
2026 $this->object->setTitle( $_POST["title"] );
2027 $this->object->setAuthor( $_POST["author"] );
2028 $this->object->setComment( $_POST["comment"] );
2029 if ($this->object->getSelfAssessmentEditingMode())
2030 {
2031 $this->object->setNrOfTries( $_POST['nr_of_tries'] );
2032 }
2033 $this->object->setQuestion( ilUtil::stripOnlySlashes($_POST['question']) ); // ?
2034 $this->object->setEstimatedWorkingTime(
2035 $_POST["Estimated"]["hh"],
2036 $_POST["Estimated"]["mm"],
2037 $_POST["Estimated"]["ss"]
2038 );
2039 }
2040
2041 abstract public function getPreview($show_question_only = FALSE, $showInlineFeedback = false);
2042
2051 final public function outQuestionForTest(
2052 $formaction,
2053 $active_id,
2054 // hey: prevPassSolutions - pass will be always available from now on
2055 $pass,
2056 // hey.
2057 $is_question_postponed = FALSE,
2058 $user_post_solutions = FALSE,
2059 $show_specific_inline_feedback = FALSE
2060 )
2061 {
2062 $formaction = $this->completeTestOutputFormAction($formaction, $active_id, $pass);
2063
2064 $test_output = $this->getTestOutput(
2065 $active_id,
2066 $pass,
2067 $is_question_postponed,
2068 $user_post_solutions,
2069 $show_specific_inline_feedback
2070 );
2071
2072 $this->magicAfterTestOutput();
2073
2074 $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
2075 $this->tpl->setVariable("FORMACTION", $formaction);
2076 $this->tpl->setVariable("ENCTYPE", 'enctype="'.$this->getFormEncodingType().'"');
2077 $this->tpl->setVariable("FORM_TIMESTAMP", time());
2078 }
2079
2080 // hey: prevPassSolutions - $pass will be passed always from now on
2081 protected function completeTestOutputFormAction($formAction, $active_id, $pass)
2082 // hey.
2083 {
2084 return $formAction;
2085 }
2086
2087 public function magicAfterTestOutput()
2088 {
2089 return;
2090 }
2091
2092 abstract public function getTestOutput(
2093 $active_id,
2094 $pass,
2095 $is_question_postponed,
2096 $user_post_solutions,
2097 $show_specific_inline_feedback
2098 );
2099
2100 // hey: prevPassSolutions - accept and prefer intermediate only from current pass
2101 protected function getTestOutputSolutions($activeId, $pass)
2102 {
2103 if( $this->isPreviousSolutionPrefilled() )
2104 {
2105 return $this->object->getSolutionValues($activeId, $pass, true);
2106 }
2107
2108 return $this->object->getUserSolutionPreferingIntermediate($activeId, $pass);
2109 }
2110 // hey.
2111
2112 public function getFormEncodingType()
2113 {
2115 }
2116
2120 protected function addBackTab(ilTabsGUI $ilTabs)
2121 {
2122 if(($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
2123 {
2124 $ref_id = $_GET["calling_test"];
2125 if(strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
2126
2127 if(!$_GET['test_express_mode'] && !$GLOBALS['___test_express_mode'])
2128 {
2129 $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
2130 }
2131 else
2132 {
2134 $ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), $link);
2135 }
2136 }
2137 else if(isset($_GET['calling_consumer']) && (int)$_GET['calling_consumer'])
2138 {
2139 $ref_id = (int)$_GET['calling_consumer'];
2141 if($consumer instanceof ilQuestionEditingFormConsumer)
2142 {
2143 $ilTabs->setBackTarget($consumer->getQuestionEditingFormBackTargetLabel(), $consumer->getQuestionEditingFormBackTarget($_GET['consumer_context']));
2144 }
2145 else
2146 {
2147 require_once 'Services/Link/classes/class.ilLink.php';
2148 $ilTabs->setBackTarget($this->lng->txt("qpl"), ilLink::_getLink($ref_id));
2149 }
2150 }
2151 else
2152 {
2153 $ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
2154 }
2155 }
2156
2161
2166 {
2167 $this->previewSession = $previewSession;
2168 }
2169
2173 public function getPreviewSession()
2174 {
2175 return $this->previewSession;
2176 }
2177
2181 protected function buildBasicEditFormObject()
2182 {
2183 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
2184 $form = new ilPropertyFormGUI();
2185
2186 $form->setFormAction($this->ctrl->getFormAction($this));
2187
2188 $form->setId($this->getType());
2189 $form->setTitle($this->outQuestionType());
2190
2191 $form->setTableWidth('100%');
2192
2193 $form->setMultipart(true);
2194
2195 return $form;
2196 }
2197
2198 public function showHints()
2199 {
2200 global $ilCtrl;
2201 $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
2202 }
2203}
$result
print $file
$test
Definition: Utf8Test.php:85
$_GET["client_id"]
$_SESSION["AccountId"]
Basic GUI class for assessment questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
isLastSolutionSubmitAuthorized($active_id, $pass)
fetches solutions from database and prefers intermediate solutions, but falls back to authorized solu...
addNewIdListener(&$a_object, $a_method, $a_parameters="")
Add a listener that is notified with the new question ID, when a new question is saved.
callNewIdListeners($a_new_id)
Call the new id listeners.
const SESSION_PREVIEW_DATA_BASE_INDEX
getContextPath($cont_obj, $a_endnode_id, $a_startnode_id=1)
get context path in content object tree
setErrorMessage($errormessage)
getPreview($show_question_only=FALSE, $showInlineFeedback=false)
getQuestionType()
Returns the question type string.
getType()
needed for page editor compliance
cancel()
cancel action
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
setNavigationGUI($navigationGUI)
setTargetGuiClass($targetGuiClass)
setQuestionCount($a_question_count)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getILIASPage($html="")
Returns the ILIAS Page around a question.
getQuestionTemplate()
get question template
& createQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation.
setTaxonomyIds($taxonomyIds)
originalSyncForm($return_to="", $return_to_feedback='')
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
getAsValueAttribute($a_value)
Returns a HTML value attribute.
setPreviewSession($previewSession)
setTargetGui($linkTargetGui)
getSolutionOutput( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
saveReturn()
save question
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
& _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
outQuestionForTest( $formaction, $active_id, $pass, $is_question_postponed=FALSE, $user_post_solutions=FALSE, $show_specific_inline_feedback=FALSE)
getTestOutput( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
apply()
apply changes
& executeCommand()
execute command
getTestOutputSolutions($activeId, $pass)
setPresentationContext($presentationContext)
setQuestionHeaderBlockBuilder($questionHeaderBlockBuilder)
addErrorMessage($errormessage)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
getSpecificFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
suggestedsolution()
Allows to add suggested solutions for questions.
saveEdit()
save question
completeTestOutputFormAction($formAction, $active_id, $pass)
setOutputMode($outputMode)
addBackTab(ilTabsGUI $ilTabs)
setPreviousSolutionPrefilled($previousSolutionPrefilled)
__construct()
assQuestionGUI constructor
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
static getCommandsFromClassConstants($guiClassName, $cmdConstantNameBegin='CMD_')
extracts values of all constants of given class with given prefix as array can be used to get all pos...
setQuestionActionCmd($questionActionCmd)
$sequence_no
sequence number in test
$question_count
question count in test
getAnswerFeedbackOutput($active_id, $pass)
Returns the answer generic feedback depending on the results of the question.
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
static getFeedbackClassNameByQuestionType($questionType)
_questionExistsInTest($question_id, $test_id)
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
_getInternalLinkHref($target="")
_questionExistsInPool($question_id)
Returns true if the question already exists in the database and is assigned to a question pool.
static getGuiClassNameByQuestionType($questionType)
_isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT
constant for additional content editing mode "pageobject"
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
getQuestionTypeFromDb($question_id)
get question type for question id
const CMD_SHOW_LIST
command constants
Question page GUI class.
static getSelfAssessmentTags()
Get tags allowed in question tags in self assessment mode.
This class represents a checkbox property in a property form.
This class represents a duration (typical hh:mm:ss) property in a property form.
This class represents a file property in a property form.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
getPageList($lm_id)
static
This class represents a number property in a property form.
& _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
Class ilObjContentObjectGUI.
Class ilObjGlossary.
static getManualFeedback($active_id, $question_id, $pass)
Retrieves the manual feedback for a question in a test.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
Class ilQuestionUsagesTableGUI.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a custom property in a property form.
Tabs GUI.
setBackTarget($a_title, $a_target, $a_frame="")
back target for upper context
addTarget($a_text, $a_link, $a_cmd="", $a_cmdClass="", $a_frame="", $a_activate=false, $a_dir_text=false)
DEPRECATED.
Input GUI class for taxonomy assignments.
special template class to simplify handling of ITX/PEAR
static getReturnToPageLink($q_id=null)
This class represents a text area property in a property form.
This class represents a text property in a property form.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static stripOnlySlashes($a_str)
strip slashes if magic qoutes is enabled
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
http redirect to other script
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
$_POST['username']
Definition: cron.php:12
$html
Definition: example_001.php:87
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
QTI assessment class.
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
$url
Definition: shib_logout.php:72
$path
Definition: index.php:22
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
global $ilDB
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15