ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilTestSkillAdministrationGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 
35 {
36  public function __construct(
37  private ilCtrl $ctrl,
38  private ilAccessHandler $access,
39  private ilTabsGUI $tabs,
40  private ilGlobalTemplateInterface $tpl,
41  private ilLanguage $lng,
42  private Refinery $refinery,
43  private ilDBInterface $db,
44  private ilLogger $log,
45  private ilTree $tree,
46  private ilComponentRepository $component_repository,
47  private ilObjTest $test_obj,
48  private QuestionInfoService $questioninfo,
49  private int $ref_id
50  ) {
51  }
52 
53  public function executeCommand()
54  {
55  if ($this->isAccessDenied()) {
56  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_permission"), true);
57  $this->ctrl->setParameterByClass(ilObjTestGUI::class, 'ref_id', $this->ref_id);
58  $this->ctrl->redirectByClass(ilObjTestGUI::class);
59  }
60 
61  $nextClass = $this->ctrl->getNextClass();
62 
63  $this->manageTabs($nextClass);
64 
65  switch ($nextClass) {
66  case 'ilassquestionskillassignmentsgui':
67 
68  $questionContainerId = $this->test_obj->getId();
69 
70  $questionList = new ilAssQuestionList($this->db, $this->lng, $this->refinery, $this->component_repository);
71  $questionList->setParentObjId($questionContainerId);
72  $questionList->setQuestionInstanceTypeFilter($this->getRequiredQuestionInstanceTypeFilter());
73  $questionList->load();
74 
75  $gui = new ilAssQuestionSkillAssignmentsGUI($this->ctrl, $this->access, $this->tpl, $this->lng, $this->db);
76  $gui->setAssignmentEditingEnabled($this->isAssignmentEditingRequired());
77  $gui->setQuestionContainerId($questionContainerId);
78  $gui->setQuestionList($questionList);
79 
80  if ($this->test_obj->isFixedTest()) {
81  $gui->setQuestionOrderSequence($this->test_obj->getQuestions());
82  } else {
83  $gui->setAssignmentConfigurationHintMessage($this->buildAssignmentConfigurationInPoolHintMessage());
84  }
85 
86  $this->ctrl->forwardCommand($gui);
87 
88  break;
89 
90  case 'iltestskilllevelthresholdsgui':
91 
92  $gui = new ilTestSkillLevelThresholdsGUI($this->ctrl, $this->tpl, $this->lng, $this->db, $this->test_obj->getTestId());
93  $gui->setQuestionAssignmentColumnsEnabled(!$this->test_obj->isRandomTest());
94  $gui->setQuestionContainerId($this->test_obj->getId());
95  $this->ctrl->forwardCommand($gui);
96  break;
97  }
98  }
99 
100  private function isAssignmentEditingRequired(): bool
101  {
102  if (!$this->test_obj->isFixedTest()) {
103  return false;
104  }
105 
106  if ($this->test_obj->participantDataExist()) {
107  return false;
108  }
109 
110  return true;
111  }
112 
113  public function manageTabs($activeSubTabId)
114  {
115  $link = $this->ctrl->getLinkTargetByClass(
116  'ilAssQuestionSkillAssignmentsGUI',
118  );
119  $this->tabs->addSubTab(
120  'ilassquestionskillassignmentsgui',
121  $this->lng->txt('qpl_skl_sub_tab_quest_assign'),
122  $link
123  );
124 
125  $link = $this->ctrl->getLinkTargetByClass(
126  'ilTestSkillLevelThresholdsGUI',
128  );
129  $this->tabs->addSubTab(
130  'iltestskilllevelthresholdsgui',
131  $this->lng->txt('tst_skl_sub_tab_thresholds'),
132  $link
133  );
134 
135  $this->tabs->activateTab('tst_tab_competences');
136  $this->tabs->activateSubTab($activeSubTabId);
137  }
138 
139  private function isAccessDenied(): bool
140  {
141  if (!$this->test_obj->isSkillServiceEnabled()) {
142  return true;
143  }
144 
146  return true;
147  }
148 
149  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
150  return true;
151  }
152 
153  return false;
154  }
155 
156  private function getRequiredQuestionInstanceTypeFilter(): ?string
157  {
158  if ($this->test_obj->isRandomTest()) {
160  }
161 
162  return null;
163  }
164 
166  {
167  $question_set_config_factory = new ilTestQuestionSetConfigFactory(
168  $this->tree,
169  $this->db,
170  $this->lng,
171  $this->log,
172  $this->component_repository,
173  $this->test_obj,
174  $this->questioninfo
175  );
176 
177  $question_set_config = $question_set_config_factory->getQuestionSetConfig();
178 
179  if ($this->test_obj->isRandomTest()) {
180  $testMode = $this->lng->txt('tst_question_set_type_random');
181  $poolLinks = $question_set_config->getCommaSeparatedSourceQuestionPoolLinks();
182 
183  return sprintf($this->lng->txt('tst_qst_skl_cfg_in_pool_hint_rndquestset'), $testMode, $poolLinks);
184  }
185 
186  return '';
187  }
188 }
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
$lng
$log
Definition: result.php:33
setQuestionAssignmentColumnsEnabled($questionAssignmentColumnsEnabled)
static isSkillManagementGloballyActivated()
__construct(private ilCtrl $ctrl, private ilAccessHandler $access, private ilTabsGUI $tabs, private ilGlobalTemplateInterface $tpl, private ilLanguage $lng, private Refinery $refinery, private ilDBInterface $db, private ilLogger $log, private ilTree $tree, private ilComponentRepository $component_repository, private ilObjTest $test_obj, private QuestionInfoService $questioninfo, private int $ref_id)
Refinery Factory $refinery