ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTestSkillAdministrationGUI.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/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentsGUI.php';
5 require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdsGUI.php';
6 
8 
19 {
23  private $ilias;
24 
28  private $ctrl;
29 
33  private $access;
34 
38  private $tabs;
39 
43  private $tpl;
44 
48  private $lng;
49 
53  private $db;
54 
58  protected $refinery;
59 
63  private $tree;
64 
68  private $pluginAdmin;
69 
73  private $testOBJ;
74 
76  {
77  $this->ilias = $ilias;
78  $this->ctrl = $ctrl;
79  $this->access = $access;
80  $this->tabs = $tabs;
81  $this->tpl = $tpl;
82  $this->lng = $lng;
83  $this->refinery = $refinery;
84  $this->db = $db;
85  $this->tree = $tree;
86  $this->pluginAdmin = $pluginAdmin;
87  $this->testOBJ = $testOBJ;
88  $this->refId = $refId;
89  }
90 
91  public function executeCommand()
92  {
93  if ($this->isAccessDenied()) {
94  $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
95  }
96 
97  $nextClass = $this->ctrl->getNextClass();
98 
99  $this->manageTabs($nextClass);
100 
101  switch ($nextClass) {
102  case 'ilassquestionskillassignmentsgui':
103 
104  $questionContainerId = $this->getQuestionContainerId();
105 
106  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
107  $questionList = new ilAssQuestionList($this->db, $this->lng, $this->refinery, $this->pluginAdmin);
108  $questionList->setParentObjId($questionContainerId);
109  $questionList->setQuestionInstanceTypeFilter($this->getRequiredQuestionInstanceTypeFilter());
110  $questionList->load();
111 
112  $gui = new ilAssQuestionSkillAssignmentsGUI($this->ctrl, $this->access, $this->tpl, $this->lng, $this->db);
113  $gui->setAssignmentEditingEnabled($this->isAssignmentEditingRequired());
114  $gui->setQuestionContainerId($questionContainerId);
115  $gui->setQuestionList($questionList);
116 
117  if ($this->testOBJ->isFixedTest()) {
118  $gui->setQuestionOrderSequence($this->testOBJ->getQuestions());
119  } else {
120  $gui->setAssignmentConfigurationHintMessage($this->buildAssignmentConfigurationInPoolHintMessage());
121  }
122 
123  $this->ctrl->forwardCommand($gui);
124 
125  break;
126 
127  case 'iltestskilllevelthresholdsgui':
128 
129  $gui = new ilTestSkillLevelThresholdsGUI($this->ctrl, $this->tpl, $this->lng, $this->db, $this->testOBJ->getTestId());
130  $gui->setQuestionAssignmentColumnsEnabled(!$this->testOBJ->isRandomTest());
131  $gui->setQuestionContainerId($this->getQuestionContainerId());
132  $this->ctrl->forwardCommand($gui);
133  break;
134  }
135  }
136 
137  private function isAssignmentEditingRequired()
138  {
139  if (!$this->testOBJ->isFixedTest()) {
140  return false;
141  }
142 
143  if ($this->testOBJ->participantDataExist()) {
144  return false;
145  }
146 
147  return true;
148  }
149 
150  public function manageTabs($activeSubTabId)
151  {
152  $link = $this->ctrl->getLinkTargetByClass(
153  'ilAssQuestionSkillAssignmentsGUI',
155  );
156  $this->tabs->addSubTab(
157  'ilassquestionskillassignmentsgui',
158  $this->lng->txt('qpl_skl_sub_tab_quest_assign'),
159  $link
160  );
161 
162  $link = $this->ctrl->getLinkTargetByClass(
163  'ilTestSkillLevelThresholdsGUI',
165  );
166  $this->tabs->addSubTab(
167  'iltestskilllevelthresholdsgui',
168  $this->lng->txt('tst_skl_sub_tab_thresholds'),
169  $link
170  );
171 
172  $this->tabs->activateTab('tst_tab_competences');
173  $this->tabs->activateSubTab($activeSubTabId);
174  }
175 
176  private function isAccessDenied()
177  {
178  if (!$this->testOBJ->isSkillServiceEnabled()) {
179  return true;
180  }
181 
183  return true;
184  }
185 
186  if (!$this->access->checkAccess('write', '', $this->refId)) {
187  return true;
188  }
189 
190  return false;
191  }
192 
193  private function getQuestionContainerId()
194  {
195  if ($this->testOBJ->isDynamicTest()) {
196  $questionSetConfigFactory = new ilTestQuestionSetConfigFactory(
197  $this->tree,
198  $this->db,
199  $this->pluginAdmin,
200  $this->testOBJ
201  );
202 
203  $questionSetConfig = $questionSetConfigFactory->getQuestionSetConfig();
204 
205  return $questionSetConfig->getSourceQuestionPoolId();
206  }
207 
208  return $this->testOBJ->getId();
209  }
210 
212  {
213  if ($this->testOBJ->isDynamicTest()) {
215  }
216 
217  if ($this->testOBJ->isRandomTest()) {
219  }
220 
221  return null;
222  }
223 
225  {
226  $questionSetConfigFactory = new ilTestQuestionSetConfigFactory(
227  $this->tree,
228  $this->db,
229  $this->pluginAdmin,
230  $this->testOBJ
231  );
232 
233  $questionSetConfig = $questionSetConfigFactory->getQuestionSetConfig();
234 
235  if ($this->testOBJ->isRandomTest()) {
236  $testMode = $this->lng->txt('tst_question_set_type_random');
237  $poolLinks = $questionSetConfig->getCommaSeparatedSourceQuestionPoolLinks();
238 
239  return sprintf($this->lng->txt('tst_qst_skl_cfg_in_pool_hint_rndquestset'), $testMode, $poolLinks);
240  } elseif ($this->testOBJ->isDynamicTest()) {
241  $testMode = $this->lng->txt('tst_question_set_type_dynamic');
242  $poolLink = $questionSetConfig->getSourceQuestionPoolLink($questionSetConfig->getSourceQuestionPoolId());
243 
244  return sprintf($this->lng->txt('tst_qst_skl_cfg_in_pool_hint_dynquestset'), $testMode, $poolLink);
245  }
246 
247  return '';
248  }
249 }
__construct(ILIAS $ilias, ilCtrl $ctrl, ilAccessHandler $access, ilTabsGUI $tabs, ilGlobalTemplateInterface $tpl, ilLanguage $lng, \ILIAS\Refinery\Factory $refinery, ilDBInterface $db, ilTree $tree, ilPluginAdmin $pluginAdmin, ilObjTest $testOBJ, $refId)
This class provides processing control methods.
Tabs GUI.
Class ChatMainBarProvider .
$refId
Definition: xapitoken.php:40
Administration class for plugins.
setQuestionAssignmentColumnsEnabled($questionAssignmentColumnsEnabled)
redirection script todo: (a better solution should control the processing via a xml file) ...
static isSkillManagementGloballyActivated()