ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 398 of file class.ilTestParticipantList.php.

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

Referenced by getParticipantsTableRows(), and getScoringsTableRows().

399  {
400  if ($this->getTestObj()->getFixedParticipants() && !$participant->getActiveId()) {
401  return $this->buildInviteeFullname($participant);
402  }
403 
404  return $this->buildParticipantsFullname($participant);
405  }
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 411 of file class.ilTestParticipantList.php.

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

Referenced by buildFullname().

412  {
413  global $DIC; /* @var ILIAS\DI\Container $DIC */
414 
415  if (strlen($participant->getFirstname() . $participant->getLastname()) == 0) {
416  return $DIC->language()->txt("deleted_user");
417  }
418 
419  if ($this->getTestObj()->getAnonymity()) {
420  return $DIC->language()->txt('anonymous');
421  }
422 
423  return trim($participant->getLastname() . ", " . $participant->getFirstname());
424  }
global $DIC
Definition: goto.php:24
+ 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 430 of file class.ilTestParticipantList.php.

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

Referenced by buildFullname().

431  {
432  require_once 'Modules/Test/classes/class.ilObjTestAccess.php';
433  return ilObjTestAccess::_getParticipantData($participant->getActiveId());
434  }
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 262 of file class.ilTestParticipantList.php.

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

Referenced by getScoredParticipantList().

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

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

299  {
300  $rows = array();
301 
302  foreach ($this as $participant) {
303  $row = array(
304  'usr_id' => $participant->getUsrId(),
305  'active_id' => $participant->getActiveId(),
306  'login' => $participant->getLogin(),
307  'clientip' => $participant->getClientIp(),
308  'firstname' => $participant->getFirstname(),
309  'lastname' => $participant->getLastname(),
310  'name' => $this->buildFullname($participant),
311  'started' => ($participant->getActiveId() > 0) ? 1 : 0,
312  'unfinished' => $participant->hasUnfinishedPasses() ? 1 : 0,
313  'finished' => $participant->isTestFinished() ? 1 : 0,
314  'access' => $this->lookupLastAccess($participant->getActiveId()),
315  'tries' => $this->lookupNrOfTries($participant->getActiveId())
316  );
317 
318  $rows[] = $row;
319  }
320 
321  return $rows;
322  }
buildFullname(ilTestParticipant $participant)
$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, ilObjTest\_getResultPass(), assQuestion\_updateTestResultCache(), 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  if (ilObjTest::_getResultPass($row['active_fi']) != $row['pass']) {
231  assQuestion::_updateTestResultCache($row['active_fi']);
232  }
233  }
234 
235  $res = $DIC->database()->query($this->buildScoringsQuery());
236 
237  while ($row = $DIC->database()->fetchAssoc($res)) {
238  $scoring = new ilTestParticipantScoring();
239 
240  $scoring->setActiveId((int) $row['active_fi']);
241  $scoring->setScoredPass((int) $row['pass']);
242 
243  $scoring->setAnsweredQuestions((int) $row['answeredquestions']);
244  $scoring->setTotalQuestions((int) $row['questioncount']);
245 
246  $scoring->setReachedPoints((float) $row['reached_points']);
247  $scoring->setMaxPoints((float) $row['max_points']);
248 
249  $scoring->setPassed((bool) $row['passed']);
250  $scoring->setFinalMark((string) $row['mark_short']);
251 
252  $this->getParticipantByActiveId($row['active_fi'])->setScoring($scoring);
253 
254  $scoredParticipantList->addParticipant(
255  $this->getParticipantByActiveId($row['active_fi'])
256  );
257  }
258 
259  return $scoredParticipantList;
260  }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
foreach($_POST as $key=> $value) $res
static _getResultPass($active_id)
Retrieves the pass number that should be counted for a given user.
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

◆ getScoringsTableRows()

ilTestParticipantList::getScoringsTableRows ( )

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

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

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

References getTestObj().

Referenced by getParticipantsTableRows().

386  {
387  if (!$activeId) {
388  return '';
389  }
390 
391  return $this->getTestObj()->_getLastAccess($activeId);
392  }
+ 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 369 of file class.ilTestParticipantList.php.

References ilObjTest\_getMaxPass().

Referenced by getParticipantsTableRows().

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