ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 206 of file class.ilTestPassesSelector.php.

References getLastFinishedPass().

Referenced by isClosedPass().

207  {
208  if( $this->getLastFinishedPass() === null )
209  {
210  throw new ilTestException('invalid object state: last finished pass was not set!');
211  }
212  }
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  {
59  $this->loadPasses();
60  }
61  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchClosedPasses()

ilTestPassesSelector::fetchClosedPasses (   $existingPasses)
private

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

References $pass, array, and isClosedPass().

Referenced by getClosedPasses().

152  {
153  $closedPasses = array();
154 
155  foreach($existingPasses as $pass)
156  {
157  if( $this->isClosedPass($pass) )
158  {
159  $closedPasses[] = $pass;
160  }
161  }
162 
163  return $closedPasses;
164  }
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 166 of file class.ilTestPassesSelector.php.

References $pass.

Referenced by fetchReportablePasses().

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

◆ fetchReportablePasses()

ilTestPassesSelector::fetchReportablePasses (   $existingPasses)
private

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

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

Referenced by getReportablePasses().

135  {
136  $lastPass = $this->fetchLastPass($existingPasses);
137 
138  $reportablePasses = array();
139 
140  foreach($existingPasses as $pass)
141  {
142  if( $this->isReportablePass($lastPass, $pass) )
143  {
144  $reportablePasses[] = $pass;
145  }
146  }
147 
148  return $reportablePasses;
149  }
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 117 of file class.ilTestPassesSelector.php.

References fetchClosedPasses(), and getExistingPasses().

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

◆ getExistingPasses()

ilTestPassesSelector::getExistingPasses ( )

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

References getLazyLoadedPasses().

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

108  {
109  return array_keys($this->getLazyLoadedPasses());
110  }
+ 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 267 of file class.ilTestPassesSelector.php.

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

268  {
269  if( $this->getLastFinishedPass() === null )
270  {
271  return null;
272  }
273 
274  $passes = $this->getLazyLoadedPasses();
275  return $passes[$this->getLastFinishedPass()]['tstamp'];
276  }
+ 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 112 of file class.ilTestPassesSelector.php.

References getExistingPasses().

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

◆ getReportablePasses()

ilTestPassesSelector::getReportablePasses ( )

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

References fetchReportablePasses(), and getExistingPasses().

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

◆ isClosedPass()

ilTestPassesSelector::isClosedPass (   $pass)
private

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

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

Referenced by fetchClosedPasses(), and isReportablePass().

215  {
217 
218  if( $pass <= $this->getLastFinishedPass() )
219  {
220  return true;
221  }
222 
223  if( $this->isProcessingTimeReached($pass) )
224  {
225  return true;
226  }
227 
228  return false;
229  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isProcessingTimeReached()

ilTestPassesSelector::isProcessingTimeReached (   $pass)
private

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

References $pass, and getActiveId().

Referenced by isClosedPass().

248  {
249  if( !$this->testOBJ->getEnableProcessingTime() )
250  {
251  return false;
252  }
253 
254  $startingTime = $this->testOBJ->getStartingTimeOfUser($this->getActiveId(), $pass);
255 
256  if($startingTime === FALSE)
257  {
258  return false;
259  }
260 
261  return $this->testOBJ->isMaxProcessingTimeReached($startingTime, $this->getActiveId());
262  }
+ 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 181 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().

182  {
183  switch( $this->testOBJ->getScoreReporting() )
184  {
186 
187  return true;
188 
190 
191  return $this->isReportingDateReached();
192 
194 
195  if($pass < $lastPass)
196  {
197  return true;
198  }
199 
200  return $this->isClosedPass($pass);
201  }
202 
203  return false;
204  }
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 231 of file class.ilTestPassesSelector.php.

References time.

Referenced by isReportablePass().

232  {
233  $reg = '/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/';
234  $date = $this->testOBJ->getReportingDate();
235  $matches = null;
236 
237  if( !preg_match($reg, $date, $matches) )
238  {
239  return false;
240  }
241 
242  $repTS = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
243 
244  return time() >= $repTS;
245  }
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, array('integer'), array($this->getActiveId())
99  );
100 
101  while( $row = $this->db->fetchAssoc($res) )
102  {
103  $this->setLastFinishedPass($row['last_finished_pass']);
104  }
105  }
setLastFinishedPass($lastFinishedPass)
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ loadPasses()

ilTestPassesSelector::loadPasses ( )
private

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

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

Referenced by ensureLoadedPasses().

63  {
64  $query = "
65  SELECT DISTINCT tst_pass_result.* FROM tst_pass_result
66  LEFT JOIN tst_test_result
67  ON tst_pass_result.pass = tst_test_result.pass
68  AND tst_pass_result.active_fi = tst_test_result.active_fi
69  WHERE tst_pass_result.active_fi = %s
70  ORDER BY tst_pass_result.pass
71  ";
72 
73  $res = $this->db->queryF(
74  $query, array('integer'), array($this->getActiveId())
75  );
76 
77  $this->passes = array();
78 
79  while( $row = $this->db->fetchAssoc($res) )
80  {
81  $this->passes[$row['pass']] = $row;
82  }
83  }
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: