19 declare(strict_types=1);
32 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
78 'ilpublicuserprofilegui',
'ilobjportfoliogui' 85 private \ILIAS\Filesystem\Util\Archive\LegacyArchives
$archives;
118 $this->navigation_history = $DIC[
'ilNavigationHistory'];
119 $this->component_repository = $DIC[
'component.repository'];
120 $this->component_factory = $DIC[
'component.factory'];
121 $this->ui_factory = $DIC[
'ui.factory'];
122 $this->ui_renderer = $DIC[
'ui.renderer'];
123 $this->
http = $DIC[
'http'];
124 $this->error = $DIC[
'ilErr'];
125 $this->db = $DIC[
'ilDB'];
126 $this->logging_services = $DIC->logger();
127 $this->
help = $DIC[
'ilHelp'];
128 $this->global_screen = $DIC[
'global_screen'];
129 $this->obj_data_cache = $DIC[
'ilObjDataCache'];
130 $this->skills_service = $DIC->skills();
131 $this->questioninfo = $DIC->testQuestionPool()->questionInfo();
133 $this->testrequest = $DIC->test()->internal()->request();
134 $this->archives = $DIC->legacyArchives();
135 $this->content_style = $DIC->contentStyle();
138 if ($this->testrequest->hasRefId() && is_numeric($this->testrequest->getRefId())) {
139 $ref_id = $this->testrequest->getRefId();
143 $this->
ctrl->saveParameter($this, [
'ref_id',
'test_ref_id',
'calling_test',
'test_express_mode',
'q_id']);
145 $this->
lng->loadLanguageModule(
'assessment');
147 if ($this->
object instanceof
ilObjTest) {
153 if (!$this->
object->isFixedTest() && !$this->
object->isRandomTest()) {
154 $this->tpl->setOnScreenMessage(
'failure', sprintf(
155 'You tried to access a Dynamic Test. This is not possible anymore with ILIAS 9. ' 156 .
'Please tell your administrator to run the corresponding migration to remove this Test completely.',
160 $this->
ctrl->redirectByClass(
'ilrepositorygui');
167 $this->logging_services->root(),
181 if ($this->
object instanceof ilObjTest) {
186 $this->request_wrapper,
190 $this->objective_oriented_container
193 $tabs_manager->
setTestSession($this->test_session_factory->getSession());
204 $cmd = $this->
ctrl->getCmd(
'testScreen');
206 $cmds_disabled_due_to_offline_status = [
207 'resumePlayer',
'resumePlayer',
'outUserResultsOverview',
'outUserListOfAnswerPasses' 210 if (!$this->
getCreationMode() && $this->
object->getOfflineStatus() && in_array($cmd, $cmds_disabled_due_to_offline_status)) {
214 $next_class = $this->
ctrl->getNextClass($this);
218 $this->
access->checkAccess(
'read',
'', $this->testrequest->getRefId())
220 $this->navigation_history->addItem(
221 $this->testrequest->getRefId(),
222 ilLink::_getLink($this->testrequest->getRefId(),
"tst"),
228 if ($this->testrequest->raw(
'prev_qid')) {
229 global $___prev_question_id;
230 $___prev_question_id = $this->testrequest->raw(
'prev_qid');
231 $this->
ctrl->setParameter($this,
'prev_qid', $this->testrequest->raw(
'prev_qid'));
236 && isset($this->test_question_set_config_factory)
237 && $this->test_question_set_config_factory->getQuestionSetConfig()->areDepenciesBroken()
238 && !$this->test_question_set_config_factory->getQuestionSetConfig()->isValidRequestOnBrokenQuestionSetDepencies($next_class, $cmd)
240 $this->
ctrl->redirectByClass(
'ilObjTestGUI',
'infoScreen');
245 switch ($next_class) {
246 case 'illtiproviderobjectsettinggui':
247 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
252 $this->tabs_manager->getSettingsSubTabs();
253 $this->tabs_gui->activateTab(
'settings');
254 $this->tabs_gui->activateSubTab(
'lti_provider');
257 $lti_gui->offerLTIRolesForSelection(
false);
258 $this->
ctrl->forwardCommand($lti_gui);
262 case 'iltestexportgui':
263 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
271 $selected_files = [];
272 if ($this->testrequest->isset(
'file') && $this->testrequest->raw(
'file')) {
273 $selected_files = $this->testrequest->raw(
'file');
276 if (is_string($selected_files)) {
277 $selected_files = [$selected_files];
283 $this->logging_services->root(),
286 $this->component_factory->getActivePluginsInSlot(
'texp'),
291 $this->
ctrl->forwardCommand($export_gui);
294 case "ilinfoscreengui":
295 if (!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()) && !$this->
access->checkAccess(
"visible",
"", $this->testrequest->getRefId())) {
303 case "iltestscreengui":
304 if (!$this->
access->checkAccess(
'read',
'', $this->testrequest->getRefId()) && !$this->
access->checkAccess(
'visible',
'', $this->testrequest->getRefId())) {
312 case 'ilobjectmetadatagui':
313 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
321 $this->
ctrl->forwardCommand($md_gui);
324 case 'iltestdashboardgui':
325 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
332 $this->getTestObject(),
343 $this->test_question_set_config_factory->getQuestionSetConfig(),
351 $this->
ctrl->forwardCommand($gui);
354 case 'iltestresultsgui':
355 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
362 $this->getTestObject(),
363 $this->test_question_set_config_factory->getQuestionSetConfig(),
384 $gui->setTestSession($this->test_session_factory->getSession());
388 $this->
ctrl->forwardCommand($gui);
391 case "iltestplayerfixedquestionsetgui":
392 if ($cmd !==
'autosave' 393 && !$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId())) {
397 if (!$this->
object->getKioskMode()) {
402 $this->
ctrl->forwardCommand($gui);
405 case "iltestplayerrandomquestionsetgui":
406 if ($cmd !==
'autosave' 407 && !$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId())) {
411 if (!$this->
object->getKioskMode()) {
416 $this->
ctrl->forwardCommand($gui);
419 case "iltestevaluationgui":
420 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
426 case "iltestevalobjectiveorientedgui":
427 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
432 $this->forwardToEvalObjectiveOrientedGUI();
435 case "iltestservicegui":
436 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
442 $this->
ctrl->forwardCommand($serviceGUI);
445 case 'ilpermissiongui':
446 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
453 $ret = $this->
ctrl->forwardCommand($perm_gui);
456 case "illearningprogressgui":
457 if (!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId())) {
464 $test_object = $this->getTestObject();
465 if ($test_object === null) {
470 $test_session = $this->test_session_factory->getSessionByUserId($this->user->getId());
472 && !$test_object->canShowTestResults($test_session)) {
473 $this->tpl->setOnScreenMessage(
475 $this->lng->txt(
'tst_res_tab_msg_no_lp_access'),
482 $this->
ctrl->forwardCommand($new_gui);
486 case "ilcertificategui":
487 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
496 $output_gui = $guiFactory->create($this->
object);
498 $this->
ctrl->forwardCommand($output_gui);
501 case "iltestscoringgui":
502 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
509 $this->
ctrl->forwardCommand($output_gui);
512 case 'ilmarkschemagui':
513 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
516 if (!$this->access->checkAccess(
'write',
'', $this->object->getRefId())) {
517 $this->tpl->setOnScreenMessage(
'info', $this->lng->txt(
'cannot_edit_test'),
true);
518 $this->
ctrl->redirect($this,
'infoScreen');
523 $this->
ctrl->forwardCommand($mark_schema_gui);
526 case 'iltestscoringbyquestionsgui':
527 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
534 $this->
ctrl->forwardCommand($output_gui);
537 case 'ilobjtestsettingsmaingui':
538 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
549 $this->component_repository,
554 $this->
ctrl->forwardCommand($gui);
557 case 'ilobjtestsettingsscoringresultsgui':
558 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
569 $this->component_repository,
573 $this->getTestObject()->getScoreSettingsRepository(),
574 $this->getTestObject()->getTestId(),
582 $this->
ctrl->forwardCommand($gui);
585 case 'iltestrandomquestionsetconfiggui':
586 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
594 ))->withContextId($this->
object->getId());
596 $this->getTestObject(),
604 $this->logging_services->root(),
611 $test_process_locker_factory,
615 $this->
ctrl->forwardCommand($gui);
618 case 'iltestquestionbrowsertablegui':
619 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
628 $this->logging_services->root(),
630 $this->getTestObject(),
639 $gui->
setWriteAccess($this->access->checkAccess(
"write",
"", $this->ref_id));
641 $this->
ctrl->forwardCommand($gui);
644 case 'iltestskilladministrationgui':
645 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
658 $this->logging_services->root(),
661 $this->getTestObject(),
665 $this->
ctrl->forwardCommand($gui);
668 case 'ilobjectcopygui':
669 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
676 $this->
ctrl->forwardCommand($cp);
679 case 'ilpageeditorgui':
680 case 'iltestexpresspageobjectgui':
681 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
687 $incompleteQuestionPurger->setOwnerId($this->user->getId());
688 $incompleteQuestionPurger->purge();
697 if (!in_array($cmd, [
'addQuestion',
'browseForQuestions'])) {
701 if (!$qid || in_array($cmd, [
'insertQuestions',
'browseForQuestions'])) {
703 $ret = $this->
ctrl->forwardCommand($pageObject);
704 $this->tpl->setContent($ret);
707 $this->tpl->setCurrentBlock(
"ContentStyle");
708 $this->tpl->setVariable(
709 "LOCATION_CONTENT_STYLESHEET",
712 $this->tpl->parseCurrentBlock();
715 $this->tpl->setCurrentBlock(
"SyntaxStyle");
716 $this->tpl->setVariable(
717 "LOCATION_SYNTAX_STYLESHEET",
720 $this->tpl->parseCurrentBlock();
724 $this->
ctrl->setParameterByClass(
'iltestexpresspageobjectgui',
'q_id',
'');
725 $this->
ctrl->redirectByClass(
'iltestexpresspageobjectgui', $this->
ctrl->getCmd());
730 $q_gui->outAdditionalOutput();
731 $q_gui->object->setObjId($this->
object->getId());
733 $q_gui->setTargetGuiClass(null);
734 $q_gui->setQuestionActionCmd(
'');
736 $question = $q_gui->object;
737 $this->
ctrl->saveParameter($this,
"q_id");
739 #$this->lng->loadLanguageModule("content"); 740 $this->
ctrl->setReturnByClass(
"ilTestExpressPageObjectGUI",
"view");
741 $this->
ctrl->setReturn($this,
"questions");
744 $page_gui->setEditPreview(
true);
745 $page_gui->setEnabledTabs(
false);
746 if (strlen($this->
ctrl->getCmd()) == 0) {
747 $this->
ctrl->setCmdClass(get_class($page_gui));
748 $this->
ctrl->setCmd(
"preview");
751 $page_gui->setQuestionHTML([$q_gui->object->getId() => $q_gui->getPreview(
true)]);
752 $page_gui->setTemplateTargetVar(
"ADM_CONTENT");
754 $page_gui->setOutputMode($this->
object->evalTotalPersons() == 0 ?
"edit" :
'preview');
756 $page_gui->setHeader($question->getTitleForHTMLOutput());
757 $page_gui->setFileDownloadLink($this->
ctrl->getLinkTarget($this,
"downloadFile"));
758 $page_gui->setFullscreenLink($this->
ctrl->getLinkTarget($this,
"fullscreen"));
759 $page_gui->setSourcecodeDownloadScript($this->
ctrl->getLinkTarget($this));
760 $page_gui->setPresentationTitle($question->getTitleForHTMLOutput() .
' [' . $this->lng->txt(
'question_id_short') .
': ' . $question->getId() .
']');
761 $ret = $this->
ctrl->forwardCommand($page_gui);
763 $this->tpl->setContent($ret);
765 $this->tabs_gui->activateTab(
'assQuestions');
769 case 'ilassquestionpreviewgui':
770 if (!$this->access->checkAccess(
'write',
'', $this->object->getRefId())) {
775 $this->
ctrl->saveParameter($this,
"q_id");
785 $this->refinery->random(),
792 $gui->initPreviewSettings($this->
object->getRefId());
793 $gui->initPreviewSession($this->user->getId(), $this->testrequest->getQuestionId());
794 $gui->initHintTracking();
795 $gui->initStyleSheets();
797 $this->
ctrl->forwardCommand($gui);
801 case 'ilassquestionpagegui':
802 if ($cmd ==
'finishEditing') {
806 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
809 if ($cmd ===
'edit' && !$this->access->checkAccess(
'write',
'', $this->testrequest->getRefId())) {
814 $forwarder->setTestObj($this->getTestObject());
815 $forwarder->forward();
818 case 'ilassspecfeedbackpagegui':
819 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
823 $this->
ctrl->forwardCommand($pg_gui);
826 case 'ilassgenfeedbackpagegui':
827 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
831 $this->
ctrl->forwardCommand($pg_gui);
834 case 'illocalunitconfigurationgui':
835 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
841 $this->
ctrl->setReturn($this,
"questions");
843 $questionGUI->object->setObjId($this->
object->getId());
844 $questionGUI->setQuestionTabs();
848 $this->
ctrl->forwardCommand($gui);
851 case "ilcommonactiondispatchergui":
852 if (!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()) && !$this->access->checkAccess(
"visible",
"", $this->testrequest->getRefId())) {
857 $this->
ctrl->forwardCommand($gui);
860 case 'ilassquestionhintsgui':
861 if (!$this->access->checkAccess(
'write',
'', $this->object->getRefId())) {
867 $this->
ctrl->setReturn($this,
"questions");
869 $questionGUI->object->setObjId($this->
object->getId());
870 $questionGUI->setQuestionTabs();
872 if ($this->
object->evalTotalPersons() !== 0) {
873 $this->tpl->setOnScreenMessage(
'failure', $this->lng->txt(
"question_is_part_of_running_test"),
true);
878 $gui->setEditingEnabled(
879 $this->access->checkAccess(
'write',
'', $this->object->getRefId())
882 $this->
ctrl->forwardCommand($gui);
886 case 'ilassquestionfeedbackeditinggui':
887 if (!$this->access->checkAccess(
'write',
'', $this->object->getRefId())) {
893 $this->
ctrl->setReturn($this,
"questions");
895 $questionGUI->object->setObjId($this->
object->getId());
896 $questionGUI->setQuestionTabs();
898 if ($this->
object->evalTotalPersons() !== 0) {
899 $this->tpl->setOnScreenMessage(
'failure', $this->lng->txt(
"question_is_part_of_running_test"),
true);
903 $this->
ctrl->forwardCommand($gui);
907 case 'iltestcorrectionsgui':
908 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
925 $this->getTestObject(),
928 $this->
ctrl->forwardCommand($gui);
931 case 'iltestpagegui':
932 if ((!$this->access->checkAccess(
"write",
"", $this->testrequest->getRefId()))) {
935 if ($cmd ===
'downloadFile') {
936 $page_id = $this->
object->getIntroductionPageId();
937 if ($this->testrequest->strVal(
'page_type') ===
'concludingremarkspage') {
938 $page_id = $this->
object->getConcludingRemarksPageId();
947 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()) && !$this->access->checkAccess(
"visible",
"", $this->testrequest->getRefId()))) {
952 if ((strcmp($cmd,
"properties") == 0) && ($this->testrequest->raw(
"browse"))) {
956 if ((strcmp($cmd,
"properties") == 0) && ($this->testrequest->raw(
"up") || $this->testrequest->raw(
"down"))) {
963 if ((!$this->access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
966 if (in_array($cmd, [
'editQuestion',
'save',
'suggestedsolution'])
967 && !$this->access->checkAccess(
'write',
'', $this->object->getRefId())) {
971 if ($this->testrequest->raw(
'prev_qid')) {
972 global $___prev_question_id;
973 $___prev_question_id = $this->testrequest->raw(
'prev_qid');
974 $this->
ctrl->setParameterByClass(
'ilassquestionpagegui',
'prev_qid', $this->testrequest->raw(
'prev_qid'));
975 $this->
ctrl->setParameterByClass($this->testrequest->raw(
'sel_question_types') .
'gui',
'prev_qid', $this->testrequest->raw(
'prev_qid'));
977 $this->create_question_mode =
true;
980 $this->
ctrl->setReturn($this,
"questions");
991 $questionGui->object->setObjId($this->
object->getId());
993 if (in_array($cmd, [
'editQuestion',
'save',
'suggestedsolution'])
994 && $this->
object->evalTotalPersons() !== 0) {
995 $this->tpl->setOnScreenMessage(
'failure', $this->lng->txt(
"question_is_part_of_running_test"),
true);
999 $questionGuiClass = get_class($questionGui);
1000 $this->
ctrl->setParameterByClass($questionGuiClass,
'prev_qid', $this->testrequest->raw(
'prev_qid'));
1001 $this->
ctrl->setParameterByClass($questionGuiClass,
'test_ref_id', $this->testrequest->getRefId());
1002 $this->
ctrl->setParameterByClass($questionGuiClass,
'q_id', $qid);
1004 if ($this->testrequest->isset(
'test_express_mode')) {
1005 $this->
ctrl->setParameterByClass($questionGuiClass,
'test_express_mode', 1);
1008 $questionGui->setQuestionTabs();
1010 $this->
ctrl->forwardCommand($questionGui);
1012 if ($this->testrequest->isset(
'test_express_mode')) {
1013 $this->
ctrl->redirect($this,
'showPage');
1015 $this->
ctrl->redirect($this,
'questions');
1020 if (!in_array(strtolower($this->testrequest->raw(
'baseClass')), [
'iladministrationgui',
'ilrepositorygui'])
1022 $this->tpl->printToStdout();
1028 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"no_permission"),
true);
1029 $target_class = get_class($this->
object) .
"GUI";
1030 $this->
ctrl->setParameterByClass($target_class,
'ref_id', $this->ref_id);
1031 $this->
ctrl->redirectByClass($target_class);
1036 $this->tpl->setOnScreenMessage(
'failure', sprintf(
1037 $this->
lng->txt(
"msg_no_perm_read_item"),
1038 $this->
object->getTitle()
1041 $this->
ctrl->redirectByClass(
'ilrepositorygui');
1047 $this->
object->getType(),
1048 $this->
object->getRefId(),
1049 $this->
object->getId(),
1050 $this->
user->getId()
1060 $this->
ctrl->redirectByClass(
'ilTestExportGUI');
1069 $qid = $this->testrequest->int(
'q_id');
1071 if ($this->
object->checkQuestionParent($qid)) {
1075 throw new ilTestException(
'question id does not relate to parent object!');
1080 if ($this->
object->isRandomTest()) {
1081 $this->
ctrl->redirectByClass(
'ilTestRandomQuestionSetConfigGUI');
1084 $this->
ctrl->redirectByClass(
'ilObjTestGUI',
'questions');
1089 $this->
ctrl->setCmdClass(
'ilTestEvaluationGUI');
1090 $this->
ctrl->setCmd(
'outUserResultsOverview');
1091 $this->tabs_gui->clearTargets();
1098 $this->
ctrl->redirectByClass(
1100 ilRepositoryGUI::class,
1102 ilTestResultsGUI::class,
1103 ilParticipantsTestResultsGUI::class
1112 $this->tabs_manager->getSettingsSubTabs();
1114 if ($this->request_wrapper->has(
'page_type')
1115 && $this->request_wrapper->retrieve(
1117 $this->
refinery->kindlyTo()->string()
1118 ) ===
'introductionpage' 1120 $page_type =
'IntroductionPage';
1122 $page_id = $this->
object->getIntroductionPageId();
1124 $page_type =
'ConcludingRemarksPage';
1126 $page_id = $this->
object->getConcludingRemarksPageId();
1128 $this->
ctrl->saveParameterByClass(ilTestPageGUI::class,
'page_type');
1131 $this->content_style->gui()->addCss($this->tpl, $this->testrequest->getRefId());
1132 $this->tpl->setContent($this->
ctrl->forwardCommand($gui));
1165 $this->
ctrl->forwardCommand($gui);
1175 $this->tpl->loadStandardTemplate();
1186 $this->
ctrl->redirect($this,
"infoScreen");
1191 $this->
ctrl->redirectByClass(
"iltestevaluationgui",
"outEvaluation");
1203 $form = $this->
initImportForm($this->testrequest->raw(
"new_type"));
1204 if ($form->checkInput()) {
1205 $this->
ctrl->setParameter($this,
"new_type", $this->type);
1211 $form->setValuesByPost();
1212 $this->tpl->setContent($form->getHTML());
1218 $defaults = $tst->getAvailableDefaults();
1219 if (count($defaults)) {
1220 foreach ($defaults as $row) {
1221 $options[
"tstdef_" . $row[
"test_defaults_id"]] = [$row[
"name"],
1222 $this->
lng->txt(
"tst_default_settings")];
1233 $new_object->saveToDb();
1236 if ($test_def_id !== 0) {
1237 $test_defaults = $new_object->getTestDefaults($test_def_id);
1238 $new_object->applyDefaults($test_defaults);
1243 $new_object->setTemplate($template_id);
1246 $new_object->saveToDb();
1249 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"object_added"),
true);
1250 $this->
ctrl->setParameter($this,
'ref_id', $new_object->
getRefId());
1251 $this->
ctrl->redirectByClass(
'ilObjTestSettingsMainGUI');
1256 $path = $this->tree->getPathFull($this->
object->getRefID());
1265 if ($_FILES[
"xmldoc"][
"error"] > UPLOAD_ERR_OK) {
1266 $this->
lng->loadLanguageModule(
'file');
1267 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'general_upload_error_occured'));
1268 $this->
ctrl->redirect($this,
'create');
1272 $file = pathinfo($_FILES[
"xmldoc"][
"name"]);
1273 $subdir = basename($file[
"basename"],
"." . $file[
"extension"]);
1275 if (strpos($subdir,
'tst') ===
false) {
1276 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'import_file_not_valid'),
true);
1277 $this->
ctrl->redirect($this,
'create');
1282 $full_path = $basedir .
"/" . $_FILES[
"xmldoc"][
"name"];
1286 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'import_file_not_valid'),
true);
1287 $this->
ctrl->redirect($this,
'create');
1291 $this->archives->unzip($full_path);
1298 if (!is_file($qti_file)) {
1300 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"tst_import_non_ilias_zip"),
true);
1301 $this->
ctrl->redirect($this,
'create');
1305 $qtiParser->startParsing();
1306 $founditems = $qtiParser->getFoundItems();
1310 foreach ($founditems as $item) {
1311 if (strlen($item[
"type"])) {
1318 if (count($founditems) && $complete == 0) {
1321 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_import_non_ilias_files"));
1332 || file_exists($results_file)) {
1337 $importVerificationTpl =
new ilTemplate(
'tpl.tst_import_verification.html',
true,
true,
'Modules/Test');
1341 $QplOrTstID = isset($_POST[
"qpl"]) && (
int) $_POST[
"qpl"] != 0 ? $_POST[
"qpl"] : -1;
1343 $importVerificationTpl->setVariable(
"TEXT_TYPE", $this->
lng->txt(
"question_type"));
1344 $importVerificationTpl->setVariable(
"TEXT_TITLE", $this->
lng->txt(
"question_title"));
1345 $importVerificationTpl->setVariable(
"FOUND_QUESTIONS_INTRODUCTION", $this->
lng->txt(
"tst_import_verify_found_questions"));
1346 $importVerificationTpl->setVariable(
"VERIFICATION_HEADING", $this->
lng->txt(
"import_tst"));
1347 $importVerificationTpl->setVariable(
"FORMACTION", $this->
ctrl->getFormAction($this));
1349 $importVerificationTpl->setVariable(
"QUESTIONPOOL_ID", $QplOrTstID);
1350 $importVerificationTpl->setVariable(
"VALUE_IMPORT", $this->
lng->txt(
"import"));
1351 $importVerificationTpl->setVariable(
"VALUE_CANCEL", $this->
lng->txt(
"cancel"));
1353 $row_class = [
"tblrow1",
"tblrow2"];
1355 foreach ($founditems as $item) {
1356 $importVerificationTpl->setCurrentBlock(
"verification_row");
1357 $importVerificationTpl->setVariable(
"ROW_CLASS", $row_class[$counter++ % 2]);
1358 $importVerificationTpl->setVariable(
"QUESTION_TITLE", $item[
"title"]);
1359 $importVerificationTpl->setVariable(
"QUESTION_IDENT", $item[
"ident"]);
1361 switch ($item[
"type"]) {
1364 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assMultipleChoice"));
1368 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assSingleChoice"));
1372 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assKprimChoice"));
1376 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assLongMenu"));
1380 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assNumeric"));
1384 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assFormulaQuestion"));
1388 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assTextSubset"));
1392 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assClozeTest"));
1396 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assErrorText"));
1400 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assImagemapQuestion"));
1404 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assMatchingQuestion"));
1408 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assOrderingQuestion"));
1412 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assOrderingHorizontal"));
1416 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assTextQuestion"));
1420 $importVerificationTpl->setVariable(
"QUESTION_TYPE", $this->
lng->txt(
"assFileUpload"));
1423 $importVerificationTpl->parseCurrentBlock();
1426 $this->tpl->setContent($importVerificationTpl->get());
1429 public function getTestObject(): ?
ilObjTest 1448 $newObj->setType($this->testrequest->raw(
"new_type"));
1450 $newObj->setTitle(
"dummy");
1452 $newObj->setDescription(
"test import");
1454 $newObj->create(
true);
1456 $newObj->createReference();
1458 $newObj->putInTree($this->testrequest->getRefId());
1460 $newObj->setPermissions($this->testrequest->getRefId());
1462 $newObj->resetMarkSchema();
1466 if (!isset($_POST[
"qpl"]) ||
"-1" === (
string) $_POST[
"qpl"]) {
1467 $questionParentObjId = $newObj->getId();
1469 $questionParentObjId = $_POST[
"qpl"];
1472 $imp =
new ilImport($this->testrequest->getRefId());
1474 $map->addMapping(
'Modules/Test',
'tst',
'new_id', (
string) $newObj->getId());
1480 $newObj->saveToDb();
1485 $imp->importObject($newObj, $fullPath, $fileName,
'tst',
'Modules/Test',
true);
1488 $test_importer->setImport($imp);
1491 $test_importer->init();
1493 $test_importer->importXmlRepresentation(
1508 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"object_imported"),
true);
1509 ilUtil::redirect(
"ilias.php?ref_id=" . $newObj->getRefId() .
"&baseClass=ilObjTestGUI");
1531 $file = explode(
"_", $this->testrequest->raw(
"file_id"));
1532 $fileObj =
new ilObjFile((
int) $file[count($file) - 1],
false);
1533 $fileObj->sendFile();
1552 $pg_obj->
sendParagraph($this->testrequest->raw(
"par_id"), $this->testrequest->raw(
"downloadtitle"));
1581 $this->
ctrl->redirect($this,
"questions");
1594 $parent_ref = $this->tree->getParentId($this->
object->getRefId());
1596 $qpl->setType(
"qpl");
1597 $qpl->setTitle($name);
1598 $qpl->setDescription($description);
1600 $qpl->createReference();
1601 $qpl->putInTree($parent_ref);
1602 $qpl->setPermissions($parent_ref);
1603 $qpl->getObjectProperties()->storePropertyIsOnline($qpl->getObjectProperties()->getPropertyIsOnline()->withOnline());
1605 return $qpl->getRefId();
1621 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1624 $qpl_ref_id = $this->testrequest->raw(
"sel_qpl");
1627 $qpl_mode = $this->testrequest->int(
'usage');
1632 if ($this->testrequest->isset(
'qtype')) {
1634 } elseif ($this->testrequest->isset(
'sel_question_types')) {
1635 $sel_question_types = $this->testrequest->raw(
"sel_question_types");
1638 if (($qpl_mode === 2 && $this->testrequest->raw(
"txt_qpl") ===
'')
1639 || $qpl_mode === 3 && $qpl_ref_id ===
'') {
1640 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"questionpool_not_entered"));
1646 if ($qpl_mode === 2) {
1649 } elseif ($qpl_mode === 1) {
1650 $qpl_ref_id = $this->testrequest->getRefId();
1652 $baselink =
"ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $qpl_ref_id .
"&cmd=createQuestionForTest&test_ref_id=" . $this->testrequest->getRefId() .
"&calling_test=" . $this->testrequest->getRefId() .
"&sel_question_types=" . $sel_question_types;
1654 if ($this->testrequest->isset(
'prev_qid')) {
1655 $baselink .=
'&prev_qid=' . $this->testrequest->raw(
'prev_qid');
1656 } elseif ($this->testrequest->isset(
'position')) {
1657 $baselink .=
'&prev_qid=' . $this->testrequest->raw(
'position');
1660 if ($this->testrequest->raw(
'test_express_mode')) {
1661 $baselink .=
'&test_express_mode=1';
1664 if ($this->testrequest->isset(
'add_quest_cont_edit_mode')) {
1667 "add_quest_cont_edit_mode={$this->testrequest->raw('add_quest_cont_edit_mode')}",
1684 $this->
ctrl->redirect($this,
"questions");
1696 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1702 $questionpools = $this->
object->getAvailableQuestionpools(
false,
false,
false,
true,
false,
"write");
1705 $form->setFormAction($this->
ctrl->getFormAction($this,
"executeCreateQuestion"));
1706 $form->setTitle($this->
lng->txt(
"ass_create_question"));
1708 if ($this->testrequest->isset(
'qtype')) {
1710 } elseif ($this->testrequest->isset(
'sel_question_types')) {
1711 $sel_question_types = $this->testrequest->raw(
"sel_question_types");
1716 $hidden->setValue($sel_question_types);
1717 $form->addItem($hidden);
1724 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_IPE'),
1727 $option_ipe->
setInfo($this->
lng->txt(
'tst_add_quest_cont_edit_mode_IPE_info'));
1728 $ri->addOption($option_ipe);
1731 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_RTE'),
1734 $option_rte->
setInfo($this->
lng->txt(
'tst_add_quest_cont_edit_mode_RTE_info'));
1735 $ri->addOption($option_rte);
1739 $form->addItem($ri,
true);
1743 $form->addItem($hi,
true);
1750 $usage->addOption($no_pool);
1751 $existing_pool =
new ilRadioOption($this->
lng->txt(
"assessment_existing_pool"),
'3');
1752 $usage->addOption($existing_pool);
1753 $new_pool =
new ilRadioOption($this->
lng->txt(
"assessment_new_pool"),
'2');
1754 $usage->addOption($new_pool);
1755 $form->addItem($usage);
1761 foreach ($questionpools as
$key => $p) {
1762 $pools_data[
$key] = $p[
'title'];
1766 $existing_pool->addSubItem($pools);
1769 $this->
lng->loadLanguageModule(
'rbac');
1772 $name->setMaxLength(50);
1773 $new_pool->addSubItem($name);
1775 $form->addCommandButton(
"executeCreateQuestion", $this->
lng->txt(
"submit"));
1776 $form->addCommandButton(
"cancelCreateQuestion", $this->
lng->txt(
"cancel"));
1778 $this->tpl->setVariable(
'ADM_CONTENT', $form->getHTML());
1786 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1790 $removeQuestionIds = (array) $_POST[
"q_id"];
1792 $questions = $this->
object->getQuestionTitlesAndIndexes();
1794 $this->
object->removeQuestions($removeQuestionIds);
1796 $this->
object->saveCompleteStatus($this->test_question_set_config_factory->getQuestionSetConfig());
1798 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"tst_questions_removed"));
1800 if ($this->testrequest->raw(
'test_express_mode')) {
1803 $deleted_tmp = $removeQuestionIds;
1804 $first = array_shift($deleted_tmp);
1805 foreach ($questions as
$key => $value) {
1806 if (!in_array(
$key, $removeQuestionIds)) {
1814 } elseif (
$key == $first) {
1819 $first = array_shift($deleted_tmp);
1824 count($questions) == count($removeQuestionIds) ||
1827 $this->
ctrl->setParameter($this,
'q_id',
'');
1828 $this->
ctrl->redirect($this,
'showPage');
1831 $this->
ctrl->setParameter($this,
'q_id', $return_to);
1832 $this->
ctrl->redirect($this,
"showPage");
1834 $this->
ctrl->setParameter($this,
'q_id',
'');
1835 $this->
ctrl->redirect($this,
'questions');
1848 if ($this->testrequest->raw(
'test_express_mode')) {
1849 $this->
ctrl->setParameter($this,
'q_id', $this->testrequest->raw(
'q_id'));
1850 $this->
ctrl->redirect($this,
"showPage");
1852 $this->
ctrl->redirect($this,
"questions");
1865 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1869 $total = $this->
object->evalTotalPersons();
1872 $question = sprintf($this->
lng->txt(
"tst_remove_questions_and_results"), $total);
1874 if (count($checked_questions) == 1) {
1875 $question = $this->
lng->txt(
"tst_remove_question");
1877 $question = $this->
lng->txt(
"tst_remove_questions");
1882 $cgui->setHeaderText($question);
1884 $this->
ctrl->saveParameter($this,
'test_express_mode');
1885 $this->
ctrl->saveParameter($this,
'q_id');
1887 $cgui->setFormAction($this->
ctrl->getFormAction($this));
1888 $cgui->setCancel($this->
lng->txt(
"cancel"),
"cancelRemoveQuestions");
1889 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmRemoveQuestions");
1890 $removablequestions = $this->
object->getTestQuestions();
1891 if (count($removablequestions)) {
1892 foreach ($removablequestions as
$data) {
1893 if (in_array($data[
"question_id"], $checked_questions)) {
1894 $txt = $data[
"title"] .
" (" . $this->questioninfo->getQuestionTypeName($data[
"question_id"]) .
")";
1895 $txt .=
' [' . $this->
lng->txt(
'question_id_short') .
': ' . $data[
'question_id'] .
']';
1897 if ($data[
"description"]) {
1898 $txt .=
"<div class=\"small\">" . $data[
"description"] .
"</div>";
1901 $cgui->addItem(
"q_id[]", (
string) $data[
"question_id"],
$txt);
1906 $this->tpl->setContent($cgui->getHTML());
1914 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1921 $checked_questions = $this->testrequest->raw(
'q_id');
1923 if (!is_array($checked_questions) && $checked_questions) {
1924 $checked_questions = [$checked_questions];
1927 if (!is_array($checked_questions)) {
1928 $checked_questions = [];
1931 if (count($checked_questions) > 0) {
1933 } elseif (0 === count($checked_questions)) {
1934 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"tst_no_question_selected_for_removal"),
true);
1935 $this->
ctrl->redirect($this,
"questions");
1944 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1948 $selected_questions = $this->testrequest->getQuestionIds();
1949 $selected_question = $this->testrequest->getQuestionId();
1950 if ($selected_questions === [] && $selected_question !== 0) {
1951 $selected_questions = [$selected_question];
1954 if ($selected_questions === []) {
1955 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_selection_for_move'),
true);
1956 $this->
ctrl->redirect($this,
'questions');
1961 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_selected_for_move"),
true);
1962 $this->
ctrl->redirect($this,
'questions');
1970 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1982 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1994 $target_questions = $this->testrequest->getQuestionIds();
1995 $target_question = $this->testrequest->getQuestionId();
1996 if ($target_questions === [] && $target_question !== 0) {
1997 $target_questions = [$target_question];
2000 if (count($target_questions) === 0) {
2001 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_target_selected_for_move'),
true);
2002 $this->
ctrl->redirect($this,
'questions');
2003 } elseif (count($target_questions) > 1) {
2004 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'too_many_targets_selected_for_move'),
true);
2005 $this->
ctrl->redirect($this,
'questions');
2008 $this->
object->moveQuestions(
ilSession::get(
'tst_qst_move_' . $this->
object->getTestId()), $target_questions[0], $insert_mode);
2009 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_questions_moved'),
true);
2011 $this->
ctrl->redirect($this,
'questions');
2021 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
2025 $selected_questions = $this->testrequest->getQuestionIds();
2026 $selected_question = $this->testrequest->getQuestionId();
2027 if ($selected_questions === [] && $selected_question !== 0) {
2028 $selected_questions = [$selected_question];
2031 if (count($selected_questions) === 0) {
2032 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tst_insert_missing_question'),
true);
2033 $this->
ctrl->redirect($this,
'browseForQuestions');
2037 $man_scoring =
false;
2038 foreach ($selected_questions as
$key => $value) {
2039 $this->
object->insertQuestion($this->test_question_set_config_factory->getQuestionSetConfig(), $value);
2043 $this->
object->saveCompleteStatus($this->test_question_set_config_factory->getQuestionSetConfig());
2045 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'manscoring_hint'),
true);
2047 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_questions_inserted'),
true);
2049 $this->
ctrl->redirect($this,
'questions');
2054 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
2061 $subScreenId = [
'createQuestion'];
2063 $this->
ctrl->setParameter($this,
'qtype', $this->testrequest->raw(
'qtype'));
2067 $form->setFormAction($this->
ctrl->getFormAction($this,
"executeCreateQuestion"));
2068 $form->setTitle($this->
lng->txt(
"ass_create_question"));
2071 $questionTypes = $pool->getQuestionTypes(
false,
true,
false);
2075 foreach ($questionTypes as $label =>
$data) {
2076 $options[
$data[
'question_type_id']] = $label;
2080 $form->addItem($si,
true);
2083 $questions = $this->
object->getQuestionTitlesAndIndexes();
2086 $options = [
'0' => $this->
lng->txt(
'first')];
2087 foreach ($questions as
$key => $title) {
2088 $options[
$key] = $this->
lng->txt(
'behind') .
' ' . $title .
' [' . $this->
lng->txt(
'question_id_short') .
': ' .
$key .
']';
2090 $si->setOptions($options);
2091 $si->setValue($this->testrequest->raw(
'q_id'));
2092 $form->addItem($si,
true);
2097 $subScreenId[] =
'editMode';
2102 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_IPE'),
2105 $option_ipe->
setInfo($this->
lng->txt(
'tst_add_quest_cont_edit_mode_IPE_info'));
2106 $ri->addOption($option_ipe);
2109 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_RTE'),
2112 $option_rte->
setInfo($this->
lng->txt(
'tst_add_quest_cont_edit_mode_RTE_info'));
2113 $ri->addOption($option_rte);
2117 $form->addItem($ri,
true);
2121 $form->addItem($hi,
true);
2124 $subScreenId[] =
'poolSelect';
2130 $usage->addOption($no_pool);
2131 $existing_pool =
new ilRadioOption($this->
lng->txt(
"assessment_existing_pool"),
'3');
2132 $usage->addOption($existing_pool);
2133 $new_pool =
new ilRadioOption($this->
lng->txt(
"assessment_new_pool"),
'2');
2134 $usage->addOption($new_pool);
2135 $form->addItem($usage);
2141 foreach ($questionpools as
$key => $p) {
2142 $pools_data[
$key] = $p[
'title'];
2146 $existing_pool->addSubItem($pools);
2150 $name->setMaxLength(50);
2151 $new_pool->addSubItem($name);
2153 $form->addCommandButton(
"executeCreateQuestion", $this->
lng->txt(
"create"));
2154 $form->addCommandButton(
"questions", $this->
lng->txt(
"cancel"));
2156 $this->tabs_gui->activateTab(
'assQuestions');
2157 $this->
help->setScreenId(
'assQuestions');
2158 $this->
help->setSubScreenId(implode(
'_', $subScreenId));
2160 return $this->tpl->setContent($form->getHTML());
2165 $this->
ctrl->setParameter($this,
'test_express_mode',
'');
2167 if (!$this->
access->checkAccess(
"write",
"", $this->ref_id)) {
2169 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"cannot_edit_test"),
true);
2170 $this->
ctrl->redirect($this,
"infoScreen");
2177 $this->
ctrl->setParameter($this,
'q_id',
'');
2179 if ($this->testrequest->raw(
"eqid") && $this->testrequest->raw(
"eqpl")) {
2181 . $this->testrequest->raw(
"eqpl") .
"&cmd=editQuestionForTest&calling_test=" 2182 . $this->testrequest->getRefId() .
"&q_id=" . $this->testrequest->raw(
"eqid"));
2185 if ($this->testrequest->raw(
"up") > 0) {
2186 $this->
object->questionMoveUp($this->testrequest->raw(
"up"));
2188 if ($this->testrequest->raw(
"down") > 0) {
2189 $this->
object->questionMoveDown($this->testrequest->raw(
"down"));
2192 if ($this->testrequest->raw(
"add")) {
2193 $selected_array = [];
2194 array_push($selected_array, $this->testrequest->raw(
"add"));
2195 $total = $this->
object->evalTotalPersons();
2198 $this->tpl->setOnScreenMessage(
'info', sprintf($this->
lng->txt(
"tst_insert_questions_and_results"), $total));
2200 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"tst_insert_questions"));
2204 $this->insertQuestions($selected_array);
2208 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_as_tst_questions.html",
"Modules/Test");
2210 $has_started_test_runs = $this->
object->evalTotalPersons() !== 0;
2211 if ($this->
access->checkAccess(
"write",
"", $this->ref_id)) {
2212 if ($has_started_test_runs) {
2213 $link = $this->ui_factory->link()->standard(
2214 $this->
lng->txt(
"test_has_datasets_warning_page_view_link"),
2215 $this->
ctrl->getLinkTargetByClass([
'ilTestResultsGUI',
'ilParticipantsTestResultsGUI'])
2218 $message = $this->
lng->txt(
"test_has_datasets_warning_page_view");
2219 $massage_box = $this->ui_factory->messageBox()->info(
$message)->withLinks([$link]);
2220 $this->tpl->setCurrentBlock(
'mess');
2221 $this->tpl->setVariable(
2223 $this->ui_renderer->render($massage_box)
2225 $this->tpl->parseCurrentBlock();
2227 $this->
toolbar->addButton($this->
lng->txt(
"ass_create_question"), $this->
ctrl->getLinkTarget($this,
"addQuestion"));
2228 $this->
toolbar->addSeparator();
2236 $this->
object->getRefId(),
2244 $table_gui->setPositionInsertCommandsEnabled(
2250 $table_gui->setQuestionPositioningEnabled(!$has_started_test_runs);
2251 $table_gui->setQuestionManagingEnabled(!$has_started_test_runs);
2252 $table_gui->setObligatoryQuestionsHandlingEnabled($this->
object->areObligationsEnabled());
2254 $table_gui->setTotalPoints($this->
object->getFixedQuestionSetTotalPoints());
2258 $table_gui->setData($this->
object->getTestQuestions());
2260 $this->tpl->setCurrentBlock(
"adm_content");
2261 $this->tpl->setVariable(
"ACTION_QUESTION_FORM", $this->
ctrl->getFormAction($this));
2262 $this->tpl->setVariable(
'QUESTIONBROWSER', $table_gui->getHTML());
2263 $this->tpl->parseCurrentBlock();
2268 $this->
ctrl->setParameterByClass(
2269 ilTestQuestionBrowserTableGUI::class,
2273 $this->
ctrl->setParameterByClass(
2274 ilTestQuestionBrowserTableGUI::class,
2280 $this->
lng->txt(
"tst_browse_for_qpl_questions"),
2281 $this->
ctrl->getLinkTargetByClass(
2282 ilTestQuestionBrowserTableGUI::class,
2287 $this->
ctrl->setParameterByClass(
2288 ilTestQuestionBrowserTableGUI::class,
2294 $this->
lng->txt(
"tst_browse_for_tst_questions"),
2295 $this->
ctrl->getLinkTargetByClass(
2296 ilTestQuestionBrowserTableGUI::class,
2315 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
2321 $table_gui->setTestObject($this->
object);
2323 $table_gui->setData(
$log);
2324 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
2330 $form->setTarget(
"_top");
2331 $n_type = $this->testrequest->raw(
"new_type");
2332 $this->
ctrl->setParameter($this,
"new_type", $n_type);
2333 $form->setFormAction($this->
ctrl->getFormAction($this));
2334 $form->setTitle($this->
lng->txt(
"import_tst"));
2337 $fi->setRequired(
true);
2338 $form->addItem($fi);
2340 $questionpools = $tst->getAvailableQuestionpools(
true,
false,
true,
true);
2341 if (count($questionpools)) {
2342 $options = [
"-1" => $this->
lng->txt(
"dont_use_questionpool")];
2343 foreach ($questionpools as
$key => $value) {
2344 $options[
$key] = $value[
"title"];
2348 $pool->
setInfo($this->
lng->txt(
'select_question_pool_info'));
2349 $pool->setOptions($options);
2350 $form->addItem($pool);
2353 $form->addCommandButton(
"importFile", $this->
lng->txt(
"import"));
2354 $form->addCommandButton(
"cancel", $this->
lng->txt(
"cancel"));
2366 $command = $_POST[
"command"];
2367 if (strlen($command)) {
2368 $method = $command .
"Object";
2369 if (method_exists($this, $method)) {
2374 $this->
ctrl->redirect($this,
"participants");
2386 if (!$this->
access->checkAccess(
"write",
"", $this->ref_id)) {
2388 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"cannot_edit_test"),
true);
2389 $this->
ctrl->redirect($this,
"infoScreen");
2393 $template =
new ilTemplate(
"tpl.il_as_tst_print_test_confirm.html",
true,
true,
"Modules/Test");
2395 $template->setCurrentBlock(
"navigation_buttons");
2396 $template->setVariable(
"BUTTON_PRINT", $this->
lng->txt(
"print"));
2397 $template->parseCurrentBlock();
2401 $print_date = mktime((
int) date(
"H"), (
int) date(
"i"), (
int) date(
"s"), (
int) date(
"m"), (
int) date(
"d"), (
int) date(
"Y"));
2405 $questionHeaderBlockBuilder->setHeaderMode($this->
object->getTitleOutput());
2407 foreach ($this->
object->questions as $question) {
2408 $template->setCurrentBlock(
"question");
2409 $question_gui = $this->
object->createQuestionGUI(
"", $question);
2412 $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitleForHTMLOutput());
2413 $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
2414 $questionHeaderBlockBuilder->setQuestionPosition($counter);
2415 $template->setVariable(
"QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
2417 $template->setVariable(
"TXT_QUESTION_ID", $this->
lng->txt(
'question_id_short'));
2418 $template->setVariable(
"QUESTION_ID", $question_gui->object->getId());
2419 $result_output = $question_gui->getSolutionOutput(0, null,
false,
true,
false,
false);
2420 $template->setVariable(
"SOLUTION_OUTPUT", $result_output);
2421 $template->parseCurrentBlock(
"question");
2423 $max_points += $question_gui->object->getMaximumPoints();
2429 $template->setVariable(
2433 $template->setVariable(
2434 "TXT_MAXIMUM_POINTS",
2438 $this->tpl->setVariable(
"PRINT_CONTENT", $template->get());
2450 if (!$this->
access->checkAccess(
"write",
"", $this->ref_id)) {
2452 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"cannot_edit_test"),
true);
2453 $this->
ctrl->redirect($this,
"infoScreen");
2456 $template =
new ilTemplate(
"tpl.il_as_tst_print_test_confirm.html",
true,
true,
"Modules/Test");
2463 $questionHeaderBlockBuilder->setHeaderMode($this->
object->getTitleOutput());
2465 foreach ($this->
object->questions as $question) {
2466 $template->setCurrentBlock(
"question");
2467 $question_gui = $this->
object->createQuestionGUI(
"", $question);
2470 $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitleForHTMLOutput());
2471 $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
2472 $questionHeaderBlockBuilder->setQuestionPosition($counter);
2473 $template->setVariable(
"QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
2475 $template->setVariable(
"SOLUTION_OUTPUT", $question_gui->getPreview(
false));
2476 $template->parseCurrentBlock(
"question");
2478 $max_points += $question_gui->object->getMaximumPoints();
2482 $template->setVariable(
2489 $template->setVariable(
2494 $template->setVariable(
2495 "TXT_MAXIMUM_POINTS",
2500 $template->setCurrentBlock(
"navigation_buttons");
2501 $template->setVariable(
"BUTTON_PRINT", $this->
lng->txt(
"print"));
2502 $template->parseCurrentBlock();
2504 $this->tpl->setVariable(
"PRINT_CONTENT", $template->get());
2512 if (!$this->
access->checkAccess(
"write",
"", $this->ref_id)) {
2513 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"cannot_edit_test"),
true);
2514 $this->
ctrl->redirect($this,
"infoScreen");
2519 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this,
'addDefaults'));
2520 $this->
toolbar->addFormButton($this->
lng->txt(
'add'),
'addDefaults');
2523 $defaults = $this->
object->getAvailableDefaults();
2524 $table->setData($defaults);
2525 $this->tpl->setContent($table->getHTML());
2533 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
2537 if (isset($_POST[
'chb_defaults']) && is_array($_POST[
'chb_defaults']) && count($_POST[
'chb_defaults'])) {
2538 foreach ($_POST[
'chb_defaults'] as $test_default_id) {
2539 $this->
object->deleteDefaults($test_default_id);
2542 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
2552 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
2565 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
2570 if (!isset($_POST[
'chb_defaults']) || !is_array($_POST[
"chb_defaults"]) || 1 !== count($_POST[
"chb_defaults"])) {
2571 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"tst_defaults_apply_select_one"));
2580 if ($this->
object->evalTotalPersons() > 0) {
2581 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"tst_defaults_apply_not_possible"));
2588 $defaults = $this->
object->getTestDefaults((
int) $_POST[
"chb_defaults"][0]);
2590 $defaults = $this->
object->getTestDefaults((
int) $_POST[
"confirmed_defaults_id"]);
2593 $defaultSettings = unserialize($defaults[
"defaults"]);
2595 if (isset($defaultSettings[
'isRandomTest'])) {
2596 if ($defaultSettings[
'isRandomTest']) {
2603 } elseif (isset($defaultSettings[
'questionSetType'])) {
2604 $newQuestionSetType = $defaultSettings[
'questionSetType'];
2606 $oldQuestionSetType = $this->
object->getQuestionSetType();
2607 $questionSetTypeSettingSwitched = ($oldQuestionSetType != $newQuestionSetType);
2609 $oldQuestionSetConfig = $this->test_question_set_config_factory->getQuestionSetConfig();
2612 case !$questionSetTypeSettingSwitched:
2613 case !$oldQuestionSetConfig->doesQuestionSetRelatedDataExist():
2622 $confirmation->setFormAction($this->
ctrl->getFormAction($this));
2623 $confirmation->setCancel($this->
lng->txt(
'cancel'),
'defaults');
2624 $confirmation->setConfirm($this->
lng->txt(
'confirm'),
'confirmedApplyDefaults');
2626 $confirmation->setOldQuestionSetType($this->
object->getQuestionSetType());
2627 $confirmation->setNewQuestionSetType($newQuestionSetType);
2628 $confirmation->setQuestionLossInfoEnabled(
false);
2629 $confirmation->build();
2631 $confirmation->addHiddenItem(
"confirmed_defaults_id", $_POST[
"chb_defaults"][0]);
2633 $this->tpl->setContent($this->
ctrl->getHTML($confirmation));
2638 if ($questionSetTypeSettingSwitched && !$this->
object->getOfflineStatus()) {
2639 $this->
object->setOfflineStatus(
true);
2641 $info = $this->
lng->txt(
"tst_set_offline_due_to_switched_question_set_type_setting");
2643 $this->tpl->setOnScreenMessage(
'info', $info,
true);
2646 $this->
object->applyDefaults($defaults);
2648 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"tst_defaults_applied"),
true);
2650 if ($questionSetTypeSettingSwitched && $oldQuestionSetConfig->doesQuestionSetRelatedDataExist()) {
2651 $oldQuestionSetConfig->removeQuestionSetRelatedData();
2654 $this->
ctrl->redirect($this,
'defaults');
2662 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
2666 if (strlen($_POST[
"name"]) > 0) {
2667 $this->
object->addDefaults($_POST[
'name']);
2669 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"tst_defaults_enter_name"));
2676 if (in_array($this->
ctrl->getCmdClass(), self::$infoScreenChildClasses)) {
2690 $this->
ctrl->setCmd(
"showSummary");
2691 $this->
ctrl->setCmdClass(
"ilinfoscreengui");
2697 $this->
ctrl->setCmd(
"showSummary");
2698 $this->
ctrl->setCmdClass(
"ilinfoscreengui");
2699 $this->
infoScreen($this->testrequest->raw(
'lock') ??
'');
2707 if (!$this->
access->checkAccess(
"visible",
"", $this->ref_id) &&
2708 !$this->
access->checkAccess(
"read",
"", $this->ref_id)) {
2713 if ($this->
object->getMainSettings()->getAdditionalSettings()->getHideInfoTab()) {
2720 if ($this->
access->checkAccess(
"read",
"", $this->ref_id)) {
2726 return $this->
ctrl->forwardCommand($info);
2731 $this->test_player_factory->getPlayerGUI(),
2732 $this->test_question_set_config_factory->getQuestionSetConfig(),
2733 $this->test_session_factory->getSession(),
2746 $toolbar->setSessionLockString($session_lock);
2750 $info->enablePrivateNotes();
2752 $info->addSection($this->lng->txt(
"tst_general_properties"));
2754 $this->lng->txt(
"author"),
2756 $this->
object->getAuthor(),
2761 $this->lng->txt(
"title"),
2763 $this->
object->getTitle(),
2768 if ($this->type !==
'tst') {
2769 $info->hideFurtherSections(
false);
2772 $info->addSection($this->lng->txt(
"tst_sequence_properties"));
2774 $this->lng->txt(
"tst_sequence"),
2776 $this->
object->getMainSettings()->getParticipantFunctionalitySettings()->getPostponedQuestionsMoveToEnd()
2777 ?
"tst_sequence_postpone" :
"tst_sequence_fixed" 2781 $info->addSection($this->lng->txt(
"tst_heading_scoring"));
2782 $info->addProperty($this->lng->txt(
"tst_text_count_system"), $this->lng->txt(($this->
object->getCountSystem() ==
COUNT_PARTIAL_SOLUTIONS) ?
"tst_count_partial_solutions" :
"tst_count_correct_solutions"));
2783 if ($this->
object->isRandomTest()) {
2784 $info->addProperty($this->lng->txt(
"tst_pass_scoring"), $this->lng->txt(($this->
object->getPassScoring() ==
SCORE_BEST_PASS) ?
"tst_pass_best_pass" :
"tst_pass_last_pass"));
2787 $info->addSection($this->lng->txt(
"tst_score_reporting"));
2788 $score_reporting_text =
"";
2789 switch ($this->
object->getScoreReporting()) {
2791 $score_reporting_text = $this->lng->txt(
"tst_report_after_test");
2794 $score_reporting_text = $this->lng->txt(
"tst_report_after_first_question");
2797 $score_reporting_text = $this->lng->txt(
"tst_report_after_date");
2800 $score_reporting_text = $this->lng->txt(
"tst_report_after_passed");
2803 $score_reporting_text = $this->lng->txt(
"tst_report_never");
2806 $info->addProperty($this->lng->txt(
"tst_score_reporting"), $score_reporting_text);
2807 $reporting_date = $this->getTestObject()
2808 ->getScoreSettings()
2809 ->getResultSummarySettings()
2810 ->getReportingDate();
2811 if ($reporting_date !== null) {
2813 $this->lng->txt(
'tst_score_reporting_date'),
2818 $reporting_date->getTimezone()->getName()
2823 $info->addSection($this->lng->txt(
"tst_session_settings"));
2824 $info->addProperty($this->lng->txt(
"tst_nr_of_tries"), $this->
object->getNrOfTries() === 0 ? $this->lng->txt(
"unlimited") : (string) $this->
object->getNrOfTries());
2825 if ($this->
object->getNrOfTries() != 1) {
2827 $this->lng->txt(
'tst_nr_of_tries_of_user'),
2828 ($this->test_session_factory->getSession()->getPass() === 0) ?
2829 $this->lng->txt(
"tst_no_tries") : (string) $this->test_session_factory->getSession()->getPass()
2833 if ($this->
object->getEnableProcessingTime()) {
2834 $info->addProperty($this->lng->txt(
"tst_processing_time"), $this->
object->getProcessingTime());
2837 $starting_time = $this->
object->getStartingTime();
2838 if ($this->
object->isStartingTimeEnabled() && $starting_time !== 0) {
2841 $ending_time = $this->
object->getEndingTime();
2842 if ($this->
object->isEndingTimeEnabled() && $ending_time != 0) {
2845 $info->addMetaDataSections($this->
object->getId(), 0, $this->
object->getType());
2847 $this->ctrl->forwardCommand($info);
2853 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
2862 $this->
ctrl->redirect($this,
'infoScreen');
2867 switch ($this->
ctrl->getCmd()) {
2870 case "redirectToInfoScreen":
2877 case "outCorrectSolution":
2879 case "showAnswersOfUser":
2880 case "outUserResultsOverview":
2881 case "backFromSummary":
2882 case "show_answers":
2885 case "outTestSummary":
2886 case "outQuestionSummary":
2887 case "gotoQuestion":
2888 case "selectImagemapRegion":
2889 case "confirmSubmitAnswers":
2890 case "finalSubmission":
2892 case "outUserPassDetails":
2893 case "checkPassword":
2895 $this->
object->getTitle(),
2898 $this->testrequest->getRefId()
2902 case "evalAllUsers":
2903 case "evalUserDetail":
2904 $this->
locator->addItem($this->
object->getTitle(), $this->
ctrl->getLinkTarget($this,
"eval_stat"),
"", $this->testrequest->getRefId());
2911 case "importVerifiedFile":
2912 case "cancelImport":
2932 $output_gui = $guiFactory->create($this->
object);
2934 $output_gui->certificateEditor();
2944 $this->
help->setScreenIdComponent(
"tst");
2948 $this->
getTabsManager()->setParentBackLabel($this->
lng->txt(
'back_to_objective_container'));
2957 parent::setTitleAndDescription();
2960 $this->tpl->setTitleIcon($icon, $this->
lng->txt(
'obj_' . $this->object->getType()));
2963 public static function accessViolationRedirect()
2967 $main_tpl = $DIC->ui()->mainTemplate();
2969 $main_tpl->setOnScreenMessage(
'failure', $DIC->language()->txt(
"no_permission"),
true);
2982 $main_tpl = $DIC->ui()->mainTemplate();
2983 $ilAccess = $DIC[
'ilAccess'];
2987 if ($ilAccess->checkAccess(
"read",
"", (
int) $target) || $ilAccess->checkAccess(
"visible",
"", (
int) $target)) {
2988 $DIC->ctrl()->setParameterByClass(
'ilObjTestGUI',
'ref_id', (
int) $target);
2991 $main_tpl->setOnScreenMessage(
'info', sprintf(
2992 $lng->
txt(
"msg_no_perm_read_item"),
3003 if ($this->create_question_mode) {
3006 $this->
ctrl->saveParameter($this,
'q_mode');
3008 $this->
ctrl->setParameterByClass(
'iltestexpresspageobjectgui',
'test_express_mode', 1);
3009 $this->
ctrl->setParameter($this,
'test_express_mode', 1);
3010 $this->
ctrl->setParameterByClass(
'iltestexpresspageobjectgui',
'q_id', $this->testrequest->raw(
'q_id'));
3011 $this->
ctrl->setParameter($this,
'q_id', $this->testrequest->raw(
'q_id'));
3012 $this->
toolbar->setFormAction($this->
ctrl->getFormActionByClass(
'iltestexpresspageobjectgui',
'edit'));
3014 if ($this->
object->evalTotalPersons() == 0) {
3015 $this->
toolbar->addFormButton($this->
lng->txt(
"ass_create_question"),
"addQuestion");
3017 $this->
toolbar->addSeparator();
3021 $show_separator =
true;
3024 $questions = $this->
object->getQuestionTitlesAndIndexes();
3028 foreach ($questions as
$id => $label) {
3029 $options[
$id] = $label .
' [' . $this->
lng->txt(
'question_id_short') .
': ' .
$id .
']';
3032 $optionKeys = array_keys($options);
3035 $options[] = $this->
lng->txt(
'none');
3038 if (count($questions)) {
3039 if (isset($show_separator) && $show_separator) {
3040 $this->
toolbar->addSeparator();
3043 $btn = $this->
ui[0]->linkButton()->standard(
$lng->
txt(
"test_prev_question"), $this->
ctrl->getLinkTargetByClass(
'iltestexpresspageobjectgui',
'prevQuestion'));
3044 $this->
toolbar->addComponent($btn);
3046 if (count($options) <= 1 || $optionKeys[0] == $qid) {
3047 $btn->setDisabled(
true);
3050 $btn = $this->
ui[0]->linkButton()->standard(
$lng->
txt(
"test_next_question"), $this->
ctrl->getLinkTargetByClass(
'iltestexpresspageobjectgui',
'nextQuestion'));
3051 $this->
toolbar->addComponent($btn);
3053 if (count($options) <= 1 || $optionKeys[count($optionKeys) - 1] == $qid) {
3054 $btn->setDisabled(
true);
3058 if (count($questions) > 1) {
3059 $this->
toolbar->addSeparator();
3062 $si->setOptions($options);
3065 $si->setValue($qid);
3068 $this->
toolbar->addInputItem($si,
true);
3071 $total = $this->
object->evalTotalPersons();
3073 if (count($questions) && !$total) {
3074 $this->
ctrl->setParameter($this,
'q_id', $this->testrequest->raw(
'q_id'));
3075 $this->
toolbar->addSeparator();
3076 $this->
toolbar->addButton($this->
lng->txt(
"test_delete_page"), $this->
ctrl->getLinkTarget($this,
"removeQuestions"));
3079 if (count($questions) > 1 && !$total) {
3080 $this->
toolbar->addSeparator();
3081 $this->
toolbar->addButton($this->
lng->txt(
"test_move_page"), $this->
ctrl->getLinkTarget($this,
"movePageForm"));
3084 $online_access =
false;
3085 if ($this->
object->getFixedParticipants()) {
3089 if (!$this->
object->getOfflineStatus() && $this->
object->isComplete($this->test_question_set_config_factory->getQuestionSetConfig())) {
3090 if ((!$this->
object->getFixedParticipants() || $online_access) && $this->
access->checkAccess(
"read",
"", $this->ref_id)) {
3091 $testSession = $this->test_session_factory->getSession();
3093 $executable = $this->
object->isExecutable($testSession, $this->
user->getId(),
true);
3095 if ($executable[
"executable"]) {
3097 $player_instance = $player_factory->getPlayerGUI();
3099 $this->
toolbar->addSeparator();
3100 if ($testSession->getActiveId() > 0) {
3101 $this->
toolbar->addButton($this->
lng->txt(
'tst_resume_test'), $this->
ctrl->getLinkTarget($player_instance,
'resumePlayer'));
3103 $this->
toolbar->addButton($this->
lng->txt(
'tst_start_test'), $this->
ctrl->getLinkTarget($player_instance,
'startTest'));
3112 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
3116 $this->
copyQuestionsToPool($this->testrequest->raw(
'q_id'), $this->testrequest->raw(
'sel_qpl'));
3117 $this->
ctrl->redirect($this,
'questions');
3127 foreach ($question_ids as $q_id) {
3129 $new_ids[$q_id] = $new_id;
3133 $result->ids = $new_ids;
3134 $result->qpoolid = $qpl_id;
3143 $new_title = $question_gui->object->getTitle();
3144 if ($this->questioninfo->questionTitleExistsInPool($target_parent_id, $question_gui->object->getTitle())) {
3146 while ($this->questioninfo->questionTitleExistsInPool($target_parent_id, $question_gui->object->getTitle() .
" ($counter)")) {
3149 $new_title = $question_gui->object->getTitle() .
" ($counter)";
3152 return $question_gui->object->createNewOriginalFromThisDuplicate($target_parent_id, $new_title);
3160 if ($this->testrequest->int(
'sel_qpl') === 0) {
3161 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"questionpool_not_selected"));
3166 $qpl_id = $this->obj_data_cache->lookupObjId($this->testrequest->int(
'sel_qpl'));
3168 $question_ids = $this->testrequest->getQuestionIds();
3169 $question_id = $this->testrequest->getQuestionId();
3170 if ($question_ids === [] && $question_id !== 0) {
3171 $question_ids = [$question_id];
3175 foreach ($result->ids as $oldId => $newId) {
3178 $original_question_id = $questionInstance->getOriginalId();
3179 if ($original_question_id !== null
3180 && $this->questioninfo->originalQuestionExists($original_question_id)) {
3182 $oldOriginal->delete($oldOriginal->getId());
3187 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_qst_added_to_pool_' . (count($result->ids) > 1 ?
'p' :
's')),
true);
3188 $this->
ctrl->redirect($this,
'questions');
3196 $title->setRequired(
true);
3197 $form->addItem($title);
3200 $form->addItem($description);
3202 $form->addCommandButton(
'createQuestionPoolAndCopy', $this->
lng->txt(
'create'));
3204 if ($this->testrequest->isset(
'q_id') && is_array($this->testrequest->raw(
'q_id'))) {
3205 foreach ($this->testrequest->raw(
'q_id') as
$id) {
3207 $hidden->setValue(
$id);
3208 $form->addItem($hidden);
3217 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
3226 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
3232 'copyAndLinkToQuestionpool' == $this->
ctrl->getCmd() &&
3233 (!$this->testrequest->isset(
'q_id') || !is_array($this->testrequest->raw(
'q_id')))
3235 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_no_question_selected_for_moving_to_qpl'),
true);
3236 $this->
ctrl->redirect($this,
'questions');
3239 foreach ($this->testrequest->getQuestionIds(
'q_id') as $q_id) {
3240 if (!$this->questioninfo->originalQuestionExists($q_id)) {
3246 if (
$type !==
'tst') {
3247 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_link_only_unassigned'),
true);
3248 $this->
ctrl->redirect($this,
'questions');
3258 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())
3263 if ($this->testrequest->raw(
'title')) {
3264 $title = $this->testrequest->raw(
'title');
3266 $title = $this->testrequest->raw(
'txt_qpl');
3270 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"questionpool_not_entered"));
3276 $_REQUEST[
'sel_qpl'] =
$ref_id;
3296 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
3303 $questionpools = $this->
object->getAvailableQuestionpools(
3312 if (count($questionpools) == 0) {
3318 case 'copyQuestionsToPool':
3321 case 'copyAndLinkQuestionsToPool':
3323 $hidden->setValue(
'1');
3324 $form->addItem($hidden);
3329 $this->tpl->setContent($form->getHTML());
3335 $form->setFormAction($this->
ctrl->getFormAction($this));
3336 $form->addCommandButton($cmd, $this->
lng->txt(
'submit'));
3337 $form->addCommandButton(
'cancelCreateQuestion', $this->
lng->txt(
'cancel'));
3339 if (count($questionpools) == 0) {
3340 $form->setTitle($this->
lng->txt(
"tst_enter_questionpool"));
3343 $title->setRequired(
true);
3344 $form->addItem($title);
3347 $form->addItem($description);
3349 $form->
setTitle($this->
lng->txt(
"tst_select_questionpool"));
3352 '' => $this->
lng->txt(
'please_select')
3355 foreach ($questionpools as
$key => $value) {
3356 $selectOptions[
$key] = $value[
"title"];
3361 $select->setOptions($selectOptions);
3363 $form->addItem($select);
3366 if ($this->testrequest->isset(
'q_id') && is_array($this->testrequest->raw(
'q_id'))) {
3367 foreach ($this->testrequest->raw(
'q_id') as
$id) {
3369 $hidden->setValue(
$id);
3370 $form->addItem($hidden);
3379 if (!$this->
access->checkAccess(
"write",
"", $this->ref_id)) {
3381 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"cannot_edit_test"),
true);
3382 $this->
ctrl->redirect($this,
"infoScreen");
3385 $order = $this->testrequest->raw(
'order') ?? [];
3386 $obligatory_questions = $this->testrequest->raw(
'obligatory') ?? [];
3388 foreach ($order as $question_id => $order) {
3389 $orders[$question_id] = $order;
3392 if ($this->
object->areObligationsEnabled()) {
3393 foreach ($obligatory_questions as $question_id => $obligation) {
3395 unset($obligatory_questions[$question_id]);
3400 $this->
object->setQuestionOrderAndObligations(
3402 $obligatory_questions
3405 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
3406 $this->
ctrl->redirect($this,
'questions');
3414 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
3419 $form->setFormAction($this->
ctrl->getFormAction($this,
"movePage"));
3420 $form->setTitle($this->
lng->txt(
"test_move_page"));
3423 $old_pos->setValue($this->testrequest->raw(
'q_id'));
3424 $form->addItem($old_pos);
3426 $questions = $this->
object->getQuestionTitlesAndIndexes();
3427 if (!is_array($questions)) {
3431 foreach ($questions as $k =>
$q) {
3432 if ($k == $this->testrequest->raw(
'q_id')) {
3433 unset($questions[$k]);
3436 $questions[$k] = $this->
lng->txt(
'behind') .
' ' .
$q;
3440 0 => $this->
lng->txt(
'first')
3442 foreach ($questions as $k =>
$q) {
3443 $options[$k] =
$q .
' [' . $this->
lng->txt(
'question_id_short') .
': ' . $k .
']';
3448 $form->addItem($pos);
3450 $form->addCommandButton(
"movePage", $this->
lng->txt(
"submit"));
3451 $form->addCommandButton(
"showPage", $this->
lng->txt(
"cancel"));
3453 return $this->tpl->setContent($form->getHTML());
3458 if (!$this->
access->checkAccess(
"write",
"", $this->ref_id)) {
3460 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"cannot_edit_test"),
true);
3461 $this->
ctrl->redirect($this,
"infoScreen");
3464 $this->
object->moveQuestionAfter($this->testrequest->raw(
'q_id'), $this->testrequest->raw(
'position_after'));
3470 $this->
ctrl->setParameterByClass(
'iltestexpresspageobjectgui',
'q_id', $this->testrequest->raw(
'q_id'));
3471 $this->
ctrl->redirectByClass(
'iltestexpresspageobjectgui',
'showPage');
3476 if (!$this->
access->checkAccess(
"write",
"", $this->ref_id)) {
3478 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"cannot_edit_test"),
true);
3479 $this->
ctrl->redirect($this,
"infoScreen");
3482 if ($this->testrequest->hasQuestionId() && !is_array($this->testrequest->raw(
'q_id'))) {
3483 $ids = [$this->testrequest->getQuestionId()];
3484 } elseif ($this->testrequest->getQuestionIds()) {
3485 $ids = $this->testrequest->getQuestionIds();
3487 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'copy_no_questions_selected'),
true);
3488 $this->
ctrl->redirect($this,
'questions');
3493 $questionTitles = $this->
object->getQuestionTitles();
3495 foreach ($ids as
$id) {
3498 $title = $question->object->getTitle();
3500 while (in_array($title .
' (' . $i .
')', $questionTitles)) {
3504 $title .=
' (' . $i .
')';
3506 $questionTitles[] = $title;
3508 $new_id = $question->object->duplicate(
false, $title);
3511 $clone->object->setObjId($this->
object->getId());
3512 $clone->object->saveToDb();
3514 $this->
object->insertQuestion($this->test_question_set_config_factory->getQuestionSetConfig(), $new_id,
true);
3520 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'copy_questions_success'),
true);
3522 $this->
ctrl->redirect($this,
'questions');
3531 $path = $this->tree->getPathFull($this->ref_id);
3533 while ($parent = array_pop(
$path)) {
3534 if ($parent[
'type'] ===
'crs') {
3535 $container_ref_id = $parent[
'ref_id'];
3542 $this->objective_oriented_container->setObjId($container_obj_id);
3543 $this->objective_oriented_container->setRefId($container_ref_id);
3562 $this->content_style,
const MATCHING_QUESTION_IDENTIFIER
initImportForm(string $new_type)
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER
setTestOBJ(ilObjTest $test_object)
const ADDITIONAL_CONTENT_EDITING_MODE_IPE
ilObjectDefinition $obj_definition
copyQuestionsToPoolObject()
getQuestionpoolCreationForm()
static get(string $a_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
populateQuestionBrowserToolbarButtons(ilToolbarGUI $toolbar, string $context)
static _goto($target)
Redirect script to call a test with the test reference id.
setTestAccess(ilTestAccess $testAccess)
Readable part of repository interface to ilComponentDataDB.
const SETTINGS_SUBTAB_ID_EDIT_CONCLUSION_PAGE
copyToQuestionpoolObject()
ilTestQuestionSetConfigFactory $test_question_set_config_factory
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
ilTestSessionFactory $test_session_factory
userResultsGatewayObject()
const ERROR_TEXT_IDENTIFIER
static isQuestionObligationPossible(int $question_id)
createQuestionObject()
Called when a new question should be created from a test.
getTabs()
adds tabs to tab gui object
confirmedApplyDefaultsObject()
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
Export User Interface Class.
static _getLog(int $ts_from, int $ts_to, int $test_id, bool $test_only=false)
Retrieve assessment log datasets from the database.
trackTestObjectReadEvent()
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
reviewobject()
Review tab to create a print of all questions without points and solutions.
fullscreenObject()
show fullscreen view
GUI class for the workflow of copying objects.
const QUESTION_SET_TYPE_RANDOM
uploadObject($redirect=true)
display status information or report errors messages in case of error
Class ilTestPersonalDefaultSettingsTableGUI.
__construct($data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getAvailableQuestionpools( $use_object_id=false, $equal_points=false, $could_be_offline=false, $showPath=false, $with_questioncount=false, $permission='read', $usr_id='')
Returns the available question pools for the active user.
const SCORE_REPORTING_AFTER_PASSED
prepareOutput(bool $show_sub_objects=true)
cancelCreateQuestionObject()
Called when the creation of a new question is cancelled.
Provides fluid interface to LoggingServices.
buildPageViewToolbar($qid=0)
ilComponentFactory $component_factory
afterSave(ilObject $new_object)
save object public
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static getQuestionTypeByTypeId($type_id)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
determineObjectiveOrientedContainer()
insertQuestionsBeforeObject()
Insert checked questions before the actual selection.
const KPRIM_CHOICE_QUESTION_IDENTIFIER
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
getDidacticTemplateVar(string $type)
Get didactic template setting from creation screen.
const LONG_MENU_QUESTION_IDENTIFIER
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TEXTSUBSET_QUESTION_IDENTIFIER
static lookupParentObjId(int $questionId)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTabsManager(ilTestTabsManager $tabs_manager)
historyObject()
Creates the change history for a test.
downloadFileObject()
download file
createQuestionpoolTargetObject($cmd)
Called when a new question should be created from a test Important: $cmd may be overwritten if no que...
createObject()
create new object form
redirectTo_ilObjTestSettingsMainGUI_showForm_Object()
const CMD_BROWSE_QUESTIONS
confirmRemoveQuestionsObject()
Remove questions from the test after confirmation.
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
infoScreen($session_lock="")
show information screen
redirectAfterMissingRead()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static $infoScreenChildClasses
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
redirectAfterMissingWrite()
copyQuestionToPool(int $source_question_id, int $target_parent_id)
addDefaultsObject()
Adds the defaults of this test to the defaults.
Base Exception for all Exceptions relating to Modules/Test.
participantsActionObject()
Evaluates the actions on the participants page.
static useRelativeDates()
const FILE_UPLOAD_IDENTIFIER
ilObjectDataCache $obj_data_cache
uploadTst()
imports test and question(s)
static _lookupObjId(int $ref_id)
static instantiateQuestionGUI(int $a_question_id)
setCreationMode(bool $mode=true)
If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode...
const SCORE_REPORTING_FINISHED
cancelRemoveQuestionsObject()
Cancels the removal of questions from the test.
getTestScreenGUIInstance()
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
setWriteAccess(bool $value)
isCommandClassAnyInfoScreenChild()
defaultsObject()
Displays the settings page for test defaults.
ContentStyle $content_style
bool $create_question_mode
saveOrderAndObligationsObject()
copyAndLinkQuestionsToPoolObject()
ilObjectDataCache $ilObjDataCache
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
removeImportFailsObject()
questionsTabGatewayObject()
static instantiateQuestion(int $question_id)
const ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
Importer class for files.
static _needsManualScoring(int $question_id)
copyAndLinkToQuestionpoolObject()
static http()
Fetches the global http state from ILIAS.
ilGlobalTemplateInterface $tpl
deleteRegisteredImportFails()
ilObjTestSettingsMainGUI: ilPropertyFormGUI ilObjTestSettingsMainGUI: ilConfirmationGUI ilObjTestSe...
static _lookupTitle(int $obj_id)
const NUMERIC_QUESTION_IDENTIFIER
ilNavigationHistory $navigation_history
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
copyQuestionsToPool(array $question_ids, int $qpl_id)
removeQuestionsObject()
Called when a selection of questions should be removed from the test.
const ORDERING_HORIZONTAL_IDENTIFIER
const COUNT_PARTIAL_SOLUTIONS
ilTestObjectiveOrientedContainer $objective_oriented_container
applyDefaultsObject($confirmed=false)
Applies the selected test defaults.
download_paragraphObject()
download source code paragraph
ilTestPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI ilTestPageGUI: ilPublicUserProfile...
const QT_MULTIPLE_CHOICE_SR
fetchAuthoringQuestionIdParameter()
Class ilObjectGUI Basic methods of all Output classes.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
setValue(string $a_value)
const ORDERING_QUESTION_IDENTIFIER
insertQuestionsAfterObject()
Insert checked questions after the actual selection.
ilTestPlayerFactory $test_player_factory
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
InternalRequestService $testrequest
createQuestionPool($name="dummy", $description="")
Creates a new questionpool and returns the reference id.
ilTestAccess $test_access
const SCORE_REPORTING_DATE
showEditTestPageGUI(string $cmd)
Output class for assessment test evaluation.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static getSyntaxStylePath()
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
insertQuestionsBeforeOrAfter(int $insert_mode)
const TEXT_QUESTION_IDENTIFIER
Basic GUI class for assessment questions.
addDidacticTemplateOptions(array &$options)
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
Last visited history for repository items.
const EDIT_CONTEXT_AUTHORING
const TAB_ID_LEARNING_PROGRESS
static saveOriginalId(int $questionId, int $originalId)
setCustomRolesForSelection(array $a_roles)
Set custom roles for mapping to LTI roles.
const PRESENTATION_CONTEXT_TEST
getTargetQuestionpoolForm($questionpools, $cmd)
ILIAS Filesystem Util Archive LegacyArchives $archives
const QT_MULTIPLE_CHOICE_MR
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
QuestionInfoService $questioninfo
static isObjectiveTest(int $a_trst_ref_id)
Check if test ref_id is used in an objective course.
importFileObject(int $parent_id=null)
form for new test object import
static redirect(string $a_script)
Class that handles PDF generation for test and assessment.
static _createImportDirectory()
creates data directory for import files (data_dir/tst_data/tst_<id>/import, depending on data directo...
printObject()
Print tab to create a print of all questions with points and solutions.
executeCommand()
execute command
exportObject()
Gateway for exports initiated from workspace, as there is a generic forward to {objTypeMainGUI}::expo...
redirectToInfoScreenObject()
setTestAccess(ilTestAccess $test_access)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createQuestionPoolAndCopyObject()
SkillService $skills_service
importVerifiedFileObject()
imports question(s) into the questionpool (after verification)
certificateObject()
Shows the certificate editor.
sendParagraph(string $par_id, string $filename)
LoggingServices $logging_services
getReturnLocation(string $cmd, string $default_location="")
Get return location for command (command is method name without "Object", e.g.
const LP_CONTEXT_REPOSITORY
This class represents a text area property in a property form.
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
setTestAccess(ilTestAccess $test_access)
executeCreateQuestionObject()
Called when a new question should be created from a test after confirmation.
initQuestion($questionId, $parentObjId)
static isAdditionalQuestionContentEditingModePageObjectEnabled()
Returns the fact wether content editing with ilias page editor is enabled for questions or not...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const QUESTION_SET_TYPE_FIXED
movePageFormObject()
Move current page.
ilTestTabsManager $tabs_manager
testResultsGatewayObject()
const SCORE_REPORTING_IMMIDIATLY
getObjectiveOrientedContainer()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
moveQuestionsObject()
Marks selected questions for moving.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
Service GUI class for tests.
insertQuestionsObject()
Insert questions from the questionbrowser into the test.
const SETTINGS_SUBTAB_ID_EDIT_INTRODUCTION_PAGE
GlobalScreen $global_screen
deleteDefaultsObject()
Deletes selected test defaults.
static _lookupType(int $id, bool $reference=false)
static setUseRelativeDates(bool $a_status)
set use relative dates
backObject()
Called when the back button in the question browser was pressed.
const SINGLE_CHOICE_QUESTION_IDENTIFIER
setTestQuestionSetConfig(ilTestQuestionSetConfig $test_question_set_config)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addHeaderAction()
Add header action menu.
static clear(string $a_var)
const RENDER_PURPOSE_PREVIEW
ilTestExpressPageObjectGUI: assMultipleChoiceGUI, assClozeTestGUI, assMatchingQuestionGUI ilTestExpr...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SUBTAB_ID_QST_PAGE_VIEW
const CMD_SHOW_FORM
command constants
static set(string $a_var, $a_val)
Set a value.
showMediaFullscreen(int $a_style_id=0)
show fullscreen view of media object
const CLOZE_TEST_IDENTIFIER
Question identifier constants.
static _setImportDirectory($a_import_dir=null)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
setTestSession($test_session)
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
static _getImportDirectory()
Get the import directory location of the test.
const QT_ORDERING_HORIZONTAL
const IMAGEMAP_QUESTION_IDENTIFIER
ilComponentRepository $component_repository
deleteRegisteredImportFails()
const SUBTAB_ID_QST_LIST_VIEW
const FORMULA_QUESTION_IDENTIFIER
removeQuestionsForm($checked_questions)
Displays a form to confirm the removal of questions from the test.