ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestPassesSelector Class Reference
+ Collaboration diagram for ilTestPassesSelector:

Public Member Functions

 __construct (private ilDBInterface $db, private ilObjTest $test_obj)
 
 getActiveId ()
 
 setActiveId (?int $active_id)
 
 getLastFinishedPass ()
 
 setLastFinishedPass (?int $last_finished_pass)
 
 loadLastFinishedPass ()
 
 getExistingPasses ()
 
 hasExistingPasses ()
 
 getNumExistingPasses ()
 
 openPassExists ()
 
 getClosedPasses ()
 
 getReportablePasses ()
 
 hasReportablePasses ()
 
 getLastFinishedPassTimestamp ()
 
 hasTestPassedOnce (int $active_id)
 

Private Member Functions

 passesLoaded ()
 
 ensureLoadedPasses ()
 
 loadPasses ()
 
 getLazyLoadedPasses ()
 
 fetchReportablePasses (array $existing_passes)
 
 fetchClosedPasses (array $existing_passes)
 
 fetchLastPass (array $existing_passes)
 
 isReportablePass (int $last_pass, int $pass)
 
 checkLastFinishedPassInitialised ()
 
 isClosedPass (int $pass)
 
 isReportingDateReached ()
 
 isProcessingTimeReached (int $pass)
 

Private Attributes

int $active_id = null
 
int $last_finished_pass = null
 
array $passes = null
 
array $test_passed_once_cache = []
 

Detailed Description

Definition at line 27 of file class.ilTestPassesSelector.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestPassesSelector::__construct ( private ilDBInterface  $db,
private ilObjTest  $test_obj 
)

Definition at line 34 of file class.ilTestPassesSelector.php.

37  {
38  }

Member Function Documentation

◆ checkLastFinishedPassInitialised()

ilTestPassesSelector::checkLastFinishedPassInitialised ( )
private

Definition at line 221 of file class.ilTestPassesSelector.php.

References getLastFinishedPass().

Referenced by isClosedPass().

222  {
223  if ($this->getLastFinishedPass() === null) {
224  throw new ilTestException('invalid object state: last finished pass was not set!');
225  }
226  }
Base Exception for all Exceptions relating to Modules/Test.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureLoadedPasses()

ilTestPassesSelector::ensureLoadedPasses ( )
private

Definition at line 65 of file class.ilTestPassesSelector.php.

References loadPasses(), and passesLoaded().

Referenced by getLazyLoadedPasses().

66  {
67  if (!$this->passesLoaded()) {
68  $this->loadPasses();
69  }
70  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchClosedPasses()

ilTestPassesSelector::fetchClosedPasses ( array  $existing_passes)
private

Definition at line 168 of file class.ilTestPassesSelector.php.

References isClosedPass().

Referenced by getClosedPasses().

168  : array
169  {
170  $closed_passes = [];
171 
172  foreach ($existing_passes as $pass) {
173  if ($this->isClosedPass($pass)) {
174  $closed_passes[] = $pass;
175  }
176  }
177 
178  return $closed_passes;
179  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchLastPass()

ilTestPassesSelector::fetchLastPass ( array  $existing_passes)
private

Definition at line 181 of file class.ilTestPassesSelector.php.

Referenced by fetchReportablePasses().

181  : ?int
182  {
183  $last_pass = null;
184 
185  foreach ($existing_passes as $pass) {
186  if ($last_pass === null || $pass > $last_pass) {
187  $last_pass = $pass;
188  }
189  }
190 
191  return $last_pass;
192  }
+ Here is the caller graph for this function:

◆ fetchReportablePasses()

ilTestPassesSelector::fetchReportablePasses ( array  $existing_passes)
private

Definition at line 153 of file class.ilTestPassesSelector.php.

References fetchLastPass(), and isReportablePass().

Referenced by getReportablePasses().

153  : array
154  {
155  $last_pass = $this->fetchLastPass($existing_passes);
156 
157  $reportable_passes = [];
158 
159  foreach ($existing_passes as $pass) {
160  if ($this->isReportablePass($last_pass, $pass)) {
161  $reportable_passes[] = $pass;
162  }
163  }
164 
165  return $reportable_passes;
166  }
fetchLastPass(array $existing_passes)
isReportablePass(int $last_pass, int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveId()

ilTestPassesSelector::getActiveId ( )

Definition at line 40 of file class.ilTestPassesSelector.php.

References $active_id.

Referenced by isProcessingTimeReached(), isReportablePass(), loadLastFinishedPass(), and loadPasses().

40  : ?int
41  {
42  return $this->active_id;
43  }
+ Here is the caller graph for this function:

◆ getClosedPasses()

ilTestPassesSelector::getClosedPasses ( )

Definition at line 136 of file class.ilTestPassesSelector.php.

References fetchClosedPasses(), and getExistingPasses().

Referenced by openPassExists().

136  : array
137  {
138  $existing_passes = $this->getExistingPasses();
139  return $this->fetchClosedPasses($existing_passes);
140  }
fetchClosedPasses(array $existing_passes)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExistingPasses()

ilTestPassesSelector::getExistingPasses ( )

Definition at line 116 of file class.ilTestPassesSelector.php.

References getLazyLoadedPasses().

Referenced by getClosedPasses(), getNumExistingPasses(), getReportablePasses(), hasExistingPasses(), and openPassExists().

116  : array
117  {
118  return array_keys($this->getLazyLoadedPasses());
119  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastFinishedPass()

ilTestPassesSelector::getLastFinishedPass ( )

Definition at line 50 of file class.ilTestPassesSelector.php.

References $last_finished_pass.

Referenced by checkLastFinishedPassInitialised(), getLastFinishedPassTimestamp(), isClosedPass(), and ilObjTest\isNextPassAllowed().

50  : ?int
51  {
53  }
+ Here is the caller graph for this function:

◆ getLastFinishedPassTimestamp()

ilTestPassesSelector::getLastFinishedPassTimestamp ( )

Definition at line 264 of file class.ilTestPassesSelector.php.

References $last_finished_pass, getLastFinishedPass(), and getLazyLoadedPasses().

Referenced by ilObjTest\isNextPassAllowed().

264  : ?int
265  {
267  if ($last_finished_pass === null || $last_finished_pass === -1) {
268  return null;
269  }
270 
271  $passes = $this->getLazyLoadedPasses();
272  if (!isset($passes[$last_finished_pass])) {
273  return null;
274  }
275  return $passes[$last_finished_pass]['tstamp'];
276  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLazyLoadedPasses()

ilTestPassesSelector::getLazyLoadedPasses ( )
private

Definition at line 95 of file class.ilTestPassesSelector.php.

References $passes, and ensureLoadedPasses().

Referenced by getExistingPasses(), and getLastFinishedPassTimestamp().

95  : array
96  {
97  $this->ensureLoadedPasses();
98  return $this->passes;
99  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumExistingPasses()

ilTestPassesSelector::getNumExistingPasses ( )

Definition at line 126 of file class.ilTestPassesSelector.php.

References getExistingPasses().

126  : int
127  {
128  return count($this->getExistingPasses());
129  }
+ Here is the call graph for this function:

◆ getReportablePasses()

ilTestPassesSelector::getReportablePasses ( )

Definition at line 142 of file class.ilTestPassesSelector.php.

References fetchReportablePasses(), and getExistingPasses().

Referenced by hasReportablePasses().

142  : array
143  {
144  $existing_passes = $this->getExistingPasses();
145  return $this->fetchReportablePasses($existing_passes);
146  }
fetchReportablePasses(array $existing_passes)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasExistingPasses()

ilTestPassesSelector::hasExistingPasses ( )

Definition at line 121 of file class.ilTestPassesSelector.php.

References getExistingPasses().

121  : bool
122  {
123  return $this->getExistingPasses() !== [];
124  }
+ Here is the call graph for this function:

◆ hasReportablePasses()

ilTestPassesSelector::hasReportablePasses ( )

Definition at line 148 of file class.ilTestPassesSelector.php.

References getReportablePasses().

148  : bool
149  {
150  return (bool) count($this->getReportablePasses());
151  }
+ Here is the call graph for this function:

◆ hasTestPassedOnce()

ilTestPassesSelector::hasTestPassedOnce ( int  $active_id)

Definition at line 278 of file class.ilTestPassesSelector.php.

References $active_id, and $res.

Referenced by isReportablePass().

278  : bool
279  {
280  if (!isset($this->test_passed_once_cache[$active_id])) {
281  $this->test_passed_once_cache[$active_id] = false;
282 
283  $res = $this->db->queryF(
284  'SELECT passed_once FROM tst_result_cache WHERE active_fi = %s',
285  ['integer'],
286  [$active_id]
287  );
288 
289  while ($row = $this->db->fetchAssoc($res)) {
290  $this->test_passed_once_cache[$active_id] = (bool) $row['passed_once'];
291  }
292  }
293 
294  return $this->test_passed_once_cache[$active_id];
295  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ isClosedPass()

ilTestPassesSelector::isClosedPass ( int  $pass)
private

Definition at line 228 of file class.ilTestPassesSelector.php.

References checkLastFinishedPassInitialised(), getLastFinishedPass(), and isProcessingTimeReached().

Referenced by fetchClosedPasses(), and isReportablePass().

228  : bool
229  {
231 
232  if ($pass <= $this->getLastFinishedPass()) {
233  return true;
234  }
235 
236  if ($this->isProcessingTimeReached($pass)) {
237  return true;
238  }
239 
240  return false;
241  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isProcessingTimeReached()

ilTestPassesSelector::isProcessingTimeReached ( int  $pass)
private

Definition at line 249 of file class.ilTestPassesSelector.php.

References getActiveId().

Referenced by isClosedPass().

249  : bool
250  {
251  if (!$this->test_obj->getEnableProcessingTime()) {
252  return false;
253  }
254 
255  $startingTime = $this->test_obj->getStartingTimeOfUser($this->getActiveId(), $pass);
256 
257  if ($startingTime === false) {
258  return false;
259  }
260 
261  return $this->test_obj->isMaxProcessingTimeReached($startingTime, $this->getActiveId());
262  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isReportablePass()

ilTestPassesSelector::isReportablePass ( int  $last_pass,
int  $pass 
)
private

Definition at line 194 of file class.ilTestPassesSelector.php.

References getActiveId(), hasTestPassedOnce(), isClosedPass(), isReportingDateReached(), ilObjTestSettingsResultSummary\SCORE_REPORTING_AFTER_PASSED, ilObjTestSettingsResultSummary\SCORE_REPORTING_DATE, ilObjTestSettingsResultSummary\SCORE_REPORTING_FINISHED, and ilObjTestSettingsResultSummary\SCORE_REPORTING_IMMIDIATLY.

Referenced by fetchReportablePasses().

194  : bool
195  {
196  switch ($this->test_obj->getScoreReporting()) {
198  return true;
199 
201  return $this->isReportingDateReached();
202 
204  if ($pass < $last_pass) {
205  return true;
206  }
207 
208  return $this->isClosedPass($pass);
209 
211  if (!$this->hasTestPassedOnce($this->getActiveId())) {
212  return false;
213  }
214 
215  return $this->isClosedPass($pass);
216  }
217 
218  return false;
219  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isReportingDateReached()

ilTestPassesSelector::isReportingDateReached ( )
private

Definition at line 243 of file class.ilTestPassesSelector.php.

Referenced by isReportablePass().

243  : bool
244  {
245  $reporting_date = $this->test_obj->getScoreSettings()->getResultSummarySettings()->getReportingDate();
246  return $reporting_date <= new DateTimeImmutable('now', new DateTimeZone('UTC'));
247  }
+ Here is the caller graph for this function:

◆ loadLastFinishedPass()

ilTestPassesSelector::loadLastFinishedPass ( )

Definition at line 101 of file class.ilTestPassesSelector.php.

References $res, getActiveId(), and setLastFinishedPass().

101  : void
102  {
103  $query = 'SELECT last_finished_pass FROM tst_active WHERE active_id = %s';
104 
105  $res = $this->db->queryF(
106  $query,
107  ['integer'],
108  [$this->getActiveId()]
109  );
110 
111  while ($row = $this->db->fetchAssoc($res)) {
112  $this->setLastFinishedPass($row['last_finished_pass']);
113  }
114  }
$res
Definition: ltiservices.php:69
setLastFinishedPass(?int $last_finished_pass)
+ Here is the call graph for this function:

◆ loadPasses()

ilTestPassesSelector::loadPasses ( )
private

Definition at line 71 of file class.ilTestPassesSelector.php.

References $res, and getActiveId().

Referenced by ensureLoadedPasses().

71  : void
72  {
73  $query = '
74  SELECT DISTINCT tst_pass_result.* FROM tst_pass_result
75  LEFT JOIN tst_test_result
76  ON tst_pass_result.pass = tst_test_result.pass
77  AND tst_pass_result.active_fi = tst_test_result.active_fi
78  WHERE tst_pass_result.active_fi = %s
79  ORDER BY tst_pass_result.pass
80  ';
81 
82  $res = $this->db->queryF(
83  $query,
84  ['integer'],
85  [$this->getActiveId()]
86  );
87 
88  $this->passes = [];
89 
90  while ($row = $this->db->fetchAssoc($res)) {
91  $this->passes[$row['pass']] = $row;
92  }
93  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ openPassExists()

ilTestPassesSelector::openPassExists ( )

Definition at line 131 of file class.ilTestPassesSelector.php.

References getClosedPasses(), and getExistingPasses().

131  : bool
132  {
133  return count($this->getExistingPasses()) > count($this->getClosedPasses());
134  }
+ Here is the call graph for this function:

◆ passesLoaded()

ilTestPassesSelector::passesLoaded ( )
private

Definition at line 60 of file class.ilTestPassesSelector.php.

Referenced by ensureLoadedPasses().

60  : bool
61  {
62  return is_array($this->passes);
63  }
+ Here is the caller graph for this function:

◆ setActiveId()

ilTestPassesSelector::setActiveId ( ?int  $active_id)

Definition at line 45 of file class.ilTestPassesSelector.php.

References $active_id.

45  : void
46  {
47  $this->active_id = $active_id;
48  }

◆ setLastFinishedPass()

ilTestPassesSelector::setLastFinishedPass ( ?int  $last_finished_pass)

Definition at line 55 of file class.ilTestPassesSelector.php.

References $last_finished_pass.

Referenced by loadLastFinishedPass().

55  : void
56  {
57  $this->last_finished_pass = $last_finished_pass === null ? -1 : $last_finished_pass;
58  }
+ Here is the caller graph for this function:

Field Documentation

◆ $active_id

int ilTestPassesSelector::$active_id = null
private

Definition at line 29 of file class.ilTestPassesSelector.php.

Referenced by getActiveId(), hasTestPassedOnce(), and setActiveId().

◆ $last_finished_pass

int ilTestPassesSelector::$last_finished_pass = null
private

◆ $passes

array ilTestPassesSelector::$passes = null
private

Definition at line 31 of file class.ilTestPassesSelector.php.

Referenced by getLazyLoadedPasses().

◆ $test_passed_once_cache

array ilTestPassesSelector::$test_passed_once_cache = []
private

Definition at line 32 of file class.ilTestPassesSelector.php.


The documentation for this class was generated from the following file: