ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestParticipantList Class Reference
+ Inheritance diagram for ilTestParticipantList:
+ Collaboration diagram for ilTestParticipantList:

Public Member Functions

 __construct (private ilObjTest $test_obj, private ilObjUser $user, private ilLanguage $lng, private ilDBInterface $db)
 
 setTestObj (ilObjTest $test_obj)
 
 addParticipant (ilTestParticipant $participant)
 
 getParticipantByUsrId (int $usr_id)
 
 getParticipantByActiveId ($active_id)
 
 hasUnfinishedPasses ()
 
 hasScorings ()
 
 getAllUserIds ()
 
 getAllActiveIds ()
 
 isActiveIdInList (int $active_id)
 
 getAccessFilteredList (Closure $user_access_filter)
 
 current ()
 
 next ()
 
 key ()
 
 valid ()
 
 rewind ()
 
 initializeFromDbRows (array $db_rows)
 
 getScoredParticipantList ()
 
 buildScoringsQuery ()
 
 getParticipantsTableRows ()
 
 getScoringsTableRows ()
 
 lookupNrOfTries (?int $active_id)
 

Protected Member Functions

 lookupLastAccess (?int $active_id)
 
 buildFullname (ilTestParticipant $participant)
 
 buildInviteeFullname (ilTestParticipant $participant)
 
 buildParticipantsFullname (ilTestParticipant $participant)
 

Protected Attributes

array $participants = []
 

Private Member Functions

 getTestObj ()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilTestParticipantList::__construct ( private ilObjTest  $test_obj,
private ilObjUser  $user,
private ilLanguage  $lng,
private ilDBInterface  $db 
)

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

42  {
43  }

Member Function Documentation

◆ addParticipant()

ilTestParticipantList::addParticipant ( ilTestParticipant  $participant)

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

Referenced by initializeFromDbRows().

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

◆ buildFullname()

ilTestParticipantList::buildFullname ( ilTestParticipant  $participant)
protected

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

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

Referenced by getParticipantsTableRows(), and getScoringsTableRows().

349  : string
350  {
351  if ($this->getTestObj()->getMainSettings()->getAccessSettings()->getFixedParticipants() && !$participant->getActiveId()) {
352  return $this->buildInviteeFullname($participant);
353  }
354 
355  return $this->buildParticipantsFullname($participant);
356  }
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

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

References ilTestParticipant\getFirstname(), ilTestParticipant\getLastname(), getTestObj(), and ILIAS\Repository\lng().

Referenced by buildFullname().

358  : string
359  {
360  if (strlen($participant->getFirstname() . $participant->getLastname()) == 0) {
361  return $this->lng->txt("deleted_user");
362  }
363 
364  if ($this->getTestObj()->getAnonymity()) {
365  return $this->lng->txt('anonymous');
366  }
367 
368  return trim($participant->getLastname() . ", " . $participant->getFirstname());
369  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildParticipantsFullname()

ilTestParticipantList::buildParticipantsFullname ( ilTestParticipant  $participant)
protected

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

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

Referenced by buildFullname().

371  : string
372  {
373  return ilObjTestAccess::_getParticipantData($participant->getActiveId());
374  }
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 237 of file class.ilTestParticipantList.php.

References getAllActiveIds().

Referenced by getScoredParticipantList().

237  : string
238  {
239  $IN_activeIds = $this->db->in(
240  'tres.active_fi',
241  $this->getAllActiveIds(),
242  false,
243  'integer'
244  );
245 
246  $query = "
247  SELECT * FROM tst_result_cache tres
248 
249  INNER JOIN tst_pass_result pres
250  ON pres.active_fi = tres.active_fi
251  AND pres.pass = tres.pass
252  WHERE $IN_activeIds
253  ";
254 
255  return $query;
256  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ current()

ilTestParticipantList::current ( )

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

156  {
157  return current($this->participants);
158  }

◆ getAccessFilteredList()

ilTestParticipantList::getAccessFilteredList ( Closure  $user_access_filter)

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

References $lng, getAllUserIds(), and getTestObj().

140  {
141  $usr_ids = $user_access_filter($this->getAllUserIds());
142 
143  $access_filtered_list = new self($this->getTestObj(), $this->user, $this->lng, $this->db);
144 
145  foreach ($this as $participant) {
146  if (in_array($participant->getUsrId(), $usr_ids)) {
147  $participant = clone $participant;
148  $access_filtered_list->addParticipant($participant);
149  }
150  }
151 
152  return $access_filtered_list;
153  }
$lng
+ Here is the call graph for this function:

◆ getAllActiveIds()

ilTestParticipantList::getAllActiveIds ( )

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

Referenced by buildScoringsQuery().

117  : array
118  {
119  $activeIds = array();
120 
121  foreach ($this as $participant) {
122  $activeIds[] = $participant->getActiveId();
123  }
124 
125  return $activeIds;
126  }
+ Here is the caller graph for this function:

◆ getAllUserIds()

ilTestParticipantList::getAllUserIds ( )

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

Referenced by getAccessFilteredList().

106  : array
107  {
108  $usrIds = array();
109 
110  foreach ($this as $participant) {
111  $usrIds[] = $participant->getUsrId();
112  }
113 
114  return $usrIds;
115  }
+ Here is the caller graph for this function:

◆ getParticipantByActiveId()

ilTestParticipantList::getParticipantByActiveId (   $active_id)

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

Referenced by getScoredParticipantList().

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

◆ getParticipantByUsrId()

ilTestParticipantList::getParticipantByUsrId ( int  $usr_id)

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

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

◆ getParticipantsTableRows()

ilTestParticipantList::getParticipantsTableRows ( )

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

References buildFullname(), lookupLastAccess(), and lookupNrOfTries().

258  : array
259  {
260  $rows = [];
261 
262  foreach ($this as $participant) {
263  $row = [
264  'usr_id' => $participant->getUsrId(),
265  'active_id' => $participant->getActiveId(),
266  'login' => $participant->getLogin(),
267  'clientip' => $participant->getClientIp(),
268  'firstname' => $participant->getFirstname(),
269  'lastname' => $participant->getLastname(),
270  'name' => $this->buildFullname($participant),
271  'started' => ($participant->getActiveId() > 0) ? 1 : 0,
272  'unfinished' => $participant->hasUnfinishedPasses() ? 1 : 0,
273  'finished' => $participant->isTestFinished() ? 1 : 0,
274  'access' => $this->lookupLastAccess($participant->getActiveId()),
275  'tries' => $this->lookupNrOfTries($participant->getActiveId())
276  ];
277 
278  $rows[] = $row;
279  }
280 
281  return $rows;
282  }
buildFullname(ilTestParticipant $participant)
+ Here is the call graph for this function:

◆ getScoredParticipantList()

ilTestParticipantList::getScoredParticipantList ( )

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

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

207  {
208  $scored_participant_list = new self($this->getTestObj(), $this->user, $this->lng, $this->db);
209 
210  $res = $this->db->query($this->buildScoringsQuery());
211 
212  while ($row = $this->db->fetchAssoc($res)) {
213  $scoring = new ilTestParticipantScoring();
214 
215  $scoring->setActiveId((int) $row['active_fi']);
216  $scoring->setScoredPass((int) $row['pass']);
217 
218  $scoring->setAnsweredQuestions((int) $row['answeredquestions']);
219  $scoring->setTotalQuestions((int) $row['questioncount']);
220 
221  $scoring->setReachedPoints((float) $row['reached_points']);
222  $scoring->setMaxPoints((float) $row['max_points']);
223 
224  $scoring->setPassed((bool) $row['passed']);
225  $scoring->setFinalMark((string) $row['mark_short']);
226 
227  $this->getParticipantByActiveId($row['active_fi'])->setScoring($scoring);
228 
229  $scored_participant_list->addParticipant(
230  $this->getParticipantByActiveId($row['active_fi'])
231  );
232  }
233 
234  return $scored_participant_list;
235  }
$res
Definition: ltiservices.php:69
$lng
+ Here is the call graph for this function:

◆ getScoringsTableRows()

ilTestParticipantList::getScoringsTableRows ( )

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

References buildFullname().

284  : array
285  {
286  $rows = [];
287 
288  foreach ($this as $participant) {
289  if (!$participant->hasScoring()) {
290  continue;
291  }
292 
293  $row = [
294  'usr_id' => $participant->getUsrId(),
295  'active_id' => $participant->getActiveId(),
296  'login' => $participant->getLogin(),
297  'firstname' => $participant->getFirstname(),
298  'lastname' => $participant->getLastname(),
299  'name' => $this->buildFullname($participant)
300  ];
301 
302  if ($participant->getScoring()) {
303  $row['scored_pass'] = $participant->getScoring()->getScoredPass();
304  $row['answered_questions'] = $participant->getScoring()->getAnsweredQuestions();
305  $row['total_questions'] = $participant->getScoring()->getTotalQuestions();
306  $row['reached_points'] = $participant->getScoring()->getReachedPoints();
307  $row['max_points'] = $participant->getScoring()->getMaxPoints();
308  $row['percent_result'] = $participant->getScoring()->getPercentResult();
309  $row['passed_status'] = $participant->getScoring()->isPassed();
310  $row['final_mark'] = $participant->getScoring()->getFinalMark();
311  $row['scored_pass_finished_timestamp'] = ilObjTest::lookupLastTestPassAccess(
312  $participant->getActiveId(),
313  $participant->getScoring()->getScoredPass()
314  );
315  $row['finished_passes'] = $participant->getFinishedTries();
316  $row['has_unfinished_passes'] = $participant->hasUnfinishedPasses();
317  }
318 
319  $rows[] = $row;
320  }
321 
322  return $rows;
323  }
buildFullname(ilTestParticipant $participant)
+ Here is the call graph for this function:

◆ getTestObj()

ilTestParticipantList::getTestObj ( )
private

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

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

45  : ilObjTest
46  {
47  return $this->test_obj;
48  }
+ Here is the caller graph for this function:

◆ hasScorings()

ilTestParticipantList::hasScorings ( )

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

95  : bool
96  {
97  foreach ($this as $participant) {
98  if ($participant->getScoring() instanceof ilTestParticipantScoring) {
99  return true;
100  }
101  }
102 
103  return false;
104  }

◆ hasUnfinishedPasses()

ilTestParticipantList::hasUnfinishedPasses ( )

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

Referenced by ilTestParticipantsGUI\initToolbarControls().

84  : bool
85  {
86  foreach ($this as $participant) {
87  if ($participant->hasUnfinishedPasses()) {
88  return true;
89  }
90  }
91 
92  return false;
93  }
+ Here is the caller graph for this function:

◆ initializeFromDbRows()

ilTestParticipantList::initializeFromDbRows ( array  $db_rows)

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

References addParticipant().

176  : void
177  {
178  foreach ($db_rows as $row_data) {
179  $participant = new ilTestParticipant();
180 
181  if ((int) $row_data['active_id']) {
182  $participant->setActiveId((int) $row_data['active_id']);
183  }
184 
185  $participant->setUsrId((int) $row_data['usr_id']);
186 
187  $participant->setLogin($row_data['login'] ?? '');
188  $participant->setLastname($row_data['lastname']);
189  $participant->setFirstname($row_data['firstname'] ?? '');
190  $participant->setMatriculation($row_data['matriculation'] ?? '');
191 
192  $participant->setActiveStatus((bool) ($row_data['active'] ?? false));
193 
194  if (isset($row_data['clientip'])) {
195  $participant->setClientIp($row_data['clientip']);
196  }
197 
198  $participant->setFinishedTries((int) $row_data['tries']);
199  $participant->setTestFinished((bool) $row_data['test_finished']);
200  $participant->setUnfinishedPasses((bool) $row_data['unfinished_passes']);
201 
202  $this->addParticipant($participant);
203  }
204  }
addParticipant(ilTestParticipant $participant)
+ Here is the call graph for this function:

◆ isActiveIdInList()

ilTestParticipantList::isActiveIdInList ( int  $active_id)

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

128  : bool
129  {
130  foreach ($this as $participant) {
131  if ($participant->getActiveId() == $active_id) {
132  return true;
133  }
134  }
135 
136  return false;
137  }

◆ key()

ilTestParticipantList::key ( )

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

Referenced by valid().

163  : int
164  {
165  return key($this->participants);
166  }
+ Here is the caller graph for this function:

◆ lookupLastAccess()

ilTestParticipantList::lookupLastAccess ( ?int  $active_id)
protected

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

References getTestObj().

Referenced by getParticipantsTableRows().

340  : string
341  {
342  if ($active_id === null) {
343  return '';
344  }
345 
346  return $this->getTestObj()->_getLastAccess($active_id);
347  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupNrOfTries()

ilTestParticipantList::lookupNrOfTries ( ?int  $active_id)

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

References ilObjTest\_getMaxPass().

Referenced by getParticipantsTableRows().

325  : ?int
326  {
327  if ($active_id === null) {
328  return null;
329  }
330 
331  $max_pass_index = ilObjTest::_getMaxPass($active_id);
332 
333  if ($max_pass_index === null) {
334  return null;
335  }
336 
337  return $max_pass_index + 1;
338  }
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 159 of file class.ilTestParticipantList.php.

159  : void
160  {
161  next($this->participants);
162  }

◆ rewind()

ilTestParticipantList::rewind ( )

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

171  : void
172  {
173  reset($this->participants);
174  }

◆ setTestObj()

ilTestParticipantList::setTestObj ( ilObjTest  $test_obj)

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

50  : void
51  {
52  $this->test_obj = $test_obj;
53  }

◆ valid()

ilTestParticipantList::valid ( )

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

References key().

167  : bool
168  {
169  return key($this->participants) !== null;
170  }
+ Here is the call graph for this function:

Field Documentation

◆ $participants

array ilTestParticipantList::$participants = []
protected

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


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