ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTestPassesSelector Class Reference
+ Collaboration diagram for ilTestPassesSelector:

Public Member Functions

 __construct (ilDBInterface $db, ilObjTest $testOBJ)
 
 getActiveId ()
 
 setActiveId ($activeId)
 
 getLastFinishedPass ()
 
 setLastFinishedPass ($lastFinishedPass)
 
 loadLastFinishedPass ()
 
 getExistingPasses ()
 
 hasExistingPasses ()
 
 getNumExistingPasses ()
 
 getClosedPasses ()
 
 getReportablePasses ()
 
 hasReportablePasses ()
 
 getLastFinishedPassTimestamp ()
 
 hasTestPassedOnce ($activeId)
 

Protected Attributes

 $db
 
 $testOBJ
 

Private Member Functions

 passesLoaded ()
 
 ensureLoadedPasses ()
 
 loadPasses ()
 
 getLazyLoadedPasses ()
 
 fetchReportablePasses ($existingPasses)
 
 fetchClosedPasses ($existingPasses)
 
 fetchLastPass ($existingPasses)
 
 isReportablePass ($lastPass, $pass)
 
 checkLastFinishedPassInitialised ()
 
 isClosedPass ($pass)
 
 isReportingDateReached ()
 
 isProcessingTimeReached ($pass)
 

Private Attributes

 $activeId
 
 $lastFinishedPass = null
 
 $passes = null
 
 $testPassedOnceCache = array()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilTestPassesSelector::__construct ( ilDBInterface  $db,
ilObjTest  $testOBJ 
)

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

References $db, and $testOBJ.

26  {
27  $this->db = $db;
28  $this->testOBJ = $testOBJ;
29  }

Member Function Documentation

◆ checkLastFinishedPassInitialised()

ilTestPassesSelector::checkLastFinishedPassInitialised ( )
private

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

References getLastFinishedPass().

Referenced by isClosedPass().

220  {
221  if ($this->getLastFinishedPass() === null) {
222  throw new ilTestException('invalid object state: last finished pass was not set!');
223  }
224  }
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 57 of file class.ilTestPassesSelector.php.

References loadPasses(), and passesLoaded().

Referenced by getLazyLoadedPasses().

58  {
59  if (!$this->passesLoaded()) {
60  $this->loadPasses();
61  }
62  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchClosedPasses()

ilTestPassesSelector::fetchClosedPasses (   $existingPasses)
private

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

References $pass, and isClosedPass().

Referenced by getClosedPasses().

163  {
164  $closedPasses = array();
165 
166  foreach ($existingPasses as $pass) {
167  if ($this->isClosedPass($pass)) {
168  $closedPasses[] = $pass;
169  }
170  }
171 
172  return $closedPasses;
173  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchLastPass()

ilTestPassesSelector::fetchLastPass (   $existingPasses)
private

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

References $pass.

Referenced by fetchReportablePasses().

176  {
177  $lastPass = null;
178 
179  foreach ($existingPasses as $pass) {
180  if ($lastPass === null || $pass > $lastPass) {
181  $lastPass = $pass;
182  }
183  }
184 
185  return $lastPass;
186  }
+ Here is the caller graph for this function:

◆ fetchReportablePasses()

ilTestPassesSelector::fetchReportablePasses (   $existingPasses)
private

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

References $pass, fetchLastPass(), and isReportablePass().

Referenced by getReportablePasses().

148  {
149  $lastPass = $this->fetchLastPass($existingPasses);
150 
151  $reportablePasses = array();
152 
153  foreach ($existingPasses as $pass) {
154  if ($this->isReportablePass($lastPass, $pass)) {
155  $reportablePasses[] = $pass;
156  }
157  }
158 
159  return $reportablePasses;
160  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveId()

ilTestPassesSelector::getActiveId ( )

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

References $activeId.

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

+ Here is the caller graph for this function:

◆ getClosedPasses()

ilTestPassesSelector::getClosedPasses ( )

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

References fetchClosedPasses(), and getExistingPasses().

126  {
127  $existingPasses = $this->getExistingPasses();
128  $closedPasses = $this->fetchClosedPasses($existingPasses);
129 
130  return $closedPasses;
131  }
+ Here is the call graph for this function:

◆ getExistingPasses()

ilTestPassesSelector::getExistingPasses ( )

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

References getLazyLoadedPasses().

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

111  {
112  return array_keys($this->getLazyLoadedPasses());
113  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastFinishedPass()

ilTestPassesSelector::getLastFinishedPass ( )

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

References $lastFinishedPass.

Referenced by checkLastFinishedPassInitialised(), getLastFinishedPassTimestamp(), and isClosedPass().

+ Here is the caller graph for this function:

◆ getLastFinishedPassTimestamp()

ilTestPassesSelector::getLastFinishedPassTimestamp ( )
Returns
int timestamp

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

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

275  {
276  if ($this->getLastFinishedPass() === null) {
277  return null;
278  }
279 
280  $passes = $this->getLazyLoadedPasses();
281  return $passes[$this->getLastFinishedPass()]['tstamp'];
282  }
+ Here is the call graph for this function:

◆ getLazyLoadedPasses()

ilTestPassesSelector::getLazyLoadedPasses ( )
private

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

References $passes, and ensureLoadedPasses().

Referenced by getExistingPasses(), and getLastFinishedPassTimestamp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumExistingPasses()

ilTestPassesSelector::getNumExistingPasses ( )

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

References getExistingPasses().

121  {
122  return count($this->getExistingPasses());
123  }
+ Here is the call graph for this function:

◆ getReportablePasses()

ilTestPassesSelector::getReportablePasses ( )

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

References fetchReportablePasses(), and getExistingPasses().

Referenced by hasReportablePasses().

134  {
135  $existingPasses = $this->getExistingPasses();
136 
137  $reportablePasses = $this->fetchReportablePasses($existingPasses);
138 
139  return $reportablePasses;
140  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasExistingPasses()

ilTestPassesSelector::hasExistingPasses ( )

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

References getExistingPasses().

116  {
117  return (bool) count($this->getExistingPasses());
118  }
+ Here is the call graph for this function:

◆ hasReportablePasses()

ilTestPassesSelector::hasReportablePasses ( )

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

References getReportablePasses().

143  {
144  return (bool) count($this->getReportablePasses());
145  }
+ Here is the call graph for this function:

◆ hasTestPassedOnce()

ilTestPassesSelector::hasTestPassedOnce (   $activeId)

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

References $activeId, $DIC, $res, and $row.

Referenced by isReportablePass().

285  {
286  global $DIC; /* @var ILIAS\DI\Container $DIC */
287 
288  if (!isset($this->testPassedOnceCache[$activeId])) {
289  $this->testPassedOnceCache[$activeId] = false;
290 
291  $res = $DIC->database()->queryF(
292  "SELECT passed_once FROM tst_result_cache WHERE active_fi = %s",
293  array('integer'),
294  array($activeId)
295  );
296 
297  while ($row = $DIC->database()->fetchAssoc($res)) {
298  $this->testPassedOnceCache[$activeId] = (bool) $row['passed_once'];
299  }
300  }
301 
302  return $this->testPassedOnceCache[$activeId];
303  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
+ Here is the caller graph for this function:

◆ isClosedPass()

ilTestPassesSelector::isClosedPass (   $pass)
private

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

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

Referenced by fetchClosedPasses(), and isReportablePass().

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

◆ isProcessingTimeReached()

ilTestPassesSelector::isProcessingTimeReached (   $pass)
private

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

References $pass, and getActiveId().

Referenced by isClosedPass().

257  {
258  if (!$this->testOBJ->getEnableProcessingTime()) {
259  return false;
260  }
261 
262  $startingTime = $this->testOBJ->getStartingTimeOfUser($this->getActiveId(), $pass);
263 
264  if ($startingTime === false) {
265  return false;
266  }
267 
268  return $this->testOBJ->isMaxProcessingTimeReached($startingTime, $this->getActiveId());
269  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isReportablePass()

ilTestPassesSelector::isReportablePass (   $lastPass,
  $pass 
)
private

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

References $pass, getActiveId(), hasTestPassedOnce(), isClosedPass(), isReportingDateReached(), ilObjTest\SCORE_REPORTING_AFTER_PASSED, ilObjTest\SCORE_REPORTING_DATE, ilObjTest\SCORE_REPORTING_FINISHED, and ilObjTest\SCORE_REPORTING_IMMIDIATLY.

Referenced by fetchReportablePasses().

189  {
190  switch ($this->testOBJ->getScoreReporting()) {
192 
193  return true;
194 
196 
197  return $this->isReportingDateReached();
198 
200 
201  if ($pass < $lastPass) {
202  return true;
203  }
204 
205  return $this->isClosedPass($pass);
206 
208 
209  if (!$this->hasTestPassedOnce($this->getActiveId())) {
210  return false;
211  }
212 
213  return $this->isClosedPass($pass);
214  }
215 
216  return false;
217  }
const SCORE_REPORTING_AFTER_PASSED
const SCORE_REPORTING_IMMIDIATLY
const SCORE_REPORTING_FINISHED
const SCORE_REPORTING_DATE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isReportingDateReached()

ilTestPassesSelector::isReportingDateReached ( )
private

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

Referenced by isReportablePass().

242  {
243  $reg = '/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/';
244  $date = $this->testOBJ->getReportingDate();
245  $matches = null;
246 
247  if (!preg_match($reg, $date, $matches)) {
248  return false;
249  }
250 
251  $repTS = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
252 
253  return time() >= $repTS;
254  }
+ Here is the caller graph for this function:

◆ loadLastFinishedPass()

ilTestPassesSelector::loadLastFinishedPass ( )

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

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

94  {
95  $query = "
96  SELECT last_finished_pass FROM tst_active WHERE active_id = %s
97  ";
98 
99  $res = $this->db->queryF(
100  $query,
101  array('integer'),
102  array($this->getActiveId())
103  );
104 
105  while ($row = $this->db->fetchAssoc($res)) {
106  $this->setLastFinishedPass($row['last_finished_pass']);
107  }
108  }
foreach($_POST as $key=> $value) $res
setLastFinishedPass($lastFinishedPass)
$query
$row
+ Here is the call graph for this function:

◆ loadPasses()

ilTestPassesSelector::loadPasses ( )
private

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

References $query, $res, $row, and getActiveId().

Referenced by ensureLoadedPasses().

64  {
65  $query = "
66  SELECT DISTINCT tst_pass_result.* FROM tst_pass_result
67  LEFT JOIN tst_test_result
68  ON tst_pass_result.pass = tst_test_result.pass
69  AND tst_pass_result.active_fi = tst_test_result.active_fi
70  WHERE tst_pass_result.active_fi = %s
71  ORDER BY tst_pass_result.pass
72  ";
73 
74  $res = $this->db->queryF(
75  $query,
76  array('integer'),
77  array($this->getActiveId())
78  );
79 
80  $this->passes = array();
81 
82  while ($row = $this->db->fetchAssoc($res)) {
83  $this->passes[$row['pass']] = $row;
84  }
85  }
foreach($_POST as $key=> $value) $res
$query
$row
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ passesLoaded()

ilTestPassesSelector::passesLoaded ( )
private

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

Referenced by ensureLoadedPasses().

53  {
54  return is_array($this->passes);
55  }
+ Here is the caller graph for this function:

◆ setActiveId()

ilTestPassesSelector::setActiveId (   $activeId)

◆ setLastFinishedPass()

ilTestPassesSelector::setLastFinishedPass (   $lastFinishedPass)

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

References $lastFinishedPass.

Referenced by loadLastFinishedPass().

47  {
49  $this->lastFinishedPass = $lastFinishedPass;
50  }
+ Here is the caller graph for this function:

Field Documentation

◆ $activeId

ilTestPassesSelector::$activeId
private

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

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

◆ $db

ilTestPassesSelector::$db
protected

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

Referenced by __construct().

◆ $lastFinishedPass

ilTestPassesSelector::$lastFinishedPass = null
private

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

Referenced by getLastFinishedPass(), and setLastFinishedPass().

◆ $passes

ilTestPassesSelector::$passes = null
private

◆ $testOBJ

ilTestPassesSelector::$testOBJ
protected

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

Referenced by __construct().

◆ $testPassedOnceCache

ilTestPassesSelector::$testPassedOnceCache = array()
private

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


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