ILIAS  Release_4_4_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  $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
456  $this->questionSetConfig->saveToDb();
457 
458  $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
459  }
460 
462  {
463  $this->questionSetConfig->loadFromDb();
464 
465  $poolId = $this->fetchQuestionPoolIdParameter();
466 
467  $sourcePoolDefinition = $this->getSourcePoolDefinitionByAvailableQuestionPoolId($poolId);
468  $availableTaxonomyIds = ilObjTaxonomy::getUsageOfObject($sourcePoolDefinition->getPoolId());
469 
470  if($form === null)
471  {
473  $form->build($sourcePoolDefinition, $availableTaxonomyIds);
474  }
475 
476  $this->tpl->setContent( $this->ctrl->getHTML($form) );
477  }
478 
480  {
482  }
483 
487  private function saveCreateSourcePoolDefinitionFormCmd($redirect_back_to_form = false)
488  {
489  $this->questionSetConfig->loadFromDb();
490 
491  $poolId = $this->fetchQuestionPoolIdParameter();
492  $sourcePoolDefinition = $this->getSourcePoolDefinitionByAvailableQuestionPoolId($poolId);
493  $availableTaxonomyIds = ilObjTaxonomy::getUsageOfObject($sourcePoolDefinition->getPoolId());
494 
496  $form->build($sourcePoolDefinition, $availableTaxonomyIds);
497 
498  $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
499  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
500 
501  if($errors)
502  {
503  return $this->showCreateSourcePoolDefinitionFormCmd($form);
504  }
505 
506  $form->applySubmit( $sourcePoolDefinition, $availableTaxonomyIds );
507 
508  $this->sourcePoolDefinitionList->loadDefinitions();
509  $sourcePoolDefinition->setSequencePosition( $this->sourcePoolDefinitionList->getNextPosition() );
510  $sourcePoolDefinition->saveToDb();
511  $this->sourcePoolDefinitionList->addDefinition($sourcePoolDefinition);
512 
513  $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
514  $this->sourcePoolDefinitionList->saveDefinitions();
515 
516  $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
517  $this->questionSetConfig->saveToDb();
518 
519  $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
520 
521  if($redirect_back_to_form)
522  {
523  ilUtil::sendSuccess($this->lng->txt("tst_msg_random_qsc_modified_add_new_rule"), true);
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);
527  }
528  else
529  {
530  ilUtil::sendSuccess($this->lng->txt("tst_msg_random_question_set_config_modified"), true);
531  $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
532  }
533  }
534 
536  {
537  require_once 'Modules/Test/classes/forms/class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php';
538 
540  $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
541  );
542 
543  $form->setSaveCommand(self::CMD_SAVE_CREATE_SRC_POOL_DEF_FORM);
544  $form->setSaveAndNewCommand(self::CMD_SAVE_AND_NEW_CREATE_SRC_POOL_DEF_FORM);
545 
546  return $form;
547  }
548 
550  {
551  $this->questionSetConfig->loadFromDb();
552 
554  $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
555  $availableTaxonomyIds = ilObjTaxonomy::getUsageOfObject($sourcePoolDefinition->getPoolId());
556 
557  if($form === null)
558  {
559  $form = $this->buildEditSourcePoolDefinitionFormGUI();
560  $form->build($sourcePoolDefinition, $availableTaxonomyIds);
561  }
562 
563  $this->tpl->setContent( $this->ctrl->getHTML($form) );
564  }
565 
567  {
568  $this->questionSetConfig->loadFromDb();
569 
571  $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByDefinitionId($defId);
572  $availableTaxonomyIds = ilObjTaxonomy::getUsageOfObject($sourcePoolDefinition->getPoolId());
573 
574  $form = $this->buildEditSourcePoolDefinitionFormGUI();
575  $form->build($sourcePoolDefinition, $availableTaxonomyIds);
576 
577  $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
578  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
579 
580  if($errors)
581  {
582  return $this->showSourcePoolDefinitionListCmd($form);
583  }
584 
585  $form->applySubmit($sourcePoolDefinition, $availableTaxonomyIds);
586 
587  $sourcePoolDefinition->saveToDb();
588 
589  $this->sourcePoolDefinitionList->loadDefinitions();
590  $this->stagingPool->rebuild( $this->sourcePoolDefinitionList );
591 
592  $this->questionSetConfig->setLastQuestionSyncTimestamp(time());
593  $this->questionSetConfig->saveToDb();
594 
595  $this->sourcePoolDefinitionList->saveDefinitions();
596 
597  $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
598 
599  ilUtil::sendSuccess($this->lng->txt("tst_msg_random_question_set_config_modified"), true);
600  $this->ctrl->redirect($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
601  }
602 
604  {
605  require_once 'Modules/Test/classes/forms/class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php';
606 
608  $this->ctrl, $this->lng, $this->testOBJ, $this, $this->questionSetConfig
609  );
610 
611  $form->setSaveCommand(self::CMD_SAVE_EDIT_SRC_POOL_DEF_FORM);
612 
613  return $form;
614  }
615 
616  private function fetchQuestionPoolIdParameter()
617  {
618  if( isset($_POST['quest_pool_id']) && (int)$_POST['quest_pool_id'] )
619  {
620  return (int)$_POST['quest_pool_id'];
621  }
622 
623  if( isset($_GET['quest_pool_id']) && (int)$_GET['quest_pool_id'] )
624  {
625  return (int)$_GET['quest_pool_id'];
626  }
627 
628  require_once 'Modules/Test/exceptions/class.ilTestMissingQuestionPoolIdParameterException.php';
630  }
631 
633  {
634  if( isset($_POST['src_pool_def_id']) && (int)$_POST['src_pool_def_id'] )
635  {
636  return (int)$_POST['src_pool_def_id'];
637  }
638 
639  if( isset($_GET['src_pool_def_id']) && (int)$_GET['src_pool_def_id'] )
640  {
641  return (int)$_GET['src_pool_def_id'];
642  }
643 
644  require_once 'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
646  }
647 
649  {
650  if( !isset($_POST['src_pool_def_ids']) || !is_array($_POST['src_pool_def_ids']) )
651  {
652  require_once 'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
654  }
655 
656  $definitionIds = array();
657 
658  foreach($_POST['src_pool_def_ids'] as $definitionId)
659  {
660  $definitionId = (int)$definitionId;
661 
662  if( !$definitionId )
663  {
664  require_once 'Modules/Test/exceptions/class.ilTestMissingSourcePoolDefinitionParameterException.php';
666  }
667 
668  $definitionIds[] = $definitionId;
669  }
670 
671  return $definitionIds;
672  }
673 
675  {
676  $availablePools = $this->testOBJ->getAvailableQuestionpools(
677  true, $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired(), false, true, true
678  );
679 
680  if( isset($availablePools[$poolId]) )
681  {
682  $originalPoolData = $availablePools[$poolId];
683 
684  $originalPoolData['qpl_path'] = $this->questionSetConfig->getQuestionPoolPathString($poolId);
685 
686  return $this->sourcePoolDefinitionFactory->getSourcePoolDefinitionByOriginalPoolData($originalPoolData);
687  }
688 
689  require_once 'Modules/Test/exceptions/class.ilTestQuestionPoolNotAvailableAsSourcePoolException.php';
691  }
692 
693  private function handleConfigurationStateMessages($currentRequestCmd)
694  {
695  if( !$this->questionSetConfig->isQuestionAmountConfigComplete() )
696  {
697  $infoMessage = $this->lng->txt('tst_msg_rand_quest_set_incomplete_quest_amount_cfg');
698 
699  if( $this->isQuestionAmountConfigPerTestHintRequired($currentRequestCmd) )
700  {
701  $infoMessage .= '<br />'.sprintf(
702  $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
704  );
705  }
706  elseif( $this->isQuestionAmountConfigPerPoolHintRequired($currentRequestCmd) )
707  {
708  $infoMessage .= '<br />'.sprintf(
709  $this->lng->txt('tst_msg_rand_quest_set_change_quest_amount_here'),
711  );
712  }
713  }
714  elseif( !$this->questionSetConfig->hasSourcePoolDefinitions() )
715  {
716  $infoMessage = $this->lng->txt('tst_msg_rand_quest_set_no_src_pool_defs');
717  }
718  elseif( !$this->questionSetConfig->isQuestionSetBuildable() )
719  {
720  $infoMessage = $this->lng->txt('tst_msg_rand_quest_set_pass_not_buildable');
721  }
722  else
723  {
724  $syncDate = new ilDateTime(
725  $this->questionSetConfig->getLastQuestionSyncTimestamp(), IL_CAL_UNIX
726  );
727 
728  $infoMessage = sprintf(
729  $this->lng->txt('tst_msg_rand_quest_set_stage_pool_last_sync'), ilDatePresentation::formatDate($syncDate)
730  );
731 
732  if( !$this->testOBJ->participantDataExist() )
733  {
734  $infoMessage .= "<br />{$this->buildQuestionStageRebuildLink($currentRequestCmd)}";
735  }
736  }
737 
738  if( $this->isNoAvailableQuestionPoolsHintRequired($currentRequestCmd) )
739  {
740  $infoMessage .= '<br />'.$this->lng->txt('tst_msg_rand_quest_set_no_pools_available');
741  }
742 
743  ilUtil::sendInfo($infoMessage);
744  }
745 
750  private function buildQuestionStageRebuildLink($afterRebuildQuestionStageCmd)
751  {
752  $this->ctrl->setParameter(
753  $this, self::HTTP_PARAM_AFTER_REBUILD_QUESTION_STAGE_CMD, $afterRebuildQuestionStageCmd
754  );
755 
756  $href = $this->ctrl->getLinkTarget($this, self::CMD_BUILD_QUESTION_STAGE);
757  $label = $this->lng->txt('tst_btn_rebuild_random_question_stage');
758 
759  return "<a href=\"{$href}\">{$label}</a>";
760  }
761 
762  private function buildGeneralConfigSubTabLink()
763  {
764  $href = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_GENERAL_CONFIG_FORM);
765  $label = $this->lng->txt('tst_rnd_quest_cfg_tab_general');
766 
767  return "<a href=\"{$href}\">{$label}</a>";
768  }
769 
771  {
772  $href = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_SRC_POOL_DEF_LIST);
773  $label = $this->lng->txt('tst_rnd_quest_cfg_tab_pool');
774 
775  return "<a href=\"{$href}\">{$label}</a>";
776  }
777 
782  private function isNoAvailableQuestionPoolsHintRequired($currentRequestCmd)
783  {
784  if( $currentRequestCmd != self::CMD_SHOW_SRC_POOL_DEF_LIST )
785  {
786  return false;
787  }
788 
789  if( $this->questionSetConfig->doesSelectableQuestionPoolsExist() )
790  {
791  return false;
792  }
793 
794  return true;
795  }
796 
801  private function isQuestionAmountConfigPerPoolHintRequired($currentRequestCmd)
802  {
803  if( $currentRequestCmd != self::CMD_SHOW_GENERAL_CONFIG_FORM )
804  {
805  return false;
806  }
807 
808  if( !$this->questionSetConfig->isQuestionAmountConfigurationModePerPool() )
809  {
810  return false;
811  }
812 
813  return true;
814  }
815 
820  private function isQuestionAmountConfigPerTestHintRequired($currentRequestCmd)
821  {
822  if( $currentRequestCmd != self::CMD_SHOW_SRC_POOL_DEF_LIST )
823  {
824  return false;
825  }
826 
827  if( !$this->questionSetConfig->isQuestionAmountConfigurationModePerTest() )
828  {
829  return false;
830  }
831 
832  return true;
833  }
834 }