ILIAS  release_8 Revision v8.24
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 27 of file class.ilTestParticipantList.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

43 {
44 $this->testObj = $testObj;
45 }

References $testObj.

Member Function Documentation

◆ addParticipant()

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

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

67 {
68 $this->participants[] = $participant;
69 }

Referenced by initializeFromDbRows().

+ Here is the caller graph for this function:

◆ buildFullname()

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

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

400 : string
401 {
402 if ($this->getTestObj()->getFixedParticipants() && !$participant->getActiveId()) {
403 return $this->buildInviteeFullname($participant);
404 }
405
406 return $this->buildParticipantsFullname($participant);
407 }
buildParticipantsFullname(ilTestParticipant $participant)
buildInviteeFullname(ilTestParticipant $participant)

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

+ Here is the call graph for this function:

◆ buildInviteeFullname()

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

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

413 : string
414 {
415 global $DIC; /* @var ILIAS\DI\Container $DIC */
416
417 if (strlen($participant->getFirstname() . $participant->getLastname()) == 0) {
418 return $DIC->language()->txt("deleted_user");
419 }
420
421 if ($this->getTestObj()->getAnonymity()) {
422 return $DIC->language()->txt('anonymous');
423 }
424
425 return trim($participant->getLastname() . ", " . $participant->getFirstname());
426 }
global $DIC
Definition: feed.php:28

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

Referenced by buildFullname().

+ 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 432 of file class.ilTestParticipantList.php.

432 : string
433 {
434 require_once 'Modules/Test/classes/class.ilObjTestAccess.php';
436 }
static _getParticipantData($active_id)
Retrieves a participant name from active id.

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

Referenced by buildFullname().

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

◆ buildScoringsQuery()

ilTestParticipantList::buildScoringsQuery ( )

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

264 : string
265 {
266 global $DIC; /* @var ILIAS\DI\Container $DIC */
267
268 $IN_activeIds = $DIC->database()->in(
269 'tres.active_fi',
270 $this->getAllActiveIds(),
271 false,
272 'integer'
273 );
274
275 if (false && !$this->getTestObj()->isDynamicTest()) { // BH: keep for the moment
276 $closedScoringsOnly = "
277 INNER JOIN tst_active tact
278 ON tact.active_id = tres.active_fi
279 AND tact.last_finished_pass = tact.last_started_pass
280 ";
281 } else {
282 $closedScoringsOnly = '';
283 }
284
285 $query = "
286 SELECT * FROM tst_result_cache tres
287
288 INNER JOIN tst_pass_result pres
289 ON pres.active_fi = tres.active_fi
290 AND pres.pass = tres.pass
291
292 $closedScoringsOnly
293
294 WHERE $IN_activeIds
295 ";
296
297 return $query;
298 }
$query

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

Referenced by getScoredParticipantList().

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

◆ current()

ilTestParticipantList::current ( )

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

173 {
174 return current($this->participants);
175 }

References current().

Referenced by current().

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

◆ getAccessFilteredList()

ilTestParticipantList::getAccessFilteredList ( callable  $userAccessFilter)

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

157 {
158 $usrIds = call_user_func_array($userAccessFilter, [$this->getAllUserIds()]);
159
160 $accessFilteredList = new self($this->getTestObj());
161
162 foreach ($this as $participant) {
163 if (in_array($participant->getUsrId(), $usrIds)) {
164 $participant = clone $participant;
165 $accessFilteredList->addParticipant($participant);
166 }
167 }
168
169 return $accessFilteredList;
170 }

References getAllUserIds(), and getTestObj().

+ Here is the call graph for this function:

◆ getAllActiveIds()

ilTestParticipantList::getAllActiveIds ( )

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

134 : array
135 {
136 $activeIds = array();
137
138 foreach ($this as $participant) {
139 $activeIds[] = $participant->getActiveId();
140 }
141
142 return $activeIds;
143 }

Referenced by buildScoringsQuery().

+ Here is the caller graph for this function:

◆ getAllUserIds()

ilTestParticipantList::getAllUserIds ( )

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

123 : array
124 {
125 $usrIds = array();
126
127 foreach ($this as $participant) {
128 $usrIds[] = $participant->getUsrId();
129 }
130
131 return $usrIds;
132 }

Referenced by getAccessFilteredList().

+ Here is the caller graph for this function:

◆ getParticipantByActiveId()

ilTestParticipantList::getParticipantByActiveId (   $activeId)

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

84 {
85 foreach ($this as $participant) {
86 if ($participant->getActiveId() != $activeId) {
87 continue;
88 }
89
90 return $participant;
91 }
92 return null;
93 }

Referenced by getScoredParticipantList().

+ Here is the caller graph for this function:

◆ getParticipantByUsrId()

ilTestParticipantList::getParticipantByUsrId (   $usrId)

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

72 {
73 foreach ($this as $participant) {
74 if ($participant->getUsrId() != $usrId) {
75 continue;
76 }
77
78 return $participant;
79 }
80 return null;
81 }

◆ getParticipantsTableRows()

ilTestParticipantList::getParticipantsTableRows ( )

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

300 : array
301 {
302 $rows = array();
303
304 foreach ($this as $participant) {
305 $row = array(
306 'usr_id' => $participant->getUsrId(),
307 'active_id' => $participant->getActiveId(),
308 'login' => $participant->getLogin(),
309 'clientip' => $participant->getClientIp(),
310 'firstname' => $participant->getFirstname(),
311 'lastname' => $participant->getLastname(),
312 'name' => $this->buildFullname($participant),
313 'started' => ($participant->getActiveId() > 0) ? 1 : 0,
314 'unfinished' => $participant->hasUnfinishedPasses() ? 1 : 0,
315 'finished' => $participant->isTestFinished() ? 1 : 0,
316 'access' => $this->lookupLastAccess($participant->getActiveId()),
317 'tries' => $this->lookupNrOfTries($participant->getActiveId())
318 );
319
320 $rows[] = $row;
321 }
322
323 return $rows;
324 }
$rows
Definition: xhr_table.php:10

References $rows.

◆ getScoredParticipantList()

ilTestParticipantList::getScoredParticipantList ( )
Returns
ilTestParticipantList

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

230 {
231 require_once 'Modules/Test/classes/class.ilTestParticipantScoring.php';
232
233 $scoredParticipantList = new self($this->getTestObj());
234
235 global $DIC; /* @var ILIAS\DI\Container $DIC */
236
237 $res = $DIC->database()->query($this->buildScoringsQuery());
238
239 while ($row = $DIC->database()->fetchAssoc($res)) {
240 $scoring = new ilTestParticipantScoring();
241
242 $scoring->setActiveId((int) $row['active_fi']);
243 $scoring->setScoredPass((int) $row['pass']);
244
245 $scoring->setAnsweredQuestions((int) $row['answeredquestions']);
246 $scoring->setTotalQuestions((int) $row['questioncount']);
247
248 $scoring->setReachedPoints((float) $row['reached_points']);
249 $scoring->setMaxPoints((float) $row['max_points']);
250
251 $scoring->setPassed((bool) $row['passed']);
252 $scoring->setFinalMark((string) $row['mark_short']);
253
254 $this->getParticipantByActiveId($row['active_fi'])->setScoring($scoring);
255
256 $scoredParticipantList->addParticipant(
257 $this->getParticipantByActiveId($row['active_fi'])
258 );
259 }
260
261 return $scoredParticipantList;
262 }
$res
Definition: ltiservices.php:69

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

+ Here is the call graph for this function:

◆ getScoringsTableRows()

ilTestParticipantList::getScoringsTableRows ( )

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

326 : array
327 {
328 $rows = array();
329
330 foreach ($this as $participant) {
331 if (!$participant->hasScoring()) {
332 continue;
333 }
334
335 $row = array(
336 'usr_id' => $participant->getUsrId(),
337 'active_id' => $participant->getActiveId(),
338 'login' => $participant->getLogin(),
339 'firstname' => $participant->getFirstname(),
340 'lastname' => $participant->getLastname(),
341 'name' => $this->buildFullname($participant)
342 );
343
344 if ($participant->getScoring()) {
345 $row['scored_pass'] = $participant->getScoring()->getScoredPass();
346 $row['answered_questions'] = $participant->getScoring()->getAnsweredQuestions();
347 $row['total_questions'] = $participant->getScoring()->getTotalQuestions();
348 $row['reached_points'] = $participant->getScoring()->getReachedPoints();
349 $row['max_points'] = $participant->getScoring()->getMaxPoints();
350 $row['percent_result'] = $participant->getScoring()->getPercentResult();
351 $row['passed_status'] = $participant->getScoring()->isPassed();
352 $row['final_mark'] = $participant->getScoring()->getFinalMark();
353 $row['scored_pass_finished_timestamp'] = ilObjTest::lookupLastTestPassAccess(
354 $participant->getActiveId(),
355 $participant->getScoring()->getScoredPass()
356 );
357 $row['finished_passes'] = $participant->getFinishedTries();
358 $row['has_unfinished_passes'] = $participant->hasUnfinishedPasses();
359 }
360
361 $rows[] = $row;
362 }
363
364 return $rows;
365 }
static lookupLastTestPassAccess($activeId, $passIndex)

References $rows, and ilObjTest\lookupLastTestPassAccess().

+ Here is the call graph for this function:

◆ getTestObj()

ilTestParticipantList::getTestObj ( )
Returns
ilObjTest

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

50 : ilObjTest
51 {
52 return $this->testObj;
53 }

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 112 of file class.ilTestParticipantList.php.

112 : bool
113 {
114 foreach ($this as $participant) {
115 if ($participant->getScoring() instanceof ilTestParticipantScoring) {
116 return true;
117 }
118 }
119
120 return false;
121 }

◆ hasUnfinishedPasses()

ilTestParticipantList::hasUnfinishedPasses ( )
Returns
bool

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

98 : bool
99 {
100 foreach ($this as $participant) {
101 if ($participant->hasUnfinishedPasses()) {
102 return true;
103 }
104 }
105
106 return false;
107 }

Referenced by ilTestParticipantsGUI\initToolbarControls().

+ Here is the caller graph for this function:

◆ initializeFromDbRows()

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

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

197 {
198 foreach ($dbRows as $rowKey => $rowData) {
199 $participant = new ilTestParticipant();
200
201 if ((int) $rowData['active_id']) {
202 $participant->setActiveId((int) $rowData['active_id']);
203 }
204
205 $participant->setUsrId((int) $rowData['usr_id']);
206
207 $participant->setLogin($rowData['login']);
208 $participant->setLastname($rowData['lastname']);
209 $participant->setFirstname($rowData['firstname']);
210 $participant->setMatriculation($rowData['matriculation']);
211
212 $participant->setActiveStatus((bool) ($rowData['active'] ?? false));
213
214 if (isset($rowData['clientip'])) {
215 $participant->setClientIp($rowData['clientip']);
216 }
217
218 $participant->setFinishedTries((int) $rowData['tries']);
219 $participant->setTestFinished((bool) $rowData['test_finished']);
220 $participant->setUnfinishedPasses((bool) $rowData['unfinished_passes']);
221
222 $this->addParticipant($participant);
223 }
224 }
addParticipant(ilTestParticipant $participant)

References addParticipant().

+ Here is the call graph for this function:

◆ isActiveIdInList()

ilTestParticipantList::isActiveIdInList (   $activeId)

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

145 : bool
146 {
147 foreach ($this as $participant) {
148 if ($participant->getActiveId() == $activeId) {
149 return true;
150 }
151 }
152
153 return false;
154 }

◆ key()

ilTestParticipantList::key ( )

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

181 {
182 return key($this->participants);
183 }

References key().

Referenced by key(), and valid().

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

◆ lookupLastAccess()

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

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

387 : string
388 {
389 if (!$activeId) {
390 return '';
391 }
392
393 return $this->getTestObj()->_getLastAccess($activeId);
394 }

References getTestObj().

+ Here is the call graph for this function:

◆ lookupNrOfTries()

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

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

371 : ?int
372 {
373 $maxPassIndex = ilObjTest::_getMaxPass($activeId);
374
375 if ($maxPassIndex !== null) {
376 $nrOfTries = $maxPassIndex + 1;
377 return $nrOfTries;
378 }
379
380 return null;
381 }
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...

References ilObjTest\_getMaxPass().

+ Here is the call graph for this function:

◆ next()

ilTestParticipantList::next ( )

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

177 {
178 return next($this->participants);
179 }

References next().

Referenced by next().

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

◆ rewind()

ilTestParticipantList::rewind ( )

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

189 {
190 return reset($this->participants);
191 }

◆ setTestObj()

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

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

59 {
60 $this->testObj = $testObj;
61 }

References $testObj.

◆ valid()

ilTestParticipantList::valid ( )

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

184 : bool
185 {
186 return key($this->participants) !== null;
187 }

References key().

+ Here is the call graph for this function:

Field Documentation

◆ $participants

ilTestParticipantList::$participants = array()
protected

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

◆ $testObj

ilTestParticipantList::$testObj
protected

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

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


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