ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestResultsGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
21 {
22  const DEFAULT_CMD = 'show';
23 
27  protected $testObj;
28 
32  protected $questionSetConfig;
33 
37  protected $testAccess;
38 
42  protected $testSession;
43 
47  protected $testTabs;
48 
52  protected $objectiveParent;
53 
59  {
60  $this->testObj = $testObj;
61  $this->questionSetConfig = $questionSetConfig;
62  }
63 
67  public function getObjectiveParent()
68  {
70  }
71 
76  {
77  $this->objectiveParent = $objectiveParent;
78  }
79 
83  public function getTestObj()
84  {
85  return $this->testObj;
86  }
87 
91  public function setTestObj($testObj)
92  {
93  $this->testObj = $testObj;
94  }
95 
99  public function getQuestionSetConfig()
100  {
102  }
103 
108  {
109  $this->questionSetConfig = $questionSetConfig;
110  }
111 
115  public function getTestAccess()
116  {
117  return $this->testAccess;
118  }
119 
123  public function setTestAccess($testAccess)
124  {
125  $this->testAccess = $testAccess;
126  }
127 
131  public function getTestSession()
132  {
133  return $this->testSession;
134  }
135 
139  public function setTestSession($testSession)
140  {
141  $this->testSession = $testSession;
142  }
143 
147  public function getTestTabs()
148  {
149  return $this->testTabs;
150  }
151 
155  public function setTestTabs($testTabs)
156  {
157  $this->testTabs = $testTabs;
158  }
159 
163  public function executeCommand()
164  {
165  global $DIC; /* @var ILIAS\DI\Container $DIC */
166 
167  $this->getTestTabs()->activateTab(ilTestTabsManager::TAB_ID_RESULTS);
168  $this->getTestTabs()->getResultsSubTabs();
169 
170  switch ($DIC->ctrl()->getNextClass()) {
171  case 'ilparticipantstestresultsgui':
172 
173  if (!$this->getTestAccess()->checkManageParticipantsAccess() && !$this->getTestAccess()->checkParticipantsResultsAccess()) {
175  }
176 
178 
179  require_once 'Modules/Test/classes/class.ilParticipantsTestResultsGUI.php';
180  $gui = new ilParticipantsTestResultsGUI();
181  $gui->setTestObj($this->getTestObj());
182  $gui->setQuestionSetConfig($this->getQuestionSetConfig());
183  $gui->setTestAccess($this->getTestAccess());
184  $gui->setObjectiveParent($this->getObjectiveParent());
185  $DIC->ctrl()->forwardCommand($gui);
186  break;
187 
188  case 'ilmytestresultsgui':
189 
190  if (!$this->getTestTabs()->needsMyResultsSubTab()) {
192  }
193 
194  $this->getTestTabs()->activateSubTab(ilTestTabsManager::SUBTAB_ID_MY_RESULTS);
195 
196  require_once 'Modules/Test/classes/class.ilMyTestResultsGUI.php';
197  $gui = new ilMyTestResultsGUI();
198  $gui->setTestObj($this->getTestObj());
199  $gui->setTestAccess($this->getTestAccess());
200  $gui->setTestSession($this->getTestSession());
201  $gui->setObjectiveParent($this->getObjectiveParent());
202  $DIC->ctrl()->forwardCommand($gui);
203  break;
204 
205  case 'iltestevalobjectiveorientedgui':
206 
207  if (!$this->getTestTabs()->needsLoResultsSubTab()) {
209  }
210 
211  $this->getTestTabs()->activateSubTab(ilTestTabsManager::SUBTAB_ID_LO_RESULTS);
212 
213  require_once 'Modules/Test/classes/class.ilTestEvalObjectiveOrientedGUI.php';
214  $gui = new ilTestEvalObjectiveOrientedGUI($this->getTestObj());
215  $gui->setObjectiveOrientedContainer($this->getObjectiveParent());
216  $DIC->ctrl()->forwardCommand($gui);
217  break;
218 
219  case 'ilmytestsolutionsgui':
220 
221  if (!$this->getTestTabs()->needsMySolutionsSubTab()) {
223  }
224 
225  $this->getTestTabs()->activateSubTab(ilTestTabsManager::SUBTAB_ID_MY_SOLUTIONS);
226 
227  require_once 'Modules/Test/classes/class.ilMyTestSolutionsGUI.php';
228  $gui = new ilMyTestSolutionsGUI();
229  $gui->setTestObj($this->getTestObj());
230  $gui->setTestAccess($this->getTestAccess());
231  $gui->setObjectiveParent($this->getObjectiveParent());
232  $DIC->ctrl()->forwardCommand($gui);
233  break;
234 
235  case 'iltesttoplistgui':
236 
237  if (!$this->getTestTabs()->needsHighSoreSubTab()) {
239  }
240 
241  $this->getTestTabs()->activateSubTab(ilTestTabsManager::SUBTAB_ID_HIGHSCORE);
242 
243  require_once './Modules/Test/classes/class.ilTestToplistGUI.php';
244  $gui = new ilTestToplistGUI($this->getTestObj());
245  $DIC->ctrl()->forwardCommand($gui);
246  break;
247 
248  case 'iltestskillevaluationgui':
249 
251 
252  global $DIC; /* @var ILIAS\DI\Container $DIC */
253  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
254  if ($this->getTestObj()->isDynamicTest()) {
255  require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfig.php';
256  $dynamicQuestionSetConfig = new ilObjTestDynamicQuestionSetConfig(
257  $DIC->repositoryTree(),
258  $DIC->database(),
259  $DIC['ilPluginAdmin'],
260  $this->getTestObj()
261  );
262  $dynamicQuestionSetConfig->loadFromDb();
263  $questionList = new ilAssQuestionList($DIC->database(), $DIC->language(), $DIC['ilPluginAdmin']);
264  $questionList->setParentObjId($dynamicQuestionSetConfig->getSourceQuestionPoolId());
265  $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_ORIGINALS);
266  } else {
267  $questionList = new ilAssQuestionList($DIC->database(), $DIC->language(), $DIC['ilPluginAdmin']);
268  $questionList->setParentObjId($this->getTestObj()->getId());
269  $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES);
270  }
271  $questionList->load();
272 
273  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
274  $testSessionFactory = new ilTestSessionFactory($this->getTestObj());
275  $testSession = $testSessionFactory->getSession();
276 
277  require_once 'Modules/Test/classes/class.ilTestSkillEvaluationGUI.php';
278  $gui = new ilTestSkillEvaluationGUI(
279  $DIC->ctrl(),
280  $DIC->tabs(),
281  $DIC->ui()->mainTemplate(),
282  $DIC->language(),
283  $DIC->database(),
284  $this->getTestObj()
285  );
286  $gui->setQuestionList($questionList);
287  $gui->setTestSession($testSession);
288  $gui->setObjectiveOrientedContainer($this->getObjectiveParent());
289 
290  $DIC->ctrl()->forwardCommand($gui);
291  break;
292 
293  case strtolower(__CLASS__):
294  default:
295 
296  $command = $DIC->ctrl()->getCmd(self::DEFAULT_CMD) . 'Cmd';
297  $this->{$command}();
298  }
299  }
300 
301  protected function showCmd()
302  {
303  global $DIC; /* @var ILIAS\DI\Container $DIC */
304 
305  if ($this->testObj->canShowTestResults($this->getTestSession())) {
306  if ($this->objectiveParent->isObjectiveOrientedPresentationRequired()) {
307  $DIC->ctrl()->redirectByClass('ilTestEvalObjectiveOrientedGUI');
308  }
309 
310  $DIC->ctrl()->redirectByClass(array('ilMyTestResultsGUI', 'ilTestEvaluationGUI'));
311  }
312 
313  $toolbar = $DIC->toolbar();
314  $validator = new ilCertificateDownloadValidator();
315  if ($validator->isCertificateDownloadable($DIC->user()->getId(), $this->getTestObj()->getId())) {
316  $button = ilLinkButton::getInstance();
317  $button->setCaption('certificate');
318  $button->setUrl($DIC->ctrl()->getFormActionByClass(ilTestEvaluationGUI::class, 'outCertificate'));
319  $toolbar->addButtonInstance($button);
320  }
321 
323  }
324 
325  protected function showNoResultsReportingMessage()
326  {
327  global $DIC; /* @var ILIAS\DI\Container $DIC */
328 
329  $message = $DIC->language()->txt('tst_res_tab_msg_res_after_taking_test');
330 
331  switch ($this->testObj->getScoreReporting()) {
333 
334  if ($this->testObj->hasAnyTestResult($this->getTestSession())) {
335  $message = $DIC->language()->txt('tst_res_tab_msg_res_after_finish_test');
336  }
337 
338  break;
339 
341 
342  $date = new ilDateTime($this->testObj->getReportingDate(), IL_CAL_TIMESTAMP);
343 
344  if (!$this->testObj->hasAnyTestResult($this->getTestSession())) {
345  $message = sprintf(
346  $DIC->language()->txt('tst_res_tab_msg_res_after_date_no_res'),
348  );
349  break;
350  }
351 
352  $message = sprintf(
353  $DIC->language()->txt('tst_res_tab_msg_res_after_date'),
355  );
356  break;
357 
359  $message = $DIC->language()->txt('tst_res_tab_msg_res_after_test_passed');
360  break;
361  }
362 
364  }
365 }
Scoring class for tests.
executeCommand()
Execute Command.
setObjectiveParent($objectiveParent)
global $DIC
Definition: saml.php:7
loadFromDb()
loads the question set config for current test from the database
const SCORE_REPORTING_AFTER_PASSED
static accessViolationRedirect()
__construct(ilObjTest $testObj, ilTestQuestionSetConfig $questionSetConfig)
ilTestParticipantsGUI constructor.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
catch(Exception $e) $message
Validates if an active certificate is stored in the database and can be downloaded by the user...
Date and time handling
const SCORE_REPORTING_FINISHED
const SCORE_REPORTING_DATE
setQuestionSetConfig($questionSetConfig)
const IL_CAL_TIMESTAMP