ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTestParticipantData Class Reference
+ Collaboration diagram for ilTestParticipantData:

Public Member Functions

 __construct (ilDB $db, ilLanguage $lng)
 
 load ($testId)
 
 getConditionalExpression ()
 
 setActiveIds ($activeIds)
 
 getActiveIds ()
 
 setUserIds ($userIds)
 
 getUserIds ()
 
 setAnonymousIds ($anonymousIds)
 
 getAnonymousIds ()
 
 getUserIdByActiveId ($activeId)
 
 getActiveIdByUserId ($userId)
 
 getConcatedFullnameByActiveId ($activeId)
 
 getFormatedFullnameByActiveId ($activeId)
 
 getOptionArray ()
 
 getAnonymousActiveIds ()
 

Protected Attributes

 $db
 
 $lng
 

Private Member Functions

 buildFormatedFullname ($usrData)
 

Private Attributes

 $activeIds
 
 $userIds
 
 $anonymousIds
 
 $byActiveId
 
 $byUserId
 
 $byAnonymousId
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $db, and $lng.

54  {
55  $this->db = $db;
56  $this->lng = $lng;
57 
58  $this->activeIds = array();
59  $this->userIds = array();
60  $this->anonymousIds = array();
61 
62  $this->byActiveId = array();
63  $this->byUserId = array();
64  $this->byAnonymousId = array();
65  }

Member Function Documentation

◆ buildFormatedFullname()

ilTestParticipantData::buildFormatedFullname (   $usrData)
private

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

Referenced by getFormatedFullnameByActiveId(), and getOptionArray().

195  {
196  return sprintf(
197  $this->lng->txt('tst_participant_fullname_pattern'), $usrData['firstname'], $usrData['lastname']
198  );
199  }
+ Here is the caller graph for this function:

◆ getActiveIdByUserId()

ilTestParticipantData::getActiveIdByUserId (   $userId)

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

166  {
167  return $this->byUserId[$userId]['active_id'];
168  }

◆ getActiveIds()

ilTestParticipantData::getActiveIds ( )

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

References $activeIds.

Referenced by getConditionalExpression(), and ilObjTest\removeTestResults().

+ Here is the caller graph for this function:

◆ getAnonymousActiveIds()

ilTestParticipantData::getAnonymousActiveIds ( )

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

Referenced by ilObjTest\removeTestResults().

202  {
203  $anonymousActiveIds = array();
204 
205  foreach($this->byActiveId as $activeId => $active)
206  {
207  if($active['user_id'] == ANONYMOUS_USER_ID)
208  {
209  $anonymousActiveIds[] = $activeId;
210  }
211  }
212 
213  return $anonymousActiveIds;
214  }
+ Here is the caller graph for this function:

◆ getAnonymousIds()

ilTestParticipantData::getAnonymousIds ( )

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

References $anonymousIds.

Referenced by getConditionalExpression().

+ Here is the caller graph for this function:

◆ getConcatedFullnameByActiveId()

ilTestParticipantData::getConcatedFullnameByActiveId (   $activeId)

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

171  {
172  return "{$this->byActiveId[$activeId]['firstname']} {$this->byActiveId[$activeId]['lastname']}";
173  }

◆ getConditionalExpression()

ilTestParticipantData::getConditionalExpression ( )

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

References getActiveIds(), getAnonymousIds(), and getUserIds().

104  {
105  $conditions = array();
106 
107  if( count($this->getActiveIds()) )
108  {
109  $conditions[] = $this->db->in('active_id', $this->getActiveIds(), false, 'integer');
110  }
111 
112  if( count($this->getUserIds()) )
113  {
114  $conditions[] = $this->db->in('user_fi', $this->getUserIds(), false, 'integer');
115  }
116 
117  if( count($this->getAnonymousIds()) )
118  {
119  $conditions[] = $this->db->in('anonymous_id', $this->getAnonymousIds(), false, 'integer');
120  }
121 
122  if( count($conditions) )
123  {
124  return '('.implode(' OR ', $conditions).')';
125  }
126 
127  return '1 = 1';
128  }
+ Here is the call graph for this function:

◆ getFormatedFullnameByActiveId()

ilTestParticipantData::getFormatedFullnameByActiveId (   $activeId)

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

References buildFormatedFullname().

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

◆ getOptionArray()

ilTestParticipantData::getOptionArray ( )

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

References $options, and buildFormatedFullname().

181  {
182  $options = array();
183 
184  foreach($this->byActiveId as $activeId => $usrData)
185  {
186  $options[$activeId] = $this->buildFormatedFullname($usrData);
187  }
188 
189  asort($options);
190 
191  return $options;
192  }
if(!is_array($argv)) $options
+ Here is the call graph for this function:

◆ getUserIdByActiveId()

ilTestParticipantData::getUserIdByActiveId (   $activeId)

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

161  {
162  return $this->byActiveId[$activeId]['user_id'];
163  }

◆ getUserIds()

ilTestParticipantData::getUserIds ( )

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

References $userIds.

Referenced by getConditionalExpression(), and ilObjTest\removeTestResults().

146  {
147  return $this->userIds;
148  }
+ Here is the caller graph for this function:

◆ load()

ilTestParticipantData::load (   $testId)

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

References $query, $res, $row, setActiveIds(), setAnonymousIds(), and setUserIds().

68  {
69  $query = "
70  SELECT ta.active_id,
71  ta.user_fi user_id,
72  ta.anonymous_id,
73  ud.firstname,
74  ud.lastname
75  FROM tst_active ta
76  LEFT JOIN usr_data ud
77  ON ud.usr_id = ta.user_fi
78  WHERE test_fi = %s
79  AND {$this->getConditionalExpression()}
80  ";
81 
82  $res = $this->db->queryF($query, array('integer'), array($testId));
83 
84  while( $row = $this->db->fetchAssoc($res) )
85  {
86  $this->byActiveId[ $row['active_id'] ] = $row;
87 
88  if( $row['user_id'] == ANONYMOUS_USER_ID )
89  {
90  $this->byAnonymousId[ $row['anonymous_id'] ] = $row;
91  }
92  else
93  {
94  $this->byUserId[ $row['user_id'] ] = $row;
95  }
96  }
97 
98  $this->setActiveIds(array_keys($this->byActiveId));
99  $this->setUserIds(array_keys($this->byUserId));
100  $this->setAnonymousIds(array_keys($this->byAnonymousId));
101  }
+ Here is the call graph for this function:

◆ setActiveIds()

ilTestParticipantData::setActiveIds (   $activeIds)

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

References $activeIds.

Referenced by load().

131  {
132  $this->activeIds = $activeIds;
133  }
+ Here is the caller graph for this function:

◆ setAnonymousIds()

ilTestParticipantData::setAnonymousIds (   $anonymousIds)

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

References $anonymousIds.

Referenced by load().

151  {
152  $this->anonymousIds = $anonymousIds;
153  }
+ Here is the caller graph for this function:

◆ setUserIds()

ilTestParticipantData::setUserIds (   $userIds)

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

References $userIds.

Referenced by load().

141  {
142  $this->userIds = $userIds;
143  }
+ Here is the caller graph for this function:

Field Documentation

◆ $activeIds

ilTestParticipantData::$activeIds
private

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

Referenced by getActiveIds(), and setActiveIds().

◆ $anonymousIds

ilTestParticipantData::$anonymousIds
private

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

Referenced by getAnonymousIds(), and setAnonymousIds().

◆ $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().

◆ $userIds

ilTestParticipantData::$userIds
private

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

Referenced by getUserIds(), and setUserIds().


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