ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTestParticipantData Class Reference
+ Collaboration diagram for ilTestParticipantData:

Public Member Functions

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

Protected Attributes

 $db
 
 $lng
 
 $participantAccessFilter
 
bool $scoredParticipantsFilterEnabled
 

Private Attributes

array $active_ids_filter
 
array $userIdsFilter
 
array $anonymousIdsFilter
 
array $byActiveId
 
array $byUserId
 
array $byAnonymousId
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

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

59  {
60  $this->db = $db;
61  $this->lng = $lng;
62 
63  $this->active_ids_filter = [];
64  $this->userIdsFilter = [];
65  $this->anonymousIdsFilter = [];
66 
67  $this->byActiveId = [];
68  $this->byUserId = [];
69  $this->byAnonymousId = [];
70 
71  $this->scoredParticipantsFilterEnabled = false;
72  }
+ Here is the call graph for this function:

Member Function Documentation

◆ getActiveIdByUserId()

ilTestParticipantData::getActiveIdByUserId (   $userId)

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

References null.

236  {
237  return $this->byUserId[$userId]['active_id'] ?? null;
238  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getActiveIds()

ilTestParticipantData::getActiveIds ( )

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

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

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

◆ getActiveIdsFilter()

ilTestParticipantData::getActiveIdsFilter ( )

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

References $active_ids_filter.

Referenced by getConditionalExpression().

190  : array
191  {
193  }
+ Here is the caller graph for this function:

◆ getAnonymousActiveIds()

ilTestParticipantData::getAnonymousActiveIds ( )

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

References ANONYMOUS_USER_ID.

Referenced by ilObjTest\removeTestResults().

267  : array
268  {
269  $anonymousActiveIds = [];
270 
271  foreach ($this->byActiveId as $activeId => $active) {
272  if ($active['user_id'] == ANONYMOUS_USER_ID) {
273  $anonymousActiveIds[] = $activeId;
274  }
275  }
276 
277  return $anonymousActiveIds;
278  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
+ Here is the caller graph for this function:

◆ getAnonymousIds()

ilTestParticipantData::getAnonymousIds ( )

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

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

◆ getAnonymousIdsFilter()

ilTestParticipantData::getAnonymousIdsFilter ( )

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

References $anonymousIdsFilter.

Referenced by getConditionalExpression().

210  : array
211  {
213  }
+ Here is the caller graph for this function:

◆ getConditionalExpression()

ilTestParticipantData::getConditionalExpression ( )

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

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

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

◆ getFileSystemCompliantFullnameByActiveId()

ilTestParticipantData::getFileSystemCompliantFullnameByActiveId (   $activeId)

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

References ilFileUtils\getASCIIFilename().

Referenced by ilAssFileUploadUploadsExporter\collectUploadedFiles().

245  : string
246  {
247  $fullname = str_replace(' ', '', $this->byActiveId[$activeId]['lastname']);
248  $fullname .= '_' . str_replace(' ', '', $this->byActiveId[$activeId]['firstname']);
249  $fullname .= '_' . $this->byActiveId[$activeId]['login'];
250 
251  return ilFileUtils::getASCIIFilename($fullname);
252  }
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 240 of file class.ilTestParticipantData.php.

References ilObjTestAccess\_getParticipantData().

240  : string
241  {
242  return ilObjTestAccess::_getParticipantData($activeId);
243  }
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 254 of file class.ilTestParticipantData.php.

References ilObjTestAccess\_getParticipantData().

254  : array
255  {
256  $options = [];
257 
258  foreach ($this->byActiveId as $activeId => $usrData) {
259  $options[$activeId] = ilObjTestAccess::_getParticipantData($activeId);
260  }
261 
262  asort($options);
263 
264  return $options;
265  }
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 77 of file class.ilTestParticipantData.php.

References $participantAccessFilter.

Referenced by load().

+ Here is the caller graph for this function:

◆ getScoredParticipantsFilterExpression()

ilTestParticipantData::getScoredParticipantsFilterExpression ( )

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

References isScoredParticipantsFilterEnabled().

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

◆ getUserDataByActiveId()

ilTestParticipantData::getUserDataByActiveId ( int  $active_Id)

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

References null.

Referenced by ilTestArchiver\createUserResultsForArchive().

280  : array
281  {
282  if (isset($this->byActiveId[$active_Id])) {
283  return $this->byActiveId[$active_Id];
284  }
285 
286  return null;
287  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getUserIdByActiveId()

ilTestParticipantData::getUserIdByActiveId (   $activeId)

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

Referenced by ilObjTest\removeTestResults().

231  {
232  return $this->byActiveId[$activeId]['user_id'];
233  }
+ Here is the caller graph for this function:

◆ getUserIds()

ilTestParticipantData::getUserIds ( )

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

Referenced by ilObjTest\removeTestResults().

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

◆ getUserIdsFilter()

ilTestParticipantData::getUserIdsFilter ( )

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

References $userIdsFilter.

Referenced by getConditionalExpression().

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

◆ isScoredParticipantsFilterEnabled()

ilTestParticipantData::isScoredParticipantsFilterEnabled ( )
Returns
bool

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

References $scoredParticipantsFilterEnabled.

Referenced by getScoredParticipantsFilterExpression().

90  : bool
91  {
93  }
+ Here is the caller graph for this function:

◆ load()

ilTestParticipantData::load (   $testId)

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

References $res, ANONYMOUS_USER_ID, and getParticipantAccessFilter().

Referenced by ilTestArchiver\createUserResultsForArchive().

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

◆ setActiveIdsFilter()

ilTestParticipantData::setActiveIdsFilter ( array  $active_ids_filter)

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

References $active_ids_filter.

Referenced by ilTestArchiver\createUserResultsForArchive().

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

◆ setAnonymousIdsFilter()

ilTestParticipantData::setAnonymousIdsFilter (   $anonymousIdsFilter)

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

References $anonymousIdsFilter.

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

◆ setParticipantAccessFilter()

ilTestParticipantData::setParticipantAccessFilter ( Closure  $participantAccessFilter)

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

References $participantAccessFilter.

Referenced by ilTestArchiver\createUserResultsForArchive().

82  : void
83  {
84  $this->participantAccessFilter = $participantAccessFilter;
85  }
+ Here is the caller graph for this function:

◆ setScoredParticipantsFilterEnabled()

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

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

References $scoredParticipantsFilterEnabled.

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

◆ setUserIdsFilter()

ilTestParticipantData::setUserIdsFilter (   $userIdsFilter)

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

References $userIdsFilter.

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

Field Documentation

◆ $active_ids_filter

array ilTestParticipantData::$active_ids_filter
private

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

Referenced by getActiveIdsFilter(), and setActiveIdsFilter().

◆ $anonymousIdsFilter

array ilTestParticipantData::$anonymousIdsFilter
private

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

Referenced by getAnonymousIdsFilter(), and setAnonymousIdsFilter().

◆ $byActiveId

array ilTestParticipantData::$byActiveId
private

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

◆ $byAnonymousId

array ilTestParticipantData::$byAnonymousId
private

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

◆ $byUserId

array ilTestParticipantData::$byUserId
private

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

◆ $db

ilTestParticipantData::$db
protected

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

Referenced by __construct().

◆ $lng

ilTestParticipantData::$lng
protected

Definition at line 37 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 41 of file class.ilTestParticipantData.php.

Referenced by getUserIdsFilter(), and setUserIdsFilter().


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