19 declare(strict_types=1);
91 $this->component_repository,
95 $this->question_set_config->loadFromDb();
105 $this->source_pool_definition_factory
108 $this->source_pool_definition_list->loadDefinitions();
123 $this->configStateMessageHandler->setTargetGUI($this);
124 $this->configStateMessageHandler->setQuestionSetConfig($this->question_set_config);
125 $this->configStateMessageHandler->setParticipantDataExists($this->test_obj->participantDataExist());
126 $this->configStateMessageHandler->setLostPools($this->source_pool_definition_list->getLostPools());
127 $this->processLockerFactory = $processLockerFactory;
132 if (!$this->
access->checkAccess(
"write",
"", $this->test_obj->getRefId())) {
133 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"cannot_edit_test"),
true);
134 $this->
ctrl->redirectByClass(
'ilObjTestGUI',
"infoScreen");
138 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"tst_msg_cannot_modify_random_question_set_conf_due_to_part"),
true);
139 $this->
ctrl->redirect($this);
144 $nextClass = $this->
ctrl->getNextClass();
146 switch ($nextClass) {
147 case 'iltestrandomquestionsetpooldefinitionformgui':
148 $this->question_set_config->loadFromDb();
153 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
155 $this->
ctrl->forwardCommand($form);
159 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM) .
'Cmd';
179 if ($this->test_obj->participantDataExist()) {
183 if ($this->source_pool_definition_list->hasLostPool()) {
192 switch ($this->
ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM)) {
193 case self::CMD_SAVE_GENERAL_CONFIG_FORM:
194 case self::CMD_SAVE_SRC_POOL_DEF_LIST:
195 case self::CMD_DELETE_SINGLE_SRC_POOL_DEF:
196 case self::CMD_DELETE_MULTI_SRC_POOL_DEFS:
197 case self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM:
198 case self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM:
199 case self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM:
200 case self::CMD_BUILD_QUESTION_STAGE:
210 $this->
tabs->activateTab(
'assQuestions');
212 $this->
tabs->addSubTab(
213 'tstRandQuestSetGeneralConfig',
215 $this->
ctrl->getLinkTarget($this, self::CMD_SHOW_GENERAL_CONFIG_FORM)
218 $this->
tabs->addSubTab(
219 'tstRandQuestSetPoolConfig',
221 $this->
ctrl->getLinkTarget($this, self::CMD_SHOW_SRC_POOL_DEF_LIST)
224 switch ($this->
ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM)) {
225 case self::CMD_SHOW_GENERAL_CONFIG_FORM:
226 case self::CMD_SAVE_GENERAL_CONFIG_FORM:
228 $this->
tabs->activateSubTab(
'tstRandQuestSetGeneralConfig');
231 case self::CMD_SHOW_SRC_POOL_DEF_LIST:
232 case self::CMD_SAVE_SRC_POOL_DEF_LIST:
233 case self::CMD_DELETE_SINGLE_SRC_POOL_DEF:
234 case self::CMD_DELETE_MULTI_SRC_POOL_DEFS:
235 case self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM:
236 case self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM:
237 case self::CMD_SHOW_EDIT_SRC_POOL_DEF_FORM:
238 case self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM:
240 $this->
tabs->activateSubTab(
'tstRandQuestSetPoolConfig');
243 default: $this->
tabs->activateSubTab(
'nonTab');
249 if ($this->source_pool_definition_list->areAllUsedPoolsAvailable()) {
250 $locker = $this->processLockerFactory->retrieveLockerForNamedOperation();
251 $locker->executeNamedOperation(__FUNCTION__,
function ():
void {
252 $this->stagingPool->rebuild($this->source_pool_definition_list);
253 $this->source_pool_definition_list->saveDefinitions();
255 $this->question_set_config->loadFromDb();
256 $this->question_set_config->setLastQuestionSyncTimestamp(time());
257 $this->question_set_config->saveToDb();
259 $this->test_obj->saveCompleteStatus($this->question_set_config);
261 $this->
ctrl->setParameterByClass(self::class,
'modified',
'sync');
270 if (!$this->testrequest->isset(self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD)) {
271 return self::CMD_SHOW_GENERAL_CONFIG_FORM;
274 if (!strlen($this->testrequest->raw(self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD))) {
275 return self::CMD_SHOW_GENERAL_CONFIG_FORM;
278 return $this->testrequest->raw(self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD);
285 if ($form === null) {
286 $this->question_set_config->loadFromDb();
290 $this->tpl->setContent($this->
ctrl->getHTML($form));
292 $this->configStateMessageHandler->setContext(
296 $this->configStateMessageHandler->handle();
308 $errors = !$form->checkInput();
309 $form->setValuesByPost();
318 $this->question_set_config->setLastQuestionSyncTimestamp(0);
319 $this->question_set_config->saveToDb();
321 $this->test_obj->saveCompleteStatus($this->question_set_config);
323 $this->
ctrl->setParameter($this,
'modified',
'save');
324 $this->
ctrl->redirect($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
335 $this->question_set_config
342 $form->setEditModeEnabled(
false);
348 $form->clearCommandButtons();
358 $this->question_set_config->loadFromDb();
364 $content .= $this->
ctrl->getHTML($toolbar);
368 $table->init($this->source_pool_definition_list);
369 $content .= $this->
ctrl->getHTML($table);
371 if (!$this->source_pool_definition_list->areAllUsedPoolsAvailable()) {
373 $table->init($this->source_pool_definition_list);
374 $content .= $this->
ctrl->getHTML($table);
377 $this->tpl->setContent($content);
379 $this->configStateMessageHandler->setContext(
383 $this->configStateMessageHandler->handle();
393 $this->question_set_config->loadFromDb();
397 $table->applySubmit($this->source_pool_definition_list);
399 $this->source_pool_definition_list->reindexPositions();
400 $this->source_pool_definition_list->saveDefinitions();
402 $this->question_set_config->setLastQuestionSyncTimestamp(0);
404 $this->question_set_config->saveToDb();
406 $this->test_obj->saveCompleteStatus($this->question_set_config);
408 $this->
ctrl->setParameter($this,
'modified',
'save');
409 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
418 $this->question_set_config
430 self::CMD_SHOW_SRC_POOL_DEF_LIST,
434 $this->testrequest->raw(
'def_order') ?? [],
435 $this->testrequest->raw(
'quest_amount') ?? []
442 $table->setQuestionAmountColumnEnabled(
443 $this->question_set_config->isQuestionAmountConfigurationModePerPool()
446 $table->setShowMappedTaxonomyFilter(
447 $this->question_set_config->getLastQuestionSyncTimestamp() != 0
451 $translater->loadLabels($this->source_pool_definition_list);
452 $table->setTaxonomyFilterLabelTranslater($translater);
455 $table->setDefinitionEditModeEnabled(
false);
468 self::CMD_SHOW_SRC_POOL_DEF_LIST
481 $this->
ctrl->setParameterByClass(self::class,
'modified',
'remove');
482 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
490 $this->
ctrl->setParameterByClass(self::class,
'modified',
'remove');
491 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
496 foreach ($definitionIds as $definitionId) {
497 $definition = $this->source_pool_definition_factory->getSourcePoolDefinitionByDefinitionId($definitionId);
498 $definition->deleteFromDb();
501 $this->source_pool_definition_list->reindexPositions();
502 $this->source_pool_definition_list->saveDefinitions();
504 $this->question_set_config->loadFromDb();
505 $this->question_set_config->setLastQuestionSyncTimestamp(0);
506 $this->question_set_config->saveToDb();
508 $this->test_obj->saveCompleteStatus($this->question_set_config);
514 $this->question_set_config->loadFromDb();
518 self::CMD_SHOW_POOL_SELECTOR_EXPLORER,
519 self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM,
523 $selector->setAvailableQuestionPools(
524 array_keys($this->question_set_config->getSelectableQuestionPools())
527 if ($selector->handleCommand()) {
531 $this->tpl->setContent($selector->getHTML());
537 $this->question_set_config->loadFromDb();
544 if ($form === null) {
546 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
549 $this->tpl->setContent($this->
ctrl->getHTML($form));
562 $this->question_set_config->loadFromDb();
569 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
571 $errors = !$form->checkInput();
572 $form->setValuesByPost();
579 $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds);
581 $sourcePoolDefinition->setSequencePosition($this->source_pool_definition_list->getNextPosition());
582 $sourcePoolDefinition->saveToDb();
583 $this->source_pool_definition_list->addDefinition($sourcePoolDefinition);
585 $this->source_pool_definition_list->saveDefinitions();
587 $this->question_set_config->setLastQuestionSyncTimestamp(0);
588 $this->question_set_config->saveToDb();
590 $this->test_obj->saveCompleteStatus($this->question_set_config);
592 if ($redirect_back_to_form) {
593 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"tst_msg_random_qsc_modified_add_new_rule"),
true);
594 $this->
ctrl->setParameter($this,
'src_pool_def_id', $sourcePoolDefinition->getId());
595 $this->
ctrl->setParameter($this,
'quest_pool_id', $sourcePoolDefinition->getPoolId());
596 $this->
ctrl->redirect($this, self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM);
598 $this->
ctrl->setParameterByClass(self::class,
'modified',
'save');
599 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
610 $this->question_set_config
613 $form->setSaveCommand(self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM);
614 $form->setSaveAndNewCommand(self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM);
621 $this->question_set_config->loadFromDb();
624 $sourcePoolDefinition = $this->source_pool_definition_factory->getSourcePoolDefinitionByDefinitionId($defId);
627 if ($form === null) {
629 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
632 $this->tpl->setContent($this->
ctrl->getHTML($form));
637 $this->question_set_config->loadFromDb();
640 $sourcePoolDefinition = $this->source_pool_definition_factory->getSourcePoolDefinitionByDefinitionId($defId);
644 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
646 $errors = !$form->checkInput();
647 $form->setValuesByPost();
654 $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds);
656 $sourcePoolDefinition->saveToDb();
658 $this->question_set_config->setLastQuestionSyncTimestamp(0);
659 $this->question_set_config->saveToDb();
661 $this->test_obj->saveCompleteStatus($this->question_set_config);
663 $this->
ctrl->setParameterByClass(self::class,
'modified',
'save');
664 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
674 $this->question_set_config
677 $form->setSaveCommand(self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM);
684 if ($this->testrequest->isset(
'quest_pool_id') && (
int) $this->testrequest->raw(
'quest_pool_id')) {
685 return (
int) $this->testrequest->raw(
'quest_pool_id');
688 if ($this->testrequest->isset(
'quest_pool_ref') && (
int) $this->testrequest->raw(
'quest_pool_ref')) {
689 return $this->obj_cache->lookupObjId((
int) $this->testrequest->raw(
'quest_pool_ref'));
697 if ($this->testrequest->isset(
'src_pool_def_id') && (
int) $this->testrequest->raw(
'src_pool_def_id')) {
698 return (
int) $this->testrequest->raw(
'src_pool_def_id');
706 if (!$this->testrequest->isset(
'src_pool_def_ids') || !is_array($this->testrequest->raw(
'src_pool_def_ids'))) {
707 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_please_select_source_pool'),
true);
708 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
714 foreach ($this->testrequest->raw(
'src_pool_def_ids') as $definitionId) {
715 $definitionId = (
int) $definitionId;
717 if (!$definitionId) {
721 $definitionIds[] = $definitionId;
724 return $definitionIds;
729 $availablePools = $this->test_obj->getAvailableQuestionpools(
731 $this->question_set_config->arePoolsWithHomogeneousScoredQuestionsRequired(),
737 if (isset($availablePools[$poolId])) {
738 $originalPoolData = $availablePools[$poolId];
740 $originalPoolData[
'qpl_path'] = $this->question_set_config->getQuestionPoolPathString($poolId);
741 $originalPoolData[
'qpl_ref_id'] = $this->question_set_config->getFirstQuestionPoolRefIdByObjId($poolId);
743 return $this->source_pool_definition_factory->getSourcePoolDefinitionByOriginalPoolData($originalPoolData);
755 if ($this->testrequest->isset(
'derive_pool_ids') && is_array($this->testrequest->raw(
'derive_pool_ids'))) {
758 foreach ($this->testrequest->raw(
'derive_pool_ids') as $pool_id) {
759 $pool_ids[] = (
int) $pool_id;
761 } elseif ($this->testrequest->isset(
'derive_pool_ids') && preg_match(
'/^\d+(\:\d+)*$/', $this->testrequest->raw(
'derive_pool_ids'))) {
762 $pool_ids = array_map(
763 fn(
int $id) => (
int) $id,
764 explode(
':', $this->testrequest->raw(
'derive_pool_ids'))
766 } elseif ($this->testrequest->isset(
'derive_pool_id') && (
int) $this->testrequest->raw(
'derive_pool_id')) {
767 $pool_ids = [(
int) $this->testrequest->raw(
'derive_pool_id')];
775 if ($this->testrequest->isset(
'target_ref') && (
int) $this->testrequest->raw(
'target_ref')) {
776 return (
int) $this->testrequest->raw(
'target_ref');
788 self::CMD_SELECT_DERIVATION_TARGET,
790 self::CMD_DERIVE_NEW_POOLS,
793 $explorer->setClickableTypes($this->obj_definition->getExplorerContainerTypes());
794 $explorer->setSelectableTypes([]);
796 if (!$explorer->handleCommand()) {
797 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tst_please_select_target_for_pool_derives'));
798 $this->tpl->setContent($this->
ctrl->getHTML($explorer));
806 if (!$this->
access->checkAccess(
'write',
'', $target_ref)) {
807 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"no_permission"),
true);
808 $this->
ctrl->setParameterByClass(ilObjTestGUI::class,
'ref_id', $this->test_obj->getRefId());
809 $this->
ctrl->redirectByClass(ilObjTestGUI::class);
812 if ($pool_ids !== []) {
813 foreach ($pool_ids as $pool_id) {
814 $lost_pool = $this->source_pool_definition_list->getLostPool($pool_id);
817 $deriver->setSourcePoolDefinitionList($this->source_pool_definition_list);
818 $deriver->setTargetContainerRef($target_ref);
819 $deriver->setOwnerId($this->
user->getId());
820 $new_pool = $deriver->derive($lost_pool);
822 $srcPoolDefinition = $this->source_pool_definition_list->getDefinitionBySourcePoolId($new_pool->getId());
823 $srcPoolDefinition->setPoolTitle($new_pool->getTitle());
824 $srcPoolDefinition->setPoolPath($this->question_set_config->getQuestionPoolPathString($new_pool->getId()));
825 $srcPoolDefinition->setPoolRefId($this->question_set_config->getFirstQuestionPoolRefIdByObjId($new_pool->getId()));
826 $srcPoolDefinition->saveToDb();
829 $this->test_obj->getTestId(),
835 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_non_available_pool_newly_derived'),
true);
838 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
846 return $this->
lng->txt(
"tst_msg_random_question_set_config_modified");
854 return $this->
lng->txt(
'tst_rnd_quest_cfg_tab_general');
862 return $this->
lng->txt(
'tst_rnd_quest_cfg_tab_pool');
869 $last_sync = $this->question_set_config->getLastQuestionSyncTimestamp();
871 if ($last_sync !== null && $last_sync !== 0 &&
880 $this->question_set_config->setLastQuestionSyncTimestamp(0);
881 $this->question_set_config->saveToDb();
882 $this->
ctrl->redirect($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
897 if ($this->testrequest->isset(
'modified')) {
898 $action = $this->testrequest->raw(
'modified');
899 if ($action ===
'save') {
901 } elseif ($action ===
'remove') {
902 $success_message = $this->ui_factory->messageBox()->success($this->
lng->txt(
"tst_msg_source_pool_definitions_deleted"));
903 } elseif ($action ===
'sync') {
904 $success_message = $this->ui_factory->messageBox()->success($this->
lng->txt(
"tst_msg_random_question_set_synced"));
906 $message .= $this->ui_renderer->render(
916 if ($this->configStateMessageHandler->isValidationFailed()) {
917 return $this->ui_renderer->render(
918 $this->ui_factory->messageBox()->failure($this->configStateMessageHandler->getValidationReportHtml())
922 if ($this->configStateMessageHandler->hasValidationReports()) {
923 return $this->ui_renderer->render(
924 $this->ui_factory->messageBox()->info($this->configStateMessageHandler->getValidationReportHtml())
928 return $this->configStateMessageHandler->getSyncInfoMessage();
936 $this->tpl->setCurrentBlock(
'mess');
937 $this->tpl->setVariable(
'MESSAGE',
$message);
938 $this->tpl->parseCurrentBlock();
preventFormBecauseOfSync()
fetchMultiSourcePoolDefinitionIdsParameter()
Readable part of repository interface to ilComponentDataDB.
buildNonAvailablePoolsTableGUI()
saveEditSourcePoolDefinitionFormCmd()
saveSourcePoolDefinitionListCmd()
Explorer for selecting repository items.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
showPoolSelectorExplorerCmd()
ilTestRandomQuestionSetSourcePoolDefinitionFactory $source_pool_definition_factory
__construct(private ilObjTest $test_obj, private ilCtrl $ctrl, private ilObjUser $user, private ilAccessHandler $access, private UIFactory $ui_factory, private UIRenderer $ui_renderer, private ilTabsGUI $tabs, private ilLanguage $lng, private ilLogger $log, private ilGlobalTemplateInterface $tpl, private ilDBInterface $db, private ilTree $tree, private ilComponentRepository $component_repository, private ilObjectDefinition $obj_definition, private ilObjectDataCache $obj_cache, private ilTestProcessLockerFactory $processLockerFactory, private InternalRequestService $testrequest, private QuestionInfoService $questioninfo)
const CMD_SHOW_EDIT_SRC_POOL_DEF_FORM
ilTestRandomQuestionSetStagingPoolBuilder $stagingPool
const CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM
getSourcePoolDefinitionByAvailableQuestionPoolId($poolId)
const CMD_SELECT_DERIVATION_TARGET
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
const CONTEXT_POOL_SELECTION
const CMD_DELETE_SINGLE_SRC_POOL_DEF
selectPoolDerivationTargetCmd()
isAvoidManipulationRedirectRequired()
fetchTargetRefParameter()
fetchQuestionPoolIdParameter()
saveGeneralConfigFormCmd()
ilTestRandomQuestionSetConfigStateMessageHandler $configStateMessageHandler
const CMD_SHOW_SRC_POOL_DEF_LIST
showEditSourcePoolDefinitionFormCmd(ilTestRandomQuestionSetPoolDefinitionFormGUI $form=null)
Exception for invalid parameters (e.g.
parses the objects.xml it handles the xml-description of all ilias objects
setDefinitionEditModeEnabled($definitionEditModeEnabled)
deleteMultipleSourcePoolDefinitionsCmd()
const CONTEXT_GENERAL_CONFIG
getGeneralConfigTabLabel()
ilTestRandomQuestionSetConfig $question_set_config
buildSourcePoolDefinitionListTableGUI(bool $disabled=false)
const CMD_SHOW_POOL_SELECTOR_EXPLORER
const CMD_SAVE_GENERAL_CONFIG_FORM
const CMD_SAVE_SRC_POOL_DEF_LIST
saveCreateSourcePoolDefinitionFormCmd($redirect_back_to_form=false)
buildEditSourcePoolDefinitionFormGUI()
fetchAfterRebuildQuestionStageCmdParameter()
buildSourcePoolDefinitionListToolbarGUI()
const CMD_SAVE_EDIT_SRC_POOL_DEF_FORM
ilTestRandomQuestionSetSourcePoolDefinitionList $source_pool_definition_list
const HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD
const CMD_SHOW_GENERAL_CONFIG_FORM
fetchSingleSourcePoolDefinitionIdParameter()
saveCreateAndNewSourcePoolDefinitionFormCmd()
deleteSourcePoolDefinitions($definitionIds)
showSourcePoolDefinitionListCmd()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
buildGeneralConfigFormGUI(bool $disabled=false)
const CMD_SAVE_CREATE_SRC_POOL_DEF_FORM
getGeneralModificationSuccessMessage()
buildCreateSourcePoolDefinitionFormGUI()
showGeneralConfigFormCmd(ilTestRandomQuestionSetGeneralConfigFormGUI $form=null)
showCreateSourcePoolDefinitionFormCmd(ilTestRandomQuestionSetPoolDefinitionFormGUI $form=null)
deleteSingleSourcePoolDefinitionCmd()
const CMD_SHOW_CREATE_SRC_POOL_DEF_FORM
static updateSourceQuestionPoolId($testId, $oldPoolId, $newPoolId)
populateOnScreenMessage($message)
const CMD_DERIVE_NEW_POOLS
const CMD_DELETE_MULTI_SRC_POOL_DEFS
const CMD_BUILD_QUESTION_STAGE