19declare(strict_types=1);
72 MimeType::APPLICATION__X_ZIP_COMPRESSED,
73 MimeType::APPLICATION__ZIP,
104 $this->db =
$DIC[
'ilDB'];
105 $this->log =
$DIC[
'ilLog'];
106 $this->
help = $DIC[
'ilHelp'];
107 $this->global_screen =
$DIC[
'global_screen'];
108 $this->component_factory =
$DIC[
'component.factory'];
109 $this->component_repository =
$DIC[
'component.repository'];
110 $this->navigation_history =
$DIC[
'ilNavigationHistory'];
111 $this->ui_service =
$DIC->uiService();
112 $this->taxonomy =
$DIC->taxonomy();
113 $this->archives =
$DIC->archives();
114 $this->content_style =
$DIC->contentStyle();
116 $this->data_factory =
new DataFactory();
118 $local_dic = QuestionPoolDIC::dic();
119 $this->request_data_collector = $local_dic[
'request_data_collector'];
120 $this->questionrepository = $local_dic[
'question.general_properties.repository'];
121 $this->global_test_settings = $local_dic[
'global_test_settings'];
125 $this->
ctrl->saveParameter($this, [
133 $this->
ctrl->saveParameterByClass(
'ilAssQuestionPageGUI',
'consumer_context');
134 $this->
ctrl->saveParameterByClass(
'ilobjquestionpoolgui',
'consumer_context');
136 $this->
lng->loadLanguageModule(
'assessment');
138 $here_uri = $this->data_factory->uri($this->request->getUri()->__toString());
140 $query_params_namespace = [
'qpool',
'table'];
142 $query_params_namespace,
150 $this->notes_service->gui()->initJavascript();
155 $write_access = $this->
access->checkAccess(
'write',
'', $this->request_data_collector->getRefId());
157 if ((!$this->
access->checkAccess(
'read',
'', $this->request_data_collector->getRefId()))
158 && (!$this->access->checkAccess(
'visible',
'', $this->request_data_collector->getRefId()))) {
159 $this->
ilias->raiseError($this->
lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
163 $this->
access->checkAccess(
'read',
'', $this->request_data_collector->getRefId())) {
164 if (
'qpl' === $this->
object->getType()) {
165 $this->navigation_history->addItem(
166 $this->request_data_collector->getRefId(),
167 ilLink::_getLink($this->request_data_collector->getRefId(),
"qpl"),
173 $cmd = $this->
ctrl->getCmd(self::DEFAULT_CMD);
174 $next_class = $this->
ctrl->getNextClass($this);
175 $q_id = $this->request_data_collector->getQuestionId() ??
null;
177 if (in_array($next_class, [
'',
'ilobjquestionpoolgui']) && $cmd == self::DEFAULT_CMD) {
185 $q_type = $this->request_data_collector->string(
'question_type');
186 switch ($next_class) {
187 case 'ilcommonactiondispatchergui':
189 $this->
ctrl->forwardCommand($gui);
192 case 'ilobjectmetadatagui':
193 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
194 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->WARNING);
197 $this->
ctrl->forwardCommand($md_gui);
200 case 'ilassquestionpreviewgui':
201 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
205 $this->
ctrl->saveParameterByClass(ilAssQuestionPreviewGUI::class,
'q_id');
206 $this->
ctrl->saveParameter($this,
'q_id');
217 $this->global_screen,
223 $question_gui = assQuestion::instantiateQuestionGUI($this->request_data_collector->int(
'q_id'));
225 $this->
lng->txt(
'edit_question'),
226 $this->ctrl->getLinkTargetByClass(
227 get_class($question_gui),
231 $gui->addAdditionalCmd(
232 $this->
lng->txt(
'edit_page'),
233 $this->ctrl->getLinkTargetByClass(
234 ilAssQuestionPageGUI::class,
243 $gui->initPreviewSettings($this->
object->getRefId());
244 $gui->initPreviewSession($this->
user->getId(), $this->fetchAuthoringQuestionIdParamater());
245 $this->
ctrl->clearParameterByClass(self::class,
'q_id');
246 $this->tabs_gui->setBackTarget(
247 $this->
lng->txt(
'backtocallingpool'),
248 $this->ctrl->getLinkTargetByClass(self::class, self::DEFAULT_CMD)
251 $this->
help->setScreenIdComponent(
'qpl');
253 $this->
ctrl->forwardCommand($gui);
256 case 'ilassquestionpagegui':
257 if ($cmd ==
'finishEditing') {
258 $this->
ctrl->redirectByClass(
'ilassquestionpreviewgui',
'show');
261 if ($cmd ===
'edit' && !$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
264 $this->tpl->setCurrentBlock(
'ContentStyle');
266 $this->tpl->parseCurrentBlock();
268 $this->tpl->setCurrentBlock(
'SyntaxStyle');
270 $this->tpl->parseCurrentBlock();
273 $question_gui->setQuestionTabs();
274 $question_gui->getObject()->setObjId($this->
object->getId());
275 $question_gui->setQuestionActionCmd(
'');
277 if ($this->
object->getType() ===
'qpl') {
278 $question_gui->addHeaderAction();
281 $question = $question_gui->getObject();
283 if ($this->questionrepository->isInActiveTest($question->getObjId())) {
284 $this->tpl->setOnScreenMessage(
286 $this->
lng->txt(
'question_is_part_of_running_test'),
292 $this->
ctrl->saveParameter($this,
'q_id');
293 $this->
lng->loadLanguageModule(
'content');
294 $this->
ctrl->setReturnByClass(
'ilAssQuestionPageGUI',
'view');
295 $this->
ctrl->setReturn($this, self::DEFAULT_CMD);
297 $page_gui->setFileDownloadLink(
298 $this->
ctrl->getLinkTargetByClass(ilObjQuestionPoolGUI::class,
'downloadFile')
300 $page_gui->obj->addUpdateListener(
304 $page_gui->setEditPreview(
true);
305 $page_gui->setEnabledTabs(
false);
306 $page_gui->setQuestionHTML([$question_gui->getObject()->getId() => $question_gui->getPreview(
true)]);
307 $page_gui->setTemplateTargetVar(
'ADM_CONTENT');
308 $page_gui->setOutputMode(
'edit');
309 $page_gui->setHeader($question->getTitleForHTMLOutput());
310 $page_gui->setPresentationTitle($question->getTitleForHTMLOutput());
311 $ret = $this->
ctrl->forwardCommand($page_gui);
313 $this->tpl->setContent($ret);
317 case 'ilpermissiongui':
319 $this->
ctrl->forwardCommand($perm_gui);
322 case 'ilobjectcopygui':
325 $this->
ctrl->forwardCommand($cp);
330 $ret = $this->
ctrl->forwardCommand($exp_gui);
333 case strtolower(ilInfoScreenGUI::class):
337 case 'illocalunitconfigurationgui':
338 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
339 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->WARNING);
345 $question = $question_gui->getObject();
346 $question->setObjId($this->
object->getId());
347 $question_gui->setObject($question);
348 $question_gui->setQuestionTabs();
350 $this->
ctrl->setReturn($this, self::DEFAULT_CMD);
354 $this->
ctrl->forwardCommand($gui);
357 case 'ilassquestionfeedbackeditinggui':
358 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
362 $this->
ctrl->setReturn($this, self::DEFAULT_CMD);
367 $question = $question_gui->getObject();
368 $question->setObjId($this->
object->getId());
369 $question_gui->setObject($question);
370 $question_gui->setQuestionTabs();
372 if ($this->questionrepository->isInActiveTest($question_gui->getObject()->getObjId())) {
373 $this->tpl->setOnScreenMessage(
375 $this->
lng->txt(
'question_is_part_of_running_test'),
381 $this->
help->setScreenIdComponent(
'qpl');
383 if ($this->
object->getType() ==
'qpl' && $write_access) {
384 $question_gui->addHeaderAction();
394 $this->request_data_collector,
395 $this->content_style,
398 $this->
ctrl->forwardCommand($gui);
402 case 'ilobjquestionpoolsettingsgeneralgui':
415 $this->
ctrl->forwardCommand($gui);
418 case strtolower(ilTaxonomySettingsGUI::class):
429 $this->component_repository,
436 $forwarder->forward();
440 case 'ilquestionpoolskilladministrationgui':
451 $this->component_repository,
456 $this->
ctrl->forwardCommand($gui);
459 case 'ilbulkeditquestionsgui':
460 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
463 $this->tabs_gui->setBackTarget(
464 $this->
lng->txt(
'backtocallingpool'),
465 $this->ctrl->getLinkTargetByClass(self::class, self::DEFAULT_CMD)
467 $this->tabs_gui->addTarget(
471 $this->
ctrl->getCmdClass(),
474 $this->tabs_gui->setTabActive(
'edit_questions');
476 $gui = new \ilBulkEditQuestionsGUI(
484 $this->request_wrapper,
487 $this->
ctrl->forwardCommand($gui);
490 case 'ilobjquestionpoolgui':
493 if ($action = $this->request_data_collector->string($this->action_parameter_token->getName())) {
494 $ids = $this->request_data_collector->raw($this->row_id_token->getName()) ??
null;
497 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_questions_selected'),
true);
498 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
500 if ($ids[0] ===
'ALL_OBJECTS') {
501 $ids = $this->
object->getAllQuestionIds();
503 if (!is_array($ids)) {
504 $ids = explode(
',', $ids);
506 $ids = array_map(
'intval', $ids);
508 $this->
ctrl->setParameterByClass(ilAssQuestionPreviewGUI::class,
'q_id', current($ids));
512 $this->
ctrl->redirectToURL(
517 $this->
ctrl->redirectToURL(
521 case 'edit_question':
522 $class = strtolower($this->questionrepository->getForQuestionId(current($ids))->getGuiClassName());
523 $this->
ctrl->setParameterByClass($class,
'q_id', current($ids));
524 $this->
ctrl->redirectToURL(
525 $this->
ctrl->getLinkTargetByClass($class,
'editQuestion')
529 $this->
ctrl->setParameterByClass(ilAssQuestionPageGUI::class,
'q_id', current($ids));
530 $this->
ctrl->redirectToURL(
531 $this->
ctrl->getLinkTargetByClass(ilAssQuestionPageGUI::class,
'edit')
535 $this->
ctrl->setParameterByClass(ilAssQuestionFeedbackEditingGUI::class,
'q_id', current($ids));
536 $this->
ctrl->redirectToURL(
542 $this->
ctrl->redirectByClass(self::class, self::DEFAULT_CMD);
546 $this->
ctrl->redirectByClass(self::class, self::DEFAULT_CMD);
553 $this->
ctrl->redirectByClass(self::class, self::DEFAULT_CMD);
558 $this->
object->getRefId(),
560 $this->object->getId(),
566 .
' event = new Event("click");'
575 $this->
ctrl->clearParameters($this);
576 $this->
ctrl->setParameterByClass(
577 ilBulkEditQuestionsGUI::class,
581 $this->
ctrl->redirectToURL(
582 $this->
ctrl->getLinkTargetByClass(
583 ilBulkEditQuestionsGUI::class,
590 throw new \Exception(
"'{$action}' not implemented");
596 if ($cmd == self::DEFAULT_CMD) {
597 $this->
ctrl->setParameterByClass(self::class,
'q_id',
'');
600 $ret = $this->$cmd();
606 [
'editQuestion',
'save',
'suggestedsolution',
'uploadImage',
'removeImage']
607 ) && !$this->
access->checkAccess(
610 $this->object->getRefId()
615 $this->
ctrl->setReturnByClass(self::class, self::DEFAULT_CMD);
623 $question = $question_gui->getObject();
624 $question->setObjId($this->
object->getId());
625 $question_gui->setObject($question);
627 if ($this->
object->getType() ===
'qpl') {
628 $question_gui->setTaxonomyIds($this->
object->getTaxonomyIds());
631 $question_gui->addHeaderAction();
635 $this->
help->setScreenIdComponent(
'qpl');
637 if ($qid === 0 && $question_gui->cmdNeedsExistingQuestion($cmd)) {
638 $question_gui->getObject()->createNewQuestion();
641 $question_gui->setQuestionTabs();
643 if (!in_array($cmd, [
'save',
'saveReturn'])) {
644 $question_gui->$cmd();
648 if (!$question_gui->saveQuestion()) {
651 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
652 if ($cmd ===
'saveReturn') {
653 $this->
ctrl->setParameterByClass(
654 ilAssQuestionPreviewGUI::class,
656 (
string) $question_gui->getObject()->getId()
658 $this->
ctrl->redirectToURL(
663 if ($cmd ===
'save') {
664 $this->tabs_gui->activateTab(
'edit_question');
665 $question_gui->editQuestion(
false,
false);
670 if (!(strtolower($this->request_data_collector->raw(
'baseClass')) ==
'iladministrationgui'
671 || strtolower($this->request_data_collector->raw(
'baseClass')) ==
'ilrepositorygui')
672 && $this->getCreationMode() !=
true) {
673 $this->tpl->printToStdout();
679 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_permission'),
true);
680 $target_class = get_class($this->
object) .
'GUI';
681 $this->
ctrl->setParameterByClass($target_class,
'ref_id', $this->ref_id);
682 $this->
ctrl->redirectByClass($target_class);
691 $this->
ctrl->redirectByClass(
'ilQuestionPoolExportGUI');
696 $file = explode(
'_', $this->request_data_collector->raw(
'file_id'));
697 $fileObj =
new ilObjFile((
int) $file[count($file) - 1],
false);
698 $fileObj->sendFile();
708 $page_gui->setFileDownloadLink(
709 $this->
ctrl->getLinkTargetByClass(ilObjQuestionPoolGUI::class,
'downloadFile')
711 $page_gui->showMediaFullscreen();
720 $pg_obj->sendParagraph($this->request_data_collector->raw(
'par_id'), $this->request_data_collector->raw(
'downloadtitle'));
726 if ($this->creation_mode
727 && !$this->
checkPermissionBool(
'create',
'', $this->request_data_collector->string(
'new_type'))
728 || !$this->creation_mode
729 && !$this->checkPermissionBool(
'read',
'', $this->object->getType())) {
738 $new_obj->setType($this->request_data_collector->raw(
'new_type'));
739 $new_obj->setTitle(
'dummy');
740 $new_obj->setDescription(
'questionpool import');
741 $new_obj->create(
true);
742 $new_obj->createReference();
743 $new_obj->putInTree($this->request_data_collector->getRefId());
744 $new_obj->setPermissions($this->request_data_collector->getRefId());
747 'importVerifiedFile',
753 if (is_file($importdir . DIRECTORY_SEPARATOR .
'manifest.xml')) {
768 $new_obj->fromXML($xmlfile);
771 $new_obj->saveToDb();
775 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'object_imported'),
true);
776 $this->
ctrl->setParameterByClass(self::class,
'ref_id', $new_obj->getRefId());
777 $this->
ctrl->redirectByClass(self::class);
784 if (mb_substr($file_to_import, -3) ===
'xml') {
785 $importdir = dirname($file_to_import);
787 'importVerifiedQuestionsFile',
801 'importVerifiedQuestionsFile',
806 if (is_file($importdir . DIRECTORY_SEPARATOR .
'manifest.xml')) {
825 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'object_imported'),
true);
832 $data = $import_questions_modal->getData();
833 if (
$data ===
null) {
835 $import_questions_modal->withOnLoad(
836 $import_questions_modal->getShowSignal()
841 $path_to_imported_file_in_temp_dir =
$data[
'import_file'][0];
847 $constraint = $this->
refinery->custom()->constraint(
848 function ($vs):
bool {
854 $this->
lng->txt(
'msg_no_files_selected')
857 $file_upload_input = $this->ui_factory->input()->field()
859 ->withAcceptedMimeTypes(self::SUPPORTED_IMPORT_MIME_TYPES)
861 ->withAdditionalTransformation($constraint);
862 return $this->ui_factory->modal()->roundtrip(
863 $this->
lng->txt(
'import'),
865 [
'import_file' => $file_upload_input],
866 $this->ctrl->getFormActionByClass(self::class,
'uploadQuestionsImport')
867 )->withSubmitLabel($this->
lng->txt(
'import'));
872 array $selected_questions,
873 string $file_to_import
876 ilSession::set(
'qpl_import_selected_questions', $selected_questions);
877 $imp =
new ilImport($this->request_data_collector->getRefId());
878 $map = $imp->getMapping();
879 $map->addMapping(
'components/ILIAS/TestQuestionPool',
'qpl',
'new_id', (
string) $obj->
getId());
880 $imp->importObject($obj, $file_to_import, basename($file_to_import),
'qpl',
'components/ILIAS/TestQuestionPool',
true);
885 array $selected_questions,
899 if ($xmlfile ===
'') {
908 $cont_parser->setQuestionMapping($qti_parser->getImportMapping());
909 $cont_parser->startParsing();
915 $this->deleteUploadedImportFile(
ilSession::get(
'path_to_uploaded_file_in_temp_dir'));
920 public function createQuestionObject(): void
922 $form = $this->buildQuestionCreationForm()->withRequest($this->request);
923 $data_with_section = $form->getData();
924 if ($data_with_section ===
null) {
925 $this->createQuestionFormObject($form);
928 $data = $data_with_section[0];
930 $this->
ctrl->setReturnByClass(self::class, self::DEFAULT_CMD);
936 $question = $question_gui->getObject();
937 $question->setObjId($this->
object->getId());
938 $question->setAdditionalContentEditingMode(
$data[
'editing_type']);
939 $question_gui->setObject($question);
940 $question_gui->setQuestionTabs();
941 $question_gui->editQuestion();
947 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'object_added'),
true);
950 'ilias.php?ref_id=' . $new_object->
getRefId() .
951 '&baseClass=ilObjQuestionPoolGUI'
957 $rbacsystem = $this->rbac_system;
959 $questionIdsToDelete = array_filter(array_map(
'intval', $ids));
960 if (0 === count($questionIdsToDelete)) {
961 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_delete_select_none'),
true);
962 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
965 $this->tpl->setOnScreenMessage(
'question', $this->
lng->txt(
'qpl_confirm_delete_questions'));
966 $deleteable_questions = $this->
object->getDeleteableQuestionDetails($questionIdsToDelete);
967 $table_gui =
new ilQuestionBrowserTableGUI($this, self::DEFAULT_CMD, (($rbacsystem->checkAccess(
'write', $this->request_data_collector->getRefId()) ?
true :
false)),
true);
968 $table_gui->setShowRowsSelector(
false);
969 $table_gui->setLimit(PHP_INT_MAX);
970 $table_gui->setEditable($rbacsystem->checkAccess(
'write', $this->request_data_collector->getRefId()));
971 $table_gui->setData($deleteable_questions);
972 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
980 $rbacsystem = $this->rbac_system;
982 $questionIdsToDelete = $this->request_data_collector->isset(
'q_id') ? (array) $this->request_data_collector->raw(
'q_id') : [];
983 if ($questionIdsToDelete === [] && $this->request_data_collector->isset(
'q_id')) {
984 $questionIdsToDelete = [$this->request_data_collector->getQuestionId()];
987 $questionIdsToDelete = array_filter(array_map(
'intval', $questionIdsToDelete));
988 if ($questionIdsToDelete === []) {
989 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_delete_select_none'),
true);
990 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
993 $this->tpl->setOnScreenMessage(
'question', $this->
lng->txt(
'qpl_confirm_delete_questions'));
994 $deleteable_questions = &$this->
object->getDeleteableQuestionDetails($questionIdsToDelete);
998 (($rbacsystem->checkAccess(
'write', $this->request_data_collector->getRefId()) ?
true :
false)),
1001 $table_gui->setShowRowsSelector(
false);
1002 $table_gui->setLimit(PHP_INT_MAX);
1003 $table_gui->setEditable($rbacsystem->checkAccess(
'write', $this->request_data_collector->getRefId()));
1004 $table_gui->setData($deleteable_questions);
1005 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
1013 $qst_ids = $this->request_data_collector->intArray(
'q_id');
1014 foreach ($qst_ids as $value) {
1015 $this->
object->deleteQuestion((
int) $value);
1016 $this->
object->cleanupClipboard((
int) $value);
1018 if ($qst_ids !== []) {
1019 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_questions_deleted'),
true);
1022 $this->
ctrl->setParameter($this,
'q_id',
'');
1023 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
1028 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
1037 $export_file = $qpl_exp->buildExportFile();
1040 if ($export_file ===
'') {
1041 $export_file =
'StandIn';
1046 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_export_select_none'),
true);
1053 $qsaImportFails->deleteRegisteredImportFails();
1055 $this->
ctrl->redirectByClass(
1057 ilRepositoryGUI::class,
1059 ilInfoScreenGUI::class
1069 if (!$this->
access->checkAccess(
"read",
"", $this->request_data_collector->getRefId())) {
1070 $this->infoScreenForward();
1074 $this->
object->purgeQuestions();
1076 if ($qsa_import_fails->failedImportsRegistered()) {
1077 $button = $this->ui_factory->button()->standard(
1078 $this->
lng->txt(
'ass_skl_import_fails_remove_btn'),
1079 $this->ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'renoveImportFails')
1081 $this->tpl->setOnScreenMessage(
1083 $qsa_import_fails->getFailedImportsMessage($this->lng) .
'<br />' . $this->ui_renderer->render(
1090 if ($this->rbac_system->checkAccess(
'write', $this->request_data_collector->getRefId())) {
1091 $btn = $this->ui_factory->button()->primary(
1092 $this->
lng->txt(
'ass_create_question'),
1093 $this->ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'createQuestionForm')
1095 $this->
toolbar->addComponent($btn);
1097 if ($import_questions_modal ===
null) {
1098 $import_questions_modal = $this->buildImportQuestionsModal();
1101 $btn_import = $this->ui_factory->button()->standard(
1102 $this->
lng->txt(
'import'),
1103 $import_questions_modal->getShowSignal()
1105 $this->
toolbar->addComponent($btn_import);
1106 $out[] = $this->ui_renderer->render($import_questions_modal);
1109 $btn_paste = $this->ui_factory->button()->standard(
1110 $this->
lng->txt(
'paste'),
1111 $this->ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'paste')
1113 $this->
toolbar->addComponent($btn_paste);
1117 $this->tpl->setPermanentLink($this->
object->getType(), $this->object->getRefId());
1118 $out[] = $this->getTable();
1119 $this->tpl->setContent(implode(
'',
$out));
1124 $q_id = $this->request_data_collector->getQuestionId();
1126 if ($q_id === 0 || $this->
object->checkQuestionParent($q_id)) {
1135 $this->
help->setScreenId(
'assQuestions');
1136 if ($this->global_test_settings->isPageEditorEnabled()) {
1137 $this->
help->setSubScreenId(
'createQuestion_editMode');
1139 $this->
help->setSubScreenId(
'createQuestion');
1142 $this->tpl->setContent(
1143 $this->ui_renderer->render(
1144 $form ?? $this->buildQuestionCreationForm()
1151 $inputs[
'question_type'] = $this->buildInputQuestionType();
1152 $inputs[
'editing_type'] = $this->buildInputEditingType();
1155 $this->ui_factory->input()->field()->section(
$inputs, $this->
lng->txt(
'ass_create_question'))
1158 $form = $this->ui_factory->input()->container()->form()->standard(
1159 $this->
ctrl->getFormAction($this,
'createQuestion'),
1161 )->withSubmitLabel($this->
lng->txt(
'create'));
1168 $question_types = (
new ilObjQuestionPool())->getQuestionTypes(
false,
true,
false);
1170 foreach ($question_types as $label =>
$data) {
1171 $options[
$data[
'question_type_id']] = $label;
1174 return $this->ui_factory->input()->field()->select(
1175 $this->
lng->txt(
'question_type'),
1177 )->withRequired(
true);
1182 if (!$this->global_test_settings->isPageEditorEnabled()) {
1183 return $this->ui_factory->input()->field()->hidden()->
withValue(
1188 return $this->ui_factory->input()->field()->radio($this->
lng->txt(
'tst_add_quest_cont_edit_mode'))
1191 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_IPE'),
1192 $this->lng->txt(
'tst_add_quest_cont_edit_mode_IPE_info')
1195 $this->
lng->txt(
'tst_add_quest_cont_edit_mode_RTE'),
1196 $this->lng->txt(
'tst_add_quest_cont_edit_mode_RTE_info')
1203 $this->tabs_gui->activateTab(
'print_view');
1204 $this->
ctrl->setParameter($this,
'output',
'overview');
1205 $output_link = $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'print');
1206 $this->
ctrl->setParameter($this,
'output',
'detailed_output_solutions');
1207 $output_link_detailed = $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'print');
1208 $this->
ctrl->setParameter($this,
'output',
'detailed_output_printview');
1209 $output_link_printview = $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'print');
1211 $mode = $this->ui_factory->dropdown()->standard([
1212 $this->ui_factory->button()->shy($this->lng->txt(
'overview'), $output_link),
1213 $this->ui_factory->button()->shy($this->lng->txt(
'detailed_output_solutions'), $output_link_detailed),
1214 $this->ui_factory->button()->shy($this->lng->txt(
'detailed_output_printview'), $output_link_printview)
1215 ])->withLabel($this->
lng->txt(
'output_mode'));
1217 $output = $this->request_data_collector->raw(
'output') ??
'';
1220 $data = $this->
object->getPrintviewQuestions();
1223 $totalPoints +=
$d[
'points'];
1225 $table_gui->setTotalPoints($totalPoints);
1226 $table_gui->initColumns();
1227 $table_gui->setData(
$data);
1228 $this->tpl->setContent($this->ui_renderer->render($mode) . $table_gui->getHTML());
1233 $this->
object->update();
1234 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
1240 if ($this->
object->pasteFromClipboard()) {
1241 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'qpl_paste_success'),
true);
1243 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'qpl_paste_error'),
true);
1246 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_paste_no_objects'),
true);
1248 $this->
ctrl->redirect($this, self::DEFAULT_CMD);
1254 foreach ($ids as
$id) {
1255 $this->
object->copyToClipboard($id);
1257 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_copy_insert_clipboard'),
true);
1259 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_copy_select_none'),
true);
1265 if ($this->checkPermission(
'write')) {
1266 $this->tpl->setOnScreenMessage(
'failure',
'permission_denied');
1271 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_move_select_none'),
true);
1275 foreach ($ids as
$id) {
1276 $this->
object->moveToClipboard($id);
1278 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qpl_move_insert_clipboard'),
true);
1283 $rbacsystem = $this->rbac_system;
1284 if ($rbacsystem->checkAccess(
'write', $this->request_data_collector->getRefId())) {
1285 $question_ids = &$this->
object->getAllQuestionIds();
1287 $qpl_exp->buildExportFile();
1288 $this->
ctrl->redirectByClass(
'ilquestionpoolexportgui',
'');
1294 $this->
ctrl->redirectByClass(ilAssQuestionPreviewGUI::class,
'show');
1299 if (!$this->temp_file_system->hasDir($path_to_uploaded_file_in_temp_dir)
1300 || ($files = $this->temp_file_system->listContents($path_to_uploaded_file_in_temp_dir)) === []) {
1301 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'obj_import_file_error'));
1304 $file_to_import = $this->import_temp_directory . DIRECTORY_SEPARATOR . $files[0]->getPath();
1305 $qtifile = $file_to_import;
1306 $importdir = dirname($file_to_import);
1309 if ($this->temp_file_system->getMimeType($files[0]->getPath()) === MimeType::APPLICATION__ZIP) {
1312 $unzip = $this->archives->unzip($this->temp_file_system->readStream($files[0]->getPath()), $options);
1316 if (!file_exists($qtifile)) {
1318 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'cannot_find_xml'),
true);
1319 $this->questionsObject();
1324 ilSession::set(
'path_to_uploaded_file_in_temp_dir', $path_to_uploaded_file_in_temp_dir);
1327 'importVerifiedQuestionsFile',
1330 $path_to_uploaded_file_in_temp_dir
1333 if ($form ===
null) {
1337 $panel = $this->ui_factory->panel()->standard(
1338 $this->
lng->txt(
'import_question'),
1340 $this->ui_factory->legacy()->content($this->lng->txt(
'qpl_import_verify_found_questions')),
1344 $this->tpl->setContent($this->ui_renderer->render($panel));
1345 $this->tpl->printToStdout();
1349 protected function importFile(
string $file_to_import,
string $path_to_uploaded_file_in_temp_dir): void
1356 $unzip = $this->archives->unzip(Streams::ofResource(fopen($file_to_import,
'r')), $options);
1359 if (!file_exists($qtifile)) {
1361 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'cannot_find_xml'),
true);
1366 ilSession::set(
'path_to_uploaded_file_in_temp_dir', $path_to_uploaded_file_in_temp_dir);
1368 $this->
ctrl->setParameterByClass(self::class,
'new_type', $this->type);
1370 'importVerifiedFile',
1373 $path_to_uploaded_file_in_temp_dir
1376 if ($form ===
null) {
1380 $panel = $this->ui_factory->panel()->standard(
1381 $this->
lng->txt(
'import_qpl'),
1383 $this->ui_factory->legacy()->content($this->lng->txt(
'qpl_import_verify_found_questions')),
1387 $this->tpl->setContent($this->ui_renderer->render($panel));
1388 $this->tpl->printToStdout();
1394 $ilLocator = $this->locator;
1396 switch ($this->
ctrl->getCmd()) {
1402 $this->
ctrl->clearParameterByClass(self::class,
'q_id');
1403 $ilLocator->addItem(
1404 $this->
object->getTitle(),
1405 $this->ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
''),
1407 $this->request_data_collector->getRefId()
1409 $this->
ctrl->setParameter($this,
'q_id', $this->request_data_collector->getQuestionId());
1413 if (!is_array($this->request_data_collector->raw(
'q_id')) && $this->request_data_collector->raw(
'q_id') > 0 && $this->request_data_collector->raw(
1415 ) !== self::DEFAULT_CMD) {
1417 if ($question_gui !==
null && $question_gui->getObject() instanceof
assQuestion) {
1418 $question = $question_gui->getObject();
1419 $question->setObjId($this->
object->getId());
1420 $question_gui->setObject($question);
1421 $title = $question_gui->getObject()->getTitleForHTMLOutput();
1423 $title = $this->
lng->txt(
'new') .
': ' . $this->questionrepository->getForQuestionId(
1424 $question_gui->getObject()->getId()
1425 )->getTypeName($this->
lng);
1427 $ilLocator->addItem($title, $this->
ctrl->getLinkTargetByClass(get_class($question_gui),
'editQuestion'));
1430 $this->
ctrl->setParameter($this,
'q_id',
'');
1431 $this->
ctrl->redirect($this);
1441 parent::setTitleAndDescription();
1443 if (!is_array($this->request_data_collector->raw(
'q_id')) && $this->request_data_collector->raw(
'q_id') > 0 && $this->request_data_collector->raw(
1445 ) !== self::DEFAULT_CMD) {
1447 if ($question_gui->getObject() instanceof
assQuestion) {
1448 $question = $question_gui->getObject();
1449 $question->setObjId($this->
object->getId());
1450 $question_gui->setObject($question);
1451 $title = $this->
object->getTitle() .
': ' . $question_gui->getObject()->getTitleForHTMLOutput();
1453 $title = $this->
lng->txt(
'new') .
': ' . $this->questionrepository->getForQuestionId(
1454 $question_gui->getObject()->getId()
1455 )->getTypeName($this->
lng);
1457 $this->tpl->setTitle(
1458 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
1462 $this->tpl->setDescription(
1463 $question_gui->getObject()->getDescriptionForHTMLOutput()
1468 $this->
ctrl->setParameter($this,
'q_id',
'');
1469 $this->
ctrl->redirect($this);
1472 $this->tpl->setTitle(
1473 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
1474 $this->object->getTitle()
1477 $this->tpl->setDescription(
1478 $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
1479 $this->object->getLongDescription()
1493 $with_write_access = $this->
access->checkAccess(
'write',
'', $this->
object->getRefId());
1494 $with_read_access = $this->
access->checkAccess(
'read',
'', $this->
object->getRefId());
1496 $this->
help->setScreenIdComponent(
'qpl');
1498 switch ($this->
ctrl->getNextClass()) {
1500 case strtolower(ilInfoScreenGUI::class):
1501 case strtolower(ilPermissionGUI::class):
1502 case strtolower(ilObjectMetaDataGUI::class):
1503 case strtolower(ilExportGUI::class):
1504 case strtolower(ilQuestionPoolSkillAdministrationGUI::class):
1507 case strtolower(ilTaxonomySettingsGUI::class):
1508 case strtolower(ilObjQuestionPoolSettingsGeneralGUI::class):
1509 if ($with_write_access) {
1510 $this->addSettingsSubTabs($this->tabs_gui);
1519 $force_active =
false;
1520 $commands = $this->request_data_collector->raw(
'cmd');
1521 if (is_array($commands)) {
1522 foreach ($commands as $key => $value) {
1523 if (preg_match(
'/^delete_.*/', $key, $matches) ||
1524 preg_match(
'/^addSelectGap_.*/', $key, $matches) ||
1525 preg_match(
'/^addTextGap_.*/', $key, $matches) ||
1526 preg_match(
'/^deleteImage_.*/', $key, $matches) ||
1527 preg_match(
'/^upload_.*/', $key, $matches) ||
1528 preg_match(
'/^addSuggestedSolution_.*/', $key, $matches)
1530 $force_active =
true;
1535 $force_active = $force_active || $this->request_data_collector->isset(
'imagemap_x');
1536 if (!$force_active) {
1537 $force_active = strtolower($this->
ctrl->getCmdClass()) === strtolower(self::class)
1538 || $this->
ctrl->getCmdClass() ===
'' && $this->
ctrl->getCmd() ===
''
1542 if ($with_read_access) {
1543 $this->tabs_gui->addTarget(
1545 $this->
ctrl->getLinkTargetByClass(
1546 [ilRepositoryGUI::class, self::class],
1556 'filterQuestionBrowser',
1565 'addSuggestedSolution',
1568 'removeSuggestedSolution',
1575 'uploadingImagemap',
1581 'uploadingJavaapplet',
1588 'toggleGraphicalAnswers',
1598 if ($with_read_access) {
1599 $this->tabs_gui->addTab(
1601 $this->
lng->txt(
'info_short'),
1602 $this->ctrl->getLinkTargetByClass(
1604 ilRepositoryGUI::class,
1606 ilInfoScreenGUI::class
1612 if ($with_write_access) {
1614 $this->tabs_gui->addTarget(
1616 $this->
ctrl->getLinkTargetByClass(ilObjQuestionPoolSettingsGeneralGUI::class),
1618 [ilObjQuestionPoolSettingsGeneralGUI::class, ilObjTaxonomyGUI::class]
1622 if ($this->isSkillsTabRequired()) {
1623 $link = $this->
ctrl->getLinkTargetByClass(
1624 [ilQuestionPoolSkillAdministrationGUI::class, ilAssQuestionSkillAssignmentsGUI::class],
1628 $this->tabs_gui->addTarget(
'qpl_tab_competences', $link, [], []);
1632 if ($with_read_access) {
1634 $this->tabs_gui->addTarget(
1636 $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class],
'print'),
1643 if ($with_write_access) {
1645 $mdtab = $mdgui->getTab();
1647 $this->tabs_gui->addTarget(
1656 if ($with_write_access) {
1657 $this->tabs_gui->addTarget(
1659 $this->
ctrl->getLinkTargetByClass(ilExportGUI::class,
''),
1665 if ($this->
access->checkAccess(
'edit_permission',
'', $this->object->getRefId())) {
1666 $this->tabs_gui->addTarget(
1668 $this->
ctrl->getLinkTargetByClass([ilRepositoryGUI::class, self::class, ilPermissionGUI::class],
'perm'),
1669 [
'perm',
'info',
'owner'],
1681 if (!$this->
object->isSkillServiceEnabled()) {
1696 $this->
lng->txt(
'qpl_settings_subtab_general'),
1697 $this->ctrl->getLinkTargetByClass(ilObjQuestionPoolSettingsGeneralGUI::class),
1702 $this->
lng->txt(
'qpl_settings_subtab_taxonomies'),
1703 $this->ctrl->getLinkTargetByClass(ilTaxonomySettingsGUI::class,
''),
1709 $this->
ctrl->redirectByClass(
1711 ilRepositoryGUI::class,
1713 ilInfoScreenGUI::class
1720 if (!$this->
access->checkAccess(
'visible',
'', $this->ref_id)) {
1721 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'));
1724 $this->tabs_gui->activateTab(
'info_short');
1726 $info->enablePrivateNotes();
1727 $info->addMetaDataSections($this->
object->getId(), 0, $this->object->getType());
1732 public static function _goto($a_target): void
1736 $main_tpl =
$DIC->ui()->mainTemplate();
1737 $ilAccess =
$DIC[
'ilAccess'];
1740 $ctrl =
$DIC[
'ilCtrl'];
1742 $target_ref_id = (
int) $a_target;
1744 if ($ilAccess->checkAccess(
'write',
'', $target_ref_id)
1745 || $ilAccess->checkAccess(
'read',
'', $target_ref_id)
1747 $ctrl->setParameterByClass(ilObjQuestionPoolGUI::class,
'ref_id', $a_target);
1748 $ctrl->redirectByClass([ilRepositoryGUI::class, ilObjQuestionPoolGUI::class], self::DEFAULT_CMD);
1751 if ($ilAccess->checkAccess(
'visible',
'', $target_ref_id)) {
1752 $DIC->ctrl()->setParameterByClass(ilInfoScreenGUI::class,
'ref_id', $a_target);
1753 $DIC->ctrl()->redirectByClass(
1755 ilRepositoryGUI::class,
1757 ilInfoScreenGUI::class
1762 $main_tpl->setOnScreenMessage(
1765 $lng->txt(
'msg_no_perm_read_item'),
1778 $f = $this->ui_factory;
1779 $r = $this->ui_renderer;
1784 $this->data_factory,
1787 $this->action_parameter_token,
1788 $this->row_id_token,
1791 $this->component_repository,
1794 $this->taxonomy->domain(),
1795 $this->notes_service,
1796 $this->object->getId(),
1797 $this->request_data_collector->getRefId()
1804 $filter_action = $this->
ctrl->getLinkTarget($this, self::DEFAULT_CMD);
1805 $filter = $table->getFilter($this->ui_service, $filter_action);
1807 $filter_params = $this->ui_service->filter()->getData($filter);
1809 if ($filter_params) {
1810 foreach (array_filter($filter_params) as $item => $value) {
1813 foreach ($value as $tax_value) {
1814 if ($tax_value ===
'null') {
1815 $table->addTaxonomyFilterNoTaxonomySet(
true);
1817 $tax_nodes = explode(
'-', $tax_value);
1818 $tax_id = array_shift($tax_nodes);
1819 $table->addTaxonomyFilter(
1823 $this->object->getType()
1829 $table->setCommentFilter((
int) $value);
1832 $table->addFieldFilter($item, $value);
1840 ->withRequest($this->request)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Stream factory which enables the user to create streams without the knowledge of the concrete class.
acquireParameters(array $namespace, string ... $names)
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
const EDIT_CONTEXT_AUTHORING
const RENDER_PURPOSE_PREVIEW
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
const ADDITIONAL_CONTENT_EDITING_MODE_IPE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CMD_SHOW_SKILL_QUEST_ASSIGNS
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
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.
Component logger with individual log levels by component id.
Export User Interface Class.
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
Class ilLocalUnitConfigurationGUI.
Last visited history for repository items.
static getListCommentsJSCall(string $a_hash, ?string $a_update_code=null)
Get list comments js call.
Class ilObjQuestionPoolGUI.
moveQuestions(array $ids)
addSettingsSubTabs(ilTabsGUI $tabs)
renoveImportFailsObject()
uploadQuestionsImportObject()
confirmDeleteQuestionsObject()
delete questions after confirmation
GlobalTestSettings $global_test_settings
updateObject()
updates object entry in object_data
DataFactory $data_factory
fetchAuthoringQuestionIdParamater()
download_paragraphObject()
download source code paragraph
afterSave(ilObject $new_object)
Post (successful) object creation hook.
deleteQuestionsObject()
delete questions confirmation screen
GlobalScreen $global_screen
getTabs()
adds tabs to tab gui object
confirmDeleteQuestions(array $ids)
importQuestionsFromQtiFile(ilObjQuestionPool $obj, array $selected_questions, string $qtifile, string $importdir, string $xmlfile='')
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
importVerifiedFileObject()
URLBuilderToken $action_parameter_token
cleanupAfterImport(string $importdir)
cancelDeleteQuestionsObject()
importFile(string $file_to_import, string $path_to_uploaded_file_in_temp_dir)
ilComponentFactory $component_factory
ilNavigationHistory $navigation_history
importVerifiedQuestionsFileObject()
redirectAfterMissingWrite()
questionsObject(?RoundTripModal $import_questions_modal=null)
list questions of question pool
setTitleAndDescription()
called by prepare output
buildImportQuestionsModal()
editQuestionForTestObject()
URLBuilderToken $row_id_token
RequestDataCollector $request_data_collector
const SUPPORTED_IMPORT_MIME_TYPES
buildQuestionCreationForm()
importQuestionsFile(string $path_to_uploaded_file_in_temp_dir)
ContentStyle $content_style
createQuestionFormObject(?Form $form=null)
exportObject()
Gateway for exports initiated from workspace, as there is a generic forward to {objTypeMainGUI}::expo...
importQuestionPoolWithValidManifest(ilObjQuestionPool $obj, array $selected_questions, string $file_to_import)
ilComponentRepository $component_repository
GeneralQuestionPropertiesRepository $questionrepository
copyQuestions(array $ids)
fullscreenObject()
show fullscreen view
exportQuestions(array $ids)
const TAB_COMMON_SETTINGS
static isSkillManagementGloballyActivated()
static getQuestionTypeByTypeId($type_id)
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
static getSyntaxStylePath()
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.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
Class ilObject Basic functions for all objects.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
startParsing()
stores xml data in array
Legacy Content Object Parser.
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 get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addSubTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Class ilUnitConfigurationRepository.
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
static redirect(string $a_script)
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...
__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)
retrieveSelectedQuestionsFromImportQuestionsSelectionForm(string $form_cmd, string $importdir, string $qtifile, ServerRequestInterface $request)
Class ilObjForumAdministration.
if(!file_exists('../ilias.ini.php'))