ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 
bool $scoredParticipantsFilterEnabled
 

Private Attributes

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

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $db, $lng, and ILIAS\Repository\lng().

57  {
58  $this->db = $db;
59  $this->lng = $lng;
60 
61  $this->activeIdsFilter = array();
62  $this->userIdsFilter = array();
63  $this->anonymousIdsFilter = array();
64 
65  $this->byActiveId = array();
66  $this->byUserId = array();
67  $this->byAnonymousId = array();
68 
69  $this->scoredParticipantsFilterEnabled = false;
70  }
+ Here is the call graph for this function:

Member Function Documentation

◆ getActiveIdByUserId()

ilTestParticipantData::getActiveIdByUserId (   $userId)

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

237  {
238  return $this->byUserId[$userId]['active_id'] ?? null;
239  }

◆ getActiveIds()

ilTestParticipantData::getActiveIds ( )

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

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

216  : array
217  {
218  return array_keys($this->byActiveId);
219  }
+ Here is the caller graph for this function:

◆ getActiveIdsFilter()

ilTestParticipantData::getActiveIdsFilter ( )

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

References $activeIdsFilter.

Referenced by getConditionalExpression().

191  : array
192  {
193  return $this->activeIdsFilter;
194  }
+ Here is the caller graph for this function:

◆ getAnonymousActiveIds()

ilTestParticipantData::getAnonymousActiveIds ( )

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

References ANONYMOUS_USER_ID.

Referenced by ilObjTest\removeTestResults().

273  : array
274  {
275  $anonymousActiveIds = array();
276 
277  foreach ($this->byActiveId as $activeId => $active) {
278  if ($active['user_id'] == ANONYMOUS_USER_ID) {
279  $anonymousActiveIds[] = $activeId;
280  }
281  }
282 
283  return $anonymousActiveIds;
284  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
+ Here is the caller graph for this function:

◆ getAnonymousIds()

ilTestParticipantData::getAnonymousIds ( )

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

226  : array
227  {
228  return array_keys($this->byAnonymousId);
229  }

◆ getAnonymousIdsFilter()

ilTestParticipantData::getAnonymousIdsFilter ( )

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

References $anonymousIdsFilter.

Referenced by getConditionalExpression().

211  : array
212  {
214  }
+ Here is the caller graph for this function:

◆ getConcatedFullnameByActiveId()

ilTestParticipantData::getConcatedFullnameByActiveId (   $activeId)

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

241  : string
242  {
243  return "{$this->byActiveId[$activeId]['firstname']} {$this->byActiveId[$activeId]['lastname']}";
244  }

◆ getConditionalExpression()

ilTestParticipantData::getConditionalExpression ( )

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

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

163  : string
164  {
165  $conditions = array();
166 
167  if (count($this->getActiveIdsFilter())) {
168  $conditions[] = $this->db->in('active_id', $this->getActiveIdsFilter(), false, 'integer');
169  }
170 
171  if (count($this->getUserIdsFilter())) {
172  $conditions[] = $this->db->in('user_fi', $this->getUserIdsFilter(), false, 'integer');
173  }
174 
175  if (count($this->getAnonymousIdsFilter())) {
176  $conditions[] = $this->db->in('anonymous_id', $this->getAnonymousIdsFilter(), false, 'integer');
177  }
178 
179  if (count($conditions)) {
180  return '(' . implode(' OR ', $conditions) . ')';
181  }
182 
183  return '1 = 1';
184  }
+ Here is the call graph for this function:

◆ getFileSystemCompliantFullnameByActiveId()

ilTestParticipantData::getFileSystemCompliantFullnameByActiveId (   $activeId)

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

References ilFileUtils\getASCIIFilename().

Referenced by ilAssFileUploadUploadsExporter\collectUploadedFiles().

251  : string
252  {
253  $fullname = str_replace(' ', '', $this->byActiveId[$activeId]['lastname']);
254  $fullname .= '_' . str_replace(' ', '', $this->byActiveId[$activeId]['firstname']);
255  $fullname .= '_' . $this->byActiveId[$activeId]['login'];
256 
257  return ilFileUtils::getASCIIFilename($fullname);
258  }
static getASCIIFilename(string $a_filename)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFormatedFullnameByActiveId()

ilTestParticipantData::getFormatedFullnameByActiveId (   $activeId)

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

References ilObjTestAccess\_getParticipantData().

246  : string
247  {
248  return ilObjTestAccess::_getParticipantData($activeId);
249  }
static _getParticipantData($active_id)
Retrieves a participant name from active id.
+ Here is the call graph for this function:

◆ getOptionArray()

ilTestParticipantData::getOptionArray ( )

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

References ilObjTestAccess\_getParticipantData().

260  : array
261  {
262  $options = array();
263 
264  foreach ($this->byActiveId as $activeId => $usrData) {
265  $options[$activeId] = ilObjTestAccess::_getParticipantData($activeId);
266  }
267 
268  asort($options);
269 
270  return $options;
271  }
static _getParticipantData($active_id)
Retrieves a participant name from active id.
+ Here is the call graph for this function:

◆ getParticipantAccessFilter()

ilTestParticipantData::getParticipantAccessFilter ( )
Returns
callable

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

References $participantAccessFilter.

Referenced by load().

75  : ?callable
76  {
78  }
+ Here is the caller graph for this function:

◆ getScoredParticipantsFilterExpression()

ilTestParticipantData::getScoredParticipantsFilterExpression ( )

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

References isScoredParticipantsFilterEnabled().

154  : string
155  {
156  if ($this->isScoredParticipantsFilterEnabled()) {
157  return "ta.last_finished_pass = ta.last_started_pass";
158  }
159 
160  return '1 = 1';
161  }
+ Here is the call graph for this function:

◆ getUserDataByActiveId()

ilTestParticipantData::getUserDataByActiveId (   $activeId)

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

287  {
288  if (isset($this->byActiveId[$activeId])) {
289  return $this->byActiveId[$activeId];
290  }
291 
292  return null;
293  }

◆ getUserIdByActiveId()

ilTestParticipantData::getUserIdByActiveId (   $activeId)

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

232  {
233  return $this->byActiveId[$activeId]['user_id'];
234  }

◆ getUserIds()

ilTestParticipantData::getUserIds ( )

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

Referenced by ilObjTest\removeTestResults().

221  : array
222  {
223  return array_keys($this->byUserId);
224  }
+ Here is the caller graph for this function:

◆ getUserIdsFilter()

ilTestParticipantData::getUserIdsFilter ( )

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

References $userIdsFilter.

Referenced by getConditionalExpression().

201  : array
202  {
203  return $this->userIdsFilter;
204  }
+ Here is the caller graph for this function:

◆ isScoredParticipantsFilterEnabled()

ilTestParticipantData::isScoredParticipantsFilterEnabled ( )
Returns
bool

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

References $scoredParticipantsFilterEnabled.

Referenced by getScoredParticipantsFilterExpression().

91  : bool
92  {
94  }
+ Here is the caller graph for this function:

◆ load()

ilTestParticipantData::load (   $testId)

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

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

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

◆ setActiveIdsFilter()

ilTestParticipantData::setActiveIdsFilter (   $activeIdsFilter)

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

References $activeIdsFilter.

Referenced by ilTestAccess\checkAccessForActiveId().

186  : void
187  {
188  $this->activeIdsFilter = $activeIdsFilter;
189  }
+ Here is the caller graph for this function:

◆ setAnonymousIdsFilter()

ilTestParticipantData::setAnonymousIdsFilter (   $anonymousIdsFilter)

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

References $anonymousIdsFilter.

206  : void
207  {
208  $this->anonymousIdsFilter = $anonymousIdsFilter;
209  }

◆ setParticipantAccessFilter()

ilTestParticipantData::setParticipantAccessFilter (   $participantAccessFilter)
Parameters
callable$participantAccessFilter

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

References $participantAccessFilter.

83  : void
84  {
85  $this->participantAccessFilter = $participantAccessFilter;
86  }

◆ setScoredParticipantsFilterEnabled()

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

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

References $scoredParticipantsFilterEnabled.

99  : void
100  {
101  $this->scoredParticipantsFilterEnabled = $scoredParticipantsFilterEnabled;
102  }

◆ setUserIdsFilter()

ilTestParticipantData::setUserIdsFilter (   $userIdsFilter)

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

References $userIdsFilter.

196  : void
197  {
198  $this->userIdsFilter = $userIdsFilter;
199  }

Field Documentation

◆ $activeIdsFilter

array ilTestParticipantData::$activeIdsFilter
private

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

Referenced by getActiveIdsFilter(), and setActiveIdsFilter().

◆ $anonymousIdsFilter

array ilTestParticipantData::$anonymousIdsFilter
private

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

Referenced by getAnonymousIdsFilter(), and setAnonymousIdsFilter().

◆ $byActiveId

array ilTestParticipantData::$byActiveId
private

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

◆ $byAnonymousId

array ilTestParticipantData::$byAnonymousId
private

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

◆ $byUserId

array ilTestParticipantData::$byUserId
private

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

◆ $db

ilTestParticipantData::$db
protected

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

Referenced by __construct().

◆ $lng

ilTestParticipantData::$lng
protected

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

Referenced by __construct().

◆ $participantAccessFilter

ilTestParticipantData::$participantAccessFilter
protected

◆ $scoredParticipantsFilterEnabled

bool ilTestParticipantData::$scoredParticipantsFilterEnabled
protected

◆ $userIdsFilter

array ilTestParticipantData::$userIdsFilter
private

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

Referenced by getUserIdsFilter(), and setUserIdsFilter().


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