ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilTestEvaluationData Class Reference
+ Collaboration diagram for ilTestEvaluationData:

Public Member Functions

 __sleep ()
 
 __construct (protected array $participants)
 
 setDatasets (int $datasets)
 
 getDatasets ()
 
 addQuestionTitle (int $question_id, string $question_title)
 
 getQuestionTitles ()
 
 getQuestionTitle (?int $question_id)
 
 getTotalFinishedParticipants ()
 
 getParticipants ()
 
 resetFilter ()
 
 setFilter (string $by, string $text)
 
 setFilterArray (array $arr_filter)
 
 addParticipant (int $active_id, ilTestEvaluationUserData $participant)
 
 getParticipant (int $active_id)
 
 participantExists ($active_id)
 
 removeParticipant ($active_id)
 
 getStatistics ()
 
 getParticipantIds ()
 

Data Fields

const FILTER_BY_NONE = ''
 
const FILTER_BY_NAME = 'name'
 
const FILTER_BY_GROUP = 'group'
 
const FILTER_BY_COURSE = 'course'
 
const FILTER_BY_ACTIVE_ID = 'active_id'
 
array $question_titles = []
 

Protected Attributes

Statistics $statistics = null
 
array $arr_filter = null
 
int $datasets
 

Private Member Functions

 orderParticipants (array $participants)
 

Detailed Description

Deprecated:
11; Result/EvaluationData will be refined.

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

Constructor & Destructor Documentation

◆ __construct()

ilTestEvaluationData::__construct ( protected array  $participants)
Parameters
array<ilTestEvaluationUserData>$participants

Definition at line 48 of file class.ilTestEvaluationData.php.

50 {
51 }

Member Function Documentation

◆ __sleep()

ilTestEvaluationData::__sleep ( )

Definition at line 40 of file class.ilTestEvaluationData.php.

40 : array
41 {
42 return ['question_titles', 'participants', 'statistics', 'arr_filter', 'datasets', 'test'];
43 }

◆ addParticipant()

ilTestEvaluationData::addParticipant ( int  $active_id,
ilTestEvaluationUserData  $participant 
)

Definition at line 187 of file class.ilTestEvaluationData.php.

187 : void
188 {
189 $this->participants[$active_id] = $participant;
190 }

◆ addQuestionTitle()

ilTestEvaluationData::addQuestionTitle ( int  $question_id,
string  $question_title 
)

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

63 : void
64 {
65 $this->question_titles[$question_id] = $question_title;
66 }

Referenced by ilTestEvaluationFactory\addQuestionsToParticipantPasses().

+ Here is the caller graph for this function:

◆ getDatasets()

ilTestEvaluationData::getDatasets ( )

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

58 : int
59 {
60 return $this->datasets;
61 }

References $datasets.

◆ getParticipant()

ilTestEvaluationData::getParticipant ( int  $active_id)

Definition at line 192 of file class.ilTestEvaluationData.php.

193 {
194 return $this->participants[$active_id] ?? null;
195 }

Referenced by ILIAS\Test\Statistics\Statistics\__construct(), ilTestEvaluationFactory\addMarksToParticipants(), and ilTestEvaluationFactory\addQuestionsToParticipantPasses().

+ Here is the caller graph for this function:

◆ getParticipantIds()

ilTestEvaluationData::getParticipantIds ( )

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

215 : array
216 {
217 return array_keys($this->participants);
218 }

Referenced by ilTestEvaluationFactory\addMarksToParticipants(), and ilTestEvaluationFactory\addQuestionsToParticipantPasses().

+ Here is the caller graph for this function:

◆ getParticipants()

ilTestEvaluationData::getParticipants ( )
Returns
array<ilTestEvaluationUserData>

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

103 : array
104 {
105 if (is_array($this->arr_filter) && count($this->arr_filter) > 0) {
106 $filtered_participants = [];
107 $courseids = [];
108 $groupids = [];
109
110 if (array_key_exists(self::FILTER_BY_GROUP, $this->arr_filter)) {
111 $ids = ilObject::_getIdsForTitle($this->arr_filter[self::FILTER_BY_GROUP], 'grp', true);
112 $groupids = array_merge($groupids, $ids);
113 }
114 if (array_key_exists(self::FILTER_BY_COURSE, $this->arr_filter)) {
115 $ids = ilObject::_getIdsForTitle($this->arr_filter[self::FILTER_BY_COURSE], 'crs', true);
116 $courseids = array_merge($courseids, $ids);
117 }
118 foreach ($this->participants as $active_id => $participant) {
119 $remove = false;
120 if (array_key_exists(self::FILTER_BY_NAME, $this->arr_filter)) {
121 if (!(strpos(strtolower($participant->getName()), strtolower((string) $this->arr_filter[self::FILTER_BY_NAME])) !== false)) {
122 $remove = true;
123 }
124 }
125 if (!$remove) {
126 if (array_key_exists(self::FILTER_BY_GROUP, $this->arr_filter)) {
127 $groups = ilParticipants::_getMembershipByType($participant->getUserID(), ['grp']);
128 $foundfilter = false;
129 if (count(array_intersect($groupids, $groups))) {
130 $foundfilter = true;
131 }
132 if (!$foundfilter) {
133 $remove = true;
134 }
135 }
136 }
137 if (!$remove) {
138 if (array_key_exists(self::FILTER_BY_COURSE, $this->arr_filter)) {
139 $courses = ilParticipants::_getMembershipByType($participant->getUserID(), ['crs']);
140 $foundfilter = false;
141 if (count(array_intersect($courseids, $courses))) {
142 $foundfilter = true;
143 }
144 if (!$foundfilter) {
145 $remove = true;
146 }
147 }
148 }
149 if (!$remove) {
150 if (array_key_exists(self::FILTER_BY_ACTIVE_ID, $this->arr_filter)) {
151 if ($active_id != $this->arr_filter[self::FILTER_BY_ACTIVE_ID]) {
152 $remove = true;
153 }
154 }
155 }
156 if (!$remove) {
157 $filtered_participants[$active_id] = $participant;
158 }
159 }
160 return $this->orderParticipants($filtered_participants);
161 }
162
163 return $this->orderParticipants($this->participants);
164 }
static _getIdsForTitle(string $title, string $type='', bool $partial_match=false)
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
orderParticipants(array $participants)

References ilObject\_getIdsForTitle(), ilParticipants\_getMembershipByType(), and orderParticipants().

Referenced by ILIAS\Test\Statistics\Statistics\__construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionTitle()

ilTestEvaluationData::getQuestionTitle ( ?int  $question_id)

Definition at line 76 of file class.ilTestEvaluationData.php.

76 : string
77 {
78 if (array_key_exists($question_id, $this->question_titles)) {
79 return $this->question_titles[$question_id];
80 }
81
82 return '';
83 }

◆ getQuestionTitles()

ilTestEvaluationData::getQuestionTitles ( )
Returns
array<string>

Definition at line 71 of file class.ilTestEvaluationData.php.

71 : array
72 {
74 }

References $question_titles.

◆ getStatistics()

ilTestEvaluationData::getStatistics ( )

Definition at line 207 of file class.ilTestEvaluationData.php.

207 : Statistics
208 {
209 if ($this->statistics === null) {
210 $this->statistics = new Statistics($this);
211 }
212 return $this->statistics;
213 }

References $statistics.

◆ getTotalFinishedParticipants()

ilTestEvaluationData::getTotalFinishedParticipants ( )

Definition at line 85 of file class.ilTestEvaluationData.php.

85 : int
86 {
87 $finishedParticipants = 0;
88
89 foreach ($this->participants as $active_id => $participant) {
90 if (!$participant->isSubmitted()) {
91 continue;
92 }
93
94 $finishedParticipants++;
95 }
96
97 return $finishedParticipants;
98 }

◆ orderParticipants()

ilTestEvaluationData::orderParticipants ( array  $participants)
private

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

220 : array
221 {
222 uasort($participants, static fn($a, $b) => $a->getName() <=> $b->getName());
223 return $participants;
224 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, and Vendor\Package\$b.

Referenced by getParticipants().

+ Here is the caller graph for this function:

◆ participantExists()

ilTestEvaluationData::participantExists (   $active_id)

Definition at line 197 of file class.ilTestEvaluationData.php.

197 : bool
198 {
199 return array_key_exists($active_id, $this->participants);
200 }

◆ removeParticipant()

ilTestEvaluationData::removeParticipant (   $active_id)

Definition at line 202 of file class.ilTestEvaluationData.php.

203 {
204 unset($this->participants[$active_id]);
205 }

◆ resetFilter()

ilTestEvaluationData::resetFilter ( )

Definition at line 166 of file class.ilTestEvaluationData.php.

166 : void
167 {
168 $this->arr_filter = [];
169 }

◆ setDatasets()

ilTestEvaluationData::setDatasets ( int  $datasets)

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

53 : void
54 {
55 $this->datasets = $datasets;
56 }

References $datasets.

◆ setFilter()

ilTestEvaluationData::setFilter ( string  $by,
string  $text 
)

Definition at line 171 of file class.ilTestEvaluationData.php.

171 : void
172 {
173 if (in_array(
174 $by,
175 [self::FILTER_BY_ACTIVE_ID, self::FILTER_BY_NAME, self::FILTER_BY_COURSE, self::FILTER_BY_GROUP],
176 true
177 )) {
178 $this->arr_filter = [$by => $text];
179 }
180 }

◆ setFilterArray()

ilTestEvaluationData::setFilterArray ( array  $arr_filter)

Definition at line 182 of file class.ilTestEvaluationData.php.

182 : void
183 {
184 $this->arr_filter = $arr_filter;
185 }

References $arr_filter.

Field Documentation

◆ $arr_filter

array ilTestEvaluationData::$arr_filter = null
protected

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

Referenced by setFilterArray().

◆ $datasets

int ilTestEvaluationData::$datasets
protected

Definition at line 38 of file class.ilTestEvaluationData.php.

Referenced by getDatasets(), and setDatasets().

◆ $question_titles

array ilTestEvaluationData::$question_titles = []

Definition at line 34 of file class.ilTestEvaluationData.php.

Referenced by getQuestionTitles().

◆ $statistics

Statistics ilTestEvaluationData::$statistics = null
protected

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

Referenced by getStatistics().

◆ FILTER_BY_ACTIVE_ID

const ilTestEvaluationData::FILTER_BY_ACTIVE_ID = 'active_id'

◆ FILTER_BY_COURSE

const ilTestEvaluationData::FILTER_BY_COURSE = 'course'

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

◆ FILTER_BY_GROUP

const ilTestEvaluationData::FILTER_BY_GROUP = 'group'

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

◆ FILTER_BY_NAME

const ilTestEvaluationData::FILTER_BY_NAME = 'name'

Definition at line 29 of file class.ilTestEvaluationData.php.

◆ FILTER_BY_NONE

const ilTestEvaluationData::FILTER_BY_NONE = ''

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