ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 
 getScoringTableRows ()
 
 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 336 of file class.ilTestParticipantList.php.

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

Referenced by getScoringsTableRows().

336  : string
337  {
338  if ($this->getTestObj()->getMainSettings()->getAccessSettings()->getFixedParticipants() && !$participant->getActiveId()) {
339  return $this->buildInviteeFullname($participant);
340  }
341 
342  return $this->buildParticipantsFullname($participant);
343  }
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 345 of file class.ilTestParticipantList.php.

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

Referenced by buildFullname().

345  : string
346  {
347  if (strlen($participant->getFirstname() . $participant->getLastname()) == 0) {
348  return $this->lng->txt("deleted_user");
349  }
350 
351  if ($this->getTestObj()->getAnonymity()) {
352  return $this->lng->txt('anonymous');
353  }
354 
355  return trim($participant->getLastname() . ", " . $participant->getFirstname());
356  }
+ 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 358 of file class.ilTestParticipantList.php.

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

Referenced by buildFullname().

358  : string
359  {
360  return ilObjTestAccess::_getParticipantData($participant->getActiveId());
361  }
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 231 of file class.ilTestParticipantList.php.

References getAllActiveIds().

Referenced by getScoredParticipantList().

231  : string
232  {
233  $IN_activeIds = $this->db->in(
234  'tres.active_fi',
235  $this->getAllActiveIds(),
236  false,
237  'integer'
238  );
239 
240  $query = "
241  SELECT * FROM tst_result_cache tres
242 
243  INNER JOIN tst_pass_result pres
244  ON pres.active_fi = tres.active_fi
245  AND pres.pass = tres.pass
246  WHERE $IN_activeIds
247  ";
248 
249  return $query;
250  }
+ 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  }
global $lng
Definition: privfeed.php:31
+ 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 = [];
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 = [];
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.

References null.

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getParticipantByUsrId()

ilTestParticipantList::getParticipantByUsrId ( int  $usr_id)

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

References null.

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

◆ getScoredParticipantList()

ilTestParticipantList::getScoredParticipantList ( )

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

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

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

◆ getScoringsTableRows()

ilTestParticipantList::getScoringsTableRows ( )

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

References buildFullname().

271  : array
272  {
273  $rows = [];
274 
275  foreach ($this as $participant) {
276  if (!$participant->hasScoring()) {
277  continue;
278  }
279 
280  $row = [
281  'usr_id' => $participant->getUsrId(),
282  'active_id' => $participant->getActiveId(),
283  'login' => $participant->getLogin(),
284  'firstname' => $participant->getFirstname(),
285  'lastname' => $participant->getLastname(),
286  'name' => $this->buildFullname($participant)
287  ];
288 
289  if ($participant->getScoring()) {
290  $row['scored_pass'] = $participant->getScoring()->getScoredPass();
291  $row['answered_questions'] = $participant->getScoring()->getAnsweredQuestions();
292  $row['total_questions'] = $participant->getScoring()->getTotalQuestions();
293  $row['reached_points'] = $participant->getScoring()->getReachedPoints();
294  $row['max_points'] = $participant->getScoring()->getMaxPoints();
295  $row['percent_result'] = $participant->getScoring()->getPercentResult();
296  $row['passed_status'] = $participant->getScoring()->isPassed();
297  $row['final_mark'] = $participant->getScoring()->getFinalMark();
298  $row['scored_pass_finished_timestamp'] = ilObjTest::lookupLastTestPassAccess(
299  $participant->getActiveId(),
300  $participant->getScoring()->getScoredPass()
301  );
302  $row['finished_passes'] = $participant->getFinishedTries();
303  $row['has_unfinished_passes'] = $participant->hasUnfinishedPasses();
304  }
305 
306  $rows[] = $row;
307  }
308 
309  return $rows;
310  }
buildFullname(ilTestParticipant $participant)
+ Here is the call graph for this function:

◆ getScoringTableRows()

ilTestParticipantList::getScoringTableRows ( )

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

252  : array
253  {
254  $rows = [];
255 
256  foreach ($this as $participant) {
257  $row = [
258  'usr_id' => $participant->getUsrId(),
259  'active_id' => $participant->getActiveId(),
260  'login' => $participant->getLogin(),
261  'firstname' => $participant->getFirstname(),
262  'lastname' => $participant->getLastname()
263  ];
264 
265  $rows[] = $row;
266  }
267 
268  return $rows;
269  }

◆ 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->hasScoring()) {
99  return true;
100  }
101  }
102 
103  return false;
104  }

◆ hasUnfinishedPasses()

ilTestParticipantList::hasUnfinishedPasses ( )

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

84  : bool
85  {
86  foreach ($this as $participant) {
87  if ($participant->hasUnfinishedPasses()) {
88  return true;
89  }
90  }
91 
92  return false;
93  }

◆ 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  $participant->setActiveStatus((bool) ($row_data['active'] ?? false));
192  $participant->setFinishedTries((int) $row_data['tries']);
193  $participant->setTestFinished((bool) $row_data['test_finished']);
194  $participant->setUnfinishedPasses((bool) $row_data['unfinished_passes']);
195 
196  $this->addParticipant($participant);
197  }
198  }
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 327 of file class.ilTestParticipantList.php.

References getTestObj(), and null.

327  : string
328  {
329  if ($active_id === null) {
330  return '';
331  }
332 
333  return $this->getTestObj()->_getLastAccess($active_id);
334  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ lookupNrOfTries()

ilTestParticipantList::lookupNrOfTries ( ?int  $active_id)

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

References ilObjTest\_getMaxPass(), and null.

312  : ?int
313  {
314  if ($active_id === null) {
315  return null;
316  }
317 
318  $max_pass_index = ilObjTest::_getMaxPass($active_id);
319 
320  if ($max_pass_index === null) {
321  return null;
322  }
323 
324  return $max_pass_index + 1;
325  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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:

◆ 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(), and null.

167  : bool
168  {
169  return key($this->participants) !== null;
170  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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: