ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilTestInfoScreenToolbarGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
5require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
6require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
7require_once 'Services/Form/classes/class.ilFormPropertyGUI.php';
8require_once 'Services/Form/classes/class.ilHiddenInputGUI.php';
9
17{
18 private static $TARGET_CLASS_PATH_BASE = array('ilRepositoryGUI', 'ilObjTestGUI');
19
23 protected $DIC;
24
29
33 protected $db;
34
38 protected $access;
39
43 protected $ctrl;
44
48 protected $lng;
49
53 protected $pluginAdmin;
54
58 protected $testOBJ;
59
64
68 protected $testPlayerGUI;
69
73 protected $testSession;
74
78 protected $testSequence;
79
84
88 private $infoMessages = array();
89
93 private $failureMessages = array();
94
96 {
97 global $DIC; /* @var ILIAS\DI\Container $DIC */
98 $this->DIC = $DIC;
99 $this->db = $db;
100 $this->access = $access;
101 $this->ctrl = $ctrl;
102 $this->lng = $lng;
103 $this->pluginAdmin = $pluginAdmin;
104 }
105
109 public function getGlobalToolbar()
110 {
112 }
113
118 {
119 $this->globalToolbar = $globalToolbar;
120 }
121
125 public function getTestOBJ()
126 {
127 return $this->testOBJ;
128 }
129
133 public function setTestOBJ($testOBJ)
134 {
135 $this->testOBJ = $testOBJ;
136 }
137
141 public function getTestQuestionSetConfig()
142 {
144 }
145
150 {
151 $this->testQuestionSetConfig = $testQuestionSetConfig;
152 }
153
157 public function getTestPlayerGUI()
158 {
160 }
161
166 {
167 $this->testPlayerGUI = $testPlayerGUI;
168 }
169
173 public function getTestSession()
174 {
175 return $this->testSession;
176 }
177
182 {
183 $this->testSession = $testSession;
184 }
185
189 public function getTestSequence()
190 {
191 return $this->testSequence;
192 }
193
198 {
199 $this->testSequence = $testSequence;
200 }
201
205 public function getSessionLockString()
206 {
208 }
209
214 {
215 $this->sessionLockString = $sessionLockString;
216 }
217
221 public function getInfoMessages()
222 {
223 return $this->infoMessages;
224 }
225
229 public function addInfoMessage($infoMessage)
230 {
231 $this->infoMessages[] = $infoMessage;
232 }
233
237 public function getFailureMessages()
238 {
240 }
241
245 public function addFailureMessage($failureMessage)
246 {
247 $this->failureMessages[] = $failureMessage;
248 }
249
250 public function setFormAction($formAction, $isMultipart = false, $target = '')
251 {
252 if ($this->globalToolbar instanceof parent) {
253 $this->globalToolbar->setFormAction($formAction, $isMultipart, $target);
254 } else {
255 parent::setFormAction($formAction, $isMultipart, $target);
256 }
257 }
258
259 public function addButtonInstance(ilButtonBase $btnInstance)
260 {
261 if ($this->globalToolbar instanceof parent) {
262 $this->globalToolbar->addButtonInstance($btnInstance);
263 } else {
264 parent::addButtonInstance($btnInstance);
265 }
266 }
267
268 public function setCloseFormTag($enabled)
269 {
270 if ($this->globalToolbar instanceof parent) {
271 $this->globalToolbar->setCloseFormTag($enabled);
272 } else {
273 parent::setCloseFormTag($enabled);
274 }
275 }
276
277 public function addInputItem(ilToolbarItem $inputItem, $outputLabel = false)
278 {
279 if ($this->globalToolbar instanceof parent) {
280 $this->globalToolbar->addInputItem($inputItem, $outputLabel);
281 } else {
282 parent::addInputItem($inputItem, $outputLabel);
283 }
284 }
285
286 public function addFormInput($formInput)
287 {
288 if ($this->globalToolbar instanceof parent) {
289 $this->globalToolbar->addFormInput($formInput);
290 } else {
291 parent::addFormInput($formInput);
292 }
293 }
294
295 public function clearItems()
296 {
297 if ($this->globalToolbar instanceof parent) {
298 $this->globalToolbar->setItems(array());
299 } else {
300 $this->setItems(array());
301 }
302 }
303
304 private function getClassName($target)
305 {
306 if (is_object($target)) {
307 $target = get_class($target);
308 }
309
310 return $target;
311 }
312
313 private function getClassNameArray($target)
314 {
315 if (is_array($target)) {
316 return $target;
317 }
318
319 return array($this->getClassName($target));
320 }
321
322 private function getClassPath($target)
323 {
324 return array_merge(self::$TARGET_CLASS_PATH_BASE, $this->getClassNameArray($target));
325 }
326
327 private function setParameter($target, $parameter, $value)
328 {
329 $this->ctrl->setParameterByClass($this->getClassName($target), $parameter, $value);
330 }
331
332 private function buildLinkTarget($target, $cmd = null)
333 {
334 return $this->ctrl->getLinkTargetByClass($this->getClassPath($target), $cmd);
335 }
336
337 private function buildFormAction($target)
338 {
339 return $this->ctrl->getFormActionByClass($this->getClassPath($target));
340 }
341
343 {
344 if (!strlen($this->getSessionLockString())) {
346 }
347 }
348
349 private function buildSessionLockString()
350 {
351 return md5($_COOKIE[session_name()] . time());
352 }
353
360 {
361 if (!$this->getTestSession()->getActiveId()) {
362 return false;
363 }
364
365 if (!$this->getTestOBJ()->isDynamicTest()) {
366 return false;
367 }
368
369 if (!$this->getTestOBJ()->isPassDeletionAllowed()) {
370 return false;
371 }
372
373 if (!$this->getTestSequence()->hasStarted($this->getTestSession())) {
374 return false;
375 }
376
377 return true;
378 }
379
385 {
386 require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
387
388 $this->ctrl->setParameterByClass(
389 'iltestevaluationgui',
390 'context',
392 );
393
394 $this->setParameter('iltestevaluationgui', 'active_id', $this->getTestSession()->getActiveId());
395 $this->setParameter('iltestevaluationgui', 'pass', $this->getTestSession()->getPass());
396
398 $btn->setCaption('tst_delete_dyn_test_results_btn');
399 $btn->setUrl($this->buildLinkTarget('iltestevaluationgui', 'confirmDeletePass'));
400 $btn->setPrimary(false);
401
402 $this->addButtonInstance($btn);
403 }
404
406 {
407 if (!$this->getTestOBJ()->isSkillServiceEnabled()) {
408 return false;
409 }
410
411 if ($this->getTestOBJ()->isDynamicTest()) {
412 $questionSetConfig = $this->getTestQuestionSetConfig();
413 $questionContainerId = $questionSetConfig->getSourceQuestionPoolId();
414 } else {
415 $questionContainerId = $this->getTestOBJ()->getId();
416 }
417
418 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
419 require_once 'Modules/Test/classes/class.ilTestSkillLevelThreshold.php';
420
421 $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
422 $assignmentList->setParentObjId($questionContainerId);
423 $assignmentList->loadFromDb();
424
425 foreach ($assignmentList->getUniqueAssignedSkills() as $data) {
426 foreach ($data['skill']->getLevelData() as $level) {
427 $treshold = new ilTestSkillLevelThreshold($this->db);
428 $treshold->setTestId($this->getTestOBJ()->getTestId());
429 $treshold->setSkillBaseId($data['skill_base_id']);
430 $treshold->setSkillTrefId($data['skill_tref_id']);
431 $treshold->setSkillLevelId($level['id']);
432
433 if (!$treshold->dbRecordExists()) {
434 return true;
435 }
436 }
437 }
438
439 return false;
440 }
441
443 {
444 $message = $this->lng->txt('tst_skl_level_thresholds_missing');
445
446 $linkTarget = $this->buildLinkTarget(
447 array('ilTestSkillAdministrationGUI', 'ilTestSkillLevelThresholdsGUI'),
449 );
450
451 $link = $this->DIC->ui()->factory()->link()->standard(
452 $this->DIC->language()->txt('tst_skl_level_thresholds_link'),
453 $linkTarget
454 );
455
456 $msgBox = $this->DIC->ui()->factory()->messageBox()->failure($message)->withLinks(array($link));
457
458 return $this->DIC->ui()->renderer()->render($msgBox);
459 }
460
462 {
463 if (!$this->testOBJ->isFixedTest()) {
464 return false;
465 }
466
467 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
468 $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
469 $assignmentList->setParentObjId($this->testOBJ->getId());
470 $assignmentList->loadFromDb();
471
472 return $assignmentList->hasSkillsAssignedLowerThanBarrier();
473 }
474
475 private function getSkillAssignBarrierInfo()
476 {
477 require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
478
479 return sprintf(
480 $this->lng->txt('tst_skill_triggerings_num_req_answers_not_reached_warn'),
482 );
483 }
484
485 public function build()
486 {
488
489 $this->setParameter($this->getTestPlayerGUI(), 'lock', $this->getSessionLockString());
490 $this->setParameter($this->getTestPlayerGUI(), 'sequence', $this->getTestSession()->getLastSequence());
491 $this->setParameter('ilObjTestGUI', 'ref_id', $this->getTestOBJ()->getRefId());
492
493 $this->setFormAction($this->buildFormAction($this->testPlayerGUI));
494
495 $online_access = false;
496 if ($this->getTestOBJ()->getFixedParticipants()) {
497 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
498 $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->getTestOBJ()->getId(), $this->getTestSession()->getUserId());
499 if ($online_access_result === true) {
500 $online_access = true;
501 } else {
502 $this->addInfoMessage($online_access_result);
503 }
504 }
505
506 if (!$this->getTestOBJ()->getOfflineStatus() && $this->getTestOBJ()->isComplete($this->getTestQuestionSetConfig())) {
507 if ((!$this->getTestOBJ()->getFixedParticipants() || $online_access) && $this->access->checkAccess("read", "", $this->getTestOBJ()->getRefId())) {
508 $executable = $this->getTestOBJ()->isExecutable(
509 $this->getTestSession(),
510 $this->getTestSession()->getUserId(),
511 $allowPassIncrease = true
512 );
513
514 if ($executable["executable"]) {
515 if ($this->getTestOBJ()->areObligationsEnabled() && $this->getTestOBJ()->hasObligations($this->getTestOBJ()->getTestId())) {
516 $this->addInfoMessage($this->lng->txt('tst_test_contains_obligatory_questions'));
517 }
518
519 if ($this->getTestSession()->getActiveId() > 0) {
520 // resume test
521 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
522 $testPassesSelector = new ilTestPassesSelector($this->db, $this->getTestOBJ());
523 $testPassesSelector->setActiveId($this->getTestSession()->getActiveId());
524 $testPassesSelector->setLastFinishedPass($this->getTestSession()->getLastFinishedPass());
525
526 $closedPasses = $testPassesSelector->getClosedPasses();
527 $existingPasses = $testPassesSelector->getExistingPasses();
528
529 if ($existingPasses > $closedPasses) {
531 $btn->setCaption('tst_resume_test');
532 $btn->setCommand('resumePlayer');
533 $btn->setPrimary(true);
534 $this->addButtonInstance($btn);
535 } else {
537 $btn->setCaption($this->getTestOBJ()->getStartTestLabel($this->getTestSession()->getActiveId()), false);
538 $btn->setCommand('startPlayer');
539 $btn->setPrimary(true);
540 $this->addButtonInstance($btn);
541 }
542 } else {
543 // start new test
545 $btn->setCaption($this->getTestOBJ()->getStartTestLabel($this->getTestSession()->getActiveId()), false);
546 $btn->setCommand('startPlayer');
547 $btn->setPrimary(true);
548 $this->addButtonInstance($btn);
549 }
550 } else {
551 $this->addInfoMessage($executable['errormessage']);
552 }
553 }
554
557 }
558
559 if ($this->DIC->user()->getId() == ANONYMOUS_USER_ID) {
560 if ($this->getItems()) {
561 $this->addSeparator();
562 }
563
564 require_once 'Services/Form/classes/class.ilTextInputGUI.php';
565 $anonymous_id = new ilTextInputGUI($this->lng->txt('enter_anonymous_code'), 'anonymous_id');
566 $anonymous_id->setSize(8);
567 $this->addInputItem($anonymous_id, true);
568 $button = ilSubmitButton::getInstance();
569 $button->setCaption('submit');
570 $button->setCommand('setAnonymousId');
571 $this->addButtonInstance($button);
572 }
573 }
574 if ($this->getTestOBJ()->getOfflineStatus() && !$this->getTestQuestionSetConfig()->areDepenciesBroken()) {
575 $message = $this->lng->txt("test_is_offline");
576
577 $links = array();
578
579 if ($this->access->checkAccess("write", "", $this->getTestOBJ()->getRefId())) {
580 $links[] = $this->DIC->ui()->factory()->link()->standard(
581 $this->DIC->language()->txt('test_edit_settings'),
582 $this->buildLinkTarget('ilobjtestsettingsgeneralgui')
583 );
584 }
585
586 $msgBox = $this->DIC->ui()->factory()->messageBox()->info($message)->withLinks($links);
587
588 $this->populateMessage($this->DIC->ui()->renderer()->render($msgBox));
589 }
590
591 if ($this->access->checkAccess("write", "", $this->getTestOBJ()->getRefId())) {
592 require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
593 $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->testOBJ->getId());
594 require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdImportFails.php';
595 $sltImportFails = new ilTestSkillLevelThresholdImportFails($this->testOBJ->getId());
596
597 if ($qsaImportFails->failedImportsRegistered() || $sltImportFails->failedImportsRegistered()) {
598 $importFailsMsg = array();
599
600 if ($qsaImportFails->failedImportsRegistered()) {
601 $importFailsMsg[] = $qsaImportFails->getFailedImportsMessage($this->lng);
602 }
603
604 if ($sltImportFails->failedImportsRegistered()) {
605 $importFailsMsg[] = $sltImportFails->getFailedImportsMessage($this->lng);
606 }
607
608 $message = implode('<br />', $importFailsMsg);
609
610 $button = $this->DIC->ui()->factory()->button()->standard(
611 $this->DIC->language()->txt('ass_skl_import_fails_remove_btn'),
612 $this->DIC->ctrl()->getLinkTargetByClass('ilObjTestGUI', 'removeImportFails')
613 );
614
615 $msgBox = $this->DIC->ui()->factory()->messageBox()->failure($message)->withButtons(array($button));
616
617 $this->populateMessage($this->DIC->ui()->renderer()->render($msgBox));
618 } elseif ($this->getTestOBJ()->isSkillServiceToBeConsidered()) {
619 if ($this->areSkillLevelThresholdsMissing()) {
621 }
622
625 }
626 }
627
628 if ($this->getTestQuestionSetConfig()->areDepenciesBroken()) {
629 $this->addFailureMessage($this->getTestQuestionSetConfig()->getDepenciesBrokenMessage($this->lng));
630
631 $this->clearItems();
632 } elseif ($this->getTestQuestionSetConfig()->areDepenciesInVulnerableState()) {
633 $this->addInfoMessage($this->getTestQuestionSetConfig()->getDepenciesInVulnerableStateMessage($this->lng));
634 }
635 }
636 }
637
641 protected function populateMessage($message)
642 {
643 $this->DIC->ui()->mainTemplate()->setCurrentBlock('mess');
644 $this->DIC->ui()->mainTemplate()->setVariable('MESSAGE', $message);
645 $this->DIC->ui()->mainTemplate()->parseCurrentBlock();
646 }
647
648 public function sendMessages()
649 {
650 ilUtil::sendInfo(array_pop($this->getInfoMessages()));
651 ilUtil::sendFailure(array_pop($this->getFailureMessages()));
652 }
653}
An exception for terminatinating execution or to throw for unit testing.
This class provides processing control methods.
language handling
static getInstance()
Factory.
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
Administration class for plugins.
static getInstance()
Factory.
addInputItem(ilToolbarItem $inputItem, $outputLabel=false)
Add input item.
addButtonInstance(ilButtonBase $btnInstance)
Add button instance.
__construct(ilDBInterface $db, ilAccessHandler $access, ilCtrl $ctrl, ilLanguage $lng, ilPluginAdmin $pluginAdmin)
setFormAction($formAction, $isMultipart=false, $target='')
Set form action (if form action is set, toolbar is wrapped into form tags)
setCloseFormTag($enabled)
Set close form tag.
setParameter($target, $parameter, $value)
This class represents a text property in a property form.
addSeparator()
Add separator.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Interface ilAccessHandler.
Interface ilDBInterface.
Interface for property form input GUI classes that can be used in ilToolbarGUI.
$data
Definition: storeScorm.php:23
$message
Definition: xapiexit.php:14
$_COOKIE[session_name()]
Definition: xapitoken.php:39