19declare(strict_types=1);
169 $this->navigation_history =
$DIC[
'ilNavigationHistory'];
170 $this->component_repository =
$DIC[
'component.repository'];
171 $this->component_factory =
$DIC[
'component.factory'];
172 $this->ui_service =
$DIC->uiService();
173 $this->
error = $DIC[
'ilErr'];
174 $this->db =
$DIC[
'ilDB'];
175 $this->
help = $DIC[
'ilHelp'];
176 $this->global_screen =
$DIC[
'global_screen'];
177 $this->obj_data_cache =
$DIC[
'ilObjDataCache'];
178 $this->irss =
$DIC[
'resource_storage'];
179 $this->skills_service =
$DIC->skills();
180 $this->archives =
$DIC->archives();
182 $this->data_factory =
new DataFactory();
183 $this->taxonomy =
$DIC->taxonomy()->domain();
184 $this->ui_service =
$DIC->uiService();
185 $this->content_style =
$DIC->contentStyle();
187 $local_dic = TestDIC::dic();
188 $this->questionrepository = $local_dic[
'question.general_properties.repository'];
189 $this->test_questions_repository = $local_dic[
'questions.properties.repository'];
190 $this->qplrequest = $local_dic[
'question.request_data_wrapper'];
191 $this->title_builder = $local_dic[
'title_columns_builder'];
192 $this->testrequest = $local_dic[
'request_data_collector'];
193 $this->response_handler = $local_dic[
'response_handler'];
194 $this->participant_repository = $local_dic[
'participant.repository'];
195 $this->results_data_factory = $local_dic[
'results.data.factory'];
196 $this->results_presentation_factory = $local_dic[
'results.presentation.factory'];
197 $this->export_factory = $local_dic[
'exportimport.factory'];
198 $this->export_repository = $local_dic[
'exportimport.repository'];
199 $this->participant_access_filter_factory = $local_dic[
'participant.access_filter.factory'];
200 $this->test_pass_result_repository = $local_dic[
'results.data.repository'];
201 $this->toplist_repository = $local_dic[
'results.toplist.repository'];
204 if ($this->testrequest->hasRefId() && is_numeric($this->testrequest->getRefId())) {
205 $ref_id = $this->testrequest->getRefId();
209 $this->
ctrl->saveParameter($this, [
'ref_id',
'test_ref_id']);
211 $this->
lng->loadLanguageModule(
'assessment');
215 if (!($this->
object instanceof
ilObjTest)) {
225 $this->component_repository,
227 $this->questionrepository
241 $this->objective_oriented_container,
242 $this->test_session_factory->getSession()
251 $cmd = $this->
ctrl->getCmd(
'testScreen');
253 $cmds_disabled_due_to_offline_status = [
254 'resumePlayer',
'resumePlayer',
'outUserResultsOverview',
'outUserListOfAnswerPasses'
257 if (!$this->
getCreationMode() && $this->
object->getOfflineStatus() && in_array($cmd, $cmds_disabled_due_to_offline_status)) {
261 $next_class = $this->
ctrl->getNextClass($this);
265 $this->
access->checkAccess(
'read',
'', $this->testrequest->getRefId())
267 $this->navigation_history->addItem(
268 $this->testrequest->getRefId(),
269 ilLink::_getLink($this->testrequest->getRefId(),
'tst'),
276 switch ($next_class) {
277 case 'illtiproviderobjectsettinggui':
278 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
283 $this->tabs_manager->getSettingsSubTabs();
284 $this->tabs_manager->activateTab(
'settings');
285 $this->tabs_manager->activateSubTab(
'lti_provider');
287 $lti_gui->setCustomRolesForSelection($this->rbac_review->getLocalRoles($this->getTestObject()->getRefId()));
288 $lti_gui->offerLTIRolesForSelection(
false);
289 $this->
ctrl->forwardCommand($lti_gui);
292 case 'iltestexportgui':
293 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
299 $this->tabs_manager->activateTab(TabsManager::TAB_ID_EXPORT);
301 $selected_files = [];
302 if ($this->testrequest->isset(
'file') && $this->testrequest->raw(
'file')) {
303 $selected_files = $this->testrequest->raw(
'file');
306 if (is_string($selected_files)) {
307 $selected_files = [$selected_files];
313 $this->obj_data_cache,
319 $this->export_repository,
320 $this->temp_file_system,
321 $this->participant_access_filter_factory,
324 $this->questionrepository,
327 $this->
ctrl->forwardCommand($export_gui);
330 case strtolower(ilInfoScreenGUI::class):
332 !$this->
access->checkAccess(
'read',
'', $this->testrequest->getRefId())
333 && !$this->access->checkAccess(
'visible',
'', $this->testrequest->getRefId())
343 case strtolower(TestScreenGUI::class):
344 if (!$this->
access->checkAccess(
'read',
'', $this->testrequest->getRefId()) && !$this->access->checkAccess(
'visible',
'', $this->testrequest->getRefId())) {
352 case 'ilobjectmetadatagui':
353 if (!$this->
access->checkAccess(
'write',
'', $this->getTestObject()->getRefId())) {
359 $this->tabs_manager->activateTab(TabsManager::TAB_ID_META_DATA);
361 $this->
ctrl->forwardCommand($md_gui);
364 case strtolower(ilTestParticipantsGUI::class):
365 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
373 $this->test_question_set_config_factory->getQuestionSetConfig(),
387 $this->component_factory,
388 $this->export_factory,
390 $this->response_handler,
391 $this->participant_repository,
392 $this->results_data_factory,
393 $this->results_presentation_factory,
394 $this->test_pass_result_repository
397 $this->
ctrl->forwardCommand($gui);
406 $this->tabs_manager->activateTab(TabsManager::TAB_ID_PARTICIPANTS);
410 case 'iltestresultsgui':
411 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
426 $this->component_repository,
432 $this->skills_service,
433 $this->questionrepository,
434 $this->toplist_repository,
438 $this->test_session_factory->getSession(),
439 $this->getObjectiveOrientedContainer()
442 $this->
ctrl->forwardCommand($gui);
445 case "iltestplayerfixedquestionsetgui":
447 $cmd !==
'autosave' &&
448 (!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))
458 $this->
ctrl->forwardCommand($gui);
461 case "iltestplayerrandomquestionsetgui":
463 $cmd !==
'autosave' &&
464 (!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))
474 $this->
ctrl->forwardCommand($gui);
477 case "iltestevaluationgui":
478 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
484 case "iltestservicegui":
485 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
491 $this->
ctrl->forwardCommand($serviceGUI);
494 case 'ilpermissiongui':
495 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
500 $this->tabs_manager->activateTab(TabsManager::TAB_ID_PERMISSIONS);
502 $ret = $this->
ctrl->forwardCommand($perm_gui);
505 case "illearningprogressgui":
506 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
512 $this->tabs_manager->activateTab(TabsManager::TAB_ID_LEARNING_PROGRESS);
514 $test_session = $this->test_session_factory->getSessionByUserId($this->
user->getId());
515 if (!$this->test_access->checkOtherParticipantsLearningProgressAccess()
516 && !$this->getTestObject()->canShowTestResults($test_session)) {
517 $this->tpl->setOnScreenMessage(
519 $this->
lng->txt(
'tst_res_tab_msg_no_lp_access'),
525 $this->
ctrl->forwardCommand($new_gui);
529 case "ilcertificategui":
530 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
536 $this->tabs_manager->activateTab(TabsManager::TAB_ID_SETTINGS);
541 $this->
ctrl->forwardCommand($output_gui);
544 case strtolower(TestScoringByQuestionGUI::class):
545 if (!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId())
546 && !$this->access->checkAccess(
"score_anon",
"", $this->testrequest->getRefId())
554 $this->
ctrl->forwardCommand($output_gui);
557 case strtolower(TestScoringByParticipantGUI::class):
558 if (!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId())
559 && !$this->access->checkAccess(
"score_anon",
"", $this->testrequest->getRefId())
567 $this->
ctrl->forwardCommand($output_gui);
570 case strtolower(MarkSchemaGUI::class):
571 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
585 $this->request_wrapper,
586 $this->response_handler,
592 $this->
ctrl->forwardCommand($mark_schema_gui);
596 $this->tabs_manager->activateTab(TabsManager::TAB_ID_SETTINGS);
597 $this->tabs_manager->activateSubTab(TabsManager::SETTINGS_SUBTAB_ID_MARK_SCHEMA);
601 case strtolower(SettingsMainGUI::class):
602 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
614 $this->obj_data_cache,
620 $this->component_repository,
624 $this->questionrepository
626 $this->
ctrl->forwardCommand($gui);
628 $this->tabs_manager->activateTab(TabsManager::TAB_ID_SETTINGS);
629 $this->tabs_manager->activateSubTab(TabsManager::SUBTAB_ID_GENERAL_SETTINGS);
633 case strtolower(SettingsScoringGUI::class):
634 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
645 $this->component_repository,
659 $this->
ctrl->forwardCommand($gui);
662 case 'iltestrandomquestionsetconfiggui':
663 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
686 $this->component_repository,
687 $this->obj_definition,
688 $this->obj_data_cache,
689 $test_process_locker_factory,
691 $this->title_builder,
692 $this->questionrepository
694 $this->
ctrl->forwardCommand($gui);
697 case 'iltestquestionbrowsertablegui':
698 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
708 $this->component_repository,
717 $this->questionrepository,
725 $this->
ctrl->forwardCommand($gui);
728 case 'iltestskilladministrationgui':
729 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
744 $this->component_repository,
746 $this->questionrepository,
750 $this->
ctrl->forwardCommand($gui);
753 case 'ilobjectcopygui':
754 if ((!$this->
access->checkAccess(
"copy",
"", $this->testrequest->getRefId()))) {
761 $this->
ctrl->forwardCommand($cp);
764 case strtolower(ilAssQuestionPreviewGUI::class):
765 if (!$this->
access->checkAccess(
'write',
'', $this->getTestObject()->getRefId())) {
771 case 'ilassquestionpagegui':
772 if ($cmd ===
'finishEditing') {
777 if ((!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()))) {
780 if ($cmd ===
'edit' && !$this->
access->checkAccess(
'write',
'', $this->testrequest->getRefId())) {
789 $this->questionrepository,
792 $forwarder->forward();
795 case 'ilassspecfeedbackpagegui':
796 if ((!$this->
access->checkAccess(
"write",
"", $this->testrequest->getRefId()))) {
800 $this->
ctrl->forwardCommand($pg_gui);
803 case 'ilassgenfeedbackpagegui':
804 if ((!$this->
access->checkAccess(
"write",
"", $this->testrequest->getRefId()))) {
808 $this->
ctrl->forwardCommand($pg_gui);
811 case 'illocalunitconfigurationgui':
812 if ((!$this->
access->checkAccess(
"write",
"", $this->testrequest->getRefId()))) {
819 $question = $question_gui->getObject();
821 $question_gui->setObject($question);
822 $question_gui->setQuestionTabs();
826 $this->
ctrl->forwardCommand($gui);
829 case "ilcommonactiondispatchergui":
830 if (!$this->
access->checkAccess(
"read",
"", $this->testrequest->getRefId()) && !$this->access->checkAccess(
"visible",
"", $this->testrequest->getRefId())) {
835 $this->
ctrl->forwardCommand($gui);
838 case 'ilassquestionfeedbackeditinggui':
839 if (!$this->
access->checkAccess(
'write',
'', $this->getTestObject()->getRefId())) {
845 $this->
ctrl->setReturnByClass(self::class, self::SHOW_QUESTIONS_CMD);
847 $question = $question_gui->getObject();
849 $question_gui->setObject($question);
850 $question_gui->setQuestionTabs();
855 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'question_is_part_of_running_test'),
true);
870 $this->
ctrl->forwardCommand($gui);
873 case 'iltestcorrectionsgui':
874 if ((!$this->
access->checkAccess(
'read',
'', $this->testrequest->getRefId()))) {
892 $this->
ctrl->forwardCommand($gui);
895 case 'iltestpagegui':
896 if ((!$this->
access->checkAccess(
"write",
"", $this->testrequest->getRefId()))) {
900 if ($cmd ===
'downloadFile') {
901 $page_id = $this->
object->getIntroductionPageId();
902 if ($this->testrequest->strVal(
'page_type') ===
'concludingremarkspage') {
903 $page_id = $this->
object->getConcludingRemarksPageId();
912 if (!$this->
access->checkAccess(
'read',
'', $this->testrequest->getRefId())
913 && !$this->access->checkAccess(
'visible',
'', $this->testrequest->getRefId())) {
919 if ($cmd ===
'testScreen') {
924 $local_cmd = $cmd .
'Object';
925 if (!method_exists($this, $local_cmd)) {
926 $local_cmd = self::SHOW_QUESTIONS_CMD .
'Object';
932 if ((!$this->
access->checkAccess(
'read',
'', $this->testrequest->getRefId()))) {
937 [
'editQuestion',
'previewQuestion',
'save',
'saveReturn',
'uploadImage',
938 'removeImage',
'syncQuestion',
'syncQuestionReturn',
'suggestedsolution']
940 && !$this->
access->checkAccess(
'write',
'', $this->getTestObject()->getRefId())) {
943 if (in_array($cmd, [
'editQuestion',
'save',
'saveReturn',
'suggestedsolution'])
945 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'question_is_part_of_running_test'),
true);
953 if (!in_array(strtolower($this->testrequest->raw(
'baseClass')), [
'iladministrationgui',
'ilrepositorygui'])
954 && $this->getCreationMode() !==
true) {
955 $this->tpl->printToStdout();
961 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_permission'),
true);
962 $target_class = get_class($this->
object) .
'GUI';
963 $this->
ctrl->setParameterByClass($target_class,
'ref_id', $this->ref_id);
964 $this->
ctrl->redirectByClass($target_class);
969 $this->tpl->setOnScreenMessage(
'failure', sprintf(
970 $this->
lng->txt(
"msg_no_perm_read_item"),
971 $this->object->getTitle()
974 $this->
ctrl->redirectByClass(
'ilrepositorygui');
981 $nr_of_participants_with_results = $this->
getTestObject()->evalTotalPersons();
983 $this->
ctrl->saveParameterByClass(self::class,
'q_id');
994 $this->global_screen,
1000 if ($nr_of_participants_with_results > 0) {
1001 $gui->addAdditionalCmd(
1002 $this->
lng->txt(
'tst_corrections_qst_form'),
1003 $this->ctrl->getLinkTargetByClass(ilTestCorrectionsGUI::class,
'showQuestion')
1011 if (!$this->
getTestObject()->isRandomTest() && $nr_of_participants_with_results === 0) {
1012 $gui->setPrimaryCmd(
1013 $this->
lng->txt(
'edit_question'),
1014 $this->ctrl->getLinkTargetByClass(
1015 get_class($question_gui),
1019 $gui->addAdditionalCmd(
1020 $this->
lng->txt(
'edit_page'),
1021 $this->ctrl->getLinkTargetByClass(
1022 ilAssQuestionPageGUI::class,
1030 $gui->initPreviewSession($this->
user->getId(), $this->testrequest->getQuestionId());
1031 $gui->initStyleSheets();
1033 $this->
ctrl->clearParameterByClass(self::class,
'q_id');
1034 $this->tabs_gui->setBackTarget(
1035 $this->
lng->txt(
'backtocallingtest'),
1036 $this->ctrl->getLinkTargetByClass(self::class, self::SHOW_QUESTIONS_CMD)
1038 $this->
ctrl->saveParameterByClass(self::class,
'q_id');
1039 $gui->{$cmd .
'Cmd'}();
1044 $this->tpl->setTitle(
1045 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
1046 "{$this->getTestObject()->getTitle()}: {$question_title}"
1053 $this->create_question_mode =
true;
1054 $this->prepareOutput();
1057 $qid = $this->fetchAuthoringQuestionIdParameter();
1059 $this->
ctrl->setReturnByClass(self::class, self::SHOW_QUESTIONS_CMD);
1067 $question = $question_gui->getObject();
1068 $question->setObjId($this->getTestObject()->
getId());
1069 $question_gui->setObject($question);
1070 $question_gui->setContextAllowsSyncToPool(
true);
1071 $question_gui->setQuestionTabs();
1073 $this->addQuestionTitleToObjectTitle($question->getTitleForHTMLOutput());
1075 $target = strpos($cmd,
'Return') ===
false ?
'stay' :
'return';
1077 if (in_array($cmd, [
'syncQuestion',
'syncQuestionReturn'])) {
1078 $question_gui->syncQuestion();
1079 $this->showNextViewAfterQuestionSave($question_gui, $target);
1083 if ($question_gui->isSaveCommand()
1084 || $question_gui->cmdNeedsExistingQuestion($cmd)) {
1085 $question_gui = $this->addPostCreationTasksToQuestionGUI($question_gui);
1088 if ($qid === 0 && $question_gui->cmdNeedsExistingQuestion($cmd)) {
1089 $question_gui->getObject()->createNewQuestion();
1090 $question_gui->setQuestionTabs();
1091 $this->executeAfterQuestionCreationTasks($question_gui);
1094 if (!$question_gui->isSaveCommand()) {
1095 $this->
ctrl->forwardCommand($question_gui);
1099 if (!$question_gui->saveQuestion()) {
1103 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
1105 $this->executeAfterQuestionCreationTasks($question_gui);
1107 $this->executeAfterQuestionSaveTasks($question_gui);
1108 $this->showNextViewAfterQuestionSave($question_gui, $target);
1110 $this->showQuestionsObject();
1117 if ($this->testrequest->isset(
'move_after_question_with_id')) {
1119 $this->testrequest->int(
'move_after_question_with_id')
1123 if ($this->testrequest->isset(
'pool_title')) {
1124 $question_gui->setCopyToNewPoolOnSave(
1125 $this->testrequest->strVal(
'pool_title')
1129 if ($this->testrequest->isset(
'pool_ref')) {
1130 $question_gui->setCopyToExistingPoolOnSave(
1131 $this->testrequest->int(
'pool_ref')
1134 return $question_gui;
1139 if ($this->getTestObject()->getTestLogger()->isLoggingEnabled()) {
1140 $this->getTestObject()->getTestLogger()->logQuestionAdministrationInteraction(
1141 $question_gui->
getObject()->toQuestionAdministrationInteraction(
1142 $this->getTestObject()->getTestLogger()->getAdditionalInformationGenerator(),
1143 $this->getTestObject()->getRefId(),
1144 TestQuestionAdministrationInteractionTypes::QUESTION_MODIFIED
1153 && !in_array($question_gui->
getObject()->getId(), $this->getTestObject()->getQuestions())) {
1154 $this->getTestObject()->insertQuestion($question_gui->
getObject()->getId(),
true);
1158 $this->getTestObject()->moveQuestions(
1161 ? $this->getTestObject()->getQuestions()[1]
1169 $original_id = $this->copyQuestionToPool(
1179 $original_id = $this->copyQuestionToPool(
1190 if ($target ===
'return') {
1191 $this->forwardCommandToQuestionPreview(
1197 if ($target ===
'stay') {
1198 $this->
ctrl->setParameterByClass(ilAssQuestionPreviewGUI::class,
'q_id', $question_gui->
getObject()->getId());
1199 $this->tabs_gui->setBackTarget(
1200 $this->
lng->txt(
'backtocallingpage'),
1201 $this->ctrl->getLinkTargetByClass(
1202 ilAssQuestionPreviewGUI::class,
1213 $this->getTestObject()->getType(),
1214 $this->getTestObject()->getRefId(),
1215 $this->getTestObject()->
getId(),
1216 $this->
user->getId()
1226 $this->
ctrl->redirectByClass(
'ilTestExportGUI');
1235 $qid = $this->testrequest->int(
'q_id');
1237 if ($qid === 0 || $this->getTestObject()->checkQuestionParent($qid)) {
1241 throw new ilTestException(
'question id does not relate to parent object!');
1246 if ($this->getTestObject()->isRandomTest()) {
1247 $this->
ctrl->redirectByClass(
'ilTestRandomQuestionSetConfigGUI');
1250 $this->
ctrl->redirectByClass(
'ilObjTestGUI', self::SHOW_QUESTIONS_CMD);
1255 $this->prepareOutput();
1256 $this->tabs_manager->getSettingsSubTabs();
1258 if ($this->request_wrapper->has(
'page_type')
1259 && $this->request_wrapper->retrieve(
1261 $this->refinery->kindlyTo()->string()
1262 ) ===
'introductionpage'
1264 $page_type =
'IntroductionPage';
1265 $this->tabs_manager->activateSubTab(TabsManager::SETTINGS_SUBTAB_ID_EDIT_INTRODUCTION_PAGE);
1266 $page_id = $this->getTestObject()->getIntroductionPageId();
1268 $page_type =
'ConcludingRemarksPage';
1269 $this->tabs_manager->activateSubTab(TabsManager::SETTINGS_SUBTAB_ID_EDIT_CONCLUSION_PAGE);
1270 $page_id = $this->getTestObject()->getConcludingRemarksPageId();
1272 $this->
ctrl->saveParameterByClass(ilTestPageGUI::class,
'page_type');
1275 $this->content_style->gui()->addCss($this->tpl, $this->ref_id);
1276 $this->tpl->setContent($this->
ctrl->forwardCommand($gui));
1278 if ($this->
ctrl->getCmdClass() === strtolower(ilTestPageGUI::class)) {
1279 $this->tabs_manager->activateTab(TabsManager::TAB_ID_SETTINGS);
1285 return $this->test_access;
1290 $this->test_access = $test_access;
1295 $this->prepareOutput();
1296 $this->addHeaderAction();
1298 $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
1299 $gui->setTestAccess($this->getTestAccess());
1301 $this->
ctrl->forwardCommand($gui);
1306 $this->
ctrl->redirectByClass(SettingsMainGUI::class, SettingsMainGUI::CMD_SHOW_FORM);
1311 $this->tpl->loadStandardTemplate();
1312 $this->setLocator();
1313 $this->setTitleAndDescription();
1318 $this->
ctrl->redirectByClass([ilRepositoryGUI::class, self::class, ilInfoScreenGUI::class]);
1321 protected function importFile(
string $file_to_import,
string $path_to_uploaded_file_in_temp_dir): void
1328 $unzip = $this->archives->unzip(Streams::ofResource(fopen($file_to_import,
'r')), $options);
1331 if (!is_file($qtifile)) {
1333 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
1334 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_import_non_ilias_zip'),
true);
1337 $qtiParser->startParsing();
1338 $founditems = $qtiParser->getFoundItems();
1342 foreach ($founditems as $item) {
1343 if ($item[
"type"] !==
'') {
1350 if (count($founditems) && $complete == 0) {
1352 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
1353 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_import_non_ilias_files'));
1358 ilSession::set(
'path_to_uploaded_file_in_temp_dir', $path_to_uploaded_file_in_temp_dir);
1362 || $founditems === []) {
1363 $this->importVerifiedFileObject(
true);
1368 'importVerifiedFile',
1372 $path_to_uploaded_file_in_temp_dir
1375 if ($form ===
null) {
1379 $panel = $this->ui_factory->panel()->standard(
1380 $this->
lng->txt(
'import_tst'),
1382 $this->ui_factory->legacy()->content($this->lng->txt(
'qpl_import_verify_found_questions')),
1386 $this->tpl->setContent($this->ui_renderer->render($panel));
1387 $this->tpl->printToStdout();
1394 $defaults = $tst->getAvailableDefaults();
1395 if ($defaults === []) {
1399 $additional_options = [];
1400 foreach ($defaults as $row) {
1401 $additional_options[
"tstdef_" . $row[
"test_defaults_id"]] = [$row[
"name"],
1402 $this->
lng->txt(
"tst_default_settings")];
1404 return $additional_options;
1414 $new_object->saveToDb();
1416 $test_def_id = $this->getSelectedPersonalDefaultsSettingsFromForm();
1417 if ($test_def_id !==
null
1418 && ($defaults = $new_object->getTestDefaults($test_def_id)) !==
null) {
1419 $info = $new_object->applyDefaults($defaults);
1422 $new_object->saveToDb();
1424 if ($new_object->getTestLogger()->isLoggingEnabled()) {
1425 $new_object->getTestLogger()->logTestAdministrationInteraction(
1426 $new_object->getTestLogger()->getInteractionFactory()->buildTestAdministrationInteraction(
1428 $this->user->getId(),
1429 TestAdministrationInteractionTypes::NEW_TEST_CREATED,
1436 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'object_added'),
true);
1438 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
$info),
true);
1440 $this->
ctrl->setParameter($this,
'ref_id', $new_object->
getRefId());
1441 $this->
ctrl->redirectByClass(SettingsMainGUI::class);
1446 $data = $this->initCreateForm($this->type)
1447 ->withRequest($this->request)
1449 return isset(
$data[
'didactic_templates'])
1450 ? $this->parseDidacticTemplateVar(
$data[
'didactic_templates'],
'tstdef')
1456 $path = $this->tree->getPathFull($this->getTestObject()->getRefID());
1457 ilUtil::redirect($this->getReturnLocation(
"cancel",
"./ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id=" .
$path[count(
$path) - 2][
"child"]));
1462 return $this->object;
1469 bool $skip_retrieve_selected_questions =
false
1471 if (!$this->checkPermissionBool(
'create',
'',
'tst')) {
1472 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_permission'),
true);
1473 $this->
ctrl->returnToParent($this);
1476 $path_to_uploaded_file_in_temp_dir =
ilSession::get(
'path_to_uploaded_file_in_temp_dir');
1480 $new_obj->setTitle(
'dummy');
1481 $new_obj->setDescription(
'test import');
1482 $new_obj->create(
true);
1483 $new_obj->createReference();
1484 $new_obj->putInTree($this->testrequest->getRefId());
1485 $new_obj->setPermissions($this->testrequest->getRefId());
1486 $new_obj->saveToDb();
1488 $selected_questions = [];
1489 if (!$skip_retrieve_selected_questions) {
1491 'importVerifiedFile',
1498 ilSession::set(
'tst_import_selected_questions', $selected_questions);
1500 $imp =
new ilImport($this->testrequest->getRefId());
1501 $map = $imp->getMapping();
1502 $map->addMapping(
'components/ILIAS/Test',
'tst',
'new_id', (
string) $new_obj->getId());
1508 if (is_file($importdir . DIRECTORY_SEPARATOR .
'/manifest.xml')) {
1509 $imp->importObject($new_obj, $file_to_import, basename($file_to_import),
'tst',
'components/ILIAS/Test',
true);
1512 $test_importer->setImport($imp);
1514 $test_importer->setImportDirectory($importdir .
'/' . $subdir);
1515 $test_importer->init();
1517 $test_importer->importXmlRepresentation(
1525 if ($new_obj->getTestLogger()->isLoggingEnabled()) {
1526 $new_obj->getTestLogger()->logTestAdministrationInteraction(
1527 $new_obj->getTestLogger()->getInteractionFactory()->buildTestAdministrationInteraction(
1528 $new_obj->getRefId(),
1529 $this->user->getId(),
1530 TestAdministrationInteractionTypes::NEW_TEST_CREATED,
1537 $this->deleteUploadedImportFile($path_to_uploaded_file_in_temp_dir);
1541 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"object_imported"),
true);
1544 if ($question_skill_assignments_import_fails->failedImportsRegistered()) {
1545 $this->tpl->setOnScreenMessage(
1547 $question_skill_assignments_import_fails->getFailedImportsMessage($this->lng),
1552 $this->
ctrl->setParameterByClass(ilObjTestGUI::class,
'ref_id', $new_obj->getRefId());
1553 $this->
ctrl->redirectByClass(ilObjTestGUI::class);
1561 $file = explode(
"_", $this->testrequest->raw(
"file_id"));
1562 $fileObj =
new ilObjFile((
int) $file[count($file) - 1],
false);
1563 $fileObj->sendFile();
1573 $page_gui->setFileDownloadLink(
1574 $this->
ctrl->getLinkTargetByClass(ilObjTestGUI::class,
'downloadFile')
1576 $page_gui->showMediaFullscreen();
1585 $pg_obj->sendParagraph($this->testrequest->raw(
"par_id"), $this->testrequest->raw(
"downloadtitle"));
1591 $parent_ref = $this->tree->getParentId($this->getTestObject()->getRefId());
1593 $qpl->setType(
"qpl");
1594 $qpl->setTitle($name);
1595 $qpl->setDescription($description);
1597 $qpl->createReference();
1598 $qpl->putInTree($parent_ref);
1599 $qpl->setPermissions($parent_ref);
1600 $qpl->getObjectProperties()->storePropertyIsOnline($qpl->getObjectProperties()->getPropertyIsOnline()->withOnline());
1605 public function createQuestionObject(): void
1607 $this->protectByWritePermission();
1609 $this->
ctrl->setReturnByClass(self::class, self::SHOW_QUESTIONS_CMD);
1611 $form = $this->buildQuestionCreationForm()->withRequest($this->request);
1612 $data_with_section = $form->getData();
1613 if ($data_with_section ===
null) {
1614 $this->createQuestionFormObject($form);
1617 $data = $data_with_section[0];
1619 $qpl_mode =
$data[
'pool_selection'][
'qpl_type'];
1620 if ($qpl_mode === self::QUESTION_CREATION_POOL_SELECTION_NEW_POOL &&
$data[
'pool_selection'][
'title'] ===
''
1621 || $qpl_mode === self::QUESTION_CREATION_POOL_SELECTION_EXISTING_POOL &&
$data[
'pool_selection'][
'pool_ref_id'] === 0) {
1622 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"questionpool_not_entered"));
1623 $this->createQuestionFormObject($form);
1632 $question = $question_gui->getObject();
1633 $question->setAdditionalContentEditingMode(
$data[
'editing_type']);
1634 $question->setObjId($this->getTestObject()->
getId());
1635 $question_gui->setObject($question);
1636 $question_gui->setQuestionTabs();
1638 if (array_key_exists(
'position',
$data)) {
1639 $question_gui->setMoveAfterQuestionId(
$data[
'position']);
1642 if ($qpl_mode === self::QUESTION_CREATION_POOL_SELECTION_NEW_POOL) {
1643 $question_gui->setCopyToNewPoolOnSave(
$data[
'pool_selection'][
'title']);
1646 if ($qpl_mode === self::QUESTION_CREATION_POOL_SELECTION_EXISTING_POOL) {
1647 $question_gui->setCopyToExistingPoolOnSave(
$data[
'pool_selection'][
'pool_ref_id']);
1650 $question_gui->editQuestion();
1655 $this->
ctrl->redirect($this, self::SHOW_QUESTIONS_CMD);
1660 $this->protectByWritePermission();
1662 if (($selected_array ?? $this->testrequest->getQuestionIds()) === []) {
1663 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tst_insert_missing_question'),
true);
1664 $this->
ctrl->redirect($this,
'browseForQuestions');
1667 $this->getTestObject()->saveCompleteStatus($this->test_question_set_config_factory->getQuestionSetConfig());
1668 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_questions_inserted'),
true);
1669 $this->
ctrl->redirect($this, self::SHOW_QUESTIONS_CMD);
1675 $this->protectByWritePermission();
1677 $this->tabs_manager->getQuestionsSubTabs();
1678 $this->tabs_manager->activateSubTab(TabsManager::SUBTAB_ID_QST_LIST_VIEW);
1680 $sub_screen_id = [
'createQuestion'];
1682 $this->tabs_manager->activateTab(TabsManager::TAB_ID_QUESTIONS);
1683 $this->
help->setScreenId(
'assQuestions');
1684 $this->
help->setSubScreenId(implode(
'_', $sub_screen_id));
1686 $this->tpl->setContent(
1687 $this->ui_renderer->render(
1688 $form ?? $this->buildQuestionCreationForm()
1695 $inputs[
'question_type'] = $this->buildInputQuestionType();
1696 $questions = $this->getTestObject()->getQuestionTitlesAndIndexes();
1697 if ($questions !== []) {
1698 $inputs[
'position'] = $this->buildInputPosition($questions);
1701 $inputs[
'editing_type'] = $this->buildInputEditingType();
1704 $sub_screen_id[] =
'editMode';
1707 $sub_screen_id[] =
'poolSelect';
1709 $inputs[
'pool_selection'] = $this->buildInputPoolSelection();
1712 $this->ui_factory->input()->field()->section(
$inputs, $this->
lng->txt(
'ass_create_question'))
1715 $form = $this->ui_factory->input()->container()->form()->standard(
1716 $this->
ctrl->getFormAction($this,
'createQuestion'),
1718 )->withSubmitLabel($this->
lng->txt(
'create'));
1725 $question_types = (
new ilObjQuestionPool())->getQuestionTypes(
false,
true,
false);
1727 foreach ($question_types as $label =>
$data) {
1728 $options[
$data[
'question_type_id']] = $label;
1731 return $this->ui_factory->input()->field()->select(
1732 $this->
lng->txt(
'question_type'),
1734 )->withRequired(
true);
1739 $options = [0 => $this->
lng->txt(
'first')];
1740 foreach ($questions as $key => $title) {
1741 $options[$key] = $this->
lng->txt(
'behind') .
' ' . $title
1742 .
' [' . $this->
lng->txt(
'question_id_short') .
': ' . $key .
']';
1744 return $this->ui_factory->input()->field()->select(
1745 $this->
lng->txt(
'position'),
1747 )->withAdditionalTransformation($this->
refinery->kindlyTo()->int());
1752 if (!$this->getTestObject()->getGlobalSettings()->isPageEditorEnabled()) {
1753 return $this->ui_factory->input()->field()->hidden()->
withValue(
1758 return $this->ui_factory->input()->field()->radio($this->
lng->txt(
'tst_add_quest_cont_edit_mode'))
1761 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_IPE'),
1762 $this->lng->txt(
'tst_add_quest_cont_edit_mode_IPE_info')
1765 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_RTE'),
1766 $this->lng->txt(
'tst_add_quest_cont_edit_mode_RTE_info')
1773 $f = $this->ui_factory->input()->field();
1776 $trafo = $this->
refinery->custom()->transformation(
1777 static function ($values) use ($kt): array {
1778 $return[
'qpl_type'] = $kt->int()->
transform($values[0]);
1779 if ($return[
'qpl_type'] === self::QUESTION_CREATION_POOL_SELECTION_NO_POOL) {
1782 if ($return[
'qpl_type'] === self::QUESTION_CREATION_POOL_SELECTION_NEW_POOL) {
1783 return $return + [
'title' => $kt->string()->
transform($values[1][0])];
1785 return $return + [
'pool_ref_id' => $kt->int()->
transform($values[1][0])];
1791 foreach ($questionpools as $key => $p) {
1792 $pools_data[$key] = $p[
'title'];
1796 self::QUESTION_CREATION_POOL_SELECTION_NO_POOL =>
$f->group([], $this->
lng->txt(
'assessment_no_pool')),
1797 self::QUESTION_CREATION_POOL_SELECTION_EXISTING_POOL =>
$f->group(
1798 [
$f->select($this->lng->txt(
'select_questionpool'), $pools_data)],
1799 $this->lng->txt(
'assessment_existing_pool')
1801 self::QUESTION_CREATION_POOL_SELECTION_NEW_POOL =>
$f->group(
1802 [
$f->text($this->lng->txt(
'name'))],
1803 $this->lng->txt(
'assessment_new_pool')
1807 return $f->switchableGroup(
1809 $this->
lng->txt(
'assessment_pool_selection')
1810 )->withAdditionalTransformation($trafo)
1811 ->withRequired(
true)
1817 $this->protectByWritePermission();
1819 if ($this->testrequest->raw(
'add')) {
1820 $this->addQuestion();
1824 $table_query = $this->getQuestionsTableQuery();
1826 if (!$this->getQuestionsTableActions()->handleCommand(
1829 fn() => $this->protectByWritePermission(),
1830 fn() => $this->createQuestionpoolTargetObject(
'copyAndLinkQuestionsToPool'),
1831 fn() => $this->getTable()
1837 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.il_as_tst_questions.html',
'components/ILIAS/Test');
1839 $this->setupToolBarAndMessage($this->getTestObject()->evalTotalPersons() !== 0);
1841 $this->tabs_manager->getQuestionsSubTabs();
1842 $this->tabs_manager->activateSubTab(TabsManager::SUBTAB_ID_QST_LIST_VIEW);
1844 $this->tpl->setCurrentBlock(
'adm_content');
1845 $this->tpl->setVariable(
'ACTION_QUESTION_FORM', $this->
ctrl->getFormAction($this));
1846 $this->tpl->setVariable(
1848 $this->ui_renderer->render(
1849 $this->getTable()->getTableComponent()
1852 $this->tpl->parseCurrentBlock();
1857 $selected_array = [$this->testrequest->int(
'add')];
1858 $total = $this->getTestObject()->evalTotalPersons();
1861 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'test_has_datasets_warning_page_view'));
1862 $this->showQuestionsObject();
1865 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tst_insert_questions'));
1866 $this->insertQuestionsObject($selected_array);
1871 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)
1872 || $this->getTestObject()->isRandomTest()) {
1876 if ($has_started_test_runs) {
1877 $link = $this->ui_factory->link()->standard(
1878 $this->
lng->txt(
'test_has_datasets_warning_page_view_link'),
1879 $this->ctrl->getLinkTargetByClass([\ilTestParticipantsGUI::class])
1882 $message = $this->
lng->txt(
'test_has_datasets_warning_page_view');
1883 $massage_box = $this->ui_factory->messageBox()->info(
$message)->withLinks([$link]);
1884 $this->tpl->setCurrentBlock(
'mess');
1885 $this->tpl->setVariable(
1887 $this->ui_renderer->render($massage_box)
1889 $this->tpl->parseCurrentBlock();
1893 $this->
toolbar->addButton($this->
lng->txt(
'ass_create_question'), $this->ctrl->getLinkTarget($this,
'createQuestionForm'));
1894 $this->
toolbar->addSeparator();
1895 $this->populateQuestionBrowserToolbarButtons($this->
toolbar);
1900 $this->
ctrl->setParameterByClass(
1901 ilTestQuestionBrowserTableGUI::class,
1907 $this->
lng->txt(
'tst_browse_for_qpl_questions'),
1908 $this->ctrl->getLinkTargetByClass(
1909 ilTestQuestionBrowserTableGUI::class,
1914 $this->
ctrl->setParameterByClass(
1915 ilTestQuestionBrowserTableGUI::class,
1921 $this->
lng->txt(
'tst_browse_for_tst_questions'),
1922 $this->ctrl->getLinkTargetByClass(
1923 ilTestQuestionBrowserTableGUI::class,
1935 if (!$this->getTestObject()->getTestLogger()->isLoggingEnabled()
1936 || !$this->rbac_review->isAssigned($this->user->getId(),
SYSTEM_ROLE_ID)
1937 && !$this->access->checkAccess(
'tst_history_read',
'', $this->getTestObject()->getRefId())) {
1938 $this->redirectAfterMissingWrite();
1941 $here_uri = $this->data_factory->uri(ILIAS_HTTP_PATH
1942 .
'/' . $this->
ctrl->getLinkTargetByClass(self::class, self::SHOW_LOGS_CMD));
1943 list($url_builder, $action_parameter_token, $row_id_token) = (
new URLBuilder($here_uri))->acquireParameters(
1944 LogTable::QUERY_PARAMETER_NAME_SPACE,
1945 LogTable::ACTION_TOKEN_STRING,
1946 LogTable::ENTRY_TOKEN_STRING
1949 if ($this->request_wrapper->has($action_parameter_token->getName())) {
1950 $this->getTestObject()->getTestLogViewer()->executeLogTableAction(
1952 $action_parameter_token,
1954 $this->getTestObject()->getRefId()
1959 $this->ui_factory->button()->standard(
1960 $this->lng->txt(
'export_legacy_logs'),
1961 $this->ctrl->getLinkTargetByClass(self::class,
'exportLegacyLogs')
1964 $this->tabs_manager->activateTab(TabsManager::TAB_ID_HISTORY);
1966 list($filter, $table_gui) = $this->getTestObject()->getTestLogViewer()->getLogTable(
1968 $action_parameter_token,
1970 $this->getTestObject()->getRefId()
1973 $this->tpl->setVariable(
'ADM_CONTENT', $this->ui_renderer->render([$filter, $table_gui]));
1978 $this->protectByWritePermission();
1980 $csv_output = $this->getTestObject()->getTestLogViewer()->getLegacyLogExportForObjId($this->getTestObject()->
getId());
1984 "legacy_logs_for_{$this->getTestObject()->getRefId()}.csv"
1993 $command = $this->testrequest->strVal(
'command');
1994 if ($command ===
'') {
1995 $method = $command .
'Object';
1996 if (method_exists($this, $method)) {
2001 $this->
ctrl->redirect($this,
'participants');
2009 $this->protectByWritePermission();
2011 $this->tabs_manager->activateTab(TabsManager::TAB_ID_SETTINGS);
2013 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this,
'addDefaults'));
2014 $this->
toolbar->addFormButton($this->
lng->txt(
'add'),
'addDefaults');
2017 $defaults = $this->getTestObject()->getAvailableDefaults();
2018 $table->setData($defaults);
2019 $this->tpl->setContent($table->getHTML());
2027 $this->protectByWritePermission();
2029 $defaults_ids = $this->testrequest->retrieveArrayOfIntsFromPost(
'chb_defaults');
2030 if ($defaults_ids !==
null && $defaults_ids !== []) {
2031 foreach ($defaults_ids as $test_default_id) {
2032 $this->getTestObject()->deleteDefaults($test_default_id);
2035 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
2037 $this->defaultsObject();
2045 $this->protectByWritePermission();
2047 $this->applyDefaultsObject(
true);
2056 $this->protectByWritePermission();
2058 $defaults_id = $this->testrequest->retrieveArrayOfIntsFromPost(
'chb_defaults');
2059 if ($defaults_id === []) {
2060 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tst_defaults_apply_select_one'));
2061 $this->defaultsObject();
2066 if ($this->getTestObject()->evalTotalPersons() > 0
2067 || ($defaults = $this->getTestObject()->getTestDefaults($defaults_id[0])) ===
null) {
2068 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tst_defaults_apply_not_possible'));
2069 $this->defaultsObject();
2073 $default_settings = unserialize(
2074 $defaults[
'defaults'],
2075 [
'allowed_classes' => [DateTimeImmutable::class]]
2078 if (isset($default_settings[
'isRandomTest'])) {
2079 if ($default_settings[
'isRandomTest']) {
2086 } elseif (isset($default_settings[
'questionSetType'])) {
2087 $new_question_set_type = $default_settings[
'questionSetType'];
2089 $old_question_set_type = $this->getTestObject()->getQuestionSetType();
2090 $question_set_type_setting_switched = ($old_question_set_type != $new_question_set_type);
2092 $old_question_set_config = $this->test_question_set_config_factory->getQuestionSetConfig();
2095 case !$question_set_type_setting_switched:
2096 case !$old_question_set_config->doesQuestionSetRelatedDataExist():
2105 $confirmation->setFormAction($this->
ctrl->getFormAction($this));
2106 $confirmation->setCancel($this->
lng->txt(
'cancel'),
'defaults');
2107 $confirmation->setConfirm($this->
lng->txt(
'confirm'),
'confirmedApplyDefaults');
2109 $confirmation->setOldQuestionSetType($this->getTestObject()->getQuestionSetType());
2110 $confirmation->setNewQuestionSetType($new_question_set_type);
2111 $confirmation->setQuestionLossInfoEnabled(
false);
2112 $confirmation->build();
2114 $confirmation->populateParametersFromPost();
2116 $this->tpl->setContent($this->
ctrl->getHTML($confirmation));
2121 if ($question_set_type_setting_switched && !$this->getTestObject()->getOfflineStatus()) {
2122 $this->getTestObject()->setOfflineStatus(
true);
2123 $info = $this->
lng->txt(
'tst_set_offline_due_to_switched_question_set_type_setting');
2124 $this->tpl->setOnScreenMessage(
'info',
$info,
true);
2127 $info = $this->getTestObject()->applyDefaults($defaults);
2129 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_defaults_applied'),
true);
2131 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
$info),
true);
2136 if ($question_set_type_setting_switched && $old_question_set_config->doesQuestionSetRelatedDataExist()) {
2137 $old_question_set_config->removeQuestionSetRelatedData();
2140 $this->
ctrl->redirect($this,
'defaults');
2148 $this->protectByWritePermission();
2150 $name = $this->testrequest->strVal(
'name');
2152 $this->getTestObject()->addDefaults($name);
2154 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tst_defaults_enter_name'));
2156 $this->defaultsObject();
2162 $this->
ctrl->getCmdClass(),
2164 strtolower(PublicProfileGUI::class),
2176 $this->
ctrl->redirectByClass(
2177 [ilRepositoryGUI::class, self::class, ilInfoScreenGUI::class]
2183 if (!$this->
access->checkAccess(
'visible',
'', $this->ref_id)
2184 && !$this->access->checkAccess(
'read',
'', $this->ref_id)) {
2185 $this->redirectAfterMissingRead();
2188 if ($this->getTestObject()->getMainSettings()->getAdditionalSettings()->getHideInfoTab()) {
2189 $this->
ctrl->redirectByClass([self::class, TestScreenGUI::class], TestScreenGUI::DEFAULT_CMD);
2192 $this->tabs_manager->activateTab(TabsManager::TAB_ID_INFOSCREEN);
2194 if ($this->
access->checkAccess(
'read',
'', $this->ref_id)) {
2195 $this->trackTestObjectReadEvent();
2199 if ($this->isCommandClassAnyInfoScreenChild()) {
2204 $this->getTestObject(),
2205 $this->test_player_factory->getPlayerGUI(),
2206 $this->test_question_set_config_factory->getQuestionSetConfig(),
2207 $this->test_session_factory->getSession(),
2218 $toolbar->setCloseFormTag(
false);
2220 $toolbar->setSessionLockString(
'');
2222 $toolbar->sendMessages();
2224 $info->enablePrivateNotes();
2226 $info->addSection($this->
lng->txt(
'tst_general_properties'));
2228 $this->
lng->txt(
'author'),
2229 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform(
2230 $this->getTestObject()->getAuthor()
2234 $this->
lng->txt(
'title'),
2235 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform(
2236 $this->getTestObject()->getTitle()
2240 if ($this->type !==
'tst') {
2241 $info->hideFurtherSections(
false);
2244 $info->addSection($this->
lng->txt(
'tst_sequence_properties'));
2246 $this->
lng->txt(
'tst_sequence'),
2248 $this->getTestObject()->getMainSettings()->getParticipantFunctionalitySettings()->getPostponedQuestionsMoveToEnd()
2249 ?
'tst_sequence_postpone' :
'tst_sequence_fixed'
2253 $info->addSection($this->
lng->txt(
'tst_heading_scoring'));
2255 $this->
lng->txt(
'tst_text_count_system'),
2257 ($this->getTestObject()->getCountSystem() == SettingsScoring::COUNT_PARTIAL_SOLUTIONS) ?
'tst_count_partial_solutions' :
'tst_count_correct_solutions'
2260 if ($this->getTestObject()->isRandomTest()) {
2261 $info->addProperty($this->
lng->txt(
'tst_pass_scoring'), $this->lng->txt(($this->getTestObject()->getPassScoring() ==
ilObjTest::SCORE_BEST_PASS) ?
'tst_pass_best_pass' :
'tst_pass_last_pass'));
2264 $info->addSection($this->
lng->txt(
'tst_score_reporting'));
2266 $this->
lng->txt(
'tst_score_reporting'),
2267 $this->getTestObject()->getScoreSettings()->getResultSummarySettings()
2268 ->getScoreReporting()->getTranslatedValue($this->lng)
2270 $reporting_date = $this->getTestObject()
2271 ->getScoreSettings()
2272 ->getResultSummarySettings()
2273 ->getReportingDate();
2274 if ($reporting_date !==
null) {
2276 $this->
lng->txt(
'tst_score_reporting_date'),
2278 ->setTimezone(
new DateTimeZone($this->
user->getTimeZone()))
2279 ->format($this->user->getDateTimeFormat()->toString())
2283 $info->addSection($this->
lng->txt(
'tst_session_settings'));
2284 $info->addProperty($this->
lng->txt(
'tst_nr_of_tries'), $this->getTestObject()->getNrOfTries() === 0 ? $this->lng->txt(
'unlimited') : (
string) $this->getTestObject()->getNrOfTries());
2285 if ($this->getTestObject()->getNrOfTries() != 1) {
2287 $this->
lng->txt(
'tst_nr_of_tries_of_user'),
2288 ($this->test_session_factory->getSession()->getPass() === 0) ?
2289 $this->lng->txt(
'tst_no_tries') : (
string) $this->test_session_factory->getSession()->getPass()
2293 if ($this->getTestObject()->getEnableProcessingTime()) {
2294 $info->addProperty($this->
lng->txt(
'tst_processing_time'), $this->getTestObject()->getProcessingTime());
2297 $starting_time = $this->getTestObject()->getStartingTime();
2298 if ($this->getTestObject()->isStartingTimeEnabled() && $starting_time !== 0) {
2301 $ending_time = $this->getTestObject()->getEndingTime();
2302 if ($this->getTestObject()->isEndingTimeEnabled() && $ending_time != 0) {
2305 $info->addMetaDataSections($this->getTestObject()->
getId(), 0, $this->getTestObject()->getType());
2313 $qsaImportFails->deleteRegisteredImportFails();
2315 $sltImportFails->deleteRegisteredImportFails();
2317 $this->
ctrl->redirectByClass([ilRepositoryGUI::class, self::class, ilInfoScreenGUI::class]);
2322 switch ($this->
ctrl->getCmd()) {
2325 case "redirectToInfoScreen":
2332 case "outCorrectSolution":
2333 case "showAnswersOfUser":
2334 case "outUserResultsOverview":
2335 case "backFromSummary":
2336 case "show_answers":
2339 case "outTestSummary":
2340 case "outQuestionSummary":
2341 case "gotoQuestion":
2342 case "selectImagemapRegion":
2343 case "confirmSubmitAnswers":
2344 case "finalSubmission":
2346 case "outUserPassDetails":
2347 case "checkPassword":
2349 $this->getTestObject()->
getTitle(),
2350 $this->
ctrl->getLinkTargetByClass(
2351 [self::class, TestScreenGUI::class],
2352 TestScreenGUI::DEFAULT_CMD
2355 $this->testrequest->getRefId()
2359 case "evalAllUsers":
2360 case "evalUserDetail":
2362 $this->getTestObject()->
getTitle(),
2363 $this->
ctrl->getLinkTarget($this,
'eval_stat'),
2365 $this->testrequest->getRefId()
2370 case "importVerifiedFile":
2371 case "cancelImport":
2375 $this->getTestObject()->
getTitle(),
2376 $this->
ctrl->getLinkTargetByClass(
2377 [self::class, TestScreenGUI::class],
2378 TestScreenGUI::DEFAULT_CMD
2381 $this->testrequest->getRefId()
2396 $this->tabs_manager->activateTab(TabsManager::TAB_ID_SETTINGS);
2399 $output_gui = $guiFactory->create($this->getTestObject());
2401 $output_gui->certificateEditor();
2411 $this->
help->setScreenIdComponent(
"tst");
2413 if ($this->tabs_manager ===
null) {
2417 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
2418 $courseLink = ilLink::_getLink($this->getObjectiveOrientedContainer()->getRefId());
2419 $this->tabs_manager->setParentBackLabel($this->
lng->txt(
'back_to_objective_container'));
2420 $this->tabs_manager->setParentBackHref($courseLink);
2423 $this->tabs_manager->perform();
2426 public static function accessViolationRedirect()
2430 $main_tpl =
$DIC->ui()->mainTemplate();
2432 $main_tpl->setOnScreenMessage(
'failure',
$DIC->language()->txt(
"no_permission"),
true);
2433 $DIC->ctrl()->redirectByClass(TestScreenGUI::class, TestScreenGUI::DEFAULT_CMD);
2445 $main_tpl =
$DIC->ui()->mainTemplate();
2446 $ilAccess =
$DIC[
'ilAccess'];
2450 if ($ilAccess->checkAccess(
'read',
'', (
int) $target)
2451 || $ilAccess->checkAccess(
'visible',
'', (
int) $target)) {
2452 $DIC->ctrl()->setParameterByClass(self::class,
'ref_id', (
int) $target);
2453 $DIC->ctrl()->redirectByClass(
2455 ilRepositoryGUI::class,
2456 ilObjTestGUI::class,
2457 TestScreenGUI::class
2459 TestScreenGUI::DEFAULT_CMD
2462 $main_tpl->setOnScreenMessage(
'info', sprintf(
2463 $lng->txt(
'msg_no_perm_read_item'),
2474 $this->copyQuestionsToPool($this->testrequest->raw(
'q_id'), $this->testrequest->raw(
'sel_qpl'));
2475 $this->
ctrl->redirect($this, self::SHOW_QUESTIONS_CMD);
2486 foreach ($question_ids as $q_id) {
2487 $new_id = $this->copyQuestionToPool(assQuestion::instantiateQuestionGUI($q_id), $target_pool);
2488 $new_ids[$q_id] = $new_id;
2491 $result =
new stdClass();
2492 $result->ids = $new_ids;
2493 $result->qpoolid = $qpl_id;
2501 $source_question_gui->
getObject()->getTitle()
2504 return $source_question_gui->
getObject()->createNewOriginalFromThisDuplicate($target_pool->
getId(), $new_title);
2509 array $question_ids = []
2515 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"questionpool_not_selected"));
2516 $this->showQuestionsObject();
2520 $qpl_id = $this->obj_data_cache->lookupObjId(
$ref_id);
2523 if ($question_ids === []) {
2524 $question_ids = $this->testrequest->getQuestionIds();
2525 $question_id = $this->testrequest->getQuestionId();
2526 if ($question_ids === [] && $question_id !== 0) {
2527 $question_ids = [$question_id];
2531 if ($question_ids === []) {
2532 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"tst_no_question_selected_for_moving_to_qpl"));
2533 $this->
ctrl->redirect($this,
'questions');
2536 $result = $this->copyQuestionsToPool($question_ids, $qpl_id);
2538 foreach ($result->ids as $oldId => $newId) {
2541 $original_question_id = $questionInstance->getOriginalId();
2542 if ($original_question_id !==
null
2543 && $this->test_questions_repository->originalQuestionExists($original_question_id)) {
2545 $oldOriginal->delete($oldOriginal->getId());
2550 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_qst_added_to_pool_' . (count($result->ids) > 1 ?
'p' :
's')),
true);
2551 $this->
ctrl->redirect($this, self::SHOW_QUESTIONS_CMD);
2556 $this->createQuestionpoolTargetObject(
'copyQuestionsToPool');
2561 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())
2562 || !$this->checkPermissionBool(
'create',
'',
'qpl')) {
2563 $this->redirectAfterMissingWrite();
2566 if ($this->testrequest->raw(
'title')) {
2567 $title = $this->testrequest->raw(
'title');
2569 $title = $this->testrequest->raw(
'txt_qpl');
2573 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'questionpool_not_entered'));
2574 $this->createQuestionpoolTargetObject(
'createQuestionPoolAndCopy');
2578 $question_pool = $this->createQuestionPool($title, $this->testrequest->raw(
'description'));
2579 $_REQUEST[
'sel_qpl'] = $question_pool->getRefId();
2581 $this->copyAndLinkQuestionsToPoolObject();
2590 $this->protectByWritePermission();
2592 $this->tabs_manager->getQuestionsSubTabs();
2593 $this->tabs_manager->activateSubTab(TabsManager::SUBTAB_ID_QST_LIST_VIEW);
2595 $questionpools = $this->getTestObject()->getAvailableQuestionpools(
2604 if ($questionpools === []) {
2605 $form = $this->getTargetQuestionpoolForm($questionpools,
'createQuestionPoolAndCopy');
2607 $form = $this->getTargetQuestionpoolForm($questionpools, $cmd);
2610 case 'copyQuestionsToPool':
2613 case 'copyAndLinkQuestionsToPool':
2615 $hidden->setValue(
'1');
2616 $form->addItem($hidden);
2621 $this->tpl->setContent($form->getHTML());
2627 $form->setFormAction($this->
ctrl->getFormAction($this));
2628 $form->addCommandButton($cmd, $this->
lng->txt(
'submit'));
2629 $form->addCommandButton(
'cancelCreateQuestion', $this->
lng->txt(
'cancel'));
2631 if (count($questionpools) == 0) {
2632 $form->setTitle($this->
lng->txt(
"tst_enter_questionpool"));
2635 $title->setRequired(
true);
2636 $form->addItem($title);
2639 $form->addItem($description);
2641 $form->setTitle($this->
lng->txt(
"tst_select_questionpool"));
2644 '' => $this->
lng->txt(
'please_select')
2647 foreach ($questionpools as $key => $value) {
2648 $selectOptions[$key] = $value[
"title"];
2652 $select->setRequired(
true);
2653 $select->setOptions($selectOptions);
2655 $form->addItem($select);
2658 $table_query = $this->getQuestionsTableQuery();
2660 $question_ids = $table_query->
getRowIds($this->
object);
2661 } elseif ($this->testrequest->isset(
'q_id') && is_array($this->testrequest->raw(
'q_id'))) {
2662 $question_ids = $this->testrequest->raw(
'q_id');
2665 foreach ($question_ids as
$id) {
2667 $hidden->setValue((
string)
$id);
2668 $form->addItem($hidden);
2676 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
2677 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'cannot_edit_test'),
true);
2678 $this->
ctrl->redirectByClass([ilRepositoryGUI::class, self::class, ilInfoScreenGUI::class]);
2688 $path = $this->tree->getPathFull($this->ref_id);
2690 while ($parent = array_pop(
$path)) {
2691 if ($parent[
'type'] ===
'crs') {
2692 $container_ref_id = $parent[
'ref_id'];
2699 $this->objective_oriented_container->setObjId($container_obj_id);
2700 $this->objective_oriented_container->setRefId($container_ref_id);
2705 return $this->objective_oriented_container;
2711 $this->getTestObject(),
2719 $this->content_style,
2721 $this->tabs_manager,
2731 if ($this->table_query ===
null) {
2732 $id = $this->
object ? $this->
object->getId() :
'';
2736 $this->data_factory,
2740 return $this->table_query;
2745 if ($this->table_actions ===
null) {
2751 $this->getQuestionsTableQuery(),
2754 $this->test_questions_repository,
2755 new QuestionPrinter(
2758 $this->tabs_manager,
2765 $this->getTestObject()
2768 $this->getTestObject()->getGlobalSettings()->isAdjustingQuestionsWithResultsAllowed(),
2769 $this->getTestObject()->evalTotalPersons() !== 0,
2770 $this->getTestObject()->isRandomTest(),
2771 $this->test_question_set_config_factory
2774 return $this->table_actions;
2782 $this->
http->request(),
2783 $this->getQuestionsTableActions(),
2786 $this->test_questions_repository,
2787 $this->title_builder
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
getRowIds(\ilObjTest $obj_test)
@ilCtrl_Calls ILIAS\Test\Settings\MainSettings\SettingsMainGUI: ilPropertyFormGUI @ilCtrl_Calls ILIAS...
GUI class for public user profile presentation.
setMoveAfterQuestionId(?int $question_id)
setCopyToNewPoolOnSave(?string $pool_title)
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
const EDIT_CONTEXT_AUTHORING
setCopyToExistingPoolOnSave(?int $pool_ref_id)
getCopyToExistingPoolOnSave()
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
const ADDITIONAL_CONTENT_EDITING_MODE_IPE
static saveOriginalId(int $questionId, int $originalId)
static instantiateQuestion(int $question_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static isObjectiveTest(int $a_trst_ref_id)
Check if test ref_id is used in an objective course.
GUI class for LTI provider object settings.
const LP_CONTEXT_REPOSITORY
Class ilObjUserTrackingGUI.
Class ilLocalUnitConfigurationGUI.
Last visited history for repository items.
static _getAvailableQuestionpools(bool $use_object_id=false, bool $equal_points=false, bool $could_be_offline=false, bool $showPath=false, bool $with_questioncount=false, string $permission='read', int $usr_id=0)
Returns the available question pools for the active user.
static getQuestionTypeByTypeId($type_id)
appendCounterToQuestionTitleIfNecessary(string $title)
RequestDataCollector $testrequest
SkillService $skills_service
trackTestObjectReadEvent()
addQuestionTitleToObjectTitle(string $question_title)
createQuestionpoolTargetObject(string $cmd)
Called when a new question should be created from a test Important: $cmd may be overwritten if no que...
addPostCreationTasksToQuestionGUI(assQuestionGUI $question_gui)
executeAfterQuestionCreationTasks(assQuestionGUI $question_gui)
redirectAfterMissingRead()
download_paragraphObject()
download source code paragraph
GeneralQuestionPropertiesRepository $questionrepository
TestTopListRepository $toplist_repository
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
ilTestPlayerFactory $test_player_factory
static _goto($target)
Redirect script to call a test with the test reference id.
ResponseHandler $response_handler
ExportRepository $export_repository
TestResultRepository $test_pass_result_repository
ParticipantRepository $participant_repository
showNextViewAfterQuestionSave(assQuestionGUI $question_gui, string $target)
ilComponentRepository $component_repository
createQuestionPool($name="dummy", $description="")
buildInputPoolSelection()
createQuestionPoolAndCopyObject()
retrieveAdditionalDidacticTemplateOptions()
ilNavigationHistory $navigation_history
insertQuestionsObject(?array $selected_array=null)
ExportImportFactory $export_factory
TitleColumnsBuilder $title_builder
getTargetQuestionpoolForm($questionpools, string $cmd)
QuestionsTableActions $table_actions
importFile(string $file_to_import, string $path_to_uploaded_file_in_temp_dir)
participantsActionObject()
Evaluates the actions on the participants page.
isCommandClassAnyInfoScreenChild()
TaxonomyService $taxonomy
protectByWritePermission()
executeCommand()
execute command
QPLRequestDataCollector $qplrequest
bool $create_question_mode
fetchAuthoringQuestionIdParameter()
getObjectiveOrientedContainer()
ilTestObjectiveOrientedContainer $objective_oriented_container
determineObjectiveOrientedContainer()
getTestScreenGUIInstance()
ilTestQuestionSetConfigFactory $test_question_set_config_factory
getQuestionsTableActions()
getSelectedPersonalDefaultsSettingsFromForm()
forwardCommandToQuestionPreview(string $cmd, ?assQuestionGUI $question_gui=null)
ResultsDataFactory $results_data_factory
ilTestParticipantAccessFilterFactory $participant_access_filter_factory
forwardCommandToQuestion(string $cmd)
afterSave(ilObject $new_object)
save object @access public
populateQuestionBrowserToolbarButtons(ilToolbarGUI $toolbar)
applyDefaultsObject($confirmed=false)
Applies the selected test defaults.
TestQuestionsRepository $test_questions_repository
ilTestSessionFactory $test_session_factory
downloadFileObject()
download file
const QUESTION_CREATION_POOL_SELECTION_NO_POOL
copyAndLinkQuestionsToPoolObject(?int $ref_id=null, array $question_ids=[])
copyQuestionsToPoolObject()
copyToQuestionpoolObject()
buildQuestionCreationForm()
setupToolBarAndMessage(bool $has_started_test_runs)
copyQuestionsToPool(array $question_ids, int $qpl_id)
getTabs()
adds tabs to tab gui object
questionsTabGatewayObject()
const QUESTION_CREATION_POOL_SELECTION_EXISTING_POOL
fullscreenObject()
show fullscreen view
GlobalScreen $global_screen
cancelCreateQuestionObject()
ContentStyle $content_style
copyQuestionToPool(assQuestionGUI $source_question_gui, ilObjQuestionPool $target_pool)
createQuestionFormObject(?Form $form=null)
executeAfterQuestionSaveTasks(assQuestionGUI $question_gui)
exportObject()
Gateway for exports initiated from workspace, as there is a generic forward to {objTypeMainGUI}::expo...
deleteDefaultsObject()
Deletes selected test defaults.
defaultsObject()
Displays the settings page for test defaults.
redirectAfterMissingWrite()
buildInputPosition(array $questions)
setTestAccess(ilTestAccess $test_access)
ilObjectDataCache $obj_data_cache
removeImportFailsObject()
confirmedApplyDefaultsObject()
DataFactory $data_factory
const QUESTION_CREATION_POOL_SELECTION_NEW_POOL
ilComponentFactory $component_factory
addDefaultsObject()
Adds the defaults of this test to the defaults.
redirectTo_SettingsMainGUI_showForm_Object()
QuestionsTableQuery $table_query
importVerifiedFileObject(bool $skip_retrieve_selected_questions=false)
imports question(s) into the questionpool (after verification)
ilTestAccess $test_access
ResultsPresentationFactory $results_presentation_factory
certificateObject()
Shows the certificate editor.
TabsManager $tabs_manager
const QUESTION_SET_TYPE_RANDOM
const QUESTION_SET_TYPE_FIXED
GUI class for the workflow of copying objects.
Class ilObjectGUI Basic methods of all Output classes.
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
setCreationMode(bool $mode=true)
If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode...
addHeaderAction()
Add header action menu.
prepareOutput(bool $show_sub_objects=true)
Class ilObject Basic functions for all objects.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
Output class for assessment test evaluation.
Base Exception for all Exceptions relating to Modules/Test.
Export User Interface Class.
Class that handles PDF generation for test and assessment.
Importer class for files.
@ilCtrl_Calls ilTestPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI @ilCtrl_Calls ilTestP...
Class ilTestParticipantsGUI.
Class ilTestPersonalDefaultSettingsTableGUI.
@ilCtrl_Calls ilTestQuestionBrowserTableGUI: ilFormPropertyDispatchGUI
const CMD_BROWSE_QUESTIONS
Service GUI class for tests.
This class represents a text area property in a property form.
This class represents a text property in a property form.
Class ilUnitConfigurationRepository.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static redirect(string $a_script)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
An entity that renders components to a string output.
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
trait TestQuestionsImportTrait
buildImportQuestionsSelectionForm(string $form_cmd, string $importdir, string $qtifile, ?string $path_to_uploaded_file_in_temp_dir=null)
buildImportDirectoriesFromImportFile(string $file_to_import)
buildResultsFilePath(string $importdir, string $subdir)
retrieveSelectedQuestionsFromImportQuestionsSelectionForm(string $form_cmd, string $importdir, string $qtifile, ServerRequestInterface $request)
TestAdministrationInteractionTypes
TestQuestionAdministrationInteractionTypes
if(!file_exists('../ilias.ini.php'))