19 declare(strict_types=1);
100 $this->db = $DIC[
'ilDB'];
101 $this->log = $DIC[
'ilLog'];
102 $this->
help = $DIC[
'ilHelp'];
103 $this->global_screen = $DIC[
'global_screen'];
104 $this->component_factory = $DIC[
'component.factory'];
105 $this->component_repository = $DIC[
'component.repository'];
106 $this->navigation_history = $DIC[
'ilNavigationHistory'];
107 $this->ui_service = $DIC->uiService();
108 $this->taxonomy = $DIC->taxonomy();
109 $this->
http = $DIC->http();
110 $this->archives = $DIC->archives();
111 $this->content_style = $DIC->contentStyle();
115 $local_dic = QuestionPoolDIC::dic();
116 $this->request_data_collector = $local_dic[
'request_data_collector'];
117 $this->questionrepository = $local_dic[
'question.general_properties.repository'];
118 $this->global_test_settings = $local_dic[
'global_test_settings'];
122 $this->
ctrl->saveParameter($this, [
130 $this->
ctrl->saveParameterByClass(
'ilAssQuestionPageGUI',
'consumer_context');
131 $this->
ctrl->saveParameterByClass(
'ilobjquestionpoolgui',
'consumer_context');
133 $this->
lng->loadLanguageModule(
'assessment');
135 $here_uri = $this->data_factory->uri($this->request->getUri()->__toString());
137 $query_params_namespace = [
'qpool',
'table'];
138 list($url_builder, $action_parameter_token, $row_id_token) = $url_builder->
acquireParameters(
139 $query_params_namespace,
147 $this->notes_service->gui()->initJavascript();
152 $write_access = $this->
access->checkAccess(
'write',
'', $this->request_data_collector->getRefId());
154 if ((!$this->
access->checkAccess(
'read',
'', $this->request_data_collector->getRefId()))
155 && (!$this->
access->checkAccess(
'visible',
'', $this->request_data_collector->getRefId()))) {
156 $this->
ilias->raiseError($this->
lng->txt(
'permission_denied'), $this->
ilias->error_obj->MESSAGE);
160 $this->
access->checkAccess(
'read',
'', $this->request_data_collector->getRefId())) {
161 if (
'qpl' === $this->
object->getType()) {
162 $this->navigation_history->addItem(
163 $this->request_data_collector->getRefId(),
164 ilLink::_getLink($this->request_data_collector->getRefId(),
"qpl"),
170 $cmd = $this->
ctrl->getCmd(self::DEFAULT_CMD);
171 $next_class = $this->
ctrl->getNextClass($this);
172 $q_id = $this->request_data_collector->getQuestionId() ?? null;
174 if (in_array($next_class, [
'',
'ilobjquestionpoolgui']) && $cmd == self::DEFAULT_CMD) {
182 $q_type = $this->request_data_collector->string(
'question_type');
183 switch ($next_class) {
184 case 'ilcommonactiondispatchergui':
186 $this->
ctrl->forwardCommand($gui);
189 case 'ilobjectmetadatagui':
190 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
191 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->WARNING);
194 $this->
ctrl->forwardCommand($md_gui);
197 case 'ilassquestionpreviewgui':
198 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
202 $this->
ctrl->saveParameterByClass(ilAssQuestionPreviewGUI::class,
'q_id');
203 $this->
ctrl->saveParameterByClass(ilAssQuestionHintRequestGUI::class,
'q_id');
204 $this->
ctrl->saveParameter($this,
'q_id');
221 $question_gui = assQuestion::instantiateQuestionGUI($this->request_data_collector->int(
'q_id'));
223 $this->
lng->txt(
'edit_question'),
224 $this->
ctrl->getLinkTargetByClass(
225 get_class($question_gui),
229 $gui->addAdditionalCmd(
230 $this->
lng->txt(
'edit_page'),
231 $this->
ctrl->getLinkTargetByClass(
232 ilAssQuestionPageGUI::class,
241 $gui->initPreviewSettings($this->
object->getRefId());
243 $gui->initHintTracking();
244 $this->
ctrl->clearParameterByClass(self::class,
'q_id');
245 $this->tabs_gui->setBackTarget(
246 $this->
lng->txt(
'backtocallingpool'),
247 $this->
ctrl->getLinkTargetByClass(self::class, self::DEFAULT_CMD)
250 $this->
help->setScreenIdComponent(
'qpl');
252 $this->
ctrl->forwardCommand($gui);
255 case 'ilassquestionpagegui':
256 if ($cmd ==
'finishEditing') {
257 $this->
ctrl->redirectByClass(
'ilassquestionpreviewgui',
'show');
260 if ($cmd ===
'edit' && !$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
263 $this->tpl->setCurrentBlock(
'ContentStyle');
265 $this->tpl->parseCurrentBlock();
267 $this->tpl->setCurrentBlock(
'SyntaxStyle');
269 $this->tpl->parseCurrentBlock();
272 $question_gui->setQuestionTabs();
274 $question_gui->setQuestionActionCmd(
'');
276 if ($this->
object->getType() ===
'qpl') {
277 $question_gui->addHeaderAction();
282 if ($this->questionrepository->isInActiveTest($question->getObjId())) {
283 $this->tpl->setOnScreenMessage(
285 $this->
lng->txt(
'question_is_part_of_running_test'),
291 $this->
ctrl->saveParameter($this,
'q_id');
292 $this->
lng->loadLanguageModule(
'content');
293 $this->
ctrl->setReturnByClass(
'ilAssQuestionPageGUI',
'view');
294 $this->
ctrl->setReturn($this, self::DEFAULT_CMD);
296 $page_gui->obj->addUpdateListener(
301 $page_gui->setEnabledTabs(
false);
302 $page_gui->setQuestionHTML([$question_gui->
getObject()->getId() => $question_gui->getPreview(
true)]);
303 $page_gui->setTemplateTargetVar(
'ADM_CONTENT');
304 $page_gui->setOutputMode(
'edit');
305 $page_gui->setHeader($question->getTitleForHTMLOutput());
306 $page_gui->setPresentationTitle($question->getTitleForHTMLOutput());
307 $ret = $this->
ctrl->forwardCommand($page_gui);
309 $this->tpl->setContent($ret);
313 case 'ilpermissiongui':
315 $this->
ctrl->forwardCommand($perm_gui);
318 case 'ilobjectcopygui':
321 $this->
ctrl->forwardCommand($cp);
326 $ret = $this->
ctrl->forwardCommand($exp_gui);
329 case strtolower(ilInfoScreenGUI::class):
333 case 'ilassquestionhintsgui':
334 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
338 $this->
ctrl->setReturn($this, self::DEFAULT_CMD);
344 $question->setObjId($this->
object->getId());
345 $question_gui->setObject($question);
346 $question_gui->setQuestionTabs();
348 if ($this->questionrepository->isInActiveTest($question_gui->
getObject()->getObjId())) {
349 $this->tpl->setOnScreenMessage(
351 $this->
lng->txt(
'question_is_part_of_running_test'),
357 $this->
help->setScreenIdComponent(
'qpl');
359 if ($this->
object->getType() ==
'qpl' && $write_access) {
360 $question_gui->addHeaderAction();
364 $gui->setEditingEnabled(
365 $this->
access->checkAccess(
'write',
'', $this->object->getRefId())
368 $this->
ctrl->forwardCommand($gui);
372 case 'illocalunitconfigurationgui':
373 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
374 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->WARNING);
381 $question->setObjId($this->
object->getId());
382 $question_gui->setObject($question);
383 $question_gui->setQuestionTabs();
385 $this->
ctrl->setReturn($this, self::DEFAULT_CMD);
389 $this->
ctrl->forwardCommand($gui);
392 case 'ilassquestionfeedbackeditinggui':
393 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
397 $this->
ctrl->setReturn($this, self::DEFAULT_CMD);
403 $question->setObjId($this->
object->getId());
404 $question_gui->setObject($question);
405 $question_gui->setQuestionTabs();
407 if ($this->questionrepository->isInActiveTest($question_gui->
getObject()->getObjId())) {
408 $this->tpl->setOnScreenMessage(
410 $this->
lng->txt(
'question_is_part_of_running_test'),
416 $this->
help->setScreenIdComponent(
'qpl');
418 if ($this->
object->getType() ==
'qpl' && $write_access) {
419 $question_gui->addHeaderAction();
429 $this->request_data_collector,
430 $this->content_style,
433 $this->
ctrl->forwardCommand($gui);
437 case 'ilobjquestionpoolsettingsgeneralgui':
450 $this->
ctrl->forwardCommand($gui);
453 case strtolower(ilTaxonomySettingsGUI::class):
454 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
464 $this->component_repository,
471 $forwarder->forward();
475 case 'ilquestionpoolskilladministrationgui':
486 $this->component_repository,
491 $this->
ctrl->forwardCommand($gui);
494 case 'ilbulkeditquestionsgui':
495 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
498 $this->tabs_gui->setBackTarget(
499 $this->
lng->txt(
'backtocallingpool'),
500 $this->
ctrl->getLinkTargetByClass(self::class, self::DEFAULT_CMD)
502 $this->tabs_gui->addTarget(
506 $this->
ctrl->getCmdClass(),
509 $this->tabs_gui->setTabActive(
'edit_questions');
511 $gui = new \ilBulkEditQuestionsGUI(
519 $this->request_wrapper,
522 $this->
ctrl->forwardCommand($gui);
525 case 'ilobjquestionpoolgui':
528 if ($action = $this->request_data_collector->string($this->action_parameter_token->getName())) {
529 $ids = $this->request_data_collector->raw($this->row_id_token->getName()) ?? null;
532 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_questions_selected'),
true);
533 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
535 if ($ids[0] ===
'ALL_OBJECTS') {
536 $ids = $this->
object->getAllQuestionIds();
538 if (!is_array($ids)) {
539 $ids = explode(
',', $ids);
543 $class = strtolower($this->questionrepository->getForQuestionId(current($ids))->getGuiClassName());
544 $this->
ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id", current($ids));
545 $this->
ctrl->setParameterByClass(
"ilAssQuestionPreviewGUI",
"q_id", current($ids));
546 $this->
ctrl->setParameterByClass(
'ilAssQuestionFeedbackEditingGUI',
'q_id', current($ids));
547 $this->
ctrl->setParameterByClass(
'ilAssQuestionHintsGUI',
'q_id', current($ids));
548 $this->
ctrl->setParameterByClass($class,
"q_id", current($ids));
559 case 'edit_question':
560 $url = $this->
ctrl->getLinkTargetByClass($class,
'editQuestion');
564 $url = $this->
ctrl->getLinkTargetByClass(
'ilAssQuestionPageGUI',
'edit');
577 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
581 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
588 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
593 $this->
object->getRefId(),
595 $this->
object->getId(),
601 .
' event = new Event("click");' 610 $this->
ctrl->clearParameters($this);
611 $this->
ctrl->setParameterByClass(
612 ilBulkEditQuestionsGUI::class,
616 $url = $this->
ctrl->getLinkTargetByClass(
617 ilBulkEditQuestionsGUI::class,
624 throw new \Exception(
"'$action'" .
" not implemented");
630 if ($cmd == self::DEFAULT_CMD) {
631 $this->
ctrl->setParameter($this,
'q_id',
'');
634 $ret = $this->$cmd();
640 [
'editQuestion',
'save',
'suggestedsolution',
'uploadImage',
'removeImage']
641 ) && !$this->
access->checkAccess(
644 $this->object->getRefId()
649 $this->
ctrl->setReturnByClass(self::class, self::DEFAULT_CMD);
658 $question->setObjId($this->
object->getId());
659 $question_gui->setObject($question);
661 if ($this->
object->getType() ===
'qpl') {
662 $question_gui->setTaxonomyIds($this->
object->getTaxonomyIds());
665 $question_gui->addHeaderAction();
669 $this->
help->setScreenIdComponent(
'qpl');
671 if ($qid === 0 && $question_gui->cmdNeedsExistingQuestion($cmd)) {
672 $question_gui->
getObject()->createNewQuestion();
675 $question_gui->setQuestionTabs();
677 if (!in_array($cmd, [
'save',
'saveReturn'])) {
678 $question_gui->$cmd();
682 if (!$question_gui->saveQuestion()) {
685 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
686 if ($cmd ===
'saveReturn') {
687 $this->
ctrl->setParameterByClass(
688 ilAssQuestionPreviewGUI::class,
690 (
string) $question_gui->
getObject()->getId()
692 $this->
ctrl->redirectToURL(
697 if ($cmd ===
'save') {
698 $this->tabs_gui->activateTab(
'edit_question');
699 $question_gui->editQuestion(
false,
false);
704 if (!(strtolower($this->request_data_collector->raw(
'baseClass')) ==
'iladministrationgui' 705 || strtolower($this->request_data_collector->raw(
'baseClass')) ==
'ilrepositorygui')
707 $this->tpl->printToStdout();
713 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_permission'),
true);
714 $target_class = get_class($this->
object) .
'GUI';
715 $this->
ctrl->setParameterByClass($target_class,
'ref_id', $this->ref_id);
716 $this->
ctrl->redirectByClass($target_class);
725 $this->
ctrl->redirectByClass(
'ilQuestionPoolExportGUI');
730 $file = explode(
'_', $this->request_data_collector->raw(
'file_id'));
731 $fileObj =
new ilObjFile((
int) $file[count($file) - 1],
false);
732 $fileObj->sendFile();
751 $pg_obj->
sendParagraph($this->request_data_collector->raw(
'par_id'), $this->request_data_collector->raw(
'downloadtitle'));
757 if ($this->creation_mode
758 && !$this->
checkPermissionBool(
'create',
'', $this->request_data_collector->string(
'new_type'))
759 || !$this->creation_mode
769 $new_obj->setType($this->request_data_collector->raw(
'new_type'));
770 $new_obj->setTitle(
'dummy');
771 $new_obj->setDescription(
'questionpool import');
772 $new_obj->create(
true);
773 $new_obj->createReference();
774 $new_obj->putInTree($this->request_data_collector->getRefId());
775 $new_obj->setPermissions($this->request_data_collector->getRefId());
778 'importVerifiedFile',
784 if (is_file($importdir . DIRECTORY_SEPARATOR .
'manifest.xml')) {
799 $new_obj->fromXML($xmlfile);
802 $new_obj->saveToDb();
806 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'object_imported'),
true);
807 $this->
ctrl->setParameterByClass(self::class,
'ref_id', $new_obj->getRefId());
808 $this->
ctrl->redirectByClass(self::class);
815 if (mb_substr($file_to_import, -3) ===
'xml') {
816 $importdir = dirname($file_to_import);
818 'importVerifiedQuestionsFile',
832 'importVerifiedQuestionsFile',
837 if (is_file($importdir . DIRECTORY_SEPARATOR .
'manifest.xml')) {
856 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'object_imported'),
true);
863 $data = $import_questions_modal->getData();
864 if (
$data === null) {
866 $import_questions_modal->withOnLoad(
867 $import_questions_modal->getShowSignal()
872 $path_to_imported_file_in_temp_dir =
$data[
'import_file'][0];
878 $constraint = $this->
refinery->custom()->constraint(
879 function ($vs):
bool {
885 $this->
lng->txt(
'msg_no_files_selected')
888 $file_upload_input = $this->ui_factory->input()->field()
890 ->withAcceptedMimeTypes(self::SUPPORTED_IMPORT_MIME_TYPES)
892 ->withAdditionalTransformation($constraint);
893 return $this->ui_factory->modal()->roundtrip(
894 $this->
lng->txt(
'import'),
896 [
'import_file' => $file_upload_input],
897 $this->
ctrl->getFormActionByClass(self::class,
'uploadQuestionsImport')
898 )->withSubmitLabel($this->
lng->txt(
'import'));
903 array $selected_questions,
904 string $file_to_import
907 ilSession::set(
'qpl_import_selected_questions', $selected_questions);
908 $imp =
new ilImport($this->request_data_collector->getRefId());
910 $map->addMapping(
'components/ILIAS/TestQuestionPool',
'qpl',
'new_id', (
string) $obj->
getId());
911 $imp->
importObject($obj, $file_to_import, basename($file_to_import),
'qpl',
'components/ILIAS/TestQuestionPool',
true);
916 array $selected_questions,
930 if ($xmlfile ===
'') {
939 $cont_parser->setQuestionMapping($qti_parser->getImportMapping());
940 $cont_parser->startParsing();
951 public function createQuestionObject():
void 954 $data_with_section = $form->getData();
955 if ($data_with_section === null) {
959 $data = $data_with_section[0];
961 $this->
ctrl->setReturnByClass(self::class, self::DEFAULT_CMD);
967 $question = $question_gui->getObject();
968 $question->setObjId($this->
object->getId());
969 $question->setAdditionalContentEditingMode(
$data[
'editing_type']);
970 $question_gui->setObject($question);
971 $question_gui->setQuestionTabs();
972 $question_gui->editQuestion();
978 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'object_added'),
true);
981 'ilias.php?ref_id=' . $new_object->
getRefId() .
982 '&baseClass=ilObjQuestionPoolGUI' 990 $questionIdsToDelete = array_filter(
array_map(
'intval', $ids));
991 if (0 === count($questionIdsToDelete)) {
992 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_delete_select_none'),
true);
993 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
996 $this->tpl->setOnScreenMessage(
'question', $this->
lng->txt(
'qpl_confirm_delete_questions'));
997 $deleteable_questions = $this->
object->getDeleteableQuestionDetails($questionIdsToDelete);
998 $table_gui =
new ilQuestionBrowserTableGUI($this, self::DEFAULT_CMD, (($rbacsystem->checkAccess(
'write', $this->request_data_collector->getRefId()) ?
true :
false)),
true);
999 $table_gui->setShowRowsSelector(
false);
1000 $table_gui->setLimit(PHP_INT_MAX);
1001 $table_gui->setEditable($rbacsystem->checkAccess(
'write', $this->request_data_collector->getRefId()));
1002 $table_gui->setData($deleteable_questions);
1003 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
1013 $questionIdsToDelete = $this->request_data_collector->isset(
'q_id') ? (array) $this->request_data_collector->raw(
'q_id') : [];
1014 if ($questionIdsToDelete === [] && $this->request_data_collector->isset(
'q_id')) {
1015 $questionIdsToDelete = [$this->request_data_collector->getQuestionId()];
1018 $questionIdsToDelete = array_filter(
array_map(
'intval', $questionIdsToDelete));
1019 if ($questionIdsToDelete === []) {
1020 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_delete_select_none'),
true);
1021 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
1024 $this->tpl->setOnScreenMessage(
'question', $this->
lng->txt(
'qpl_confirm_delete_questions'));
1025 $deleteable_questions = &$this->
object->getDeleteableQuestionDetails($questionIdsToDelete);
1029 (($rbacsystem->checkAccess(
'write', $this->request_data_collector->getRefId()) ?
true :
false)),
1032 $table_gui->setShowRowsSelector(
false);
1033 $table_gui->setLimit(PHP_INT_MAX);
1034 $table_gui->setEditable($rbacsystem->checkAccess(
'write', $this->request_data_collector->getRefId()));
1035 $table_gui->setData($deleteable_questions);
1036 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
1044 $qst_ids = $this->request_data_collector->intArray(
'q_id');
1045 foreach ($qst_ids as $value) {
1046 $this->
object->deleteQuestion((
int) $value);
1047 $this->
object->cleanupClipboard((
int) $value);
1049 if ($qst_ids !== []) {
1050 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_questions_deleted'),
true);
1053 $this->
ctrl->setParameter($this,
'q_id',
'');
1054 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
1059 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
1068 $export_file = $qpl_exp->buildExportFile();
1071 if ($export_file ===
'') {
1072 $export_file =
'StandIn';
1077 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_export_select_none'),
true);
1086 $this->
ctrl->redirectByClass(
1088 ilRepositoryGUI::class,
1090 ilInfoScreenGUI::class
1100 if (!$this->
access->checkAccess(
"read",
"", $this->request_data_collector->getRefId())) {
1105 $this->
object->purgeQuestions();
1107 if ($qsa_import_fails->failedImportsRegistered()) {
1108 $button = $this->ui_factory->button()->standard(
1109 $this->
lng->txt(
'ass_skl_import_fails_remove_btn'),
1110 $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'renoveImportFails')
1112 $this->tpl->setOnScreenMessage(
1114 $qsa_import_fails->getFailedImportsMessage($this->lng) .
'<br />' . $this->ui_renderer->render(
1121 if ($this->rbac_system->checkAccess(
'write', $this->request_data_collector->getRefId())) {
1122 $btn = $this->ui_factory->button()->primary(
1123 $this->
lng->txt(
'ass_create_question'),
1124 $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'createQuestionForm')
1126 $this->
toolbar->addComponent($btn);
1128 if ($import_questions_modal === null) {
1132 $btn_import = $this->ui_factory->button()->standard(
1133 $this->
lng->txt(
'import'),
1134 $import_questions_modal->getShowSignal()
1136 $this->
toolbar->addComponent($btn_import);
1137 $out[] = $this->ui_renderer->render($import_questions_modal);
1140 $btn_paste = $this->ui_factory->button()->standard(
1141 $this->
lng->txt(
'paste'),
1142 $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'paste')
1144 $this->
toolbar->addComponent($btn_paste);
1148 $this->tpl->setPermanentLink($this->
object->getType(), $this->
object->getRefId());
1150 $this->tpl->setContent(implode(
'',
$out));
1155 $q_id = $this->request_data_collector->getQuestionId();
1157 if ($q_id === 0 || $this->
object->checkQuestionParent($q_id)) {
1166 $this->
help->setScreenId(
'assQuestions');
1167 if ($this->global_test_settings->isPageEditorEnabled()) {
1168 $this->
help->setSubScreenId(
'createQuestion_editMode');
1170 $this->
help->setSubScreenId(
'createQuestion');
1173 $this->tpl->setContent(
1174 $this->ui_renderer->render(
1175 $form ?? $this->buildQuestionCreationForm()
1186 $this->ui_factory->input()->field()->section(
$inputs, $this->
lng->txt(
'ass_create_question'))
1189 $form = $this->ui_factory->input()->container()->form()->standard(
1190 $this->
ctrl->getFormAction($this,
'createQuestion'),
1192 )->withSubmitLabel($this->
lng->txt(
'create'));
1199 $question_types = (
new ilObjQuestionPool())->getQuestionTypes(
false,
true,
false);
1201 foreach ($question_types as $label =>
$data) {
1202 $options[
$data[
'question_type_id']] = $label;
1205 return $this->ui_factory->input()->field()->select(
1206 $this->
lng->txt(
'question_type'),
1208 )->withRequired(
true);
1213 if (!$this->global_test_settings->isPageEditorEnabled()) {
1214 return $this->ui_factory->input()->field()->hidden()->
withValue(
1219 return $this->ui_factory->input()->field()->radio($this->
lng->txt(
'tst_add_quest_cont_edit_mode'))
1222 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_IPE'),
1223 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_IPE_info')
1226 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_RTE'),
1227 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_RTE_info')
1234 $this->tabs_gui->activateTab(
'print_view');
1235 $this->
ctrl->setParameter($this,
'output',
'overview');
1236 $output_link = $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'print');
1237 $this->
ctrl->setParameter($this,
'output',
'detailed_output_solutions');
1238 $output_link_detailed = $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'print');
1239 $this->
ctrl->setParameter($this,
'output',
'detailed_output_printview');
1240 $output_link_printview = $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'print');
1242 $mode = $this->ui_factory->dropdown()->standard([
1243 $this->ui_factory->button()->shy($this->
lng->txt(
'overview'), $output_link),
1244 $this->ui_factory->button()->shy($this->
lng->txt(
'detailed_output_solutions'), $output_link_detailed),
1245 $this->ui_factory->button()->shy($this->
lng->txt(
'detailed_output_printview'), $output_link_printview)
1246 ])->withLabel($this->
lng->txt(
'output_mode'));
1248 $output = $this->request_data_collector->raw(
'output') ??
'';
1251 $data = $this->
object->getPrintviewQuestions();
1254 $totalPoints += $d[
'points'];
1256 $table_gui->setTotalPoints($totalPoints);
1257 $table_gui->initColumns();
1258 $table_gui->setData(
$data);
1259 $this->tpl->setContent($this->ui_renderer->render($mode) . $table_gui->getHTML());
1264 $this->
object->update();
1265 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
1271 if ($this->
object->pasteFromClipboard()) {
1272 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_paste_success'),
true);
1274 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'qpl_paste_error'),
true);
1277 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_paste_no_objects'),
true);
1279 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
1285 foreach ($ids as
$id) {
1286 $this->
object->copyToClipboard($id);
1288 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_copy_insert_clipboard'),
true);
1290 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_copy_select_none'),
true);
1297 foreach ($ids as
$id) {
1298 $this->
object->moveToClipboard($id);
1300 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_move_insert_clipboard'),
true);
1302 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_move_select_none'),
true);
1309 if ($rbacsystem->checkAccess(
'write', $this->request_data_collector->getRefId())) {
1310 $question_ids = &$this->
object->getAllQuestionIds();
1312 $qpl_exp->buildExportFile();
1313 $this->
ctrl->redirectByClass(
'ilquestionpoolexportgui',
'');
1319 $this->
ctrl->redirectByClass(ilAssQuestionPreviewGUI::class,
'show');
1324 if (!$this->temp_file_system->hasDir($path_to_uploaded_file_in_temp_dir)
1325 || ($files = $this->temp_file_system->listContents($path_to_uploaded_file_in_temp_dir)) === []) {
1326 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'obj_import_file_error'));
1329 $file_to_import = $this->import_temp_directory . DIRECTORY_SEPARATOR . $files[0]->getPath();
1330 $qtifile = $file_to_import;
1331 $importdir = dirname($file_to_import);
1334 if ($this->temp_file_system->getMimeType($files[0]->getPath()) === MimeType::APPLICATION__ZIP) {
1337 $unzip = $this->archives->unzip($this->temp_file_system->readStream($files[0]->getPath()), $options);
1341 if (!file_exists($qtifile)) {
1343 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'cannot_find_xml'),
true);
1349 ilSession::set(
'path_to_uploaded_file_in_temp_dir', $path_to_uploaded_file_in_temp_dir);
1352 'importVerifiedQuestionsFile',
1355 $path_to_uploaded_file_in_temp_dir
1358 if ($form === null) {
1362 $panel = $this->ui_factory->panel()->standard(
1363 $this->
lng->txt(
'import_question'),
1365 $this->ui_factory->legacy($this->
lng->txt(
'qpl_import_verify_found_questions')),
1369 $this->tpl->setContent($this->ui_renderer->render($panel));
1370 $this->tpl->printToStdout();
1374 protected function importFile(
string $file_to_import,
string $path_to_uploaded_file_in_temp_dir): void
1381 $unzip = $this->archives->unzip(Streams::ofResource(fopen($file_to_import,
'r')), $options);
1384 if (!file_exists($qtifile)) {
1386 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'cannot_find_xml'),
true);
1391 ilSession::set(
'path_to_uploaded_file_in_temp_dir', $path_to_uploaded_file_in_temp_dir);
1393 $this->
ctrl->setParameterByClass(self::class,
'new_type', $this->type);
1395 'importVerifiedFile',
1398 $path_to_uploaded_file_in_temp_dir
1401 if ($form === null) {
1405 $panel = $this->ui_factory->panel()->standard(
1406 $this->
lng->txt(
'import_qpl'),
1408 $this->ui_factory->legacy($this->
lng->txt(
'qpl_import_verify_found_questions')),
1412 $this->tpl->setContent($this->ui_renderer->render($panel));
1413 $this->tpl->printToStdout();
1421 switch ($this->
ctrl->getCmd()) {
1427 $this->
ctrl->clearParameterByClass(self::class,
'q_id');
1428 $ilLocator->addItem(
1429 $this->
object->getTitle(),
1430 $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
''),
1432 $this->request_data_collector->getRefId()
1434 $this->
ctrl->setParameter($this,
'q_id', $this->request_data_collector->getQuestionId());
1438 if (!is_array($this->request_data_collector->raw(
'q_id')) && $this->request_data_collector->raw(
'q_id') > 0 && $this->request_data_collector->raw(
1440 ) !== self::DEFAULT_CMD) {
1442 if ($question_gui !== null && $question_gui->getObject() instanceof
assQuestion) {
1443 $question = $question_gui->getObject();
1444 $question->setObjId($this->
object->getId());
1445 $question_gui->setObject($question);
1446 $title = $question_gui->getObject()->getTitleForHTMLOutput();
1448 $title = $this->
lng->txt(
'new') .
': ' . $this->questionrepository->getForQuestionId(
1449 $question_gui->getObject()->getId()
1450 )->getTypeName($this->
lng);
1452 $ilLocator->addItem($title, $this->
ctrl->getLinkTargetByClass(get_class($question_gui),
'editQuestion'));
1455 $this->
ctrl->setParameter($this,
'q_id',
'');
1456 $this->
ctrl->redirect($this);
1466 parent::setTitleAndDescription();
1468 if (!is_array($this->request_data_collector->raw(
'q_id')) && $this->request_data_collector->raw(
'q_id') > 0 && $this->request_data_collector->raw(
1470 ) !== self::DEFAULT_CMD) {
1472 if ($question_gui->getObject() instanceof
assQuestion) {
1473 $question = $question_gui->getObject();
1474 $question->setObjId($this->
object->getId());
1475 $question_gui->setObject($question);
1476 $title = $this->
object->getTitle() .
': ' . $question_gui->getObject()->getTitle();
1478 $title = $this->
lng->txt(
'new') .
': ' . $this->questionrepository->getForQuestionId(
1479 $question_gui->getObject()->getId()
1480 )->getTypeName($this->
lng);
1482 $this->tpl->setTitle(
1483 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
1487 $this->tpl->setDescription(
1488 $question_gui->getObject()->getDescriptionForHTMLOutput()
1493 $this->
ctrl->setParameter($this,
'q_id',
'');
1494 $this->
ctrl->redirect($this);
1497 $this->tpl->setTitle(
1498 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
1499 $this->
object->getTitle()
1502 $this->tpl->setDescription(
1503 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
1504 $this->
object->getLongDescription()
1518 $with_write_access = $this->
access->checkAccess(
'write',
'', $this->
object->getRefId());
1519 $with_read_access = $this->
access->checkAccess(
'read',
'', $this->
object->getRefId());
1521 $this->
help->setScreenIdComponent(
'qpl');
1523 switch ($this->
ctrl->getNextClass()) {
1525 case strtolower(ilInfoScreenGUI::class):
1526 case strtolower(ilPermissionGUI::class):
1527 case strtolower(ilObjectMetaDataGUI::class):
1528 case strtolower(ilExportGUI::class):
1529 case strtolower(ilQuestionPoolSkillAdministrationGUI::class):
1532 case strtolower(ilTaxonomySettingsGUI::class):
1533 case strtolower(ilObjQuestionPoolSettingsGeneralGUI::class):
1534 if ($with_write_access) {
1544 $force_active =
false;
1545 $commands = $this->request_data_collector->raw(
'cmd');
1546 if (is_array($commands)) {
1547 foreach ($commands as $key => $value) {
1548 if (preg_match(
'/^delete_.*/', $key, $matches) ||
1549 preg_match(
'/^addSelectGap_.*/', $key, $matches) ||
1550 preg_match(
'/^addTextGap_.*/', $key, $matches) ||
1551 preg_match(
'/^deleteImage_.*/', $key, $matches) ||
1552 preg_match(
'/^upload_.*/', $key, $matches) ||
1553 preg_match(
'/^addSuggestedSolution_.*/', $key, $matches)
1555 $force_active =
true;
1560 $force_active = $force_active || $this->request_data_collector->isset(
'imagemap_x');
1561 if (!$force_active) {
1562 $force_active = strtolower($this->
ctrl->getCmdClass()) === strtolower(self::class)
1563 || $this->
ctrl->getCmdClass() ===
'' && $this->
ctrl->getCmd() ===
'' 1567 if ($with_read_access) {
1568 $this->tabs_gui->addTarget(
1570 $this->
ctrl->getLinkTargetByClass(
1571 [ilRepositoryGUI::class, self::class],
1581 'filterQuestionBrowser',
1590 'addSuggestedSolution',
1593 'removeSuggestedSolution',
1600 'uploadingImagemap',
1606 'uploadingJavaapplet',
1613 'toggleGraphicalAnswers',
1623 if ($with_read_access) {
1624 $this->tabs_gui->addTab(
1626 $this->
lng->txt(
'info_short'),
1627 $this->
ctrl->getLinkTargetByClass(
1629 ilRepositoryGUI::class,
1631 ilInfoScreenGUI::class
1637 if ($with_write_access) {
1639 $this->tabs_gui->addTarget(
1641 $this->
ctrl->getLinkTargetByClass(ilObjQuestionPoolSettingsGeneralGUI::class),
1643 [ilObjQuestionPoolSettingsGeneralGUI::class, ilObjTaxonomyGUI::class]
1648 $link = $this->
ctrl->getLinkTargetByClass(
1649 [ilQuestionPoolSkillAdministrationGUI::class, ilAssQuestionSkillAssignmentsGUI::class],
1653 $this->tabs_gui->addTarget(
'qpl_tab_competences', $link, [], []);
1657 if ($with_read_access) {
1659 $this->tabs_gui->addTarget(
1661 $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'print'),
1668 if ($with_write_access) {
1670 $mdtab = $mdgui->getTab();
1672 $this->tabs_gui->addTarget(
1681 if ($with_write_access) {
1682 $this->tabs_gui->addTarget(
1684 $this->
ctrl->getLinkTargetByClass(ilExportGUI::class,
''),
1690 if ($this->
access->checkAccess(
'edit_permission',
'', $this->object->getRefId())) {
1691 $this->tabs_gui->addTarget(
1693 $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class, ilPermissionGUI::class],
'perm'),
1694 [
'perm',
'info',
'owner'],
1706 if (!$this->
object->isSkillServiceEnabled()) {
1721 $this->
lng->txt(
'qpl_settings_subtab_general'),
1722 $this->
ctrl->getLinkTargetByClass(ilObjQuestionPoolSettingsGeneralGUI::class),
1727 $this->
lng->txt(
'qpl_settings_subtab_taxonomies'),
1728 $this->
ctrl->getLinkTargetByClass(ilTaxonomySettingsGUI::class,
''),
1734 $this->
ctrl->redirectByClass(
1736 ilRepositoryGUI::class,
1738 ilInfoScreenGUI::class
1745 if (!$this->
access->checkAccess(
'visible',
'', $this->ref_id)) {
1746 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'));
1749 $this->tabs_gui->activateTab(
'info_short');
1751 $info->enablePrivateNotes();
1752 $info->addMetaDataSections($this->
object->getId(), 0, $this->
object->getType());
1754 $this->
ctrl->forwardCommand($info);
1757 public static function _goto($a_target):
void 1761 $main_tpl = $DIC->ui()->mainTemplate();
1762 $ilAccess = $DIC[
'ilAccess'];
1765 $ctrl = $DIC[
'ilCtrl'];
1767 $target_ref_id = (
int) $a_target;
1769 if ($ilAccess->checkAccess(
'write',
'', $target_ref_id)
1770 || $ilAccess->checkAccess(
'read',
'', $target_ref_id)
1773 $ctrl->
redirectByClass([ilRepositoryGUI::class, ilObjQuestionPoolGUI::class], self::DEFAULT_CMD);
1776 if ($ilAccess->checkAccess(
'visible',
'', $target_ref_id)) {
1777 $DIC->ctrl()->setParameterByClass(ilInfoScreenGUI::class,
'ref_id', $a_target);
1778 $DIC->ctrl()->redirectByClass(
1780 ilRepositoryGUI::class,
1782 ilInfoScreenGUI::class
1787 $main_tpl->setOnScreenMessage(
1790 $lng->
txt(
'msg_no_perm_read_item'),
1809 $this->data_factory,
1812 $this->action_parameter_token,
1813 $this->row_id_token,
1816 $this->component_repository,
1819 $this->taxonomy->domain(),
1821 $this->
object->getId(),
1822 $this->request_data_collector->getRefId()
1829 $filter_action = $this->
ctrl->getLinkTarget($this, self::DEFAULT_CMD);
1830 $filter = $table->getFilter($this->ui_service, $filter_action);
1832 $filter_params = $this->ui_service->filter()->getData($filter);
1834 if ($filter_params) {
1835 foreach (array_filter($filter_params) as $item => $value) {
1838 foreach ($value as $tax_value) {
1839 if ($tax_value ===
'null') {
1840 $table->addTaxonomyFilterNoTaxonomySet(
true);
1842 $tax_nodes = explode(
'-', $tax_value);
1843 $tax_id = array_shift($tax_nodes);
1844 $table->addTaxonomyFilter(
1848 $this->
object->getType()
1854 $table->setCommentFilter((
int) $value);
1857 $table->addFieldFilter($item, $value);
1865 ->withRequest($this->request)
const ADDITIONAL_CONTENT_EDITING_MODE_IPE
ilNavigationHistory $navigation_history
setEditPreview(bool $a_editpreview)
Set Display first Edit tab, then Preview tab, instead of Page and Edit.
static get(string $a_var)
afterSave(ilObject $new_object)
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
Readable part of repository interface to ilComponentDataDB.
buildImportQuestionsModal()
ilRbacSystem $rbac_system
importQuestionsFile(string $path_to_uploaded_file_in_temp_dir)
URLBuilderToken $action_parameter_token
DataFactory $data_factory
importVerifiedQuestionsFileObject()
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
renoveImportFailsObject()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
confirmDeleteQuestions(array $ids)
confirmDeleteQuestionsObject()
delete questions after confirmation
GUI class for the workflow of copying objects.
prepareOutput(bool $show_sub_objects=true)
static getQuestionTypeByTypeId($type_id)
importFile(string $file_to_import, string $path_to_uploaded_file_in_temp_dir)
copyQuestions(array $ids)
buildImportQuestionsSelectionForm(string $form_cmd, string $importdir, string $qtifile, string $path_to_uploaded_file_in_temp_dir=null)
trait TestQuestionsImportTrait
acquireParameters(array $namespace, string ... $names)
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...
setParameterByClass(string $a_class, string $a_parameter, $a_value)
const TAB_COMMON_SETTINGS
Component logger with individual log levels by component id.
getTabs()
adds tabs to tab gui object
download_paragraphObject()
download source code paragraph
RequestDataCollector $request_data_collector
const SUPPORTED_IMPORT_MIME_TYPES
exportObject()
Gateway for exports initiated from workspace, as there is a generic forward to {objTypeMainGUI}::expo...
GlobalScreen $global_screen
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
const CMD_SHOW_LIST
command constants
importObject(?object $a_new_obj, string $a_tmp_file, string $a_filename, string $a_type, string $a_comp="", bool $a_copy_file=false)
static _lookupObjId(int $ref_id)
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
editQuestionForTestObject()
deleteUploadedImportFile(string $path_to_uploaded_file_in_temp_dir)
URLBuilderToken $row_id_token
moveQuestions(array $ids)
ilComponentRepository $component_repository
addSubTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
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.
importQuestionsFromQtiFile(ilObjQuestionPool $obj, array $selected_questions, string $qtifile, string $importdir, string $xmlfile='')
deleteQuestionsObject()
delete questions confirmation screen
deleteRegisteredImportFails()
ilComponentFactory $component_factory
static _lookupTitle(int $obj_id)
ILIAS Notes Service $notes_service
setTitleAndDescription()
called by prepare output
questionsObject(RoundTripModal $import_questions_modal=null)
list questions of question pool
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importQuestionPoolWithValidManifest(ilObjQuestionPool $obj, array $selected_questions, string $file_to_import)
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
GeneralQuestionPropertiesRepository $questionrepository
cancelDeleteQuestionsObject()
Legacy Content Object Parser.
Class ilObjForumAdministration.
addSettingsSubTabs(ilTabsGUI $tabs)
static getSyntaxStylePath()
importVerifiedFileObject()
buildQuestionCreationForm()
Class ilObjQuestionPoolGUI.
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
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static redirect(string $a_script)
ContentStyle $content_style
static buildAjaxHash(int $node_type, ?int $node_id, string $obj_type, int $obj_id, string $sub_type=null, int $sub_id=null, int $news_id=0)
Build ajax hash.
fullscreenObject()
show fullscreen view
createQuestionFormObject(Form $form=null)
fetchAuthoringQuestionIdParamater()
static isSkillManagementGloballyActivated()
retrieveSelectedQuestionsFromImportQuestionsSelectionForm(string $form_cmd, string $importdir, string $qtifile, ServerRequestInterface $request)
sendParagraph(string $par_id, string $filename)
__construct(Container $dic, ilPlugin $plugin)
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
GlobalTestSettings $global_test_settings
uploadQuestionsImportObject()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
array buildImportDirectoriesFromImportFile(string $file_to_import)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
redirectAfterMissingWrite()
exportQuestions(array $ids)
setPrimaryCmd(string $label, string $cmd)
static getListCommentsJSCall(string $a_hash, string $a_update_code=null)
Get list comments js call.
static clear(string $a_var)
const RENDER_PURPOSE_PREVIEW
static set(string $a_var, $a_val)
Set a value.
const CMD_SHOW_SKILL_QUEST_ASSIGNS
showMediaFullscreen(int $a_style_id=0)
show fullscreen view of media object
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
cleanupAfterImport(string $importdir)