19 declare(strict_types=1);
73 private readonly
ilCtrl $ctrl,
84 private readonly
ilTree $tree,
98 $this->component_repository,
100 $this->questionrepository
102 $this->question_set_config->loadFromDb();
112 $this->source_pool_definition_factory
115 $this->source_pool_definition_list->loadDefinitions();
130 $this->configStateMessageHandler->setTargetGUI($this);
131 $this->configStateMessageHandler->setQuestionSetConfig($this->question_set_config);
132 $this->configStateMessageHandler->setParticipantDataExists($this->test_obj->participantDataExist());
133 $this->configStateMessageHandler->setLostPools($this->source_pool_definition_list->getLostPools());
134 $this->processLockerFactory = $processLockerFactory;
139 if (!$this->
access->checkAccess(
"write",
"", $this->test_obj->getRefId())) {
140 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"cannot_edit_test"),
true);
141 $this->
ctrl->redirectByClass([ilRepositoryGUI::class, ilObjTestGUI::class, ilInfoScreenGUI::class]);
145 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"tst_msg_cannot_modify_random_question_set_conf_due_to_part"),
true);
146 $this->
ctrl->redirect($this);
149 $this->tabs_manager->getQuestionsSubTabs();
151 $next_class = $this->
ctrl->getNextClass();
153 switch ($next_class) {
154 case 'iltestrandomquestionsetpooldefinitionformgui':
155 $this->question_set_config->loadFromDb();
160 $form->build($source_pool_definition, $available_taxonomy_ids);
162 $this->
ctrl->forwardCommand($form);
166 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM) .
'Cmd';
186 if ($this->test_obj->participantDataExist()) {
190 if ($this->source_pool_definition_list->hasLostPool()) {
200 $this->
ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM),
202 self::CMD_SAVE_GENERAL_CONFIG_FORM,
203 self::CMD_SAVE_SRC_POOL_DEF_LIST,
204 self::CMD_DELETE_SRC_POOL_DEF,
205 self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM,
206 self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM,
207 self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM,
208 self::CMD_BUILD_QUESTION_STAGE
219 $this->tabs_manager->activateTab(
'assQuestions');
221 switch ($this->
ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM)) {
222 case self::CMD_SHOW_GENERAL_CONFIG_FORM:
223 case self::CMD_SAVE_GENERAL_CONFIG_FORM:
224 $this->tabs_manager->activateSubTab(
'tstRandQuestSetGeneralConfig');
227 case self::CMD_SHOW_SRC_POOL_DEF_LIST:
228 case self::CMD_SAVE_SRC_POOL_DEF_LIST:
229 case self::CMD_DELETE_SRC_POOL_DEF:
230 case self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM:
231 case self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM:
232 case self::CMD_SHOW_EDIT_SRC_POOL_DEF_FORM:
233 case self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM:
234 $this->tabs_manager->activateSubTab(
'tstRandQuestSetPoolConfig');
241 if ($this->source_pool_definition_list->areAllUsedPoolsAvailable()) {
242 $locker = $this->processLockerFactory->retrieveLockerForNamedOperation();
243 $locker->executeNamedOperation(__FUNCTION__,
function ():
void {
244 $this->stagingPool->rebuild($this->source_pool_definition_list);
245 $this->source_pool_definition_list->saveDefinitions();
247 $this->question_set_config->loadFromDb();
248 $this->question_set_config->setLastQuestionSyncTimestamp(time());
249 $this->question_set_config->saveToDb();
251 $this->test_obj->saveCompleteStatus($this->question_set_config);
253 $this->
ctrl->setParameterByClass(self::class,
'modified',
'sync');
255 if ($this->
logger->isLoggingEnabled()) {
256 $this->
logger->logTestAdministrationInteraction(
257 $this->
logger->getInteractionFactory()->buildTestAdministrationInteraction(
258 $this->test_obj->getRefId(),
259 $this->
user->getId(),
260 TestAdministrationInteractionTypes::QUESTIONS_SYNCHRONISED,
272 if (!$this->testrequest->isset(self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD)) {
273 return self::CMD_SHOW_GENERAL_CONFIG_FORM;
276 if (!strlen($this->testrequest->raw(self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD))) {
277 return self::CMD_SHOW_GENERAL_CONFIG_FORM;
280 return $this->testrequest->raw(self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD);
287 if ($form === null) {
288 $this->question_set_config->loadFromDb();
292 $this->tpl->setContent($this->
ctrl->getHTML($form));
294 $this->configStateMessageHandler->setContext(
298 $this->configStateMessageHandler->handle();
301 if ($message !==
'') {
310 $errors = !$form->checkInput();
311 $form->setValuesByPost();
318 $log_array = $form->save($this->
logger->getAdditionalInformationGenerator());
320 $this->question_set_config->setLastQuestionSyncTimestamp(0);
321 $this->question_set_config->saveToDb();
323 if ($this->
logger->isLoggingEnabled()) {
324 $this->
logger->logTestAdministrationInteraction(
325 $this->
logger->getInteractionFactory()->buildTestAdministrationInteraction(
326 $this->test_obj->getRefId(),
327 $this->
user->getId(),
328 TestAdministrationInteractionTypes::QUESTION_SELECTION_CRITERIA_MODIFIED,
334 $this->test_obj->saveCompleteStatus($this->question_set_config);
336 $this->
ctrl->setParameter($this,
'modified',
'save');
337 $this->
ctrl->redirect($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
345 $this->question_set_config
352 $form->setEditModeEnabled(
false);
358 $form->clearCommandButtons();
368 $this->question_set_config->loadFromDb();
374 $content .= $this->
ctrl->getHTML($toolbar);
378 $content .= $this->ui_renderer->render($table->getComponent());
380 if (!$this->source_pool_definition_list->areAllUsedPoolsAvailable()) {
386 $this->testrequest->getRequest(),
389 $content .= $this->ui_renderer->render($table->getComponent());
392 $this->tpl->setContent($content);
394 $this->configStateMessageHandler->setContext(
398 $this->configStateMessageHandler->handle();
408 $this->question_set_config->loadFromDb();
411 $table->applySubmit($this->testrequest);
413 $this->source_pool_definition_list->reindexPositions();
414 $this->source_pool_definition_list->saveDefinitions();
416 $this->question_set_config->setLastQuestionSyncTimestamp(0);
417 $this->question_set_config->saveToDb();
419 $this->test_obj->saveCompleteStatus($this->question_set_config);
421 $this->
ctrl->setParameter($this,
'modified',
'save');
422 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
431 $this->question_set_config
442 $translator->loadLabels($this->source_pool_definition_list);
449 $this->testrequest->getRequest(),
450 $this->title_builder,
454 $this->question_set_config->isQuestionAmountConfigurationModePerPool()
461 foreach ($definition_ids as $definition_id) {
462 $definition = $this->source_pool_definition_factory->getSourcePoolDefinitionByDefinitionId($definition_id);
463 $definition->deleteFromDb();
466 $this->source_pool_definition_list->reindexPositions();
467 $this->source_pool_definition_list->saveDefinitions();
469 $this->question_set_config->loadFromDb();
470 $this->question_set_config->setLastQuestionSyncTimestamp(0);
471 $this->question_set_config->saveToDb();
473 $this->test_obj->saveCompleteStatus($this->question_set_config);
475 $this->
ctrl->setParameterByClass(self::class,
'modified',
'remove');
476 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
481 $this->question_set_config->loadFromDb();
485 self::CMD_SHOW_POOL_SELECTOR_EXPLORER,
486 self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM,
490 $selector->setAvailableQuestionPools(
491 array_keys($this->question_set_config->getSelectableQuestionPools())
494 if ($selector->handleCommand()) {
498 $this->tpl->setContent($selector->getHTML(
true));
503 $this->question_set_config->loadFromDb();
510 if ($form === null) {
512 $form->build($source_pool_definition, $available_taxonomy_ids);
515 $this->tpl->setContent($this->
ctrl->getHTML($form));
528 $this->question_set_config->loadFromDb();
535 $form->build($source_pool_definition, $available_taxonomy_ids);
537 $errors = !$form->checkInput();
538 $form->setValuesByPost();
545 $log_array = $form->applySubmit($source_pool_definition, $available_taxonomy_ids);
547 $source_pool_definition->setSequencePosition($this->source_pool_definition_list->getNextPosition());
548 $source_pool_definition->saveToDb();
549 $this->source_pool_definition_list->addDefinition($source_pool_definition);
551 $this->source_pool_definition_list->saveDefinitions();
553 $this->question_set_config->setLastQuestionSyncTimestamp(0);
554 $this->question_set_config->saveToDb();
556 $this->test_obj->saveCompleteStatus($this->question_set_config);
558 if ($this->
logger->isLoggingEnabled()) {
559 $this->
logger->logTestAdministrationInteraction(
560 $this->
logger->getInteractionFactory()->buildTestAdministrationInteraction(
561 $this->test_obj->getRefId(),
562 $this->
user->getId(),
563 TestAdministrationInteractionTypes::QUESTION_SELECTION_CRITERIA_MODIFIED,
569 if ($redirect_back_to_form) {
570 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"tst_msg_random_qsc_modified_add_new_rule"),
true);
571 $this->
ctrl->setParameter($this,
'src_pool_def_id', $source_pool_definition->getId());
572 $this->
ctrl->setParameter($this,
'quest_pool_id', $source_pool_definition->getPoolId());
573 $this->
ctrl->redirect($this, self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM);
577 $this->
ctrl->setParameterByClass(self::class,
'modified',
'save');
578 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
588 $this->question_set_config
591 $form->setSaveCommand(self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM);
592 $form->setSaveAndNewCommand(self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM);
599 $this->question_set_config->loadFromDb();
602 $source_pool_definition = $this->source_pool_definition_factory->getSourcePoolDefinitionByDefinitionId($defId);
605 if ($form === null) {
607 $form->build($source_pool_definition, $available_taxonomy_ids);
610 $this->tpl->setContent($this->
ctrl->getHTML($form));
615 $this->question_set_config->loadFromDb();
617 $source_pool_definition = $this->source_pool_definition_factory->getSourcePoolDefinitionByDefinitionId(
623 $form->build($source_pool_definition, $available_taxonomy_ids);
625 $errors = !$form->checkInput();
626 $form->setValuesByPost();
633 $log_array = $form->applySubmit($source_pool_definition, $available_taxonomy_ids);
635 $source_pool_definition->saveToDb();
637 $this->question_set_config->setLastQuestionSyncTimestamp(0);
638 $this->question_set_config->saveToDb();
640 $this->test_obj->saveCompleteStatus($this->question_set_config);
642 if ($this->
logger->isLoggingEnabled()) {
643 $this->
logger->logTestAdministrationInteraction(
644 $this->
logger->getInteractionFactory()->buildTestAdministrationInteraction(
645 $this->test_obj->getRefId(),
646 $this->
user->getId(),
647 TestAdministrationInteractionTypes::QUESTIONS_SYNCHRONISATION_RESET,
653 $this->
ctrl->setParameterByClass(self::class,
'modified',
'save');
654 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
664 $this->question_set_config
667 $form->setSaveCommand(self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM);
674 if ($this->testrequest->isset(
'quest_pool_id') && (
int) $this->testrequest->raw(
'quest_pool_id')) {
675 return (
int) $this->testrequest->raw(
'quest_pool_id');
678 if ($this->testrequest->isset(
'quest_pool_ref') && (
int) $this->testrequest->raw(
'quest_pool_ref')) {
679 return $this->obj_cache->lookupObjId((
int) $this->testrequest->raw(
'quest_pool_ref'));
687 if (!$this->testrequest->isset(
'src_pool_def_id')) {
688 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_please_select_source_pool'),
true);
689 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
693 $definition_ids = is_array($this->testrequest->raw(
'src_pool_def_id'))
694 ?
array_map(
'intval', $this->testrequest->raw(
'src_pool_def_id'))
695 : [(
int) $this->testrequest->raw(
'src_pool_def_id')];
697 foreach ($definition_ids as $definition_id) {
698 if ($definition_id === 0) {
702 return $definition_ids;
709 if (count($definition_ids) !== 1) {
712 return $definition_ids[0];
717 $availablePools = $this->test_obj->getAvailableQuestionpools(
719 $this->question_set_config->arePoolsWithHomogeneousScoredQuestionsRequired(),
725 if (isset($availablePools[$pool_id])) {
726 $originalPoolData = $availablePools[$pool_id];
728 $originalPoolData[
'qpl_path'] = $this->question_set_config->getQuestionPoolPathString($pool_id);
729 $originalPoolData[
'qpl_ref_id'] = $this->question_set_config->getFirstQuestionPoolRefIdByObjId($pool_id);
731 return $this->source_pool_definition_factory->getSourcePoolDefinitionByOriginalPoolData($originalPoolData);
743 if ($this->testrequest->isset(
'derive_pool_ids') && is_array($this->testrequest->raw(
'derive_pool_ids'))) {
746 foreach ($this->testrequest->raw(
'derive_pool_ids') as $pool_id) {
747 $pool_ids[] = (
int) $pool_id;
749 } elseif ($this->testrequest->isset(
'derive_pool_ids') && preg_match(
'/^\d+(\:\d+)*$/', $this->testrequest->raw(
'derive_pool_ids'))) {
751 fn(
int $id) => (
int) $id,
752 explode(
':', $this->testrequest->raw(
'derive_pool_ids'))
754 } elseif ($this->testrequest->isset(
'derive_pool_id') && (
int) $this->testrequest->raw(
'derive_pool_id')) {
755 $pool_ids = [(
int) $this->testrequest->raw(
'derive_pool_id')];
763 if ($this->testrequest->isset(
'target_ref') && (
int) $this->testrequest->raw(
'target_ref')) {
764 return (
int) $this->testrequest->raw(
'target_ref');
775 self::CMD_SELECT_DERIVATION_TARGET,
777 self::CMD_DERIVE_NEW_POOLS,
780 $explorer->setClickableTypes($this->obj_definition->getExplorerContainerTypes());
781 $explorer->setSelectableTypes([]);
783 if (!$explorer->handleCommand()) {
784 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tst_please_select_target_for_pool_derives'));
785 $this->tpl->setContent($this->
ctrl->getHTML($explorer));
793 if (!$this->
access->checkAccess(
'write',
'', $target_ref)) {
794 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"no_permission"),
true);
795 $this->
ctrl->setParameterByClass(ilObjTestGUI::class,
'ref_id', $this->test_obj->getRefId());
796 $this->
ctrl->redirectByClass(ilObjTestGUI::class);
799 if ($pool_ids !== []) {
800 foreach ($pool_ids as $pool_id) {
801 $lost_pool = $this->source_pool_definition_list->getLostPool($pool_id);
805 $this->component_repository,
807 $this->source_pool_definition_list,
808 $this->
user->getId(),
811 $new_pool = $deriver->
derive($lost_pool);
813 $srcPoolDefinition = $this->source_pool_definition_list->getDefinitionBySourcePoolId($new_pool->getId());
814 $srcPoolDefinition->setPoolTitle($new_pool->getTitle());
815 $srcPoolDefinition->setPoolPath($this->question_set_config->getQuestionPoolPathString($new_pool->getId()));
816 $srcPoolDefinition->setPoolRefId($this->question_set_config->getFirstQuestionPoolRefIdByObjId($new_pool->getId()));
817 $srcPoolDefinition->saveToDb();
820 $this->test_obj->getTestId(),
826 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_non_available_pool_newly_derived'),
true);
829 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
834 $last_sync = $this->question_set_config->getLastQuestionSyncTimestamp();
835 if ($last_sync !== null && $last_sync !== 0 &&
844 $this->question_set_config->setLastQuestionSyncTimestamp(0);
845 $this->question_set_config->saveToDb();
846 if ($this->
logger->isLoggingEnabled()) {
847 $this->
logger->logTestAdministrationInteraction(
848 $this->
logger->getInteractionFactory()->buildTestAdministrationInteraction(
849 $this->test_obj->getRefId(),
850 $this->
user->getId(),
851 TestAdministrationInteractionTypes::QUESTIONS_SYNCHRONISATION_RESET,
856 $this->
ctrl->redirect($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
871 if ($this->testrequest->isset(
'modified')) {
872 $action = $this->testrequest->raw(
'modified');
873 if ($action ===
'save') {
874 $success_message = $this->ui_factory->messageBox()->success($this->
lng->txt(
'tst_msg_random_question_set_config_modified'));
875 } elseif ($action ===
'remove') {
876 $success_message = $this->ui_factory->messageBox()->success($this->
lng->txt(
'tst_msg_source_pool_definitions_deleted'));
877 } elseif ($action ===
'sync') {
878 $success_message = $this->ui_factory->messageBox()->success($this->
lng->txt(
'tst_msg_random_question_set_synced'));
880 $message .= $this->ui_renderer->render(
890 if ($this->configStateMessageHandler->isValidationFailed()) {
891 return $this->ui_renderer->render(
892 $this->ui_factory->messageBox()->failure($this->configStateMessageHandler->getValidationReportHtml())
896 if ($this->configStateMessageHandler->hasValidationReports()) {
897 return $this->ui_renderer->render(
898 $this->ui_factory->messageBox()->info($this->configStateMessageHandler->getValidationReportHtml())
902 return $this->configStateMessageHandler->getSyncInfoMessage();
910 $this->tpl->setCurrentBlock(
'mess');
911 $this->tpl->setVariable(
'MESSAGE', $message);
912 $this->tpl->parseCurrentBlock();
preventFormBecauseOfSync()
derive(ilTestRandomQuestionSetNonAvailablePool $non_available_pool)
fetchMultiSourcePoolDefinitionIdsParameter()
Readable part of repository interface to ilComponentDataDB.
TestAdministrationInteractionTypes
saveEditSourcePoolDefinitionFormCmd()
saveSourcePoolDefinitionListCmd()
showPoolSelectorExplorerCmd()
ilTestRandomQuestionSetSourcePoolDefinitionFactory $source_pool_definition_factory
const CMD_SHOW_EDIT_SRC_POOL_DEF_FORM
ilTestRandomQuestionSetStagingPoolBuilder $stagingPool
const CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM
const CMD_SELECT_DERIVATION_TARGET
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
const CONTEXT_POOL_SELECTION
selectPoolDerivationTargetCmd()
isAvoidManipulationRedirectRequired()
fetchTargetRefParameter()
fetchQuestionPoolIdParameter()
saveGeneralConfigFormCmd()
ilTestRandomQuestionSetConfigStateMessageHandler $configStateMessageHandler
const CMD_SHOW_SRC_POOL_DEF_LIST
showEditSourcePoolDefinitionFormCmd(ilTestRandomQuestionSetPoolDefinitionFormGUI $form=null)
Exception for invalid parameters (e.g.
const CONTEXT_GENERAL_CONFIG
ilTestRandomQuestionSetConfig $question_set_config
buildSourcePoolDefinitionListTableGUI(bool $disabled=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(private readonly ilObjTest $test_obj, private readonly ilCtrl $ctrl, private readonly ilObjUser $user, private readonly ilAccessHandler $access, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly DataFactory $data_factory, private readonly TabsManager $tabs_manager, private readonly ilLanguage $lng, private readonly TestLogger $logger, private readonly ilGlobalTemplateInterface $tpl, private readonly ilDBInterface $db, private readonly ilTree $tree, private readonly ilComponentRepository $component_repository, private readonly ilObjectDefinition $obj_definition, private readonly ilObjectDataCache $obj_cache, private ilTestProcessLockerFactory $processLockerFactory, private readonly RequestDataCollector $testrequest, private readonly TitleColumnsBuilder $title_builder, private readonly GeneralQuestionPropertiesRepository $questionrepository)
const CMD_SHOW_POOL_SELECTOR_EXPLORER
const CMD_SAVE_GENERAL_CONFIG_FORM
getSourcePoolDefinitionByAvailableQuestionPoolId($pool_id)
const CMD_DELETE_SRC_POOL_DEF
const CMD_SAVE_SRC_POOL_DEF_LIST
saveCreateSourcePoolDefinitionFormCmd($redirect_back_to_form=false)
deleteSourcePoolDefinitionCmd()
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()
showSourcePoolDefinitionListCmd()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
buildGeneralConfigFormGUI(bool $disabled=false)
const CMD_SAVE_CREATE_SRC_POOL_DEF_FORM
buildCreateSourcePoolDefinitionFormGUI()
showGeneralConfigFormCmd(ilTestRandomQuestionSetGeneralConfigFormGUI $form=null)
showCreateSourcePoolDefinitionFormCmd(ilTestRandomQuestionSetPoolDefinitionFormGUI $form=null)
const CMD_SHOW_CREATE_SRC_POOL_DEF_FORM
populateOnScreenMessage($message)
const CMD_DERIVE_NEW_POOLS
const CMD_BUILD_QUESTION_STAGE
static updateSourceQuestionPoolId(int $test_id, int $old_pool_id, int $new_pool_id)