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';
9 require_once
'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
122 $this->tree, $this->db, $this->pluginAdmin, $this->testOBJ
126 $this->db, $this->testOBJ
130 $this->db, $this->testOBJ, $this->sourcePoolDefinitionFactory
134 $this->db, $this->testOBJ
140 if (!$this->access->checkAccess(
"write",
"", $this->testOBJ->getRefId()))
143 $this->ctrl->redirectByClass(
'ilObjTestGUI',
"infoScreen");
148 ilUtil::sendFailure($this->lng->txt(
"tst_msg_cannot_modify_random_question_set_conf_due_to_part"),
true);
149 $this->ctrl->redirect($this);
154 $nextClass = $this->ctrl->getNextClass();
158 case 'ilTestRandomQuestionSetPoolDefinitionFormGUI':
161 $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
164 $this->ctrl->forwardCommand($formGUI);
170 $cmd = $this->ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM).
'Cmd';
178 if( !$this->testOBJ->participantDataExist() )
193 switch( $this->ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM) )
195 case self::CMD_SAVE_GENERAL_CONFIG_FORM:
196 case self::CMD_SAVE_SRC_POOL_DEF_LIST:
197 case self::CMD_DELETE_SINGLE_SRC_POOL_DEF:
198 case self::CMD_DELETE_MULTI_SRC_POOL_DEFS:
199 case self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM:
200 case self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM:
201 case self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM:
202 case self::CMD_BUILD_QUESTION_STAGE:
212 $this->tabs->activateTab(
'assQuestions');
214 $this->tabs->addSubTab(
215 'tstRandQuestSetGeneralConfig',
216 $this->lng->txt(
'tst_rnd_quest_cfg_tab_general'),
217 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_GENERAL_CONFIG_FORM)
220 $this->tabs->addSubTab(
221 'tstRandQuestSetPoolConfig',
222 $this->lng->txt(
'tst_rnd_quest_cfg_tab_pool'),
223 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_SRC_POOL_DEF_LIST)
226 switch( $this->ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM) )
228 case self::CMD_SHOW_GENERAL_CONFIG_FORM:
229 case self::CMD_SAVE_GENERAL_CONFIG_FORM:
231 $this->tabs->activateSubTab(
'tstRandQuestSetGeneralConfig');
234 case self::CMD_SHOW_SRC_POOL_DEF_LIST:
235 case self::CMD_SAVE_SRC_POOL_DEF_LIST:
236 case self::CMD_DELETE_SINGLE_SRC_POOL_DEF:
237 case self::CMD_DELETE_MULTI_SRC_POOL_DEFS:
238 case self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM:
239 case self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM:
240 case self::CMD_SHOW_EDIT_SRC_POOL_DEF_FORM:
241 case self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM:
243 $this->tabs->activateSubTab(
'tstRandQuestSetPoolConfig');
250 $this->sourcePoolDefinitionList->loadDefinitions();
251 $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
252 $this->sourcePoolDefinitionList->saveDefinitions();
254 $this->questionSetConfig->loadFromDb();
255 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
256 $this->questionSetConfig->saveToDb();
258 $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
266 if( !isset(
$_GET[self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD]) )
271 if( !strlen(
$_GET[self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD]) )
283 $this->questionSetConfig->loadFromDb();
287 $this->tpl->setContent( $this->ctrl->getHTML($form) );
294 $this->questionSetConfig->loadFromDb();
298 $errors = !$form->checkInput();
299 $form->setValuesByPost();
308 $this->sourcePoolDefinitionList->loadDefinitions();
309 $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
310 $this->sourcePoolDefinitionList->saveDefinitions();
312 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
313 $this->questionSetConfig->saveToDb();
315 $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
318 $this->ctrl->redirect($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
323 require_once
'Modules/Test/classes/forms/class.ilTestRandomQuestionSetGeneralConfigFormGUI.php';
326 $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
336 $this->questionSetConfig->loadFromDb();
337 $this->sourcePoolDefinitionList->loadDefinitions();
341 if( !$this->testOBJ->participantDataExist() )
344 $content .= $this->ctrl->getHTML($toolbar);
348 $table->init( $this->sourcePoolDefinitionList);
349 $content .= $this->ctrl->getHTML($table);
351 $this->tpl->setContent($content);
358 $this->questionSetConfig->loadFromDb();
362 $this->sourcePoolDefinitionList->loadDefinitions();
364 $table->applySubmit($this->sourcePoolDefinitionList);
366 $this->sourcePoolDefinitionList->reindexPositions();
367 $this->sourcePoolDefinitionList->saveDefinitions();
369 $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
370 $this->sourcePoolDefinitionList->saveDefinitions();
372 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
373 $this->questionSetConfig->saveToDb();
375 $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
378 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
383 require_once
'Modules/Test/classes/toolbars/class.ilTestRandomQuestionSetSourcePoolDefinitionListToolbarGUI.php';
386 $this->ctrl, $this->lng, $this, $this->questionSetConfig
396 require_once
'Modules/Test/classes/tables/class.ilTestRandomQuestionSetSourcePoolDefinitionListTableGUI.php';
399 $this->ctrl, $this->lng, $this, self::CMD_SHOW_SRC_POOL_DEF_LIST
402 if( !$this->testOBJ->participantDataExist() )
404 $table->setDefinitionEditModeEnabled(
true);
407 $table->setQuestionAmountColumnEnabled(
408 $this->questionSetConfig->isQuestionAmountConfigurationModePerPool()
411 require_once
'Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
413 $translater->loadLabels($this->sourcePoolDefinitionList);
414 $table->setTaxonomyFilterLabelTranslater($translater);
427 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
436 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
441 foreach($definitionIds as $definitionId)
443 $definition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($definitionId);
444 $definition->deleteFromDb();
447 $this->sourcePoolDefinitionList->loadDefinitions();
448 $this->sourcePoolDefinitionList->reindexPositions();
449 $this->sourcePoolDefinitionList->saveDefinitions();
451 $this->sourcePoolDefinitionList->loadDefinitions();
452 $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
453 $this->sourcePoolDefinitionList->saveDefinitions();
455 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
456 $this->questionSetConfig->saveToDb();
458 $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
463 $this->questionSetConfig->loadFromDb();
473 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
476 $this->tpl->setContent( $this->ctrl->getHTML($form) );
489 $this->questionSetConfig->loadFromDb();
496 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
498 $errors = !$form->checkInput();
499 $form->setValuesByPost();
506 $form->applySubmit( $sourcePoolDefinition, $availableTaxonomyIds );
508 $this->sourcePoolDefinitionList->loadDefinitions();
509 $sourcePoolDefinition->setSequencePosition( $this->sourcePoolDefinitionList->getNextPosition() );
510 $sourcePoolDefinition->saveToDb();
511 $this->sourcePoolDefinitionList->addDefinition($sourcePoolDefinition);
513 $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
514 $this->sourcePoolDefinitionList->saveDefinitions();
516 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
517 $this->questionSetConfig->saveToDb();
519 $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
521 if($redirect_back_to_form)
524 $this->ctrl->setParameter($this,
'src_pool_def_id', $sourcePoolDefinition->getId());
525 $this->ctrl->setParameter($this,
'quest_pool_id', $sourcePoolDefinition->getPoolId());
526 $this->ctrl->redirect($this, self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM);
531 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
537 require_once
'Modules/Test/classes/forms/class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php';
540 $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
543 $form->setSaveCommand(self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM);
544 $form->setSaveAndNewCommand(self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM);
551 $this->questionSetConfig->loadFromDb();
554 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
560 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
563 $this->tpl->setContent( $this->ctrl->getHTML($form) );
568 $this->questionSetConfig->loadFromDb();
571 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
575 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
577 $errors = !$form->checkInput();
578 $form->setValuesByPost();
585 $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds);
587 $sourcePoolDefinition->saveToDb();
589 $this->sourcePoolDefinitionList->loadDefinitions();
590 $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
592 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
593 $this->questionSetConfig->saveToDb();
595 $this->sourcePoolDefinitionList->saveDefinitions();
597 $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
600 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
605 require_once
'Modules/Test/classes/forms/class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php';
608 $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
611 $form->setSaveCommand(self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM);
618 if( isset(
$_POST[
'quest_pool_id']) && (
int)
$_POST[
'quest_pool_id'] )
620 return (
int)$_POST[
'quest_pool_id'];
623 if( isset(
$_GET[
'quest_pool_id']) && (
int)
$_GET[
'quest_pool_id'] )
625 return (
int)$_GET[
'quest_pool_id'];
628 require_once
'Modules/Test/exceptions/class.ilTestMissingQuestionPoolIdParameterException.php';
634 if( isset(
$_POST[
'src_pool_def_id']) && (
int)
$_POST[
'src_pool_def_id'] )
636 return (
int)$_POST[
'src_pool_def_id'];
639 if( isset(
$_GET[
'src_pool_def_id']) && (
int)
$_GET[
'src_pool_def_id'] )
641 return (
int)$_GET[
'src_pool_def_id'];
644 require_once
'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
650 if( !isset(
$_POST[
'src_pool_def_ids']) || !is_array(
$_POST[
'src_pool_def_ids']) )
652 require_once
'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
656 $definitionIds = array();
658 foreach(
$_POST[
'src_pool_def_ids'] as $definitionId)
660 $definitionId = (int)$definitionId;
664 require_once
'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
668 $definitionIds[] = $definitionId;
671 return $definitionIds;
676 $availablePools = $this->testOBJ->getAvailableQuestionpools(
677 true, $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired(),
false,
true, true
680 if( isset($availablePools[$poolId]) )
682 $originalPoolData = $availablePools[$poolId];
684 $originalPoolData[
'qpl_path'] = $this->questionSetConfig->getQuestionPoolPathString($poolId);
686 return $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByOriginalPoolData($originalPoolData);
689 require_once
'Modules/Test/exceptions/class.ilTestQuestionPoolNotAvailableAsSourcePoolException.php';
695 if( !$this->questionSetConfig->isQuestionAmountConfigComplete() )
697 $infoMessage = $this->lng->txt(
'tst_msg_rand_quest_set_incomplete_quest_amount_cfg');
701 $infoMessage .=
'<br />'.sprintf(
702 $this->lng->txt(
'tst_msg_rand_quest_set_change_quest_amount_here'),
708 $infoMessage .=
'<br />'.sprintf(
709 $this->lng->txt(
'tst_msg_rand_quest_set_change_quest_amount_here'),
714 elseif( !$this->questionSetConfig->hasSourcePoolDefinitions() )
716 $infoMessage = $this->lng->txt(
'tst_msg_rand_quest_set_no_src_pool_defs');
718 elseif( !$this->questionSetConfig->isQuestionSetBuildable() )
720 $infoMessage = $this->lng->txt(
'tst_msg_rand_quest_set_pass_not_buildable');
725 $this->questionSetConfig->getLastQuestionSyncTimestamp(),
IL_CAL_UNIX
728 $infoMessage = sprintf(
732 if( !$this->testOBJ->participantDataExist() )
734 $infoMessage .=
"<br />{$this->buildQuestionStageRebuildLink($currentRequestCmd)}";
740 $infoMessage .=
'<br />'.$this->lng->txt(
'tst_msg_rand_quest_set_no_pools_available');
752 $this->ctrl->setParameter(
753 $this, self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD, $afterRebuildQuestionStageCmd
756 $href = $this->ctrl->getLinkTarget($this, self::CMD_BUILD_QUESTION_STAGE);
757 $label = $this->lng->txt(
'tst_btn_rebuild_random_question_stage');
759 return "<a href=\"{$href}\">{$label}</a>";
764 $href = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
765 $label = $this->lng->txt(
'tst_rnd_quest_cfg_tab_general');
767 return "<a href=\"{$href}\">{$label}</a>";
772 $href = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
773 $label = $this->lng->txt(
'tst_rnd_quest_cfg_tab_pool');
775 return "<a href=\"{$href}\">{$label}</a>";
784 if( $currentRequestCmd != self::CMD_SHOW_SRC_POOL_DEF_LIST )
789 if( $this->questionSetConfig->doesSelectableQuestionPoolsExist() )
803 if( $currentRequestCmd != self::CMD_SHOW_GENERAL_CONFIG_FORM )
808 if( !$this->questionSetConfig->isQuestionAmountConfigurationModePerPool() )
822 if( $currentRequestCmd != self::CMD_SHOW_SRC_POOL_DEF_LIST )
827 if( !$this->questionSetConfig->isQuestionAmountConfigurationModePerTest() )