ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilTestPassesSelector Class Reference
+ Collaboration diagram for ilTestPassesSelector:

Public Member Functions

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

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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $db, and $testOBJ.

24  {
25  $this->db = $db;
26  $this->testOBJ = $testOBJ;
27  }

Member Function Documentation

◆ checkLastFinishedPassInitialised()

ilTestPassesSelector::checkLastFinishedPassInitialised ( )
private

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

References getLastFinishedPass().

Referenced by isClosedPass().

200  {
201  if ($this->getLastFinishedPass() === null) {
202  throw new ilTestException('invalid object state: last finished pass was not set!');
203  }
204  }
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 55 of file class.ilTestPassesSelector.php.

References loadPasses(), and passesLoaded().

Referenced by getLazyLoadedPasses().

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

◆ fetchClosedPasses()

ilTestPassesSelector::fetchClosedPasses (   $existingPasses)
private

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

References $pass, array, and isClosedPass().

Referenced by getClosedPasses().

151  {
152  $closedPasses = array();
153 
154  foreach ($existingPasses as $pass) {
155  if ($this->isClosedPass($pass)) {
156  $closedPasses[] = $pass;
157  }
158  }
159 
160  return $closedPasses;
161  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchLastPass()

ilTestPassesSelector::fetchLastPass (   $existingPasses)
private

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

References $pass.

Referenced by fetchReportablePasses().

164  {
165  $lastPass = null;
166 
167  foreach ($existingPasses as $pass) {
168  if ($lastPass === null || $pass > $lastPass) {
169  $lastPass = $pass;
170  }
171  }
172 
173  return $lastPass;
174  }
+ Here is the caller graph for this function:

◆ fetchReportablePasses()

ilTestPassesSelector::fetchReportablePasses (   $existingPasses)
private

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

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

Referenced by getReportablePasses().

136  {
137  $lastPass = $this->fetchLastPass($existingPasses);
138 
139  $reportablePasses = array();
140 
141  foreach ($existingPasses as $pass) {
142  if ($this->isReportablePass($lastPass, $pass)) {
143  $reportablePasses[] = $pass;
144  }
145  }
146 
147  return $reportablePasses;
148  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveId()

ilTestPassesSelector::getActiveId ( )

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

References $activeId.

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

+ Here is the caller graph for this function:

◆ getClosedPasses()

ilTestPassesSelector::getClosedPasses ( )

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

References fetchClosedPasses(), and getExistingPasses().

119  {
120  $existingPasses = $this->getExistingPasses();
121  $closedPasses = $this->fetchClosedPasses($existingPasses);
122 
123  return $closedPasses;
124  }
+ Here is the call graph for this function:

◆ getExistingPasses()

ilTestPassesSelector::getExistingPasses ( )

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

References getLazyLoadedPasses().

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

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

◆ getLastFinishedPass()

ilTestPassesSelector::getLastFinishedPass ( )

Definition at line 39 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 254 of file class.ilTestPassesSelector.php.

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

255  {
256  if ($this->getLastFinishedPass() === null) {
257  return null;
258  }
259 
260  $passes = $this->getLazyLoadedPasses();
261  return $passes[$this->getLastFinishedPass()]['tstamp'];
262  }
+ Here is the call graph for this function:

◆ getLazyLoadedPasses()

ilTestPassesSelector::getLazyLoadedPasses ( )
private

Definition at line 85 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 113 of file class.ilTestPassesSelector.php.

References getExistingPasses().

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

◆ getReportablePasses()

ilTestPassesSelector::getReportablePasses ( )

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

References fetchReportablePasses(), and getExistingPasses().

127  {
128  $existingPasses = $this->getExistingPasses();
129 
130  $reportablePasses = $this->fetchReportablePasses($existingPasses);
131 
132  return $reportablePasses;
133  }
+ Here is the call graph for this function:

◆ isClosedPass()

ilTestPassesSelector::isClosedPass (   $pass)
private

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

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

Referenced by fetchClosedPasses(), and isReportablePass().

207  {
209 
210  if ($pass <= $this->getLastFinishedPass()) {
211  return true;
212  }
213 
214  if ($this->isProcessingTimeReached($pass)) {
215  return true;
216  }
217 
218  return false;
219  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isProcessingTimeReached()

ilTestPassesSelector::isProcessingTimeReached (   $pass)
private

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

References $pass, and getActiveId().

Referenced by isClosedPass().

237  {
238  if (!$this->testOBJ->getEnableProcessingTime()) {
239  return false;
240  }
241 
242  $startingTime = $this->testOBJ->getStartingTimeOfUser($this->getActiveId(), $pass);
243 
244  if ($startingTime === false) {
245  return false;
246  }
247 
248  return $this->testOBJ->isMaxProcessingTimeReached($startingTime, $this->getActiveId());
249  }
+ 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 176 of file class.ilTestPassesSelector.php.

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

Referenced by fetchReportablePasses().

177  {
178  switch ($this->testOBJ->getScoreReporting()) {
180 
181  return true;
182 
184 
185  return $this->isReportingDateReached();
186 
188 
189  if ($pass < $lastPass) {
190  return true;
191  }
192 
193  return $this->isClosedPass($pass);
194  }
195 
196  return false;
197  }
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 221 of file class.ilTestPassesSelector.php.

References time.

Referenced by isReportablePass().

222  {
223  $reg = '/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/';
224  $date = $this->testOBJ->getReportingDate();
225  $matches = null;
226 
227  if (!preg_match($reg, $date, $matches)) {
228  return false;
229  }
230 
231  $repTS = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
232 
233  return time() >= $repTS;
234  }
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ loadLastFinishedPass()

ilTestPassesSelector::loadLastFinishedPass ( )

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

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

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

◆ loadPasses()

ilTestPassesSelector::loadPasses ( )
private

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

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

Referenced by ensureLoadedPasses().

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

◆ passesLoaded()

ilTestPassesSelector::passesLoaded ( )
private

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

Referenced by ensureLoadedPasses().

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

◆ setActiveId()

ilTestPassesSelector::setActiveId (   $activeId)

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

References $activeId.

35  {
36  $this->activeId = $activeId;
37  }

◆ setLastFinishedPass()

ilTestPassesSelector::setLastFinishedPass (   $lastFinishedPass)

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

References $lastFinishedPass.

Referenced by loadLastFinishedPass().

45  {
47  $this->lastFinishedPass = $lastFinishedPass;
48  }
+ 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(), 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().


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