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

Public Member Functions

 __construct (ilDBInterface $db, ilLanguage $lng)
 
 getParticipantAccessFilter ()
 
 setParticipantAccessFilter ($participantAccessFilter)
 
 isScoredParticipantsFilterEnabled ()
 
 setScoredParticipantsFilterEnabled ($scoredParticipantsFilterEnabled)
 
 load ($testId)
 
 getScoredParticipantsFilterExpression ()
 
 getConditionalExpression ()
 
 setActiveIdsFilter ($activeIdsFilter)
 
 getActiveIdsFilter ()
 
 setUserIdsFilter ($userIdsFilter)
 
 getUserIdsFilter ()
 
 setAnonymousIdsFilter ($anonymousIdsFilter)
 
 getAnonymousIdsFilter ()
 
 getActiveIds ()
 
 getUserIds ()
 
 getAnonymousIds ()
 
 getUserIdByActiveId ($activeId)
 
 getActiveIdByUserId ($userId)
 
 getConcatedFullnameByActiveId ($activeId)
 
 getFormatedFullnameByActiveId ($activeId)
 
 getFileSystemCompliantFullnameByActiveId ($activeId)
 
 getOptionArray ()
 
 getAnonymousActiveIds ()
 
 getUserDataByActiveId ($activeId)
 

Protected Attributes

 $db
 
 $lng
 
 $participantAccessFilter
 
 $scoredParticipantsFilterEnabled
 

Private Member Functions

 buildFormatedFullname ($usrData)
 

Private Attributes

 $activeIdsFilter
 
 $userIdsFilter
 
 $anonymousIdsFilter
 
 $byActiveId
 
 $byUserId
 
 $byAnonymousId
 

Detailed Description

Definition at line 11 of file class.ilTestParticipantData.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestParticipantData::__construct ( ilDBInterface  $db,
ilLanguage  $lng 
)

Definition at line 63 of file class.ilTestParticipantData.php.

References $db, and $lng.

64  {
65  $this->db = $db;
66  $this->lng = $lng;
67 
68  $this->activeIdsFilter = array();
69  $this->userIdsFilter = array();
70  $this->anonymousIdsFilter = array();
71 
72  $this->byActiveId = array();
73  $this->byUserId = array();
74  $this->byAnonymousId = array();
75 
76  $this->scoredParticipantsFilterEnabled = false;
77  }

Member Function Documentation

◆ buildFormatedFullname()

ilTestParticipantData::buildFormatedFullname (   $usrData)
private

Definition at line 280 of file class.ilTestParticipantData.php.

Referenced by getFormatedFullnameByActiveId(), and getOptionArray().

281  {
282  return sprintf(
283  $this->lng->txt('tst_participant_fullname_pattern'),
284  $usrData['firstname'],
285  $usrData['lastname']
286  );
287  }
+ Here is the caller graph for this function:

◆ getActiveIdByUserId()

ilTestParticipantData::getActiveIdByUserId (   $userId)

Definition at line 243 of file class.ilTestParticipantData.php.

244  {
245  return $this->byUserId[$userId]['active_id'];
246  }

◆ getActiveIds()

ilTestParticipantData::getActiveIds ( )

Definition at line 223 of file class.ilTestParticipantData.php.

Referenced by ilAssFileUploadUploadsExporter\collectUploadedFiles(), and ilObjTest\removeTestResults().

224  {
225  return array_keys($this->byActiveId);
226  }
+ Here is the caller graph for this function:

◆ getActiveIdsFilter()

ilTestParticipantData::getActiveIdsFilter ( )

Definition at line 198 of file class.ilTestParticipantData.php.

References $activeIdsFilter.

Referenced by getConditionalExpression().

+ Here is the caller graph for this function:

◆ getAnonymousActiveIds()

ilTestParticipantData::getAnonymousActiveIds ( )

Definition at line 289 of file class.ilTestParticipantData.php.

Referenced by ilObjTest\removeTestResults().

290  {
291  $anonymousActiveIds = array();
292 
293  foreach ($this->byActiveId as $activeId => $active) {
294  if ($active['user_id'] == ANONYMOUS_USER_ID) {
295  $anonymousActiveIds[] = $activeId;
296  }
297  }
298 
299  return $anonymousActiveIds;
300  }
+ Here is the caller graph for this function:

◆ getAnonymousIds()

ilTestParticipantData::getAnonymousIds ( )

Definition at line 233 of file class.ilTestParticipantData.php.

234  {
235  return array_keys($this->byAnonymousId);
236  }

◆ getAnonymousIdsFilter()

ilTestParticipantData::getAnonymousIdsFilter ( )

Definition at line 218 of file class.ilTestParticipantData.php.

References $anonymousIdsFilter.

Referenced by getConditionalExpression().

+ Here is the caller graph for this function:

◆ getConcatedFullnameByActiveId()

ilTestParticipantData::getConcatedFullnameByActiveId (   $activeId)

Definition at line 248 of file class.ilTestParticipantData.php.

249  {
250  return "{$this->byActiveId[$activeId]['firstname']} {$this->byActiveId[$activeId]['lastname']}";
251  }

◆ getConditionalExpression()

ilTestParticipantData::getConditionalExpression ( )

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

References getActiveIdsFilter(), getAnonymousIdsFilter(), and getUserIdsFilter().

171  {
172  $conditions = array();
173 
174  if (count($this->getActiveIdsFilter())) {
175  $conditions[] = $this->db->in('active_id', $this->getActiveIdsFilter(), false, 'integer');
176  }
177 
178  if (count($this->getUserIdsFilter())) {
179  $conditions[] = $this->db->in('user_fi', $this->getUserIdsFilter(), false, 'integer');
180  }
181 
182  if (count($this->getAnonymousIdsFilter())) {
183  $conditions[] = $this->db->in('anonymous_id', $this->getAnonymousIdsFilter(), false, 'integer');
184  }
185 
186  if (count($conditions)) {
187  return '(' . implode(' OR ', $conditions) . ')';
188  }
189 
190  return '1 = 1';
191  }
+ Here is the call graph for this function:

◆ getFileSystemCompliantFullnameByActiveId()

ilTestParticipantData::getFileSystemCompliantFullnameByActiveId (   $activeId)

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

References ilUtil\getASCIIFilename().

Referenced by ilAssFileUploadUploadsExporter\collectUploadedFiles().

259  {
260  $fullname = str_replace(' ', '', $this->byActiveId[$activeId]['lastname']);
261  $fullname .= '_' . str_replace(' ', '', $this->byActiveId[$activeId]['firstname']);
262  $fullname .= '_' . $this->byActiveId[$activeId]['login'];
263 
264  return ilUtil::getASCIIFilename($fullname);
265  }
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFormatedFullnameByActiveId()

ilTestParticipantData::getFormatedFullnameByActiveId (   $activeId)

Definition at line 253 of file class.ilTestParticipantData.php.

References buildFormatedFullname().

254  {
255  return $this->buildFormatedFullname($this->byActiveId[$activeId]);
256  }
+ Here is the call graph for this function:

◆ getOptionArray()

ilTestParticipantData::getOptionArray ( )

Definition at line 267 of file class.ilTestParticipantData.php.

References PHPMailer\PHPMailer\$options, and buildFormatedFullname().

268  {
269  $options = array();
270 
271  foreach ($this->byActiveId as $activeId => $usrData) {
272  $options[$activeId] = $this->buildFormatedFullname($usrData);
273  }
274 
275  asort($options);
276 
277  return $options;
278  }
+ Here is the call graph for this function:

◆ getParticipantAccessFilter()

ilTestParticipantData::getParticipantAccessFilter ( )
Returns
callable

Definition at line 82 of file class.ilTestParticipantData.php.

References $participantAccessFilter.

Referenced by load().

+ Here is the caller graph for this function:

◆ getScoredParticipantsFilterExpression()

ilTestParticipantData::getScoredParticipantsFilterExpression ( )

Definition at line 161 of file class.ilTestParticipantData.php.

References isScoredParticipantsFilterEnabled().

162  {
163  if ($this->isScoredParticipantsFilterEnabled()) {
164  return "ta.last_finished_pass = ta.last_started_pass";
165  }
166 
167  return '1 = 1';
168  }
+ Here is the call graph for this function:

◆ getUserDataByActiveId()

ilTestParticipantData::getUserDataByActiveId (   $activeId)

Definition at line 302 of file class.ilTestParticipantData.php.

303  {
304  if (isset($this->byActiveId[$activeId])) {
305  return $this->byActiveId[$activeId];
306  }
307 
308  return null;
309  }

◆ getUserIdByActiveId()

ilTestParticipantData::getUserIdByActiveId (   $activeId)

Definition at line 238 of file class.ilTestParticipantData.php.

239  {
240  return $this->byActiveId[$activeId]['user_id'];
241  }

◆ getUserIds()

ilTestParticipantData::getUserIds ( )

Definition at line 228 of file class.ilTestParticipantData.php.

Referenced by ilObjTest\removeTestResults().

229  {
230  return array_keys($this->byUserId);
231  }
+ Here is the caller graph for this function:

◆ getUserIdsFilter()

ilTestParticipantData::getUserIdsFilter ( )

Definition at line 208 of file class.ilTestParticipantData.php.

References $userIdsFilter.

Referenced by getConditionalExpression().

+ Here is the caller graph for this function:

◆ isScoredParticipantsFilterEnabled()

ilTestParticipantData::isScoredParticipantsFilterEnabled ( )
Returns
bool

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

References $scoredParticipantsFilterEnabled.

Referenced by getScoredParticipantsFilterExpression().

+ Here is the caller graph for this function:

◆ load()

ilTestParticipantData::load (   $testId)

Definition at line 111 of file class.ilTestParticipantData.php.

References $query, $res, $row, $rows, and getParticipantAccessFilter().

Referenced by ilTestCorrectionsGUI\performQuestionRemoval().

112  {
113  $this->byActiveId = array();
114  $this->byUserId = array();
115 
116  $query = "
117  SELECT ta.active_id,
118  ta.user_fi user_id,
119  ta.anonymous_id,
120  ud.firstname,
121  ud.lastname,
122  ud.login,
123  ud.matriculation
124  FROM tst_active ta
125  LEFT JOIN usr_data ud
126  ON ud.usr_id = ta.user_fi
127  WHERE test_fi = %s
128  AND {$this->getConditionalExpression()}
129  AND {$this->getScoredParticipantsFilterExpression()}
130  ";
131 
132  $res = $this->db->queryF($query, array('integer'), array($testId));
133 
134  $rows = array();
135  $accessFilteredUsrIds = array();
136 
137  while ($row = $this->db->fetchAssoc($res)) {
138  $accessFilteredUsrIds[] = $row['user_id'];
139  $rows[] = $row;
140  }
141 
142  if (is_callable($this->getParticipantAccessFilter(), true)) {
143  $accessFilteredUsrIds = call_user_func_array($this->getParticipantAccessFilter(), [$accessFilteredUsrIds]);
144  }
145 
146  foreach ($rows as $row) {
147  if (!in_array($row['user_id'], $accessFilteredUsrIds)) {
148  continue;
149  }
150 
151  $this->byActiveId[ $row['active_id'] ] = $row;
152 
153  if ($row['user_id'] == ANONYMOUS_USER_ID) {
154  $this->byAnonymousId[ $row['anonymous_id'] ] = $row;
155  } else {
156  $this->byUserId[ $row['user_id'] ] = $row;
157  }
158  }
159  }
foreach($_POST as $key=> $value) $res
$query
$row
$rows
Definition: xhr_table.php:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setActiveIdsFilter()

ilTestParticipantData::setActiveIdsFilter (   $activeIdsFilter)

Definition at line 193 of file class.ilTestParticipantData.php.

References $activeIdsFilter.

Referenced by ilTestAccess\checkAccessForActiveId().

194  {
195  $this->activeIdsFilter = $activeIdsFilter;
196  }
+ Here is the caller graph for this function:

◆ setAnonymousIdsFilter()

ilTestParticipantData::setAnonymousIdsFilter (   $anonymousIdsFilter)

Definition at line 213 of file class.ilTestParticipantData.php.

References $anonymousIdsFilter.

214  {
215  $this->anonymousIdsFilter = $anonymousIdsFilter;
216  }

◆ setParticipantAccessFilter()

ilTestParticipantData::setParticipantAccessFilter (   $participantAccessFilter)

◆ setScoredParticipantsFilterEnabled()

ilTestParticipantData::setScoredParticipantsFilterEnabled (   $scoredParticipantsFilterEnabled)
Parameters
bool$scoredParticipantsFilterEnabled

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

References $scoredParticipantsFilterEnabled.

107  {
108  $this->scoredParticipantsFilterEnabled = $scoredParticipantsFilterEnabled;
109  }

◆ setUserIdsFilter()

ilTestParticipantData::setUserIdsFilter (   $userIdsFilter)

Definition at line 203 of file class.ilTestParticipantData.php.

References $userIdsFilter.

204  {
205  $this->userIdsFilter = $userIdsFilter;
206  }

Field Documentation

◆ $activeIdsFilter

ilTestParticipantData::$activeIdsFilter
private

Definition at line 26 of file class.ilTestParticipantData.php.

Referenced by getActiveIdsFilter(), and setActiveIdsFilter().

◆ $anonymousIdsFilter

ilTestParticipantData::$anonymousIdsFilter
private

Definition at line 36 of file class.ilTestParticipantData.php.

Referenced by getAnonymousIdsFilter(), and setAnonymousIdsFilter().

◆ $byActiveId

ilTestParticipantData::$byActiveId
private

Definition at line 41 of file class.ilTestParticipantData.php.

◆ $byAnonymousId

ilTestParticipantData::$byAnonymousId
private

Definition at line 51 of file class.ilTestParticipantData.php.

◆ $byUserId

ilTestParticipantData::$byUserId
private

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

◆ $db

ilTestParticipantData::$db
protected

Definition at line 16 of file class.ilTestParticipantData.php.

Referenced by __construct().

◆ $lng

ilTestParticipantData::$lng
protected

Definition at line 21 of file class.ilTestParticipantData.php.

Referenced by __construct().

◆ $participantAccessFilter

ilTestParticipantData::$participantAccessFilter
protected

◆ $scoredParticipantsFilterEnabled

ilTestParticipantData::$scoredParticipantsFilterEnabled
protected

◆ $userIdsFilter

ilTestParticipantData::$userIdsFilter
private

Definition at line 31 of file class.ilTestParticipantData.php.

Referenced by getUserIdsFilter(), and setUserIdsFilter().


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