ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilTestTabsManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
31 {
36  public const TAB_ID_QUESTIONS = 'assQuestions';
37  public const SUBTAB_ID_QST_LIST_VIEW = 'qst_list_view';
38  public const SUBTAB_ID_QST_PAGE_VIEW = 'qst_page_view';
39 
40  public const TAB_ID_TEST = 'test';
41  public const TAB_ID_INFOSCREEN = 'info_short';
42  public const TAB_ID_SETTINGS = 'settings';
43  public const SUBTAB_ID_GENERAL_SETTINGS = 'general';
44  public const TAB_ID_LEARNING_PROGRESS = 'learning_progress';
45  public const TAB_ID_MANUAL_SCORING = 'manscoring';
46  public const TAB_ID_CORRECTION = 'scoringadjust';
47  public const TAB_ID_STATISTICS = 'statistics';
48  public const TAB_ID_HISTORY = 'history';
49  public const TAB_ID_META_DATA = 'meta_data';
50  public const TAB_ID_EXPORT = 'export';
51  public const TAB_ID_PERMISSIONS = 'perm_settings';
52 
53  public const TAB_ID_EXAM_DASHBOARD = 'dashboard_tab';
54  public const SUBTAB_ID_FIXED_PARTICIPANTS = 'fixedparticipants';
55  public const SUBTAB_ID_TIME_EXTENSION = 'timeextension';
56 
57  public const TAB_ID_RESULTS = 'results';
58  public const SUBTAB_ID_PARTICIPANTS_RESULTS = 'participantsresults';
59  public const SUBTAB_ID_MY_RESULTS = 'myresults';
60  public const SUBTAB_ID_LO_RESULTS = 'loresults';
61  public const SUBTAB_ID_HIGHSCORE = 'highscore';
62  public const SUBTAB_ID_SKILL_RESULTS = 'skillresults';
63  public const SUBTAB_ID_MY_SOLUTIONS = 'mysolutions';
64 
65  private const SETTINGS_SUBTAB_ID_GENERAL = 'general';
66  private const SETTINGS_SUBTAB_ID_MARK_SCHEMA = 'mark_schema';
67  private const SETTINGS_SUBTAB_ID_SCORING = 'scoring';
68  public const SETTINGS_SUBTAB_ID_EDIT_INTRODUCTION_PAGE = 'edit_introduction';
69  public const SETTINGS_SUBTAB_ID_EDIT_CONCLUSION_PAGE = 'edit_concluding_remarks';
70  private const SETTINGS_SUBTAB_ID_CERTIFICATE = 'certificate';
71  private const SETTINGS_SUBTAB_ID_PERSONAL_DEFAULT_SETTINGS = 'tst_default_settings';
72 
76  protected $test_object;
77 
81  protected $test_session;
82 
87 
91  protected $parent_back_href;
92 
96  protected $parent_back_label;
97 
98  public function __construct(
99  private ilTabsGUI $tabs,
100  private ilLanguage $lng,
101  private ilCtrl $ctrl,
102  private RequestWrapper $wrapper,
103  private Refinery $refinery,
104  private ilAccess $access,
105  private ilTestAccess $test_access,
106  private ilTestObjectiveOrientedContainer $objective_parent
107  ) {
108  }
109 
113  public function activateTab($tabId)
114  {
115  switch ($tabId) {
116  case self::TAB_ID_EXAM_DASHBOARD:
117  case self::TAB_ID_RESULTS:
118  case self::TAB_ID_SETTINGS:
119 
120  $this->tabs->activateTab($tabId);
121  }
122  }
123 
127  public function activateSubTab($subTabId)
128  {
129  switch ($subTabId) {
130  case self::SUBTAB_ID_FIXED_PARTICIPANTS:
131  case self::SUBTAB_ID_TIME_EXTENSION:
132 
133  case self::SUBTAB_ID_PARTICIPANTS_RESULTS:
134  case self::SUBTAB_ID_MY_RESULTS:
135  case self::SUBTAB_ID_LO_RESULTS:
136  case self::SUBTAB_ID_HIGHSCORE:
137  case self::SUBTAB_ID_SKILL_RESULTS:
138  case self::SUBTAB_ID_MY_SOLUTIONS:
139 
140  case self::SUBTAB_ID_QST_LIST_VIEW:
141  case self::SUBTAB_ID_QST_PAGE_VIEW:
142 
143  case self::SETTINGS_SUBTAB_ID_GENERAL:
144  case self::SETTINGS_SUBTAB_ID_MARK_SCHEMA:
145  case self::SETTINGS_SUBTAB_ID_SCORING:
146  case self::SETTINGS_SUBTAB_ID_EDIT_INTRODUCTION_PAGE:
147  case self::SETTINGS_SUBTAB_ID_EDIT_CONCLUSION_PAGE:
148  case self::SETTINGS_SUBTAB_ID_CERTIFICATE:
149  case self::SETTINGS_SUBTAB_ID_PERSONAL_DEFAULT_SETTINGS:
150 
151  $this->tabs->activateSubTab($subTabId);
152  }
153  }
154 
158  public function getTestOBJ(): ilObjTest
159  {
160  return $this->test_object;
161  }
162 
167  {
168  $this->test_object = $test_object;
169  }
170 
174  public function getTestSession(): ilTestSession
175  {
176  return $this->test_session;
177  }
178 
182  public function setTestSession($test_session)
183  {
184  $this->test_session = $test_session;
185  }
186 
191  {
193  }
194 
199  {
200  $this->test_question_set_config = $test_question_set_config;
201  }
202 
206  public function getParentBackLabel(): ?string
207  {
209  }
210 
215  {
216  $this->parent_back_label = $parent_back_label;
217  }
218 
222  public function getParentBackHref(): ?string
223  {
225  }
226 
231  {
232  $this->parent_back_href = $parent_back_href;
233  }
234 
238  public function hasParentBackLink()
239  {
240  if (!is_string($this->getParentBackHref()) || !strlen($this->getParentBackHref())) {
241  return false;
242  }
243 
244  if (!is_string($this->getParentBackLabel()) || !strlen($this->getParentBackLabel())) {
245  return false;
246  }
247 
248  return true;
249  }
250 
254  protected function isReadAccessGranted(): bool
255  {
256  return $this->access->checkAccess('read', '', $this->getTestOBJ()->getRefId());
257  }
258 
262  protected function isWriteAccessGranted(): bool
263  {
264  return $this->access->checkAccess('write', '', $this->getTestOBJ()->getRefId());
265  }
266 
270  protected function isStatisticsAccessGranted(): bool
271  {
272  return $this->access->checkAccess('tst_statistics', '', $this->getTestOBJ()->getRefId());
273  }
274 
278  protected function isPermissionsAccessGranted(): bool
279  {
280  return $this->access->checkAccess('edit_permission', '', $this->getTestOBJ()->getRefId());
281  }
282 
286  protected function isLpAccessGranted(): bool
287  {
288  return ilLearningProgressAccess::checkAccess($this->getTestOBJ()->getRefId());
289  }
290 
294  protected function checkDashboardTabAccess(): bool
295  {
296  if ($this->test_access->checkManageParticipantsAccess()) {
297  return true;
298  }
299 
300  return false;
301  }
302 
306  protected function checkScoreParticipantsTabAccess(): bool
307  {
308  return $this->test_access->checkScoreParticipantsAccess();
309  }
310 
314  protected function checkStatisticsTabAccess(): bool
315  {
316  return $this->test_access->checkStatisticsAccess();
317  }
318 
321  public function perform()
322  {
323  if ($this->isTabsConfigSetupRequired()) {
324  $this->setupTabsGuiConfig();
325  }
326  }
327 
328  protected function isTabsConfigSetupRequired(): bool
329  {
330  if (preg_match('/^ass(.*?)gui$/i', $this->ctrl->getNextClass($this))) {
331  return false;
332  }
333 
334  if ($this->ctrl->getNextClass($this) == 'ilassquestionpagegui') {
335  return false;
336  }
337 
338  if ($this->ctrl->getCmdClass() == 'iltestoutputgui') {
339  return false;
340  }
341 
342  if ($this->ctrl->getCmdClass() == 'iltestevaluationgui') {
343  return in_array($this->ctrl->getCmd(), [
344  '', 'outUserResultsPassOverview', 'outUserListOfAnswerPasses', 'outEvaluation', 'eval_a', 'singleResults', 'detailedEvaluation'
345  ]);
346  }
347 
348  return true;
349  }
350 
351  protected function setupTabsGuiConfig()
352  {
353  if ($this->hasParentBackLink()) {
354  $this->tabs->setBack2Target($this->getParentBackLabel(), $this->getParentBackHref());
355  }
356 
357  switch (strtolower($this->ctrl->getCmdClass())) {
358  case 'ilmarkschemagui':
359  case 'ilobjtestsettingsmaingui':
360  case 'ilobjtestsettingsscoringresultsgui':
361 
362  if ($this->isWriteAccessGranted()) {
363  $this->getSettingsSubTabs();
364  }
365 
366  break;
367  }
368 
369  switch ($this->ctrl->getCmd()) {
370  case 'resume':
371  case 'previous':
372  case 'next':
373  case 'summary':
374  case 'directfeedback':
375  case 'finishTest':
376  case 'outCorrectSolution':
377  case 'passDetails':
378  case 'showAnswersOfUser':
379  case 'backFromSummary':
380  case 'show_answers':
381  case 'setsolved':
382  case 'resetsolved':
383  case 'confirmFinish':
384  case 'outTestSummary':
385  case 'outQuestionSummary':
386  case 'gotoQuestion':
387  case 'selectImagemapRegion':
388  case 'confirmSubmitAnswers':
389  case 'finalSubmission':
390  case 'postpone':
391  case 'outUserPassDetails':
392  case 'checkPassword':
393  case 'exportCertificate':
394  case 'finishListOfAnswers':
395  case 'backConfirmFinish':
396  case 'showFinalStatement':
397  return;
398  case 'browseForQuestions':
399  case 'filter':
400  case 'resetFilter':
401  case 'resetTextFilter':
402  case 'insertQuestions':
403  $classes = [
404  'iltestdashboardgui',
405  'iltestresultsgui',
406  'illearningprogressgui' // #8497: resetfilter is also used in lp
407  ];
408  if (!in_array($this->ctrl->getNextClass($this), $classes)) {
409  $this->getBrowseForQuestionsTab();
410  }
411  break;
412  case 'scoring':
413  case 'certificate':
414  case 'certificateservice':
415  case 'certificateImport':
416  case 'certificateUpload':
417  case 'certificateEditor':
418  case 'certificateDelete':
419  case 'certificateSave':
420  case 'defaults':
421  case 'deleteDefaults':
422  case 'addDefaults':
423  case 'applyDefaults':
424  case 'inviteParticipants':
425  case 'searchParticipants':
426  if ($this->isWriteAccessGranted() && in_array(strtolower($this->ctrl->getCmdClass()), ['ilobjtestgui', 'ilcertificategui'])) {
427  $this->getSettingsSubTabs();
428  }
429  break;
430  case 'export':
431  case 'print':
432  break;
433  case 'statistics':
434  case 'eval_a':
435  case 'detailedEvaluation':
436  case 'outEvaluation':
437  case 'singleResults':
438  case 'exportEvaluation':
439  case 'evalUserDetail':
440  case 'outStatisticsResultsOverview':
441  case 'statisticsPassDetails':
442  case 'exportCertificateArchive':
443  $this->getStatisticsSubTabs();
444  break;
445  }
446 
447  // test tab
448  if ($this->isReadAccessGranted()) {
449  $this->tabs->addTab(
450  self::TAB_ID_TEST,
451  $this->lng->txt('test'),
452  $this->ctrl->getLinkTargetByClass(ilTestScreenGUI::class, ilTestScreenGUI::DEFAULT_CMD)
453  );
454  }
455 
456  // questions tab
457  if ($this->isWriteAccessGranted()) {
458  $up = $this->wrapper->has('up')
459  && $this->wrapper->retrieve('up', $this->refinery->string()) !== '';
460  $down = $this->wrapper->has('down')
461  && $this->wrapper->retrieve('down', $this->refinery->string()) !== '';
462  $browse = $this->wrapper->has('browse')
463  && $this->wrapper->retrieve('browse', $this->refinery->int()) === 1;
464 
465  $force_active = ($up || $down || $browse) ? true : false;
466 
467  if ($this->getTestOBJ()->isFixedTest()) {
468  $target = $this->ctrl->getLinkTargetByClass(
469  'ilObjTestGUI',
470  'questions'
471  );
472  }
473 
474  if ($this->getTestOBJ()->isRandomTest()) {
475  $target = $this->ctrl->getLinkTargetByClass('ilTestRandomQuestionSetConfigGUI');
476  }
477 
478  $this->tabs->addTarget(
479  'assQuestions',
480  $target,
481  [
482  'questions', 'browseForQuestions', 'questionBrowser', 'createQuestion',
483  'filter', 'resetFilter', 'insertQuestions',
484  'back', 'removeQuestions', 'moveQuestions',
485  'insertQuestionsBefore', 'insertQuestionsAfter', 'confirmRemoveQuestions',
486  'cancelRemoveQuestions', 'executeCreateQuestion', 'cancelCreateQuestion',
487  'addQuestionpool', 'saveRandomQuestions', 'saveQuestionSelectionMode', 'print',
488  'addsource', 'removesource', 'randomQuestions'
489  ],
490  '',
491  '',
492  $force_active
493  );
494  }
495 
496  // info tab
497  if ($this->isReadAccessGranted() && !$this->getTestOBJ()->getMainSettings()->getAdditionalSettings()->getHideInfoTab()) {
498  $this->tabs->addTarget(
499  'info_short',
500  $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'infoScreen'),
501  ['infoScreen', 'outIntroductionPage', 'showSummary',
502  'setAnonymousId', 'redirectToInfoScreen']
503  );
504  }
505 
506  // settings tab
507  if ($this->isWriteAccessGranted()) {
508  $settingsCommands = [
509  'marks', 'showMarkSchema','addMarkStep', 'deleteMarkSteps',
510  'resetToSimpleMarkSchema', 'saveMarks', 'certificate',
511  'certificateEditor', 'certificateRemoveBackground', 'certificateSave',
512  'certificatePreview', 'certificateDelete', 'certificateUpload', 'certificateImport',
513  'scoring', 'defaults', 'addDefaults', 'deleteDefaults', 'applyDefaults',
514  'inviteParticipants', 'saveFixedParticipantsStatus', 'searchParticipants', 'addParticipants' // ARE THEY RIGHT HERE
515  ];
516 
517  $reflection = new ReflectionClass('ilObjTestSettingsMainGUI');
518  foreach ($reflection->getConstants() as $name => $value) {
519  if (substr($name, 0, 4) === 'CMD_') {
520  $settingsCommands[] = $value;
521  }
522  }
523 
524  $reflection = new ReflectionClass('ilObjTestSettingsScoringResultsGUI');
525  foreach ($reflection->getConstants() as $name => $value) {
526  if (substr($name, 0, 4) === 'CMD_') {
527  $settingsCommands[] = $value;
528  }
529  }
530 
531  $settingsCommands[] = ''; // DO NOT KNOW WHAT THIS IS DOING, BUT IT'S REQUIRED
532 
533  $this->tabs->addTarget(
534  'settings',
535  $this->ctrl->getLinkTargetByClass('ilObjTestSettingsMainGUI'),
536  $settingsCommands,
537  [
538  'ilmarkschemagui',
539  'ilobjtestsettingsmaingui',
540  'ilobjtestsettingsscoringresultsgui',
541  'ilobjtestgui',
542  'ilcertificategui'
543  ]
544  );
545 
546  // skill service
547  if ($this->getTestOBJ()->isSkillServiceToBeConsidered()) {
548  $link = $this->ctrl->getLinkTargetByClass(
549  ['ilTestSkillAdministrationGUI', 'ilAssQuestionSkillAssignmentsGUI'],
551  );
552 
553  $this->tabs->addTarget('tst_tab_competences', $link, [], []);
554  }
555  }
556 
557  if ($this->needsDashboardTab()) {
558  $this->tabs->addTab(
559  self::TAB_ID_EXAM_DASHBOARD,
560  $this->lng->txt('dashboard_tab'),
561  $this->getDashboardTabTarget()
562  );
563  }
564 
565  if ($this->needsResultsTab()) {
566  $this->tabs->addTab(
567  self::TAB_ID_RESULTS,
568  $this->lng->txt('results_tab'),
569  $this->getResultsTabTarget()
570  );
571  }
572 
573  if ($this->isLpAccessGranted()) {
574  $this->tabs->addTarget(
575  self::TAB_ID_LEARNING_PROGRESS,
576  $this->ctrl->getLinkTargetByClass(['illearningprogressgui'], ''),
577  '',
578  [
579  'illplistofobjectsgui',
580  'illplistofsettingsgui',
581  'illearningprogressgui',
582  'illplistofprogressgui'
583  ]
584  );
585  }
586 
587  if ($this->checkScoreParticipantsTabAccess()) {
589  if (count($scoring)) {
590  // scoring tab
591  $this->tabs->addTarget(
592  self::TAB_ID_MANUAL_SCORING,
593  $this->ctrl->getLinkTargetByClass(
594  'ilTestScoringByQuestionsGUI',
595  'showManScoringByQuestionParticipantsTable'
596  ),
597  [
598  'showManScoringParticipantsTable',
599  'applyManScoringParticipantsFilter',
600  'resetManScoringParticipantsFilter',
601  'showManScoringParticipantScreen',
602  'showManScoringByQuestionParticipantsTable',
603  'applyManScoringByQuestionFilter',
604  'resetManScoringByQuestionFilter',
605  'saveManScoringByQuestion'
606  ],
607  ''
608  );
609  }
610  }
611 
612  // NEW CORRECTIONS TAB
613  $setting = new ilSetting('assessment');
614  $scoring_adjust_active = (bool) $setting->get('assessment_adjustments_enabled', '0');
615  if ($this->isWriteAccessGranted() && $scoring_adjust_active) {
616  $this->tabs->addTab(
617  self::TAB_ID_CORRECTION,
618  $this->lng->txt(self::TAB_ID_CORRECTION),
619  $this->ctrl->getLinkTargetByClass('ilTestCorrectionsGUI')
620  );
621  }
622 
623  if ($this->checkStatisticsTabAccess()) {
624  // statistics tab
625  $this->tabs->addTarget(
626  self::TAB_ID_STATISTICS,
627  $this->ctrl->getLinkTargetByClass(
628  [ilRepositoryGUI::class, ilObjTestGUI::class, ilTestEvaluationGUI::class],
629  'outEvaluation'
630  ),
631  [
632  'statistics',
633  'outEvaluation',
634  'exportEvaluation',
635  'detailedEvaluation',
636  'eval_a',
637  'evalUserDetail',
638  'passDetails',
639  'outStatisticsResultsOverview',
640  'statisticsPassDetails',
641  'singleResults'
642  ],
643  ''
644  );
645  }
646 
647  if ($this->isWriteAccessGranted()) {
648  $this->tabs->addTarget(
649  self::TAB_ID_HISTORY,
650  $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'history'),
651  'history',
652  ''
653  );
654 
655  $mdgui = new ilObjectMetaDataGUI($this->getTestOBJ());
656  $mdtab = $mdgui->getTab();
657  if ($mdtab) {
658  $this->tabs->addTarget(
659  self::TAB_ID_META_DATA,
660  $mdtab,
661  '',
662  'ilmdeditorgui'
663  );
664  }
665 
666  $this->tabs->addTarget(
667  self::TAB_ID_EXPORT,
668  $this->ctrl->getLinkTargetByClass('iltestexportgui', ''),
669  '',
670  ['iltestexportgui']
671  );
672  }
673 
674  if ($this->isPermissionsAccessGranted()) {
675  $this->tabs->addTarget(
676  self::TAB_ID_PERMISSIONS,
677  $this->ctrl->getLinkTargetByClass(['ilObjTestGUI','ilpermissiongui'], 'perm'),
678  ['perm','info','owner'],
679  'ilpermissiongui'
680  );
681  }
682 
683  if ($this->getTestQuestionSetConfig()->areDepenciesBroken()) {
684  $hideTabs = $this->getTestQuestionSetConfig()->getHiddenTabsOnBrokenDepencies();
685 
686  foreach ($hideTabs as $tabId) {
687  $this->tabs->removeTab($tabId);
688  }
689  }
690  }
691 
692  protected function getBrowseForQuestionsTab()
693  {
694  if ($this->isWriteAccessGranted()) {
695  $this->ctrl->saveParameterByClass($this->ctrl->getCmdClass(), 'q_id');
696  // edit page
697  $this->tabs->setBackTarget(
698  $this->lng->txt('backtocallingtest'),
699  $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), 'questions')
700  );
701  $this->tabs->addTarget(
702  'tst_browse_for_questions',
703  $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'browseForQuestions'),
704  ['browseForQuestions', 'filter', 'resetFilter', 'resetTextFilter', 'insertQuestions'],
705  '',
706  '',
707  true
708  );
709  }
710  }
711 
712  protected function getRandomQuestionsTab()
713  {
714  if ($this->isWriteAccessGranted()) {
715  // edit page
716  $this->tabs->setBackTarget($this->lng->txt('backtocallingtest'), $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'questions'));
717  $this->tabs->addTarget(
718  'random_selection',
719  $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'randomQuestions'),
720  ['randomQuestions'],
721  '',
722  ''
723  );
724  }
725  }
726 
727  public function getQuestionsSubTabs()
728  {
729  $this->tabs->activateTab(self::TAB_ID_QUESTIONS);
730 
731  $this->tabs->addSubTab(
732  self::SUBTAB_ID_QST_LIST_VIEW,
733  $this->lng->txt('edit_test_questions'),
734  $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'questions')
735  );
736 
737  // print view subtab
738  if (!$this->getTestOBJ()->isRandomTest()) {
739  $this->tabs->addSubTabTarget(
740  'print_view',
741  $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'print'),
742  'print',
743  '',
744  '',
745  $this->ctrl->getCmd() == 'print'
746  );
747  $this->tabs->addSubTabTarget(
748  'review_view',
749  $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'review'),
750  'review',
751  '',
752  '',
753  $this->ctrl->getCmd() == 'review'
754  );
755  }
756  }
757 
758  protected function getStatisticsSubTabs()
759  {
760  $this->tabs->addSubTabTarget(
761  'eval_all_users',
762  $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outEvaluation'),
763  ['outEvaluation', 'detailedEvaluation', 'exportEvaluation', 'evalUserDetail', 'passDetails',
764  'outStatisticsResultsOverview', 'statisticsPassDetails', 'exportCertificateArchive'],
765  ''
766  );
767 
768  // aggregated results subtab
769  $this->tabs->addSubTabTarget(
770  'tst_results_aggregated',
771  $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'eval_a'),
772  ['eval_a'],
773  '',
774  ''
775  );
776 
777  // question export
778  $this->tabs->addSubTabTarget(
779  'tst_single_results',
780  $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'singleResults'),
781  ['singleResults'],
782  '',
783  ''
784  );
785  }
786 
787  public function getSettingsSubTabs()
788  {
789  $this->tabs->addSubTabTarget(
790  self::SETTINGS_SUBTAB_ID_GENERAL,
791  $this->ctrl->getLinkTargetByClass('ilObjTestSettingsMainGUI'),
792  '', // auto activation regardless from cmd
793  ['ilobjtestsettingsmaingui'] // auto activation for ilObjTestSettingsGeneralGUI
794  );
795 
796  $this->tabs->addSubTabTarget(
797  self::SETTINGS_SUBTAB_ID_MARK_SCHEMA,
798  $this->ctrl->getLinkTargetByClass('ilmarkschemagui', 'showMarkSchema'),
799  '',
800  ['ilmarkschemagui']
801  );
802 
803  $this->tabs->addSubTabTarget(
804  self::SETTINGS_SUBTAB_ID_SCORING,
805  $this->ctrl->getLinkTargetByClass('ilObjTestSettingsScoringResultsGUI'),
806  '', // auto activation regardless from cmd
807  ['ilobjtestsettingsscoringresultsgui'] // auto activation for ilObjTestSettingsScoringResultsGUI
808  );
809 
810  $this->ctrl->setParameterByClass(ilTestPageGUI::class, 'page_type', 'introductionpage');
811  $this->tabs->addSubTabTarget(
812  self::SETTINGS_SUBTAB_ID_EDIT_INTRODUCTION_PAGE,
813  $this->ctrl->getLinkTargetByClass(ilTestPageGUI::class, 'preview'),
814  ['iltestpagegui']
815  );
816 
817  $this->ctrl->setParameterByClass(ilTestPageGUI::class, 'page_type', 'concludingremarkspage');
818  $this->tabs->addSubTabTarget(
819  self::SETTINGS_SUBTAB_ID_EDIT_CONCLUSION_PAGE,
820  $this->ctrl->getLinkTargetByClass(ilTestPageGUI::class, 'preview'),
821  ['iltestpagegui']
822  );
823  $this->ctrl->clearParameterByClass(ilTestPageGUI::class, 'page_type');
824 
825  $validator = new ilCertificateActiveValidator();
826  if ($validator->validate() === true) {
827  $this->tabs->addSubTabTarget(
828  self::SETTINGS_SUBTAB_ID_CERTIFICATE,
829  $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'certificate'),
830  ['certificate', 'certificateEditor', 'certificateRemoveBackground', 'ceateSave',
831  'certificatePreview', 'certificateDelete', 'certificateUpload', 'certificateImport'],
832  ['', 'ilobjtestgui', 'ilcertificategui']
833  );
834  }
835 
836  $this->tabs->addSubTabTarget(
837  self::SETTINGS_SUBTAB_ID_PERSONAL_DEFAULT_SETTINGS,
838  $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'defaults'),
839  ['defaults', 'deleteDefaults', 'addDefaults', 'applyDefaults'],
840  ['', 'ilobjtestgui', 'ilcertificategui']
841  );
842 
843  $lti_settings = new ilLTIProviderObjectSettingGUI($this->test_object->getRefId());
844  if ($lti_settings->hasSettingsAccess()) {
845  $this->tabs->addSubTabTarget(
846  'lti_provider',
847  $this->ctrl->getLinkTargetByClass(ilLTIProviderObjectSettingGUI::class),
848  '',
849  [ilLTIProviderObjectSettingGUI::class]
850  );
851  }
852  }
853 
857  protected function needsDashboardTab(): bool
858  {
859  if (!$this->checkDashboardTabAccess()) {
860  return false;
861  }
862 
863  return true;
864  }
865 
869  protected function needsTimeExtensionSubTab(): bool
870  {
871  if (!($this->getTestOBJ()->getProcessingTimeInSeconds() > 0)) {
872  return false;
873  }
874 
875  if ($this->getTestOBJ()->getNrOfTries() != 1) {
876  return false;
877  }
878 
879  if ($this->getTestQuestionSetConfig()->areDepenciesBroken()) {
880  return false;
881  }
882 
883  return true;
884  }
885 
889  protected function getDashboardTabTarget(): string
890  {
891  return $this->ctrl->getLinkTargetByClass(['ilTestDashboardGUI', 'ilTestParticipantsGUI']);
892  }
893 
894  public function getDashboardSubTabs()
895  {
896  if (!$this->test_access->checkManageParticipantsAccess()) {
897  return;
898  }
899 
900  $this->tabs->addSubTab(
901  self::SUBTAB_ID_FIXED_PARTICIPANTS,
903  $this->ctrl->getLinkTargetByClass('ilTestParticipantsGUI')
904  );
905 
906  if ($this->needsTimeExtensionSubTab()) {
907  $this->tabs->addSubTab(
908  self::SUBTAB_ID_TIME_EXTENSION,
909  $this->lng->txt('timing'),
910  $this->ctrl->getLinkTargetByClass('ilTestParticipantsTimeExtensionGUI')
911  );
912  }
913  }
914 
915  protected function getDashbardParticipantsSubTabLabel(): string
916  {
917  if ($this->getTestOBJ()->getFixedParticipants()) {
918  return $this->lng->txt('fixedparticipants_subtab');
919  }
920 
921  return $this->lng->txt('autoparticipants_subtab');
922  }
923 
927  protected function needsResultsTab(): bool
928  {
929  return $this->needsParticipantsResultsSubTab() || $this->test_object->isScoreReportingEnabled() || $this->needsMySolutionsSubTab();
930  }
931 
935  protected function getResultsTabTarget(): string
936  {
937  if ($this->needsParticipantsResultsSubTab()) {
938  return $this->ctrl->getLinkTargetByClass(['ilTestResultsGUI', 'ilParticipantsTestResultsGUI']);
939  }
940 
941  if ($this->needsLoResultsSubTab()) {
942  return $this->ctrl->getLinkTargetByClass(['ilTestResultsGUI', 'ilTestEvalObjectiveOrientedGUI']);
943  }
944 
945  if ($this->needsMyResultsSubTab()) {
946  return $this->ctrl->getLinkTargetByClass(['ilTestResultsGUI', 'ilMyTestResultsGUI', 'ilTestEvaluationGUI']);
947  }
948 
949  if ($this->needsMySolutionsSubTab()) {
950  return $this->ctrl->getLinkTargetByClass(['ilTestResultsGUI', 'ilMyTestSolutionsGUI', 'ilTestEvaluationGUI']);
951  }
952 
953  return $this->ctrl->getLinkTargetByClass('ilTestResultsGUI');
954  }
955 
959  public function needsMyResultsSubTab(): bool
960  {
961  return $this->getTestSession()->reportableResultsAvailable($this->getTestOBJ());
962  }
963 
967  public function needsLoResultsSubTab(): bool
968  {
969  if (!$this->needsMyResultsSubTab()) {
970  return false;
971  }
972 
973  return $this->objective_parent->isObjectiveOrientedPresentationRequired();
974  }
975 
979  public function needsParticipantsResultsSubTab(): bool
980  {
981  if ($this->test_access->checkParticipantsResultsAccess()) {
982  return true;
983  }
984 
985  return false;
986  }
987 
991  public function needsHighSoreSubTab(): bool
992  {
993  if (!$this->needsMyResultsSubTab()) {
994  return false;
995  }
996 
997  return $this->getTestOBJ()->getHighscoreEnabled();
998  }
999 
1003  public function needsSkillResultsSubTab(): bool
1004  {
1005  if (!$this->needsMyResultsSubTab()) {
1006  return false;
1007  }
1008 
1009  return $this->getTestOBJ()->isSkillServiceToBeConsidered();
1010  }
1011 
1012  public function needsMySolutionsSubTab(): bool
1013  {
1014  return $this->getTestOBJ()->canShowSolutionPrintview($this->getTestSession()->getUserId());
1015  }
1016 
1017  public function getResultsSubTabs()
1018  {
1019  if ($this->needsParticipantsResultsSubTab()) {
1020  $this->tabs->addSubTab(
1021  self::SUBTAB_ID_PARTICIPANTS_RESULTS,
1022  $this->lng->txt('participants_results_subtab'),
1023  $this->ctrl->getLinkTargetByClass(['ilTestResultsGUI', 'ilParticipantsTestResultsGUI'])
1024  );
1025  }
1026 
1027  if ($this->needsLoResultsSubTab()) {
1028  $this->tabs->addSubTab(
1029  self::SUBTAB_ID_LO_RESULTS,
1030  $this->lng->txt('tst_tab_results_objective_oriented'),
1031  $this->ctrl->getLinkTargetByClass(['ilTestResultsGUI', 'ilTestEvalObjectiveOrientedGUI'])
1032  );
1033  }
1034 
1035  if ($this->needsMyResultsSubTab()) {
1036  $myResultsLabel = $this->lng->txt('tst_show_results');
1037 
1038  if ($this->needsLoResultsSubTab()) {
1039  $myResultsLabel = $this->lng->txt('tst_tab_results_pass_oriented');
1040  }
1041 
1042  $this->tabs->addSubTab(
1043  self::SUBTAB_ID_MY_RESULTS,
1044  $myResultsLabel,
1045  $this->ctrl->getLinkTargetByClass(['ilTestResultsGUI', 'ilMyTestResultsGUI', 'ilTestEvaluationGUI'])
1046  );
1047  }
1048 
1049  if ($this->needsSkillResultsSubTab()) {
1050  $this->tabs->addSubTab(
1051  self::SUBTAB_ID_SKILL_RESULTS,
1052  $this->lng->txt('tst_show_comp_results'),
1053  $this->ctrl->getLinkTargetByClass(['ilTestResultsGUI', 'ilTestSkillEvaluationGUI'])
1054  );
1055  }
1056 
1057  if ($this->needsHighSoreSubTab()) {
1058  $this->tabs->addSubTab(
1059  self::SUBTAB_ID_HIGHSCORE,
1060  $this->lng->txt('tst_show_toplist'),
1061  $this->ctrl->getLinkTargetByClass(['ilTestResultsGUI', 'ilTestToplistGUI'], 'outResultsToplist')
1062  );
1063  }
1064 
1065  if ($this->needsMySolutionsSubTab()) {
1066  $this->tabs->addSubTab(
1067  self::SUBTAB_ID_MY_SOLUTIONS,
1068  $this->lng->txt('tst_list_of_answers_show'),
1069  $this->ctrl->getLinkTargetByClass(['ilTestResultsGUI', 'ilMyTestSolutionsGUI', 'ilTestEvaluationGUI'])
1070  );
1071  }
1072  }
1073 }
setTestOBJ(ilObjTest $test_object)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SETTINGS_SUBTAB_ID_PERSONAL_DEFAULT_SETTINGS
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TAB_ID_QUESTIONS
(Sub-)Tab ID constants
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lng
Interface RequestWrapper.
setParentBackLabel($parent_back_label)
setParentBackHref($parent_back_href)
__construct(private ilTabsGUI $tabs, private ilLanguage $lng, private ilCtrl $ctrl, private RequestWrapper $wrapper, private Refinery $refinery, private ilAccess $access, private ilTestAccess $test_access, private ilTestObjectiveOrientedContainer $objective_parent)
static _getManualScoring()
Retrieve the manual scoring settings.
setTestQuestionSetConfig(ilTestQuestionSetConfig $test_question_set_config)
Refinery Factory $refinery