ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestPasswordChecker.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
32 protected $rbacsystem;
33
37 protected $user;
38
42 protected $testOBJ;
43
47 protected $lng;
48
50 {
51 $this->rbacsystem = $rbacsystem;
52 $this->user = $user;
53 $this->testOBJ = $testOBJ;
54 $this->lng = $lng;
55 }
56
58 {
59 return (
61 && !$this->isPrivilegedParticipant()
63 );
64 }
65
66 protected function isTestPasswordEnabled(): bool
67 {
68 return $this->testOBJ->getPassword() !== null;
69 }
70
71 protected function isPrivilegedParticipant(): bool
72 {
73 return $this->rbacsystem->checkAccess('write', $this->testOBJ->getRefId());
74 }
75
76 public function wrongUserEnteredPasswordExist(): bool
77 {
78 if ($this->getUserEnteredPassword() && $this->getUserEnteredPassword() === '') {
79 return false;
80 }
81
82 return !$this->isUserEnteredPasswordCorrect();
83 }
84
85 public function isUserEnteredPasswordCorrect(): bool
86 {
87 return $this->getUserEnteredPassword() == $this->testOBJ->getPassword();
88 }
89
90 public function setUserEnteredPassword($enteredPassword)
91 {
92 ilSession::set($this->buildSessionKey(), $enteredPassword);
93 }
94
95 protected function getUserEnteredPassword()
96 {
97 return ilSession::get($this->buildSessionKey());
98 }
99
100 protected function buildSessionKey(): string
101 {
102 return 'tst_password_' . $this->testOBJ->getTestId();
103 }
104
105 public function logWrongEnteredPassword()
106 {
107 }
108}
language handling
User class.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
__construct(ilRbacSystem $rbacsystem, ilObjUser $user, ilObjTest $testOBJ, ilLanguage $lng)
setUserEnteredPassword($enteredPassword)