4 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetConfig.php';
5 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php';
6 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php';
7 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetStagingPoolBuilder.php';
8 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetConfigStateMessageHandler.php';
10 require_once
'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
145 $this->objDefinition =
$GLOBALS[
'DIC'][
'objDefinition'];
163 $this->sourcePoolDefinitionFactory
166 $this->sourcePoolDefinitionList->loadDefinitions();
178 $this->configStateMessageHandler->setTargetGUI($this);
179 $this->configStateMessageHandler->setQuestionSetConfig($this->questionSetConfig);
180 $this->configStateMessageHandler->setParticipantDataExists($this->testOBJ->participantDataExist());
181 $this->configStateMessageHandler->setLostPools($this->sourcePoolDefinitionList->getLostPools());
187 if (!$this->access->checkAccess(
"write",
"", $this->testOBJ->getRefId())) {
189 $this->ctrl->redirectByClass(
'ilObjTestGUI',
"infoScreen");
193 ilUtil::sendFailure($this->lng->txt(
"tst_msg_cannot_modify_random_question_set_conf_due_to_part"),
true);
194 $this->ctrl->redirect($this);
199 $nextClass = $this->ctrl->getNextClass();
201 switch ($nextClass) {
202 case 'iltestrandomquestionsetpooldefinitionformgui':
203 $this->questionSetConfig->loadFromDb();
208 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
210 $this->ctrl->forwardCommand($form);
215 $cmd = $this->ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM) .
'Cmd';
236 if ($this->testOBJ->participantDataExist()) {
240 if ($this->sourcePoolDefinitionList->hasLostPool()) {
249 switch ($this->ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM)) {
250 case self::CMD_SAVE_GENERAL_CONFIG_FORM:
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_SAVE_CREATE_SRC_POOL_DEF_FORM:
255 case self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM:
256 case self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM:
257 case self::CMD_BUILD_QUESTION_STAGE:
267 $this->tabs->activateTab(
'assQuestions');
269 $this->tabs->addSubTab(
270 'tstRandQuestSetGeneralConfig',
272 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_GENERAL_CONFIG_FORM)
275 $this->tabs->addSubTab(
276 'tstRandQuestSetPoolConfig',
278 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_SRC_POOL_DEF_LIST)
281 switch ($this->ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM)) {
282 case self::CMD_SHOW_GENERAL_CONFIG_FORM:
283 case self::CMD_SAVE_GENERAL_CONFIG_FORM:
285 $this->tabs->activateSubTab(
'tstRandQuestSetGeneralConfig');
288 case self::CMD_SHOW_SRC_POOL_DEF_LIST:
289 case self::CMD_SAVE_SRC_POOL_DEF_LIST:
290 case self::CMD_DELETE_SINGLE_SRC_POOL_DEF:
291 case self::CMD_DELETE_MULTI_SRC_POOL_DEFS:
292 case self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM:
293 case self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM:
294 case self::CMD_SHOW_EDIT_SRC_POOL_DEF_FORM:
295 case self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM:
297 $this->tabs->activateSubTab(
'tstRandQuestSetPoolConfig');
300 default: $this->tabs->activateSubTab(
'nonTab');
306 if ($this->sourcePoolDefinitionList->areAllUsedPoolsAvailable()) {
307 $locker = $this->processLockerFactory->retrieveLockerForNamedOperation();
308 $locker->executeNamedOperation(__FUNCTION__,
function() :
void {
309 $this->stagingPool->rebuild($this->sourcePoolDefinitionList);
310 $this->sourcePoolDefinitionList->saveDefinitions();
312 $this->questionSetConfig->loadFromDb();
313 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
314 $this->questionSetConfig->saveToDb();
316 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
318 ilUtil::sendSuccess($this->lng->txt(
"tst_msg_random_question_set_synced"),
true);
327 if (!isset(
$_GET[self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD])) {
328 return self::CMD_SHOW_GENERAL_CONFIG_FORM;
331 if (!strlen(
$_GET[self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD])) {
332 return self::CMD_SHOW_GENERAL_CONFIG_FORM;
335 return $_GET[self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD];
340 if ($form === null) {
341 $this->questionSetConfig->loadFromDb();
345 $this->tpl->setContent($this->ctrl->getHTML($form));
347 $this->configStateMessageHandler->setContext(
351 $this->configStateMessageHandler->handle();
353 if ($this->configStateMessageHandler->hasValidationReports()) {
354 if ($this->configStateMessageHandler->isValidationFailed()) {
356 $this->configStateMessageHandler->getValidationReportHtml()
359 ilUtil::sendInfo($this->configStateMessageHandler->getValidationReportHtml());
363 if (isset(
$_GET[
'modified']) && (int)
$_GET[
'modified']) {
370 $this->questionSetConfig->loadFromDb();
374 $errors = !$form->checkInput();
375 $form->setValuesByPost();
383 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
384 $this->questionSetConfig->saveToDb();
386 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
388 $this->ctrl->setParameter($this,
'modified', 1);
389 $this->ctrl->redirect($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
394 require_once
'Modules/Test/classes/forms/class.ilTestRandomQuestionSetGeneralConfigFormGUI.php';
401 $this->questionSetConfig
413 $this->questionSetConfig->loadFromDb();
419 $content .= $this->ctrl->getHTML($toolbar);
423 $table->init($this->sourcePoolDefinitionList);
424 $content .= $this->ctrl->getHTML($table);
426 if (!$this->sourcePoolDefinitionList->areAllUsedPoolsAvailable()) {
428 $table->init($this->sourcePoolDefinitionList);
429 $content .= $this->ctrl->getHTML($table);
432 $this->tpl->setContent($content);
434 $this->configStateMessageHandler->setContext(
438 $this->configStateMessageHandler->handle();
440 if ($this->configStateMessageHandler->hasValidationReports()) {
441 if ($this->configStateMessageHandler->isValidationFailed()) {
443 $this->configStateMessageHandler->getValidationReportHtml()
446 ilUtil::sendInfo($this->configStateMessageHandler->getValidationReportHtml());
450 if (isset(
$_GET[
'modified']) && (int)
$_GET[
'modified']) {
457 $this->questionSetConfig->loadFromDb();
461 $table->applySubmit($this->sourcePoolDefinitionList);
463 $this->sourcePoolDefinitionList->reindexPositions();
464 $this->sourcePoolDefinitionList->saveDefinitions();
467 #$this->stagingPool->rebuild( $this->sourcePoolDefinitionList ); 468 #$this->sourcePoolDefinitionList->saveDefinitions(); 469 #$this->questionSetConfig->setLastQuestionSyncTimestamp(time()); 470 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
472 $this->questionSetConfig->saveToDb();
474 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
476 $this->ctrl->setParameter($this,
'modified', 1);
477 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
482 require_once
'Modules/Test/classes/toolbars/class.ilTestRandomQuestionSetSourcePoolDefinitionListToolbarGUI.php';
488 $this->questionSetConfig
498 require_once
'Modules/Test/classes/tables/class.ilTestRandomQuestionSetSourcePoolDefinitionListTableGUI.php';
504 self::CMD_SHOW_SRC_POOL_DEF_LIST
508 $table->setDefinitionEditModeEnabled(
true);
511 $table->setQuestionAmountColumnEnabled(
512 $this->questionSetConfig->isQuestionAmountConfigurationModePerPool()
516 $table->setShowMappedTaxonomyFilter(
517 $this->questionSetConfig->getLastQuestionSyncTimestamp() != 0
521 require_once
'Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
523 $translater->loadLabels($this->sourcePoolDefinitionList);
524 $table->setTaxonomyFilterLabelTranslater($translater);
533 require_once
'Modules/Test/classes/tables/class.ilTestRandomQuestionSetNonAvailablePoolsTableGUI.php';
539 self::CMD_SHOW_SRC_POOL_DEF_LIST
552 ilUtil::sendSuccess($this->lng->txt(
"tst_msg_source_pool_definitions_deleted"),
true);
553 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
561 ilUtil::sendSuccess($this->lng->txt(
"tst_msg_source_pool_definitions_deleted"),
true);
562 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
567 foreach ($definitionIds as $definitionId) {
568 $definition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($definitionId);
569 $definition->deleteFromDb();
572 $this->sourcePoolDefinitionList->reindexPositions();
573 $this->sourcePoolDefinitionList->saveDefinitions();
575 $this->questionSetConfig->loadFromDb();
576 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
577 $this->questionSetConfig->saveToDb();
579 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
585 $this->questionSetConfig->loadFromDb();
587 require_once
'Services/Repository/classes/class.ilTestQuestionPoolSelectorExplorer.php';
590 self::CMD_SHOW_POOL_SELECTOR_EXPLORER,
591 self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM
594 $selector->setAvailableQuestionPools(
595 array_keys($this->questionSetConfig->getSelectableQuestionPools())
598 if ($selector->handleCommand()) {
602 $this->tpl->setContent($selector->getHTML());
608 $this->questionSetConfig->loadFromDb();
615 if ($form === null) {
617 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
620 $this->tpl->setContent($this->ctrl->getHTML($form));
633 $this->questionSetConfig->loadFromDb();
640 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
642 $errors = !$form->checkInput();
643 $form->setValuesByPost();
649 $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds);
651 $sourcePoolDefinition->setSequencePosition($this->sourcePoolDefinitionList->getNextPosition());
652 $sourcePoolDefinition->saveToDb();
653 $this->sourcePoolDefinitionList->addDefinition($sourcePoolDefinition);
655 $this->sourcePoolDefinitionList->saveDefinitions();
657 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
658 $this->questionSetConfig->saveToDb();
660 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
662 if ($redirect_back_to_form) {
663 ilUtil::sendSuccess($this->lng->txt(
"tst_msg_random_qsc_modified_add_new_rule"),
true);
664 $this->ctrl->setParameter($this,
'src_pool_def_id', $sourcePoolDefinition->getId());
665 $this->ctrl->setParameter($this,
'quest_pool_id', $sourcePoolDefinition->getPoolId());
666 $this->ctrl->redirect($this, self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM);
668 ilUtil::sendSuccess($this->lng->txt(
"tst_msg_random_question_set_config_modified"),
true);
669 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
675 require_once
'Modules/Test/classes/forms/class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php';
682 $this->questionSetConfig
685 $form->setSaveCommand(self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM);
686 $form->setSaveAndNewCommand(self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM);
693 $this->questionSetConfig->loadFromDb();
696 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
699 if ($form === null) {
701 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
704 $this->tpl->setContent($this->ctrl->getHTML($form));
709 $this->questionSetConfig->loadFromDb();
712 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
716 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
718 $errors = !$form->checkInput();
719 $form->setValuesByPost();
725 $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds);
727 $sourcePoolDefinition->saveToDb();
729 $this->questionSetConfig->setLastQuestionSyncTimestamp(0);
730 $this->questionSetConfig->saveToDb();
732 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
734 ilUtil::sendSuccess($this->lng->txt(
"tst_msg_random_question_set_config_modified"),
true);
735 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
740 require_once
'Modules/Test/classes/forms/class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php';
747 $this->questionSetConfig
750 $form->setSaveCommand(self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM);
757 if (isset(
$_POST[
'quest_pool_id']) && (
int)
$_POST[
'quest_pool_id']) {
758 return (
int) $_POST[
'quest_pool_id'];
761 if (isset(
$_GET[
'quest_pool_id']) && (
int)
$_GET[
'quest_pool_id']) {
762 return (
int) $_GET[
'quest_pool_id'];
765 if (isset($_GET[
'quest_pool_ref']) && (
int) $_GET[
'quest_pool_ref']) {
768 $objCache = $DIC[
'ilObjDataCache'];
770 return $objCache->lookupObjId((
int) $_GET[
'quest_pool_ref']);
773 require_once
'Modules/Test/exceptions/class.ilTestMissingQuestionPoolIdParameterException.php';
779 if (isset(
$_POST[
'src_pool_def_id']) && (
int)
$_POST[
'src_pool_def_id']) {
780 return (
int) $_POST[
'src_pool_def_id'];
783 if (isset(
$_GET[
'src_pool_def_id']) && (
int)
$_GET[
'src_pool_def_id']) {
784 return (
int) $_GET[
'src_pool_def_id'];
787 require_once
'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
793 if (!isset(
$_POST[
'src_pool_def_ids']) || !is_array(
$_POST[
'src_pool_def_ids'])) {
794 require_once
'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
798 $definitionIds = array();
800 foreach (
$_POST[
'src_pool_def_ids'] as $definitionId) {
801 $definitionId = (int) $definitionId;
803 if (!$definitionId) {
804 require_once
'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
808 $definitionIds[] = $definitionId;
811 return $definitionIds;
816 $availablePools = $this->testOBJ->getAvailableQuestionpools(
818 $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired(),
824 if (isset($availablePools[$poolId])) {
825 $originalPoolData = $availablePools[$poolId];
827 $originalPoolData[
'qpl_path'] = $this->questionSetConfig->getQuestionPoolPathString($poolId);
828 $originalPoolData[
'qpl_ref_id'] = $this->questionSetConfig->getFirstQuestionPoolRefIdByObjId($poolId);
830 return $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByOriginalPoolData($originalPoolData);
833 require_once
'Modules/Test/exceptions/class.ilTestQuestionPoolNotAvailableAsSourcePoolException.php';
839 if (isset(
$_POST[
'derive_pool_ids']) && is_array(
$_POST[
'derive_pool_ids'])) {
842 foreach (
$_POST[
'derive_pool_ids'] as $poolId) {
843 $poolIds[] = (int) $poolId;
845 } elseif (isset(
$_GET[
'derive_pool_ids']) && preg_match(
'/^\d+(\:\d+)*$/',
$_GET[
'derive_pool_ids'])) {
846 $poolIds = explode(
':',
$_GET[
'derive_pool_ids']);
847 } elseif (isset(
$_GET[
'derive_pool_id']) && (
int)
$_GET[
'derive_pool_id']) {
848 $poolIds = array( (
int) $_GET[
'derive_pool_id'] );
856 if (isset(
$_GET[
'target_ref']) && (
int)
$_GET[
'target_ref']) {
857 return (
int) $_GET[
'target_ref'];
867 require_once
'Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php';
870 self::CMD_SELECT_DERIVATION_TARGET,
872 self::CMD_DERIVE_NEW_POOLS,
875 $explorer->setClickableTypes($this->objDefinition->getExplorerContainerTypes());
876 $explorer->setSelectableTypes(array());
878 if (!$explorer->handleCommand()) {
879 ilUtil::sendInfo($this->lng->txt(
'tst_please_select_target_for_pool_derives'));
880 $this->tpl->setContent($this->ctrl->getHTML($explorer));
889 if (count($poolIds)) {
890 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetPoolDeriver.php';
892 foreach ($poolIds as $poolId) {
893 $lostPool = $this->sourcePoolDefinitionList->getLostPool($poolId);
896 $deriver->setSourcePoolDefinitionList($this->sourcePoolDefinitionList);
897 $deriver->setTargetContainerRef($targetRef);
898 $deriver->setOwnerId(
$GLOBALS[
'DIC'][
'ilUser']->getId());
899 $newPool = $deriver->derive($lostPool);
901 $srcPoolDefinition = $this->sourcePoolDefinitionList->getDefinitionBySourcePoolId($newPool->getId());
902 $srcPoolDefinition->setPoolTitle($newPool->getTitle());
903 $srcPoolDefinition->setPoolPath($this->questionSetConfig->getQuestionPoolPathString($newPool->getId()));
904 $srcPoolDefinition->setPoolRefId($this->questionSetConfig->getFirstQuestionPoolRefIdByObjId((
int) $newPool->getId()));
905 $srcPoolDefinition->saveToDb();
908 $this->testOBJ->getTestId(),
914 ilUtil::sendSuccess($this->lng->txt(
'tst_non_available_pool_newly_derived'),
true);
917 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
925 return $this->lng->txt(
"tst_msg_random_question_set_config_modified");
933 return $this->lng->txt(
'tst_rnd_quest_cfg_tab_general');
941 return $this->lng->txt(
'tst_rnd_quest_cfg_tab_pool');
buildGeneralConfigFormGUI()
fetchMultiSourcePoolDefinitionIdsParameter()
buildNonAvailablePoolsTableGUI()
This class provides processing control methods.
saveEditSourcePoolDefinitionFormCmd()
saveSourcePoolDefinitionListCmd()
Explorer for selecting repository items.
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
buildSourcePoolDefinitionListTableGUI()
showPoolSelectorExplorerCmd()
const CMD_SHOW_EDIT_SRC_POOL_DEF_FORM
const CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM
getSourcePoolDefinitionByAvailableQuestionPoolId($poolId)
const CMD_SELECT_DERIVATION_TARGET
const CONTEXT_POOL_SELECTION
const CMD_DELETE_SINGLE_SRC_POOL_DEF
selectPoolDerivationTargetCmd()
isAvoidManipulationRedirectRequired()
fetchTargetRefParameter()
fetchQuestionPoolIdParameter()
Interface ilAccessHandler.
saveGeneralConfigFormCmd()
Administration class for plugins.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
const CMD_SHOW_SRC_POOL_DEF_LIST
showEditSourcePoolDefinitionFormCmd(ilTestRandomQuestionSetPoolDefinitionFormGUI $form=null)
Exception for invalid parameters (e.g.
$configStateMessageHandler
deleteMultipleSourcePoolDefinitionsCmd()
$sourcePoolDefinitionFactory
const CONTEXT_GENERAL_CONFIG
getGeneralConfigTabLabel()
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
const CMD_SHOW_POOL_SELECTOR_EXPLORER
const CMD_SAVE_GENERAL_CONFIG_FORM
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const CMD_SAVE_SRC_POOL_DEF_LIST
saveCreateSourcePoolDefinitionFormCmd($redirect_back_to_form=false)
buildEditSourcePoolDefinitionFormGUI()
fetchAfterRebuildQuestionStageCmdParameter()
__construct(ilCtrl $ctrl, ilAccessHandler $access, ilTabsGUI $tabs, ilLanguage $lng, ilGlobalTemplateInterface $tpl, ilDBInterface $db, ilTree $tree, ilPluginAdmin $pluginAdmin, ilObjTest $testOBJ, ilTestProcessLockerFactory $processLockerFactory)
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()
const CMD_SAVE_CREATE_SRC_POOL_DEF_FORM
getGeneralModificationSuccessMessage()
buildCreateSourcePoolDefinitionFormGUI()
showGeneralConfigFormCmd(ilTestRandomQuestionSetGeneralConfigFormGUI $form=null)
showCreateSourcePoolDefinitionFormCmd(ilTestRandomQuestionSetPoolDefinitionFormGUI $form=null)
$sourcePoolDefinitionList
deleteSingleSourcePoolDefinitionCmd()
const CMD_SHOW_CREATE_SRC_POOL_DEF_FORM
static updateSourceQuestionPoolId($testId, $oldPoolId, $newPoolId)
const CMD_DERIVE_NEW_POOLS
const CMD_DELETE_MULTI_SRC_POOL_DEFS
const CMD_BUILD_QUESTION_STAGE