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();
456 $this->questionSetConfig->loadFromDb();
457 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
458 $this->questionSetConfig->saveToDb();
460 $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
465 $this->questionSetConfig->loadFromDb();
475 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
478 $this->tpl->setContent( $this->ctrl->getHTML($form) );
491 $this->questionSetConfig->loadFromDb();
498 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
500 $errors = !$form->checkInput();
501 $form->setValuesByPost();
508 $form->applySubmit( $sourcePoolDefinition, $availableTaxonomyIds );
510 $this->sourcePoolDefinitionList->loadDefinitions();
511 $sourcePoolDefinition->setSequencePosition( $this->sourcePoolDefinitionList->getNextPosition() );
512 $sourcePoolDefinition->saveToDb();
513 $this->sourcePoolDefinitionList->addDefinition($sourcePoolDefinition);
515 $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
516 $this->sourcePoolDefinitionList->saveDefinitions();
518 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
519 $this->questionSetConfig->saveToDb();
521 $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
523 if($redirect_back_to_form)
526 $this->ctrl->setParameter($this,
'src_pool_def_id', $sourcePoolDefinition->getId());
527 $this->ctrl->setParameter($this,
'quest_pool_id', $sourcePoolDefinition->getPoolId());
528 $this->ctrl->redirect($this, self::CMD_SHOW_CREATE_SRC_POOL_DEF_FORM);
533 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
539 require_once
'Modules/Test/classes/forms/class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php';
542 $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
545 $form->setSaveCommand(self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM);
546 $form->setSaveAndNewCommand(self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM);
553 $this->questionSetConfig->loadFromDb();
556 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
562 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
565 $this->tpl->setContent( $this->ctrl->getHTML($form) );
570 $this->questionSetConfig->loadFromDb();
573 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
577 $form->build($sourcePoolDefinition, $availableTaxonomyIds);
579 $errors = !$form->checkInput();
580 $form->setValuesByPost();
587 $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds);
589 $sourcePoolDefinition->saveToDb();
591 $this->sourcePoolDefinitionList->loadDefinitions();
592 $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
594 $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
595 $this->questionSetConfig->saveToDb();
597 $this->sourcePoolDefinitionList->saveDefinitions();
599 $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
602 $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
607 require_once
'Modules/Test/classes/forms/class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php';
610 $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
613 $form->setSaveCommand(self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM);
620 if( isset(
$_POST[
'quest_pool_id']) && (
int)
$_POST[
'quest_pool_id'] )
622 return (
int)$_POST[
'quest_pool_id'];
625 if( isset(
$_GET[
'quest_pool_id']) && (
int)
$_GET[
'quest_pool_id'] )
627 return (
int)$_GET[
'quest_pool_id'];
630 require_once
'Modules/Test/exceptions/class.ilTestMissingQuestionPoolIdParameterException.php';
636 if( isset(
$_POST[
'src_pool_def_id']) && (
int)
$_POST[
'src_pool_def_id'] )
638 return (
int)$_POST[
'src_pool_def_id'];
641 if( isset(
$_GET[
'src_pool_def_id']) && (
int)
$_GET[
'src_pool_def_id'] )
643 return (
int)$_GET[
'src_pool_def_id'];
646 require_once
'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
652 if( !isset(
$_POST[
'src_pool_def_ids']) || !is_array(
$_POST[
'src_pool_def_ids']) )
654 require_once
'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
658 $definitionIds = array();
660 foreach(
$_POST[
'src_pool_def_ids'] as $definitionId)
662 $definitionId = (int)$definitionId;
666 require_once
'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
670 $definitionIds[] = $definitionId;
673 return $definitionIds;
678 $availablePools = $this->testOBJ->getAvailableQuestionpools(
679 true, $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired(),
false,
true, true
682 if( isset($availablePools[$poolId]) )
684 $originalPoolData = $availablePools[$poolId];
686 $originalPoolData[
'qpl_path'] = $this->questionSetConfig->getQuestionPoolPathString($poolId);
688 return $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByOriginalPoolData($originalPoolData);
691 require_once
'Modules/Test/exceptions/class.ilTestQuestionPoolNotAvailableAsSourcePoolException.php';
697 if( !$this->questionSetConfig->isQuestionAmountConfigComplete() )
699 $infoMessage = $this->lng->txt(
'tst_msg_rand_quest_set_incomplete_quest_amount_cfg');
703 $infoMessage .=
'<br />'.sprintf(
704 $this->lng->txt(
'tst_msg_rand_quest_set_change_quest_amount_here'),
710 $infoMessage .=
'<br />'.sprintf(
711 $this->lng->txt(
'tst_msg_rand_quest_set_change_quest_amount_here'),
716 elseif( !$this->questionSetConfig->hasSourcePoolDefinitions() )
718 $infoMessage = $this->lng->txt(
'tst_msg_rand_quest_set_no_src_pool_defs');
720 elseif( !$this->questionSetConfig->isQuestionSetBuildable() )
722 $infoMessage = $this->lng->txt(
'tst_msg_rand_quest_set_pass_not_buildable');
727 $this->questionSetConfig->getLastQuestionSyncTimestamp(),
IL_CAL_UNIX
730 $infoMessage = sprintf(
734 if( !$this->testOBJ->participantDataExist() )
736 $infoMessage .=
"<br />{$this->buildQuestionStageRebuildLink($currentRequestCmd)}";
742 $infoMessage .=
'<br />'.$this->lng->txt(
'tst_msg_rand_quest_set_no_pools_available');
754 $this->ctrl->setParameter(
755 $this, self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD, $afterRebuildQuestionStageCmd
758 $href = $this->ctrl->getLinkTarget($this, self::CMD_BUILD_QUESTION_STAGE);
759 $label = $this->lng->txt(
'tst_btn_rebuild_random_question_stage');
761 return "<a href=\"{$href}\">{$label}</a>";
766 $href = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
767 $label = $this->lng->txt(
'tst_rnd_quest_cfg_tab_general');
769 return "<a href=\"{$href}\">{$label}</a>";
774 $href = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
775 $label = $this->lng->txt(
'tst_rnd_quest_cfg_tab_pool');
777 return "<a href=\"{$href}\">{$label}</a>";
786 if( $currentRequestCmd != self::CMD_SHOW_SRC_POOL_DEF_LIST )
791 if( $this->questionSetConfig->doesSelectableQuestionPoolsExist() )
805 if( $currentRequestCmd != self::CMD_SHOW_GENERAL_CONFIG_FORM )
810 if( !$this->questionSetConfig->isQuestionAmountConfigurationModePerPool() )
824 if( $currentRequestCmd != self::CMD_SHOW_SRC_POOL_DEF_LIST )
829 if( !$this->questionSetConfig->isQuestionAmountConfigurationModePerTest() )