ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestRandomQuestionSetConfigGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
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 
9 require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
10 
25 {
26  const CMD_SHOW_GENERAL_CONFIG_FORM = 'showGeneralConfigForm';
27  const CMD_SAVE_GENERAL_CONFIG_FORM = 'saveGeneralConfigForm';
28  const CMD_SHOW_SRC_POOL_DEF_LIST = 'showSourcePoolDefinitionList';
29  const CMD_SAVE_SRC_POOL_DEF_LIST = 'saveSourcePoolDefinitionList';
30  const CMD_DELETE_SINGLE_SRC_POOL_DEF = 'deleteSingleSourcePoolDefinition';
31  const CMD_DELETE_MULTI_SRC_POOL_DEFS = 'deleteMultipleSourcePoolDefinitions';
32  const CMD_SHOW_CREATE_SRC_POOL_DEF_FORM = 'showCreateSourcePoolDefinitionForm';
33  const CMD_SAVE_CREATE_SRC_POOL_DEF_FORM = 'saveCreateSourcePoolDefinitionForm';
34  const CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM = 'saveCreateAndNewSourcePoolDefinitionForm';
35  const CMD_SHOW_EDIT_SRC_POOL_DEF_FORM = 'showEditSourcePoolDefinitionForm';
36  const CMD_SAVE_EDIT_SRC_POOL_DEF_FORM = 'saveEditSourcePoolDefinitionForm';
37  const CMD_BUILD_QUESTION_STAGE = 'buildQuestionStage';
38 
39  const HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD = 'afterRebuildQuestionStageCmd';
43  public $ctrl = null;
44 
48  public $access = null;
49 
53  public $tabs = null;
54 
58  public $lng = null;
59 
63  public $tpl = null;
64 
68  public $db = null;
69 
73  public $tree = null;
74 
78  public $pluginAdmin = null;
79 
83  public $testOBJ = null;
84 
88  protected $questionSetConfig = null;
89 
93  protected $sourcePoolDefinitionFactory = null;
94 
98  protected $sourcePoolDefinitionList= null;
99 
103  protected $stagingPool = null;
104 
105  public function __construct(
108  )
109  {
110  $this->ctrl = $ctrl;
111  $this->access = $access;
112  $this->tabs = $tabs;
113  $this->lng = $lng;
114  $this->tpl = $tpl;
115  $this->db = $db;
116  $this->tree = $tree;
117  $this->pluginAdmin = $pluginAdmin;
118 
119  $this->testOBJ = $testOBJ;
120 
121  $this->questionSetConfig = new ilTestRandomQuestionSetConfig(
122  $this->tree, $this->db, $this->pluginAdmin, $this->testOBJ
123  );
124 
125  $this->sourcePoolDefinitionFactory = new ilTestRandomQuestionSetSourcePoolDefinitionFactory(
126  $this->db, $this->testOBJ
127  );
128 
129  $this->sourcePoolDefinitionList = new ilTestRandomQuestionSetSourcePoolDefinitionList(
130  $this->db, $this->testOBJ, $this->sourcePoolDefinitionFactory
131  );
132 
133  $this->stagingPool = new ilTestRandomQuestionSetStagingPoolBuilder(
134  $this->db, $this->testOBJ
135  );
136  }
137 
138  public function executeCommand()
139  {
140  if (!$this->access->checkAccess("write", "", $this->testOBJ->getRefId()))
141  {
142  ilUtil::sendFailure($this->lng->txt("cannot_edit_test"), true);
143  $this->ctrl->redirectByClass('ilObjTestGUI', "infoScreen");
144  }
145 
147  {
148  ilUtil::sendFailure($this->lng->txt("tst_msg_cannot_modify_random_question_set_conf_due_to_part"), true);
149  $this->ctrl->redirect($this);
150  }
151 
152  $this->handleTabs();
153 
154  $nextClass = $this->ctrl->getNextClass();
155 
156  switch($nextClass)
157  {
158  case 'ilTestRandomQuestionSetPoolDefinitionFormGUI':
159 
161  $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
162  );
163 
164  $this->ctrl->forwardCommand($formGUI);
165 
166  break;
167 
168  default:
169 
170  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM).'Cmd';
171 
172  $this->$cmd();
173  }
174  }
175 
177  {
178  if( !$this->testOBJ->participantDataExist() )
179  {
180  return false;
181  }
182 
183  if( !$this->isManipulationCommand() )
184  {
185  return false;
186  }
187 
188  return true;
189  }
190 
191  private function isManipulationCommand()
192  {
193  switch( $this->ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM) )
194  {
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:
203 
204  return true;
205  }
206 
207  return false;
208  }
209 
210  private function handleTabs()
211  {
212  $this->tabs->activateTab('assQuestions');
213 
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)
218  );
219 
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)
224  );
225 
226  switch( $this->ctrl->getCmd(self::CMD_SHOW_GENERAL_CONFIG_FORM) )
227  {
228  case self::CMD_SHOW_GENERAL_CONFIG_FORM:
229  case self::CMD_SAVE_GENERAL_CONFIG_FORM:
230 
231  $this->tabs->activateSubTab('tstRandQuestSetGeneralConfig');
232  break;
233 
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:
242 
243  $this->tabs->activateSubTab('tstRandQuestSetPoolConfig');
244  break;
245  }
246  }
247 
248  private function buildQuestionStageCmd()
249  {
250  $this->sourcePoolDefinitionList->loadDefinitions();
251  $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
252  $this->sourcePoolDefinitionList->saveDefinitions();
253 
254  $this->questionSetConfig->loadFromDb();
255  $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
256  $this->questionSetConfig->saveToDb();
257 
258  $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
259 
260  ilUtil::sendSuccess($this->lng->txt("tst_msg_random_question_set_synced"), true);
261  $this->ctrl->redirect($this, $this->fetchAfterRebuildQuestionStageCmdParameter());
262  }
263 
265  {
266  if( !isset($_GET[self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD]) )
267  {
269  }
270 
271  if( !strlen($_GET[self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD]) )
272  {
274  }
275 
277  }
278 
280  {
281  if($form === null)
282  {
283  $this->questionSetConfig->loadFromDb();
284  $form = $this->buildGeneralConfigFormGUI();
285  }
286 
287  $this->tpl->setContent( $this->ctrl->getHTML($form) );
288 
289  $this->handleConfigurationStateMessages(self::CMD_SHOW_GENERAL_CONFIG_FORM);
290  }
291 
292  private function saveGeneralConfigFormCmd()
293  {
294  $this->questionSetConfig->loadFromDb();
295 
296  $form = $this->buildGeneralConfigFormGUI();
297 
298  $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
299  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
300 
301  if($errors)
302  {
303  return $this->showGeneralConfigFormCmd($form);
304  }
305 
306  $form->save();
307 
308  $this->sourcePoolDefinitionList->loadDefinitions();
309  $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
310  $this->sourcePoolDefinitionList->saveDefinitions();
311 
312  $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
313  $this->questionSetConfig->saveToDb();
314 
315  $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
316 
317  ilUtil::sendSuccess($this->lng->txt("tst_msg_random_question_set_config_modified"), true);
318  $this->ctrl->redirect($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
319  }
320 
321  private function buildGeneralConfigFormGUI()
322  {
323  require_once 'Modules/Test/classes/forms/class.ilTestRandomQuestionSetGeneralConfigFormGUI.php';
324 
326  $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
327  );
328 
329  $form->build();
330 
331  return $form;
332  }
333 
335  {
336  $this->questionSetConfig->loadFromDb();
337  $this->sourcePoolDefinitionList->loadDefinitions();
338 
339  $content = '';
340 
341  if( !$this->testOBJ->participantDataExist() )
342  {
343  $toolbar = $this->buildSourcePoolDefinitionListToolbarGUI();
344  $content .= $this->ctrl->getHTML($toolbar);
345  }
346 
347  $table = $this->buildSourcePoolDefinitionListTableGUI();
348  $table->init( $this->sourcePoolDefinitionList);
349  $content .= $this->ctrl->getHTML($table);
350 
351  $this->tpl->setContent($content);
352 
353  $this->handleConfigurationStateMessages(self::CMD_SHOW_SRC_POOL_DEF_LIST);
354  }
355 
357  {
358  $this->questionSetConfig->loadFromDb();
359 
360  $table = $this->buildSourcePoolDefinitionListTableGUI();
361 
362  $this->sourcePoolDefinitionList->loadDefinitions();
363 
364  $table->applySubmit($this->sourcePoolDefinitionList);
365 
366  $this->sourcePoolDefinitionList->reindexPositions();
367  $this->sourcePoolDefinitionList->saveDefinitions();
368 
369  $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
370  $this->sourcePoolDefinitionList->saveDefinitions();
371 
372  $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
373  $this->questionSetConfig->saveToDb();
374 
375  $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
376 
377  ilUtil::sendSuccess($this->lng->txt("tst_msg_random_question_set_config_modified"), true);
378  $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
379  }
380 
382  {
383  require_once 'Modules/Test/classes/toolbars/class.ilTestRandomQuestionSetSourcePoolDefinitionListToolbarGUI.php';
384 
386  $this->ctrl, $this->lng, $this, $this->questionSetConfig
387  );
388 
389  $toolbar->build();
390 
391  return $toolbar;
392  }
393 
395  {
396  require_once 'Modules/Test/classes/tables/class.ilTestRandomQuestionSetSourcePoolDefinitionListTableGUI.php';
397 
399  $this->ctrl, $this->lng, $this, self::CMD_SHOW_SRC_POOL_DEF_LIST
400  );
401 
402  if( !$this->testOBJ->participantDataExist() )
403  {
404  $table->setDefinitionEditModeEnabled(true);
405  }
406 
407  $table->setQuestionAmountColumnEnabled(
408  $this->questionSetConfig->isQuestionAmountConfigurationModePerPool()
409  );
410 
411  require_once 'Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
412  $translater = new ilTestTaxonomyFilterLabelTranslater($this->db);
413  $translater->loadLabels($this->sourcePoolDefinitionList);
414  $table->setTaxonomyFilterLabelTranslater($translater);
415 
416  $table->build();
417 
418  return $table;
419  }
420 
422  {
423  $definitionId = $this->fetchSingleSourcePoolDefinitionIdParameter();
424  $this->deleteSourcePoolDefinitions( array($definitionId) );
425 
426  ilUtil::sendSuccess($this->lng->txt("tst_msg_source_pool_definitions_deleted"), true);
427  $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
428  }
429 
431  {
432  $definitionIds = $this->fetchMultiSourcePoolDefinitionIdsParameter();
433  $this->deleteSourcePoolDefinitions( $definitionIds );
434 
435  ilUtil::sendSuccess($this->lng->txt("tst_msg_source_pool_definitions_deleted"), true);
436  $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
437  }
438 
439  private function deleteSourcePoolDefinitions($definitionIds)
440  {
441  foreach($definitionIds as $definitionId)
442  {
443  $definition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($definitionId);
444  $definition->deleteFromDb();
445  }
446 
447  $this->sourcePoolDefinitionList->loadDefinitions();
448  $this->sourcePoolDefinitionList->reindexPositions();
449  $this->sourcePoolDefinitionList->saveDefinitions();
450 
451  $this->sourcePoolDefinitionList->loadDefinitions();
452  $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
453  $this->sourcePoolDefinitionList->saveDefinitions();
454 
455  // Bugfix for mantis: 0015082
456  $this->questionSetConfig->loadFromDb();
457  $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
458  $this->questionSetConfig->saveToDb();
459 
460  $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
461  }
462 
464  {
465  $this->questionSetConfig->loadFromDb();
466 
467  $poolId = $this->fetchQuestionPoolIdParameter();
468 
469  $sourcePoolDefinition = $this->getSourcePoolDefinitionByAvailableQuestionPoolId($poolId);
470  $availableTaxonomyIds = ilObjTaxonomy::getUsageOfObject($sourcePoolDefinition->getPoolId());
471 
472  if($form === null)
473  {
475  $form->build($sourcePoolDefinition, $availableTaxonomyIds);
476  }
477 
478  $this->tpl->setContent( $this->ctrl->getHTML($form) );
479  }
480 
482  {
484  }
485 
489  private function saveCreateSourcePoolDefinitionFormCmd($redirect_back_to_form = false)
490  {
491  $this->questionSetConfig->loadFromDb();
492 
493  $poolId = $this->fetchQuestionPoolIdParameter();
494  $sourcePoolDefinition = $this->getSourcePoolDefinitionByAvailableQuestionPoolId($poolId);
495  $availableTaxonomyIds = ilObjTaxonomy::getUsageOfObject($sourcePoolDefinition->getPoolId());
496 
498  $form->build($sourcePoolDefinition, $availableTaxonomyIds);
499 
500  $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
501  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
502 
503  if($errors)
504  {
505  return $this->showCreateSourcePoolDefinitionFormCmd($form);
506  }
507 
508  $form->applySubmit( $sourcePoolDefinition, $availableTaxonomyIds );
509 
510  $this->sourcePoolDefinitionList->loadDefinitions();
511  $sourcePoolDefinition->setSequencePosition( $this->sourcePoolDefinitionList->getNextPosition() );
512  $sourcePoolDefinition->saveToDb();
513  $this->sourcePoolDefinitionList->addDefinition($sourcePoolDefinition);
514 
515  $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
516  $this->sourcePoolDefinitionList->saveDefinitions();
517 
518  $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
519  $this->questionSetConfig->saveToDb();
520 
521  $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
522 
523  if($redirect_back_to_form)
524  {
525  ilUtil::sendSuccess($this->lng->txt("tst_msg_random_qsc_modified_add_new_rule"), true);
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);
529  }
530  else
531  {
532  ilUtil::sendSuccess($this->lng->txt("tst_msg_random_question_set_config_modified"), true);
533  $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
534  }
535  }
536 
538  {
539  require_once 'Modules/Test/classes/forms/class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php';
540 
542  $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
543  );
544 
545  $form->setSaveCommand(self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM);
546  $form->setSaveAndNewCommand(self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM);
547 
548  return $form;
549  }
550 
552  {
553  $this->questionSetConfig->loadFromDb();
554 
556  $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
557  $availableTaxonomyIds = ilObjTaxonomy::getUsageOfObject($sourcePoolDefinition->getPoolId());
558 
559  if($form === null)
560  {
561  $form = $this->buildEditSourcePoolDefinitionFormGUI();
562  $form->build($sourcePoolDefinition, $availableTaxonomyIds);
563  }
564 
565  $this->tpl->setContent( $this->ctrl->getHTML($form) );
566  }
567 
569  {
570  $this->questionSetConfig->loadFromDb();
571 
573  $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
574  $availableTaxonomyIds = ilObjTaxonomy::getUsageOfObject($sourcePoolDefinition->getPoolId());
575 
576  $form = $this->buildEditSourcePoolDefinitionFormGUI();
577  $form->build($sourcePoolDefinition, $availableTaxonomyIds);
578 
579  $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
580  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
581 
582  if($errors)
583  {
584  return $this->showSourcePoolDefinitionListCmd($form);
585  }
586 
587  $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds);
588 
589  $sourcePoolDefinition->saveToDb();
590 
591  $this->sourcePoolDefinitionList->loadDefinitions();
592  $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
593 
594  $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
595  $this->questionSetConfig->saveToDb();
596 
597  $this->sourcePoolDefinitionList->saveDefinitions();
598 
599  $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
600 
601  ilUtil::sendSuccess($this->lng->txt("tst_msg_random_question_set_config_modified"), true);
602  $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
603  }
604 
606  {
607  require_once 'Modules/Test/classes/forms/class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php';
608 
610  $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
611  );
612 
613  $form->setSaveCommand(self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM);
614 
615  return $form;
616  }
617 
618  private function fetchQuestionPoolIdParameter()
619  {
620  if( isset($_POST['quest_pool_id']) && (int)$_POST['quest_pool_id'] )
621  {
622  return (int)$_POST['quest_pool_id'];
623  }
624 
625  if( isset($_GET['quest_pool_id']) && (int)$_GET['quest_pool_id'] )
626  {
627  return (int)$_GET['quest_pool_id'];
628  }
629 
630  require_once 'Modules/Test/exceptions/class.ilTestMissingQuestionPoolIdParameterException.php';
632  }
633 
635  {
636  if( isset($_POST['src_pool_def_id']) && (int)$_POST['src_pool_def_id'] )
637  {
638  return (int)$_POST['src_pool_def_id'];
639  }
640 
641  if( isset($_GET['src_pool_def_id']) && (int)$_GET['src_pool_def_id'] )
642  {
643  return (int)$_GET['src_pool_def_id'];
644  }
645 
646  require_once 'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
648  }
649 
651  {
652  if( !isset($_POST['src_pool_def_ids']) || !is_array($_POST['src_pool_def_ids']) )
653  {
654  require_once 'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
656  }
657 
658  $definitionIds = array();
659 
660  foreach($_POST['src_pool_def_ids'] as $definitionId)
661  {
662  $definitionId = (int)$definitionId;
663 
664  if( !$definitionId )
665  {
666  require_once 'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
668  }
669 
670  $definitionIds[] = $definitionId;
671  }
672 
673  return $definitionIds;
674  }
675 
677  {
678  $availablePools = $this->testOBJ->getAvailableQuestionpools(
679  true, $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired(), false, true, true
680  );
681 
682  if( isset($availablePools[$poolId]) )
683  {
684  $originalPoolData = $availablePools[$poolId];
685 
686  $originalPoolData['qpl_path'] = $this->questionSetConfig->getQuestionPoolPathString($poolId);
687 
688  return $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByOriginalPoolData($originalPoolData);
689  }
690 
691  require_once 'Modules/Test/exceptions/class.ilTestQuestionPoolNotAvailableAsSourcePoolException.php';
693  }
694 
695  private function handleConfigurationStateMessages($currentRequestCmd)
696  {
697  if( !$this->questionSetConfig->isQuestionAmountConfigComplete() )
698  {
699  $infoMessage = $this->lng->txt('tst_msg_rand_quest_set_incomplete_quest_amount_cfg');
700 
701  if( $this->isQuestionAmountConfigPerTestHintRequired($currentRequestCmd) )
702  {
703  $infoMessage .= '<br />'.sprintf(
704  $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
706  );
707  }
708  elseif( $this->isQuestionAmountConfigPerPoolHintRequired($currentRequestCmd) )
709  {
710  $infoMessage .= '<br />'.sprintf(
711  $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
713  );
714  }
715  }
716  elseif( !$this->questionSetConfig->hasSourcePoolDefinitions() )
717  {
718  $infoMessage = $this->lng->txt('tst_msg_rand_quest_set_no_src_pool_defs');
719  }
720  elseif( !$this->questionSetConfig->isQuestionSetBuildable() )
721  {
722  $infoMessage = $this->lng->txt('tst_msg_rand_quest_set_pass_not_buildable');
723  }
724  else
725  {
726  $syncDate = new ilDateTime(
727  $this->questionSetConfig->getLastQuestionSyncTimestamp(), IL_CAL_UNIX
728  );
729 
730  $infoMessage = sprintf(
731  $this->lng->txt('tst_msg_rand_quest_set_stage_pool_last_sync'), ilDatePresentation::formatDate($syncDate)
732  );
733 
734  if( !$this->testOBJ->participantDataExist() )
735  {
736  $infoMessage .= "<br />{$this->buildQuestionStageRebuildLink($currentRequestCmd)}";
737  }
738  }
739 
740  if( $this->isNoAvailableQuestionPoolsHintRequired($currentRequestCmd) )
741  {
742  $infoMessage .= '<br />'.$this->lng->txt('tst_msg_rand_quest_set_no_pools_available');
743  }
744 
745  ilUtil::sendInfo($infoMessage);
746  }
747 
752  private function buildQuestionStageRebuildLink($afterRebuildQuestionStageCmd)
753  {
754  $this->ctrl->setParameter(
755  $this, self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD, $afterRebuildQuestionStageCmd
756  );
757 
758  $href = $this->ctrl->getLinkTarget($this, self::CMD_BUILD_QUESTION_STAGE);
759  $label = $this->lng->txt('tst_btn_rebuild_random_question_stage');
760 
761  return "<a href=\"{$href}\">{$label}</a>";
762  }
763 
764  private function buildGeneralConfigSubTabLink()
765  {
766  $href = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
767  $label = $this->lng->txt('tst_rnd_quest_cfg_tab_general');
768 
769  return "<a href=\"{$href}\">{$label}</a>";
770  }
771 
773  {
774  $href = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
775  $label = $this->lng->txt('tst_rnd_quest_cfg_tab_pool');
776 
777  return "<a href=\"{$href}\">{$label}</a>";
778  }
779 
784  private function isNoAvailableQuestionPoolsHintRequired($currentRequestCmd)
785  {
786  if( $currentRequestCmd != self::CMD_SHOW_SRC_POOL_DEF_LIST )
787  {
788  return false;
789  }
790 
791  if( $this->questionSetConfig->doesSelectableQuestionPoolsExist() )
792  {
793  return false;
794  }
795 
796  return true;
797  }
798 
803  private function isQuestionAmountConfigPerPoolHintRequired($currentRequestCmd)
804  {
805  if( $currentRequestCmd != self::CMD_SHOW_GENERAL_CONFIG_FORM )
806  {
807  return false;
808  }
809 
810  if( !$this->questionSetConfig->isQuestionAmountConfigurationModePerPool() )
811  {
812  return false;
813  }
814 
815  return true;
816  }
817 
822  private function isQuestionAmountConfigPerTestHintRequired($currentRequestCmd)
823  {
824  if( $currentRequestCmd != self::CMD_SHOW_SRC_POOL_DEF_LIST )
825  {
826  return false;
827  }
828 
829  if( !$this->questionSetConfig->isQuestionAmountConfigurationModePerTest() )
830  {
831  return false;
832  }
833 
834  return true;
835  }
836 }