ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
24
28 protected $db;
29
33 protected $access;
34
38 protected $ctrl;
39
43 protected $lng;
44
48 protected $pluginAdmin;
49
53 protected $testOBJ;
54
59
63 protected $testPlayerGUI;
64
68 protected $testSession;
69
73 protected $testSequence;
74
79
83 private $infoMessages = array();
84
88 private $failureMessages = array();
89
91 {
92 $this->db = $db;
93 $this->access = $access;
94 $this->ctrl = $ctrl;
95 $this->lng = $lng;
96 $this->pluginAdmin = $pluginAdmin;
97 }
98
102 public function getGlobalToolbar()
103 {
105 }
106
111 {
112 $this->globalToolbar = $globalToolbar;
113 }
114
118 public function getTestOBJ()
119 {
120 return $this->testOBJ;
121 }
122
126 public function setTestOBJ($testOBJ)
127 {
128 $this->testOBJ = $testOBJ;
129 }
130
134 public function getTestQuestionSetConfig()
135 {
137 }
138
143 {
144 $this->testQuestionSetConfig = $testQuestionSetConfig;
145 }
146
150 public function getTestPlayerGUI()
151 {
153 }
154
159 {
160 $this->testPlayerGUI = $testPlayerGUI;
161 }
162
166 public function getTestSession()
167 {
168 return $this->testSession;
169 }
170
175 {
176 $this->testSession = $testSession;
177 }
178
182 public function getTestSequence()
183 {
184 return $this->testSequence;
185 }
186
191 {
192 $this->testSequence = $testSequence;
193 }
194
198 public function getSessionLockString()
199 {
201 }
202
207 {
208 $this->sessionLockString = $sessionLockString;
209 }
210
214 public function getInfoMessages()
215 {
216 return $this->infoMessages;
217 }
218
222 public function addInfoMessage($infoMessage)
223 {
224 $this->infoMessages[] = $infoMessage;
225 }
226
230 public function getFailureMessages()
231 {
233 }
234
238 public function addFailureMessage($failureMessage)
239 {
240 $this->failureMessages[] = $failureMessage;
241 }
242
243 public function setFormAction($formAction, $isMultipart = false, $target = '')
244 {
245 if ($this->globalToolbar instanceof parent) {
246 $this->globalToolbar->setFormAction($formAction, $isMultipart, $target);
247 } else {
248 parent::setFormAction($formAction, $isMultipart, $target);
249 }
250 }
251
252 public function addButtonInstance(ilButtonBase $btnInstance)
253 {
254 if ($this->globalToolbar instanceof parent) {
255 $this->globalToolbar->addButtonInstance($btnInstance);
256 } else {
257 parent::addButtonInstance($btnInstance);
258 }
259 }
260
261 public function setCloseFormTag($enabled)
262 {
263 if ($this->globalToolbar instanceof parent) {
264 $this->globalToolbar->setCloseFormTag($enabled);
265 } else {
266 parent::setCloseFormTag($enabled);
267 }
268 }
269
270 public function addInputItem(ilToolbarItem $inputItem, $outputLabel = false)
271 {
272 if ($this->globalToolbar instanceof parent) {
273 $this->globalToolbar->addInputItem($inputItem, $outputLabel);
274 } else {
275 parent::addInputItem($inputItem, $outputLabel);
276 }
277 }
278
279 public function addFormInput($formInput)
280 {
281 if ($this->globalToolbar instanceof parent) {
282 $this->globalToolbar->addFormInput($formInput);
283 } else {
284 parent::addFormInput($formInput);
285 }
286 }
287
288 public function clearItems()
289 {
290 if ($this->globalToolbar instanceof parent) {
291 $this->globalToolbar->setItems(array());
292 } else {
293 $this->setItems(array());
294 }
295 }
296
297 private function getClassName($target)
298 {
299 if (is_object($target)) {
300 $target = get_class($target);
301 }
302
303 return $target;
304 }
305
306 private function getClassNameArray($target)
307 {
308 if (is_array($target)) {
309 return $target;
310 }
311
312 return array($this->getClassName($target));
313 }
314
315 private function getClassPath($target)
316 {
317 return array_merge(self::$TARGET_CLASS_PATH_BASE, $this->getClassNameArray($target));
318 }
319
320 private function setParameter($target, $parameter, $value)
321 {
322 $this->ctrl->setParameterByClass($this->getClassName($target), $parameter, $value);
323 }
324
325 private function buildLinkTarget($target, $cmd = null)
326 {
327 return $this->ctrl->getLinkTargetByClass($this->getClassPath($target), $cmd);
328 }
329
330 private function buildFormAction($target)
331 {
332 return $this->ctrl->getFormActionByClass($this->getClassPath($target));
333 }
334
336 {
337 if (!strlen($this->getSessionLockString())) {
339 }
340 }
341
342 private function buildSessionLockString()
343 {
344 return md5($_COOKIE['PHPSESSID'] . time());
345 }
346
353 {
354 if (!$this->getTestSession()->getActiveId()) {
355 return false;
356 }
357
358 if (!$this->getTestOBJ()->isDynamicTest()) {
359 return false;
360 }
361
362 if (!$this->getTestOBJ()->isPassDeletionAllowed()) {
363 return false;
364 }
365
366 if (!$this->getTestSequence()->hasStarted($this->getTestSession())) {
367 return false;
368 }
369
370 return true;
371 }
372
378 {
379 require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
380
381 $this->ctrl->setParameterByClass(
382 'iltestevaluationgui',
383 'context',
385 );
386
387 $this->setParameter('iltestevaluationgui', 'active_id', $this->getTestSession()->getActiveId());
388 $this->setParameter('iltestevaluationgui', 'pass', $this->getTestSession()->getPass());
389
391 $btn->setCaption('tst_delete_dyn_test_results_btn');
392 $btn->setUrl($this->buildLinkTarget('iltestevaluationgui', 'confirmDeletePass'));
393 $btn->setPrimary(false);
394
395 $this->addButtonInstance($btn);
396 }
397
399 {
400 if (!$this->getTestOBJ()->isSkillServiceEnabled()) {
401 return false;
402 }
403
404 if ($this->getTestOBJ()->isDynamicTest()) {
405 $questionSetConfig = $this->getTestQuestionSetConfig();
406 $questionContainerId = $questionSetConfig->getSourceQuestionPoolId();
407 } else {
408 $questionContainerId = $this->getTestOBJ()->getId();
409 }
410
411 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
412 require_once 'Modules/Test/classes/class.ilTestSkillLevelThreshold.php';
413
414 $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
415 $assignmentList->setParentObjId($questionContainerId);
416 $assignmentList->loadFromDb();
417
418 foreach ($assignmentList->getUniqueAssignedSkills() as $data) {
419 foreach ($data['skill']->getLevelData() as $level) {
420 $treshold = new ilTestSkillLevelThreshold($this->db);
421 $treshold->setTestId($this->getTestOBJ()->getTestId());
422 $treshold->setSkillBaseId($data['skill_base_id']);
423 $treshold->setSkillTrefId($data['skill_tref_id']);
424 $treshold->setSkillLevelId($level['id']);
425
426 if (!$treshold->dbRecordExists()) {
427 return true;
428 }
429 }
430 }
431
432 return false;
433 }
434
436 {
437 require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdsGUI.php';
438
439 $link = $this->buildLinkTarget(
440 array('ilTestSkillAdministrationGUI', 'ilTestSkillLevelThresholdsGUI'),
442 );
443
444 $msg = $this->lng->txt('tst_skl_level_thresholds_missing');
445 $msg .= '<br /><a href="' . $link . '">' . $this->lng->txt('tst_skl_level_thresholds_link') . '</a>';
446
447 return $msg;
448 }
449
451 {
452 if (!$this->testOBJ->isFixedTest()) {
453 return false;
454 }
455
456 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
457 $assignmentList = new ilAssQuestionSkillAssignmentList($this->db);
458 $assignmentList->setParentObjId($this->testOBJ->getId());
459 $assignmentList->loadFromDb();
460
461 return $assignmentList->hasSkillsAssignedLowerThanBarrier();
462 }
463
464 private function getSkillAssignBarrierInfo()
465 {
466 require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
467
468 return sprintf(
469 $this->lng->txt('tst_skill_triggerings_num_req_answers_not_reached_warn'),
471 );
472 }
473
474 public function build()
475 {
477
478 $this->setParameter($this->getTestPlayerGUI(), 'lock', $this->getSessionLockString());
479 $this->setParameter($this->getTestPlayerGUI(), 'sequence', $this->getTestSession()->getLastSequence());
480 $this->setParameter('ilObjTestGUI', 'ref_id', $this->getTestOBJ()->getRefId());
481
482 $this->setFormAction($this->buildFormAction($this->testPlayerGUI));
483
484 $online_access = false;
485 if ($this->getTestOBJ()->getFixedParticipants()) {
486 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
487 $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->getTestOBJ()->getId(), $this->getTestSession()->getUserId());
488 if ($online_access_result === true) {
489 $online_access = true;
490 } else {
491 $this->addInfoMessage($online_access_result);
492 }
493 }
494
495 if ($this->getTestOBJ()->isOnline() && $this->getTestOBJ()->isComplete($this->getTestQuestionSetConfig())) {
496 if ((!$this->getTestOBJ()->getFixedParticipants() || $online_access) && $this->access->checkAccess("read", "", $this->getTestOBJ()->getRefId())) {
497 $executable = $this->getTestOBJ()->isExecutable(
498 $this->getTestSession(),
499 $this->getTestSession()->getUserId(),
500 $allowPassIncrease = true
501 );
502
503 if ($executable["executable"]) {
504 if ($this->getTestOBJ()->areObligationsEnabled() && $this->getTestOBJ()->hasObligations($this->getTestOBJ()->getTestId())) {
505 $this->addInfoMessage($this->lng->txt('tst_test_contains_obligatory_questions'));
506 }
507
508 if ($this->getTestSession()->getActiveId() > 0) {
509 // resume test
510 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
511 $testPassesSelector = new ilTestPassesSelector($this->db, $this->getTestOBJ());
512 $testPassesSelector->setActiveId($this->getTestSession()->getActiveId());
513 $testPassesSelector->setLastFinishedPass($this->getTestSession()->getLastFinishedPass());
514
515 $closedPasses = $testPassesSelector->getClosedPasses();
516 $existingPasses = $testPassesSelector->getExistingPasses();
517
518 if ($existingPasses > $closedPasses) {
520 $btn->setCaption('tst_resume_test');
521 $btn->setCommand('resumePlayer');
522 $btn->setPrimary(true);
523 $this->addButtonInstance($btn);
524 } else {
526 $btn->setCaption($this->getTestOBJ()->getStartTestLabel($this->getTestSession()->getActiveId()), false);
527 $btn->setCommand('startPlayer');
528 $btn->setPrimary(true);
529 $this->addButtonInstance($btn);
530 }
531 } else {
532 // start new test
534 $btn->setCaption($this->getTestOBJ()->getStartTestLabel($this->getTestSession()->getActiveId()), false);
535 $btn->setCommand('startPlayer');
536 $btn->setPrimary(true);
537 $this->addButtonInstance($btn);
538 }
539 } else {
540 $this->addInfoMessage($executable['errormessage']);
541 }
542 if ($this->getTestSession()->getActiveId() > 0) {
543 // test results button
544
545 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
546 $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->getTestOBJ());
547 $testPassesSelector->setActiveId($this->getTestSession()->getActiveId());
548 $testPassesSelector->setLastFinishedPass($this->getTestSession()->getLastFinishedPass());
549
550 if ($this->getTestOBJ()->canShowTestResults($this->getTestSession())) {
552 $btn->setCaption('tst_show_results');
553 $btn->setUrl($this->buildLinkTarget('ilTestEvaluationGUI', 'outUserResultsOverview'));
554 $btn->setPrimary(false);
555 $this->addButtonInstance($btn);
556
557 if ($this->getTestOBJ()->getHighscoreEnabled()) {
558 // Can also compare results then
560 $btn->setCaption('tst_show_toplist');
561 $btn->setUrl($this->buildLinkTarget('ilTestToplistGUI', 'outResultsToplist'));
562 $btn->setPrimary(false);
563 $this->addButtonInstance($btn);
564 }
565
566 if ($this->getTestOBJ()->isSkillServiceToBeConsidered()) {
567 require_once 'Modules/Test/classes/class.ilTestSkillEvaluationGUI.php';
568
570 $btn->setCaption('tst_show_comp_results');
571 $btn->setUrl($this->buildLinkTarget('ilTestSkillEvaluationGUI', ilTestSkillEvaluationGUI::CMD_SHOW));
572 $btn->setPrimary(false);
573 $this->addButtonInstance($btn);
574 }
575 }
576 }
577 }
578 if ($this->getTestSession()->getActiveId() > 0) {
579 if ($this->getTestOBJ()->canShowSolutionPrintview($this->getTestSession()->getUserId())) {
581 $btn->setCaption('tst_list_of_answers_show');
582 $btn->setUrl($this->buildLinkTarget('ilTestEvaluationGUI', 'outUserListOfAnswerPasses'));
583 $btn->setPrimary(false);
584 $this->addButtonInstance($btn);
585 }
586 }
587
590 }
591
592 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID) {
593 if ($this->getItems()) {
594 $this->addSeparator();
595 }
596
597 require_once 'Services/Form/classes/class.ilTextInputGUI.php';
598 $anonymous_id = new ilTextInputGUI($this->lng->txt('enter_anonymous_code'), 'anonymous_id');
599 $anonymous_id->setSize(8);
600 $this->addInputItem($anonymous_id, true);
601 $this->addFormButton($this->lng->txt('submit'), 'setAnonymousId');
602 }
603 }
604 if (!$this->getTestOBJ()->isOnline() && !$this->getTestQuestionSetConfig()->areDepenciesBroken()) {
605 $message = $this->lng->txt("test_is_offline");
606
607 if ($this->access->checkAccess("write", "", $this->getTestOBJ()->getRefId())) {
608 $message .= "<br /><a href=\"" . $this->buildLinkTarget('ilobjtestsettingsgeneralgui') . "\">" .
609 $this->lng->txt("test_edit_settings") . "</a>";
610 }
611
612 $this->addInfoMessage($message);
613 }
614
615 if ($this->access->checkAccess("write", "", $this->getTestOBJ()->getRefId())) {
616 require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
617 $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->testOBJ->getId());
618 require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdImportFails.php';
619 $sltImportFails = new ilTestSkillLevelThresholdImportFails($this->testOBJ->getId());
620
621 if ($qsaImportFails->failedImportsRegistered() || $sltImportFails->failedImportsRegistered()) {
622 $importFailsMsg = array();
623
624 if ($qsaImportFails->failedImportsRegistered()) {
625 $importFailsMsg[] = $qsaImportFails->getFailedImportsMessage($this->lng);
626 }
627
628 if ($sltImportFails->failedImportsRegistered()) {
629 $importFailsMsg[] = $sltImportFails->getFailedImportsMessage($this->lng);
630 }
631
632 $button = ilLinkButton::getInstance();
633 $button->setUrl($this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'removeImportFails'));
634 $button->setCaption('ass_skl_import_fails_remove_btn');
635 $importFailsMsg[] = $button->render();
636
637 $this->addFailureMessage(implode('<br />', $importFailsMsg));
638 } elseif ($this->getTestOBJ()->isSkillServiceToBeConsidered()) {
639 if ($this->areSkillLevelThresholdsMissing()) {
641 }
642
645 }
646 }
647
648 if ($this->getTestQuestionSetConfig()->areDepenciesBroken()) {
649 $this->addFailureMessage($this->getTestQuestionSetConfig()->getDepenciesBrokenMessage($this->lng));
650
651 $this->clearItems();
652 } elseif ($this->getTestQuestionSetConfig()->areDepenciesInVulnerableState()) {
653 $this->addInfoMessage($this->getTestQuestionSetConfig()->getDepenciesInVulnerableStateMessage($this->lng));
654 }
655 }
656 }
657
658 public function sendMessages()
659 {
660 ilUtil::sendInfo(array_pop($this->getInfoMessages()));
661 ilUtil::sendFailure(array_pop($this->getFailureMessages()));
662 }
663}
sprintf('%.4f', $callTime)
$_COOKIE['client_id']
Definition: server.php:9
$_SESSION["AccountId"]
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.
addFormButton($a_txt, $a_cmd, $a_acc_key="", $a_primary=false, $a_class=false)
Add form button to toolbar.
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Interface ilAccessHandler.
Interface ilDBInterface.
Interface for property form input GUI classes that can be used in ilToolbarGUI.
catch(Exception $e) $message