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

Public Member Functions

 __construct (ilObjTest $testObj)
 
 getTestObj ()
 
 setTestObj ($testObj)
 
 addParticipant (ilTestParticipant $participant)
 
 getParticipantByUsrId ($usrId)
 
 getParticipantByActiveId ($activeId)
 
 hasUnfinishedPasses ()
 
 hasScorings ()
 
 getAllUserIds ()
 
 getAllActiveIds ()
 
 isActiveIdInList ($activeId)
 
 getAccessFilteredList (callable $userAccessFilter)
 
 current ()
 
 next ()
 
 key ()
 
 valid ()
 
 rewind ()
 
 initializeFromDbRows ($dbRows)
 
 getScoredParticipantList ()
 
 buildScoringsQuery ()
 
 getParticipantsTableRows ()
 
 getScoringsTableRows ()
 
 lookupNrOfTries ($activeId)
 

Protected Member Functions

 lookupLastAccess ($activeId)
 
 buildFullname (ilTestParticipant $participant)
 
 buildInviteeFullname (ilTestParticipant $participant)
 
 buildParticipantsFullname (ilTestParticipant $participant)
 

Protected Attributes

 $participants = array()
 
 $testObj
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilTestParticipantList::__construct ( ilObjTest  $testObj)
Parameters
ilObjTest$testObj

Definition at line 30 of file class.ilTestParticipantList.php.

References $testObj.

31  {
32  $this->testObj = $testObj;
33  }

Member Function Documentation

◆ addParticipant()

ilTestParticipantList::addParticipant ( ilTestParticipant  $participant)
Parameters
ilTestParticipant$participant

Definition at line 54 of file class.ilTestParticipantList.php.

Referenced by initializeFromDbRows().

55  {
56  $this->participants[] = $participant;
57  }
+ Here is the caller graph for this function:

◆ buildFullname()

ilTestParticipantList::buildFullname ( ilTestParticipant  $participant)
protected
Parameters
ilTestParticipant$participant
Returns
string

Definition at line 389 of file class.ilTestParticipantList.php.

References buildInviteeFullname(), buildParticipantsFullname(), ilTestParticipant\getActiveId(), and getTestObj().

Referenced by getParticipantsTableRows(), and getScoringsTableRows().

390  {
391  if ($this->getTestObj()->getFixedParticipants() && !$participant->getActiveId()) {
392  return $this->buildInviteeFullname($participant);
393  }
394 
395  return $this->buildParticipantsFullname($participant);
396  }
buildInviteeFullname(ilTestParticipant $participant)
buildParticipantsFullname(ilTestParticipant $participant)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildInviteeFullname()

ilTestParticipantList::buildInviteeFullname ( ilTestParticipant  $participant)
protected
Parameters
ilTestParticipant$participant
Returns
string

Definition at line 402 of file class.ilTestParticipantList.php.

References $DIC, ilTestParticipant\getFirstname(), ilTestParticipant\getLastname(), and getTestObj().

Referenced by buildFullname().

403  {
404  global $DIC; /* @var ILIAS\DI\Container $DIC */
405 
406  if (strlen($participant->getFirstname() . $participant->getLastname()) == 0) {
407  return $DIC->language()->txt("deleted_user");
408  }
409 
410  if ($this->getTestObj()->getAnonymity()) {
411  return $DIC->language()->txt('anonymous');
412  }
413 
414  return trim($participant->getLastname() . ", " . $participant->getFirstname());
415  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildParticipantsFullname()

ilTestParticipantList::buildParticipantsFullname ( ilTestParticipant  $participant)
protected
Parameters
ilTestParticipant$participant
Returns
string

Definition at line 421 of file class.ilTestParticipantList.php.

References ilObjTestAccess\_getParticipantData(), and ilTestParticipant\getActiveId().

Referenced by buildFullname().

422  {
423  require_once 'Modules/Test/classes/class.ilObjTestAccess.php';
424  return ilObjTestAccess::_getParticipantData($participant->getActiveId());
425  }
static _getParticipantData($active_id)
Retrieves a participant name from active id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildScoringsQuery()

ilTestParticipantList::buildScoringsQuery ( )

Definition at line 254 of file class.ilTestParticipantList.php.

References $DIC, $query, getAllActiveIds(), and getTestObj().

Referenced by getScoredParticipantList().

255  {
256  global $DIC; /* @var ILIAS\DI\Container $DIC */
257 
258  $IN_activeIds = $DIC->database()->in(
259  'tres.active_fi',
260  $this->getAllActiveIds(),
261  false,
262  'integer'
263  );
264 
265  if (false && !$this->getTestObj()->isDynamicTest()) { // BH: keep for the moment
266  $closedScoringsOnly = "
267  INNER JOIN tst_active tact
268  ON tact.active_id = tres.active_fi
269  AND tact.last_finished_pass = tact.last_started_pass
270  ";
271  } else {
272  $closedScoringsOnly = '';
273  }
274 
275  $query = "
276  SELECT * FROM tst_result_cache tres
277 
278  INNER JOIN tst_pass_result pres
279  ON pres.active_fi = tres.active_fi
280  AND pres.pass = tres.pass
281 
282  $closedScoringsOnly
283 
284  WHERE $IN_activeIds
285  ";
286 
287  return $query;
288  }
global $DIC
Definition: saml.php:7
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ current()

ilTestParticipantList::current ( )

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

163  {
164  return current($this->participants);
165  }

◆ getAccessFilteredList()

ilTestParticipantList::getAccessFilteredList ( callable  $userAccessFilter)

Definition at line 146 of file class.ilTestParticipantList.php.

References getAllUserIds(), and getTestObj().

147  {
148  $usrIds = call_user_func_array($userAccessFilter, [$this->getAllUserIds()]);
149 
150  $accessFilteredList = new self($this->getTestObj());
151 
152  foreach ($this as $participant) {
153  if (in_array($participant->getUsrId(), $usrIds)) {
154  $participant = clone $participant;
155  $accessFilteredList->addParticipant($participant);
156  }
157  }
158 
159  return $accessFilteredList;
160  }
+ Here is the call graph for this function:

◆ getAllActiveIds()

ilTestParticipantList::getAllActiveIds ( )

Definition at line 124 of file class.ilTestParticipantList.php.

Referenced by buildScoringsQuery().

125  {
126  $activeIds = array();
127 
128  foreach ($this as $participant) {
129  $activeIds[] = $participant->getActiveId();
130  }
131 
132  return $activeIds;
133  }
+ Here is the caller graph for this function:

◆ getAllUserIds()

ilTestParticipantList::getAllUserIds ( )

Definition at line 113 of file class.ilTestParticipantList.php.

Referenced by getAccessFilteredList().

114  {
115  $usrIds = array();
116 
117  foreach ($this as $participant) {
118  $usrIds[] = $participant->getUsrId();
119  }
120 
121  return $usrIds;
122  }
+ Here is the caller graph for this function:

◆ getParticipantByActiveId()

ilTestParticipantList::getParticipantByActiveId (   $activeId)
Parameters
$activeId
Returns
ilTestParticipant

Definition at line 74 of file class.ilTestParticipantList.php.

Referenced by getScoredParticipantList().

75  {
76  foreach ($this as $participant) {
77  if ($participant->getActiveId() != $activeId) {
78  continue;
79  }
80 
81  return $participant;
82  }
83  }
+ Here is the caller graph for this function:

◆ getParticipantByUsrId()

ilTestParticipantList::getParticipantByUsrId (   $usrId)

Definition at line 59 of file class.ilTestParticipantList.php.

60  {
61  foreach ($this as $participant) {
62  if ($participant->getUsrId() != $usrId) {
63  continue;
64  }
65 
66  return $participant;
67  }
68  }

◆ getParticipantsTableRows()

ilTestParticipantList::getParticipantsTableRows ( )

Definition at line 290 of file class.ilTestParticipantList.php.

References $row, $rows, buildFullname(), lookupLastAccess(), and lookupNrOfTries().

291  {
292  $rows = array();
293 
294  foreach ($this as $participant) {
295  $row = array(
296  'usr_id' => $participant->getUsrId(),
297  'active_id' => $participant->getActiveId(),
298  'login' => $participant->getLogin(),
299  'clientip' => $participant->getClientIp(),
300  'firstname' => $participant->getFirstname(),
301  'lastname' => $participant->getLastname(),
302  'name' => $this->buildFullname($participant),
303  'started' => ($participant->getActiveId() > 0) ? 1 : 0,
304  'unfinished' => $participant->hasUnfinishedPasses() ? 1 : 0,
305  'finished' => $participant->isTestFinished() ? 1 : 0,
306  'access' => $this->lookupLastAccess($participant->getActiveId()),
307  'tries' => $this->lookupNrOfTries($participant->getActiveId())
308  );
309 
310  $rows[] = $row;
311  }
312 
313  return $rows;
314  }
buildFullname(ilTestParticipant $participant)
$row
$rows
Definition: xhr_table.php:10
+ Here is the call graph for this function:

◆ getScoredParticipantList()

ilTestParticipantList::getScoredParticipantList ( )
Returns
ilTestParticipantList

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

References $DIC, $res, $row, buildScoringsQuery(), getParticipantByActiveId(), and getTestObj().

220  {
221  require_once 'Modules/Test/classes/class.ilTestParticipantScoring.php';
222 
223  $scoredParticipantList = new self($this->getTestObj());
224 
225  global $DIC; /* @var ILIAS\DI\Container $DIC */
226 
227  $res = $DIC->database()->query($this->buildScoringsQuery());
228 
229  while ($row = $DIC->database()->fetchAssoc($res)) {
230  $scoring = new ilTestParticipantScoring();
231 
232  $scoring->setActiveId((int) $row['active_fi']);
233  $scoring->setScoredPass((int) $row['pass']);
234 
235  $scoring->setAnsweredQuestions((int) $row['answeredquestions']);
236  $scoring->setTotalQuestions((int) $row['questioncount']);
237 
238  $scoring->setReachedPoints((float) $row['reached_points']);
239  $scoring->setMaxPoints((float) $row['max_points']);
240 
241  $scoring->setPassed((bool) $row['passed']);
242  $scoring->setFinalMark((string) $row['mark_official']);
243 
244  $this->getParticipantByActiveId($row['active_fi'])->setScoring($scoring);
245 
246  $scoredParticipantList->addParticipant(
247  $this->getParticipantByActiveId($row['active_fi'])
248  );
249  }
250 
251  return $scoredParticipantList;
252  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
+ Here is the call graph for this function:

◆ getScoringsTableRows()

ilTestParticipantList::getScoringsTableRows ( )

Definition at line 316 of file class.ilTestParticipantList.php.

References $row, $rows, buildFullname(), and ilObjTest\lookupLastTestPassAccess().

317  {
318  $rows = array();
319 
320  foreach ($this as $participant) {
321  if (!$participant->hasScoring()) {
322  continue;
323  }
324 
325  $row = array(
326  'usr_id' => $participant->getUsrId(),
327  'active_id' => $participant->getActiveId(),
328  'login' => $participant->getLogin(),
329  'firstname' => $participant->getFirstname(),
330  'lastname' => $participant->getLastname(),
331  'name' => $this->buildFullname($participant)
332  );
333 
334  if ($participant->getScoring()) {
335  $row['scored_pass'] = $participant->getScoring()->getScoredPass();
336  $row['answered_questions'] = $participant->getScoring()->getAnsweredQuestions();
337  $row['total_questions'] = $participant->getScoring()->getTotalQuestions();
338  $row['reached_points'] = $participant->getScoring()->getReachedPoints();
339  $row['max_points'] = $participant->getScoring()->getMaxPoints();
340  $row['percent_result'] = $participant->getScoring()->getPercentResult();
341  $row['passed_status'] = $participant->getScoring()->isPassed();
342  $row['final_mark'] = $participant->getScoring()->getFinalMark();
343 
344  $row['pass_finished'] = ilObjTest::lookupLastTestPassAccess(
345  $participant->getActiveId(),
346  $participant->getScoring()->getScoredPass()
347  );
348  }
349 
350  $rows[] = $row;
351  }
352 
353  return $rows;
354  }
buildFullname(ilTestParticipant $participant)
static lookupLastTestPassAccess($activeId, $passIndex)
$row
$rows
Definition: xhr_table.php:10
+ Here is the call graph for this function:

◆ getTestObj()

ilTestParticipantList::getTestObj ( )
Returns
ilObjTest

Definition at line 38 of file class.ilTestParticipantList.php.

References $testObj.

Referenced by buildFullname(), buildInviteeFullname(), buildScoringsQuery(), getAccessFilteredList(), getScoredParticipantList(), and lookupLastAccess().

+ Here is the caller graph for this function:

◆ hasScorings()

ilTestParticipantList::hasScorings ( )
Returns
bool

Definition at line 102 of file class.ilTestParticipantList.php.

103  {
104  foreach ($this as $participant) {
105  if ($participant->getScoring() instanceof ilTestParticipantScoring) {
106  return true;
107  }
108  }
109 
110  return false;
111  }

◆ hasUnfinishedPasses()

ilTestParticipantList::hasUnfinishedPasses ( )
Returns
bool

Definition at line 88 of file class.ilTestParticipantList.php.

Referenced by ilTestParticipantsGUI\initToolbarControls().

89  {
90  foreach ($this as $participant) {
91  if ($participant->hasUnfinishedPasses()) {
92  return true;
93  }
94  }
95 
96  return false;
97  }
+ Here is the caller graph for this function:

◆ initializeFromDbRows()

ilTestParticipantList::initializeFromDbRows (   $dbRows)
Parameters
array[]$dbRows

Definition at line 186 of file class.ilTestParticipantList.php.

References addParticipant().

187  {
188  foreach ($dbRows as $rowKey => $rowData) {
189  $participant = new ilTestParticipant();
190 
191  if ((int) $rowData['active_id']) {
192  $participant->setActiveId((int) $rowData['active_id']);
193  }
194 
195  $participant->setUsrId((int) $rowData['usr_id']);
196 
197  $participant->setLogin($rowData['login']);
198  $participant->setLastname($rowData['lastname']);
199  $participant->setFirstname($rowData['firstname']);
200  $participant->setMatriculation($rowData['matriculation']);
201 
202  $participant->setActiveStatus((bool) $rowData['active']);
203 
204  if (isset($rowData['clientip'])) {
205  $participant->setClientIp($rowData['clientip']);
206  }
207 
208  $participant->setFinishedTries((int) $rowData['tries']);
209  $participant->setTestFinished((bool) $rowData['test_finished']);
210  $participant->setUnfinishedPasses((bool) $rowData['unfinished_passes']);
211 
212  $this->addParticipant($participant);
213  }
214  }
addParticipant(ilTestParticipant $participant)
+ Here is the call graph for this function:

◆ isActiveIdInList()

ilTestParticipantList::isActiveIdInList (   $activeId)

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

136  {
137  foreach ($this as $participant) {
138  if ($participant->getActiveId() == $activeId) {
139  return true;
140  }
141  }
142 
143  return false;
144  }

◆ key()

ilTestParticipantList::key ( )

Definition at line 170 of file class.ilTestParticipantList.php.

Referenced by valid().

171  {
172  return key($this->participants);
173  }
+ Here is the caller graph for this function:

◆ lookupLastAccess()

ilTestParticipantList::lookupLastAccess (   $activeId)
protected
Parameters
integer$activeId
Returns
string

Definition at line 376 of file class.ilTestParticipantList.php.

References getTestObj().

Referenced by getParticipantsTableRows().

377  {
378  if (!$activeId) {
379  return '';
380  }
381 
382  return $this->getTestObj()->_getLastAccess($activeId);
383  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupNrOfTries()

ilTestParticipantList::lookupNrOfTries (   $activeId)
Parameters
integer$activeId
Returns
int|null

Definition at line 360 of file class.ilTestParticipantList.php.

References ilObjTest\_getMaxPass().

Referenced by getParticipantsTableRows().

361  {
362  $maxPassIndex = ilObjTest::_getMaxPass($activeId);
363 
364  if ($maxPassIndex !== null) {
365  $nrOfTries = $maxPassIndex + 1;
366  return $nrOfTries;
367  }
368 
369  return null;
370  }
static _getMaxPass($active_id)
Retrieves the maximum pass of a given user for a given test in which the user answered at least one q...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ next()

ilTestParticipantList::next ( )

Definition at line 166 of file class.ilTestParticipantList.php.

167  {
168  return next($this->participants);
169  }

◆ rewind()

ilTestParticipantList::rewind ( )

Definition at line 178 of file class.ilTestParticipantList.php.

179  {
180  return reset($this->participants);
181  }

◆ setTestObj()

ilTestParticipantList::setTestObj (   $testObj)
Parameters
ilObjTest$testObj

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

References $testObj.

47  {
48  $this->testObj = $testObj;
49  }

◆ valid()

ilTestParticipantList::valid ( )

Definition at line 174 of file class.ilTestParticipantList.php.

References key().

175  {
176  return key($this->participants) !== null;
177  }
+ Here is the call graph for this function:

Field Documentation

◆ $participants

ilTestParticipantList::$participants = array()
protected

Definition at line 20 of file class.ilTestParticipantList.php.

◆ $testObj

ilTestParticipantList::$testObj
protected

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

Referenced by __construct(), getTestObj(), and setTestObj().


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