93 $this->testrequest = $DIC->test()->internal()->request();
95 $this->
ui = $DIC->ui();
96 $this->
user = $DIC->user();
97 $this->obj_definition = $DIC[
'objDefinition'];
98 $this->obj_cache = $DIC[
'ilObjDataCache'];
113 $this->component_repository,
116 $this->questionSetConfig->loadFromDb();
126 $this->sourcePoolDefinitionFactory
129 $this->sourcePoolDefinitionList->loadDefinitions();
142 $this->configStateMessageHandler->setTargetGUI($this);
143 $this->configStateMessageHandler->setQuestionSetConfig($this->questionSetConfig);
144 $this->configStateMessageHandler->setParticipantDataExists($this->testOBJ->participantDataExist());
145 $this->configStateMessageHandler->setLostPools($this->sourcePoolDefinitionList->getLostPools());
151 if (!$this->
access->checkAccess(
"write",
"", $this->testOBJ->getRefId())) {
152 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"cannot_edit_test"),
true);
153 $this->
ctrl->redirectByClass(
'ilObjTestGUI',
"infoScreen");
157 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"tst_msg_cannot_modify_random_question_set_conf_due_to_part"),
true);
158 $this->
ctrl->redirect($this);
163 $nextClass = $this->
ctrl->getNextClass();
165 switch ($nextClass) {
166 case 'iltestrandomquestionsetpooldefinitionformgui':
167 $this->questionSetConfig->loadFromDb();
172 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
174 $this->
ctrl->forwardCommand($form);
178 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM) .
'Cmd';
198 if ($this->testOBJ->participantDataExist()) {
202 if ($this->sourcePoolDefinitionList->hasLostPool()) {
211 switch ($this->
ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM)) {
212 case self::CMD_SAVE_GENERAL_CONFIG_FORM:
213 case self::CMD_SAVE_SRC_POOL_DEF_LIST:
214 case self::CMD_DELETE_SINGLE_SRC_POOL_DEF:
215 case self::CMD_DELETE_MULTI_SRC_POOL_DEFS:
216 case self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM:
217 case self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM:
218 case self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM:
219 case self::CMD_BUILD_QUESTION_STAGE:
229 $this->
tabs->activateTab(
'assQuestions');
231 $this->
tabs->addSubTab(
232 'tstRandQuestSetGeneralConfig',
234 $this->
ctrl->getLinkTarget($this, self::CMD_SHOW_GENERAL_CONFIG_FORM)
237 $this->
tabs->addSubTab(
238 'tstRandQuestSetPoolConfig',
240 $this->
ctrl->getLinkTarget($this, self::CMD_SHOW_SRC_POOL_DEF_LIST)
243 switch ($this->
ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM)) {
244 case self::CMD_SHOW_GENERAL_CONFIG_FORM:
245 case self::CMD_SAVE_GENERAL_CONFIG_FORM:
247 $this->
tabs->activateSubTab(
'tstRandQuestSetGeneralConfig');
250 case self::CMD_SHOW_SRC_POOL_DEF_LIST:
251 case self::CMD_SAVE_SRC_POOL_DEF_LIST:
252 case self::CMD_DELETE_SINGLE_SRC_POOL_DEF:
253 case self::CMD_DELETE_MULTI_SRC_POOL_DEFS:
254 case self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM:
255 case self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM:
256 case self::CMD_SHOW_EDIT_SRC_POOL_DEF_FORM:
257 case self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM:
259 $this->
tabs->activateSubTab(
'tstRandQuestSetPoolConfig');
262 default: $this->
tabs->activateSubTab(
'nonTab');
268 if ($this->sourcePoolDefinitionList->areAllUsedPoolsAvailable()) {
269 $locker = $this->processLockerFactory->retrieveLockerForNamedOperation();
270 $locker->executeNamedOperation(__FUNCTION__,
function ():
void {
271 $this->stagingPool->rebuild($this->sourcePoolDefinitionList);
272 $this->sourcePoolDefinitionList->saveDefinitions();
274 $this->questionSetConfig->loadFromDb();
275 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
276 $this->questionSetConfig->saveToDb();
278 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
280 $this->
ctrl->setParameterByClass(self::class,
'modified',
'sync');
289 if (!$this->testrequest->isset(self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD)) {
290 return self::CMD_SHOW_GENERAL_CONFIG_FORM;
293 if (!strlen($this->testrequest->raw(self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD))) {
294 return self::CMD_SHOW_GENERAL_CONFIG_FORM;
297 return $this->testrequest->raw(self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD);
304 if ($form === null) {
305 $this->questionSetConfig->loadFromDb();
309 $this->tpl->setContent($this->
ctrl->getHTML($form));
311 $this->configStateMessageHandler->setContext(
315 $this->configStateMessageHandler->handle();
327 $errors = !$form->checkInput();
328 $form->setValuesByPost();
337 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
338 $this->questionSetConfig->saveToDb();
340 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
342 $this->
ctrl->setParameter($this,
'modified',
'save');
343 $this->
ctrl->redirect($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
354 $this->questionSetConfig
361 $form->setEditModeEnabled(
false);
367 $form->clearCommandButtons();
377 $this->questionSetConfig->loadFromDb();
383 $content .= $this->
ctrl->getHTML($toolbar);
387 $table->init($this->sourcePoolDefinitionList);
388 $content .= $this->
ctrl->getHTML($table);
390 if (!$this->sourcePoolDefinitionList->areAllUsedPoolsAvailable()) {
392 $table->init($this->sourcePoolDefinitionList);
393 $content .= $this->
ctrl->getHTML($table);
396 $this->tpl->setContent($content);
398 $this->configStateMessageHandler->setContext(
402 $this->configStateMessageHandler->handle();
412 $this->questionSetConfig->loadFromDb();
416 $table->applySubmit($this->sourcePoolDefinitionList);
418 $this->sourcePoolDefinitionList->reindexPositions();
419 $this->sourcePoolDefinitionList->saveDefinitions();
422 #$this->stagingPool->rebuild( $this->sourcePoolDefinitionList ); 423 #$this->sourcePoolDefinitionList->saveDefinitions(); 424 #$this->questionSetConfig->setLastQuestionSyncTimestamp(time()); 425 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
427 $this->questionSetConfig->saveToDb();
429 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
431 $this->
ctrl->setParameter($this,
'modified',
'save');
432 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
441 $this->questionSetConfig
455 self::CMD_SHOW_SRC_POOL_DEF_LIST
459 $table->setDefinitionEditModeEnabled(
true);
462 $table->setQuestionAmountColumnEnabled(
463 $this->questionSetConfig->isQuestionAmountConfigurationModePerPool()
467 $table->setShowMappedTaxonomyFilter(
468 $this->questionSetConfig->getLastQuestionSyncTimestamp() != 0
473 $translater->loadLabels($this->sourcePoolDefinitionList);
474 $table->setTaxonomyFilterLabelTranslater($translater);
477 $table->setDefinitionEditModeEnabled(
false);
490 self::CMD_SHOW_SRC_POOL_DEF_LIST
503 $this->
ctrl->setParameterByClass(self::class,
'modified',
'remove');
504 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
512 $this->
ctrl->setParameterByClass(self::class,
'modified',
'remove');
513 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
518 foreach ($definitionIds as $definitionId) {
519 $definition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($definitionId);
520 $definition->deleteFromDb();
523 $this->sourcePoolDefinitionList->reindexPositions();
524 $this->sourcePoolDefinitionList->saveDefinitions();
526 $this->questionSetConfig->loadFromDb();
527 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
528 $this->questionSetConfig->saveToDb();
530 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
536 $this->questionSetConfig->loadFromDb();
540 self::CMD_SHOW_POOL_SELECTOR_EXPLORER,
541 self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM
544 $selector->setAvailableQuestionPools(
545 array_keys($this->questionSetConfig->getSelectableQuestionPools())
548 if ($selector->handleCommand()) {
552 $this->tpl->setContent($selector->getHTML());
558 $this->questionSetConfig->loadFromDb();
565 if ($form === null) {
567 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
570 $this->tpl->setContent($this->
ctrl->getHTML($form));
583 $this->questionSetConfig->loadFromDb();
590 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
592 $errors = !$form->checkInput();
593 $form->setValuesByPost();
600 $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds);
602 $sourcePoolDefinition->setSequencePosition($this->sourcePoolDefinitionList->getNextPosition());
603 $sourcePoolDefinition->saveToDb();
604 $this->sourcePoolDefinitionList->addDefinition($sourcePoolDefinition);
606 $this->sourcePoolDefinitionList->saveDefinitions();
608 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
609 $this->questionSetConfig->saveToDb();
611 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
613 if ($redirect_back_to_form) {
614 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"tst_msg_random_qsc_modified_add_new_rule"),
true);
615 $this->
ctrl->setParameter($this,
'src_pool_def_id', $sourcePoolDefinition->getId());
616 $this->
ctrl->setParameter($this,
'quest_pool_id', $sourcePoolDefinition->getPoolId());
617 $this->
ctrl->redirect($this, self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM);
619 $this->
ctrl->setParameterByClass(self::class,
'modified',
'save');
620 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
631 $this->questionSetConfig
634 $form->setSaveCommand(self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM);
635 $form->setSaveAndNewCommand(self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM);
642 $this->questionSetConfig->loadFromDb();
645 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
648 if ($form === null) {
650 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
653 $this->tpl->setContent($this->
ctrl->getHTML($form));
658 $this->questionSetConfig->loadFromDb();
661 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
665 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
667 $errors = !$form->checkInput();
668 $form->setValuesByPost();
675 $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds);
677 $sourcePoolDefinition->saveToDb();
679 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
680 $this->questionSetConfig->saveToDb();
682 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
684 $this->
ctrl->setParameterByClass(self::class,
'modified',
'save');
685 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
695 $this->questionSetConfig
698 $form->setSaveCommand(self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM);
705 if ($this->testrequest->isset(
'quest_pool_id') && (
int) $this->testrequest->raw(
'quest_pool_id')) {
706 return (
int) $this->testrequest->raw(
'quest_pool_id');
709 if ($this->testrequest->isset(
'quest_pool_ref') && (
int) $this->testrequest->raw(
'quest_pool_ref')) {
710 return $this->obj_cache->lookupObjId((
int) $this->testrequest->raw(
'quest_pool_ref'));
718 if ($this->testrequest->isset(
'src_pool_def_id') && (
int) $this->testrequest->raw(
'src_pool_def_id')) {
719 return (
int) $this->testrequest->raw(
'src_pool_def_id');
727 if (!$this->testrequest->isset(
'src_pool_def_ids') || !is_array($this->testrequest->raw(
'src_pool_def_ids'))) {
728 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_please_select_source_pool'),
true);
729 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
735 foreach ($this->testrequest->raw(
'src_pool_def_ids') as $definitionId) {
736 $definitionId = (
int) $definitionId;
738 if (!$definitionId) {
742 $definitionIds[] = $definitionId;
745 return $definitionIds;
750 $availablePools = $this->testOBJ->getAvailableQuestionpools(
752 $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired(),
758 if (isset($availablePools[$poolId])) {
759 $originalPoolData = $availablePools[$poolId];
761 $originalPoolData[
'qpl_path'] = $this->questionSetConfig->getQuestionPoolPathString($poolId);
762 $originalPoolData[
'qpl_ref_id'] = $this->questionSetConfig->getFirstQuestionPoolRefIdByObjId($poolId);
764 return $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByOriginalPoolData($originalPoolData);
776 if ($this->testrequest->isset(
'derive_pool_ids') && is_array($this->testrequest->raw(
'derive_pool_ids'))) {
779 foreach ($this->testrequest->raw(
'derive_pool_ids') as $poolId) {
780 $poolIds[] = (
int) $poolId;
782 } elseif ($this->testrequest->isset(
'derive_pool_ids') && preg_match(
'/^\d+(\:\d+)*$/', $this->testrequest->raw(
'derive_pool_ids'))) {
783 $poolIds = explode(
':', $this->testrequest->raw(
'derive_pool_ids'));
784 } elseif ($this->testrequest->isset(
'derive_pool_id') && (
int) $this->testrequest->raw(
'derive_pool_id')) {
785 $poolIds = [(
int) $this->testrequest->raw(
'derive_pool_id')];
793 if ($this->testrequest->isset(
'target_ref') && (
int) $this->testrequest->raw(
'target_ref')) {
794 return (
int) $this->testrequest->raw(
'target_ref');
806 self::CMD_SELECT_DERIVATION_TARGET,
808 self::CMD_DERIVE_NEW_POOLS,
811 $explorer->setClickableTypes($this->obj_definition->getExplorerContainerTypes());
812 $explorer->setSelectableTypes([]);
814 if (!$explorer->handleCommand()) {
815 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'tst_please_select_target_for_pool_derives'));
816 $this->tpl->setContent($this->
ctrl->getHTML($explorer));
824 if (!$this->
access->checkAccess(
'write',
'', $targetRef)) {
825 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"no_permission"),
true);
826 $this->
ctrl->setParameterByClass(ilObjTestGUI::class,
'ref_id', $this->testOBJ->getRefId());
827 $this->
ctrl->redirectByClass(ilObjTestGUI::class);
830 if (count($poolIds)) {
831 foreach ($poolIds as $poolId) {
832 $lostPool = $this->sourcePoolDefinitionList->getLostPool($poolId);
835 $deriver->setSourcePoolDefinitionList($this->sourcePoolDefinitionList);
836 $deriver->setTargetContainerRef($targetRef);
837 $deriver->setOwnerId($this->
user->getId());
838 $newPool = $deriver->derive($lostPool);
840 $srcPoolDefinition = $this->sourcePoolDefinitionList->getDefinitionBySourcePoolId($newPool->getId());
841 $srcPoolDefinition->setPoolTitle($newPool->getTitle());
842 $srcPoolDefinition->setPoolPath($this->questionSetConfig->getQuestionPoolPathString($newPool->getId()));
843 $srcPoolDefinition->setPoolRefId($this->questionSetConfig->getFirstQuestionPoolRefIdByObjId($newPool->getId()));
844 $srcPoolDefinition->saveToDb();
847 $this->testOBJ->getTestId(),
853 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_non_available_pool_newly_derived'),
true);
856 $this->
ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
864 return $this->
lng->txt(
"tst_msg_random_question_set_config_modified");
872 return $this->
lng->txt(
'tst_rnd_quest_cfg_tab_general');
880 return $this->
lng->txt(
'tst_rnd_quest_cfg_tab_pool');
887 $last_sync = $this->questionSetConfig->getLastQuestionSyncTimestamp();
889 if ($last_sync !== null && $last_sync !== 0 &&
898 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
899 $this->questionSetConfig->saveToDb();
900 $this->
ctrl->redirect($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
915 if ($this->testrequest->isset(
'modified')) {
916 $action = $this->testrequest->raw(
'modified');
917 if ($action ===
'save') {
919 } elseif ($action ===
'remove') {
920 $success_message = $this->
ui->factory()->messageBox()->success($this->
lng->txt(
"tst_msg_source_pool_definitions_deleted"));
921 } elseif ($action ===
'sync') {
922 $success_message = $this->
ui->factory()->messageBox()->success($this->
lng->txt(
"tst_msg_random_question_set_synced"));
934 if ($this->configStateMessageHandler->isValidationFailed()) {
935 return $this->
ui->renderer()->render(
936 $this->
ui->factory()->messageBox()->failure($this->configStateMessageHandler->getValidationReportHtml())
940 if ($this->configStateMessageHandler->hasValidationReports()) {
941 return $this->
ui->renderer()->render(
942 $this->
ui->factory()->messageBox()->info($this->configStateMessageHandler->getValidationReportHtml())
946 return $this->configStateMessageHandler->getSyncInfoMessage();
954 $this->
ui->mainTemplate()->setCurrentBlock(
'mess');
955 $this->
ui->mainTemplate()->setVariable(
'MESSAGE',
$message);
956 $this->
ui->mainTemplate()->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...
ilObjectDataCache $obj_cache
showPoolSelectorExplorerCmd()
const CMD_SHOW_EDIT_SRC_POOL_DEF_FORM
ilTestRandomQuestionSetStagingPoolBuilder $stagingPool
const CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM
ilTestRandomQuestionSetSourcePoolDefinitionFactory $sourcePoolDefinitionFactory
getSourcePoolDefinitionByAvailableQuestionPoolId($poolId)
const CMD_SELECT_DERIVATION_TARGET
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
ilObjectDefinition $obj_definition
const CONTEXT_POOL_SELECTION
InternalRequestService $testrequest
const CMD_DELETE_SINGLE_SRC_POOL_DEF
selectPoolDerivationTargetCmd()
ilComponentRepository $component_repository
isAvoidManipulationRedirectRequired()
fetchTargetRefParameter()
fetchQuestionPoolIdParameter()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveGeneralConfigFormCmd()
ilTestRandomQuestionSetConfigStateMessageHandler $configStateMessageHandler
const CMD_SHOW_SRC_POOL_DEF_LIST
showEditSourcePoolDefinitionFormCmd(ilTestRandomQuestionSetPoolDefinitionFormGUI $form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parses the objects.xml it handles the xml-description of all ilias objects
Provides fluid interface to RBAC services.
ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList
deleteMultipleSourcePoolDefinitionsCmd()
ilTestRandomQuestionSetConfig $questionSetConfig
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CONTEXT_GENERAL_CONFIG
getGeneralConfigTabLabel()
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)
ilTestProcessLockerFactory $processLockerFactory
buildEditSourcePoolDefinitionFormGUI()
fetchAfterRebuildQuestionStageCmdParameter()
buildSourcePoolDefinitionListToolbarGUI()
const CMD_SAVE_EDIT_SRC_POOL_DEF_FORM
const HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD
const CMD_SHOW_GENERAL_CONFIG_FORM
fetchSingleSourcePoolDefinitionIdParameter()
saveCreateAndNewSourcePoolDefinitionFormCmd()
deleteSourcePoolDefinitions($definitionIds)
showSourcePoolDefinitionListCmd()
__construct(Container $dic, ilPlugin $plugin)
buildGeneralConfigFormGUI(bool $disabled=false)
const CMD_SAVE_CREATE_SRC_POOL_DEF_FORM
getGeneralModificationSuccessMessage()
buildCreateSourcePoolDefinitionFormGUI()
ilGlobalTemplateInterface $tpl
showGeneralConfigFormCmd(ilTestRandomQuestionSetGeneralConfigFormGUI $form=null)
showCreateSourcePoolDefinitionFormCmd(ilTestRandomQuestionSetPoolDefinitionFormGUI $form=null)
deleteSingleSourcePoolDefinitionCmd()
const CMD_SHOW_CREATE_SRC_POOL_DEF_FORM
static updateSourceQuestionPoolId($testId, $oldPoolId, $newPoolId)
populateOnScreenMessage($message)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CMD_DERIVE_NEW_POOLS
const CMD_DELETE_MULTI_SRC_POOL_DEFS
const CMD_BUILD_QUESTION_STAGE