ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestExportAbstract Class Reference
+ Inheritance diagram for ilTestExportAbstract:
+ Collaboration diagram for ilTestExportAbstract:

Public Member Functions

 deliver (string $title)
 
 getContent ()
 
 getDatarows (ilObjTest $test_obj)
 
 getHeaderRow (ilLanguage $lng, ilObjTest $test_obj)
 

Protected Member Functions

 orderQuestions (array $questions)
 

Protected Attributes

ilTestEvaluationData $complete_data
 
array $aggregated_data
 
array $additionalFields
 
ilLanguage $lng
 

Detailed Description

Author
Fabian Helfer fhelf.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de

Definition at line 24 of file class.ilTestExportAbstract.php.

Member Function Documentation

◆ deliver()

ilTestExportAbstract::deliver ( string  $title)
abstract

◆ getContent()

ilTestExportAbstract::getContent ( )
abstract

◆ getDatarows()

ilTestExportAbstract::getDatarows ( ilObjTest  $test_obj)

Definition at line 50 of file class.ilTestExportAbstract.php.

References ilObjUser\_lookupFields(), ilObjTest\buildStatisticsAccessFilteredParticipantList(), ilDatePresentation\formatDate(), ilObjTest\getAnonymity(), getHeaderRow(), ilObjTest\getMarkSchema(), ilObjTest\getPassScoring(), IL_CAL_UNIX, ilObjTest\isRandomTest(), ILIAS\Repository\lng(), ilObjTest\lookupPassResultsUpdateTimestamp(), orderQuestions(), SCORE_BEST_PASS, and ilObjTest\setAccessFilteredParticipantList().

Referenced by ilCSVTestExport\withAllResults(), and ilExcelTestExport\withResultsPage().

50  : array
51  {
54  );
55 
56  $headerrow = $this->getHeaderRow($this->lng, $test_obj);
57  $counter = 1;
58  $rows = [];
59  foreach ($this->complete_data->getParticipants() as $active_id => $userdata) {
60  $datarow = $headerrow;
61  if ($this->passedonly && !$userdata->getPassed()) {
62  continue;
63  }
64  $datarow2 = [];
65  if ($test_obj->getAnonymity()) {
66  $datarow2[] = $counter;
67  } else {
68  $datarow2[] = $userdata->getName();
69  $datarow2[] = $userdata->getLogin();
70  }
71 
72  $userfields = [];
73  if ($userdata->getUserID() !== null) {
74  $userfields = ilObjUser::_lookupFields($userdata->getUserID());
75  }
76  foreach ($this->additionalFields as $fieldname) {
77  if ($fieldname === 'gender') {
78  $datarow2[] = isset($userfields[$fieldname]) && $userfields[$fieldname] !== ''
79  ? $this->lng->txt('gender_' . $userfields[$fieldname])
80  : '';
81  } elseif ($fieldname === 'exam_id') {
82  $datarow2[] = $userdata->getExamIdFromScoredPass();
83  } else {
84  $datarow2[] = $userfields[$fieldname] ?? '';
85  }
86  }
87 
88  $datarow2[] = $userdata->getReached();
89  $datarow2[] = $userdata->getMaxpoints();
90  $datarow2[] = $userdata->getMark();
91  $datarow2[] = $userdata->getQuestionsWorkedThrough();
92  $datarow2[] = $userdata->getNumberOfQuestions();
93  $datarow2[] = $userdata->getQuestionsWorkedThroughInPercent() / 100.0;
94  $time = $userdata->getTimeOfWork();
95  $time_seconds = $time;
96  $time_hours = floor($time_seconds / 3600);
97  $time_seconds -= $time_hours * 3600;
98  $time_minutes = floor($time_seconds / 60);
99  $time_seconds -= $time_minutes * 60;
100  $datarow2[] = sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds);
101  $time = $userdata->getQuestionsWorkedThrough() ? $this->complete_data->getParticipant(
102  $active_id
103  )->getTimeOfWork() / $userdata->getQuestionsWorkedThrough() : 0;
104  $time_seconds = $time;
105  $time_hours = floor($time_seconds / 3600);
106  $time_seconds -= $time_hours * 3600;
107  $time_minutes = floor($time_seconds / 60);
108  $time_seconds -= $time_minutes * 60;
109  $datarow2[] = sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds);
110 
111  $fv = $userdata->getFirstVisit();
112  $lv = $userdata->getLastVisit();
113  foreach ([$fv, $lv] as $ts) {
114  if ($ts) {
116  $datarow2[] = $visit;
117  } else {
118  $datarow2[] = "";
119  }
120  }
121 
122  $median = $this->complete_data->getStatistics()->getStatistics()->median();
123  $pct = $userdata->getMaxpoints() ? $median / $this->complete_data->getParticipant(
124  $active_id
125  )->getMaxpoints() * 100.0 : 0;
126  $mark = $test_obj->getMarkSchema()->getMatchingMark($pct);
127  $mark_short_name = "";
128  if (is_object($mark)) {
129  $mark_short_name = $mark->getShortName();
130  }
131  $datarow2[] = $mark_short_name;
132  $datarow2[] = $this->complete_data->getStatistics()->getStatistics()->rank(
133  $userdata->getReached()
134  );
135  $datarow2[] = $this->complete_data->getStatistics()->getStatistics()->rank_median();
136  $datarow2[] = $this->complete_data->getStatistics()->getStatistics()->count();
137  $datarow2[] = $median;
138 
139  $datarow2[] = $userdata->getPassCount();
140  $datarow2[] = $userdata->getFinishedPasses();
141  if ($test_obj->getPassScoring() === SCORE_BEST_PASS) {
142  $datarow2[] = $userdata->getBestPass() + 1;
143  } else {
144  $datarow2[] = $userdata->getLastPass() + 1;
145  }
146  $shown_pass = 0;
147  if ($counter >= 2 && $test_obj->isRandomTest()) {
148  $datarow = $datarow2;
149  $datarow[] = '';
150  $datarow2 = array_map(static fn($entry) => '', $datarow2);
151  }
152 
153  for ($pass = 0; $pass <= $userdata->getLastPass(); $pass++) {
154  $finishdate = ilObjTest::lookupPassResultsUpdateTimestamp($active_id, $pass);
155 
156  if ($finishdate < 1
157  || $this->scoredonly && $pass !== $userdata->getScoredPass()) {
158  continue;
159  }
160 
161  if ($shown_pass > 0) {
162  for ($i = 1, $iMax = count($headerrow); $i < $iMax; $i++) {
163  $datarow2[] = "";
164  $datarow[] = "";
165  }
166  $datarow[] = "";
167  }
168  $datarow2[] = $pass + 1;
169  if (is_object($userdata)
170  && is_array(
171  $evaluated_questions = $userdata->getQuestions($pass)
172  )
173  ) {
174  $questions = $this->orderQuestions($evaluated_questions);
175  foreach ($questions as $question) {
176  $question_data = $userdata->getPass(
177  $pass
178  )->getAnsweredQuestionByQuestionId($question["id"]);
179  if (is_null($question_data)) {
180  $question_data = ['reached' => 0];
181  }
182  $datarow2[] = $question_data["reached"];
183  $datarow[] = preg_replace("/<.*?>/", "", $this->complete_data->getQuestionTitle($question["id"]));
184  }
185  }
186  if (($counter === 1 && $shown_pass === 0) || $test_obj->isRandomTest()) {
187  $rows[] = $datarow;
188  }
189  $datarow = [];
190 
191  $rows[] = $datarow2;
192  $datarow2 = [];
193  $shown_pass++;
194  }
195  $counter++;
196  }
197 
198  return $rows;
199  }
buildStatisticsAccessFilteredParticipantList()
static lookupPassResultsUpdateTimestamp($active_id, $pass)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
isRandomTest()
Returns the fact wether this test is a random questions test or not.
getHeaderRow(ilLanguage $lng, ilObjTest $test_obj)
getMarkSchema()
{ASS_MarkSchema}
static _lookupFields(int $a_user_id)
lookup fields (deprecated; use more specific methods instead)
setAccessFilteredParticipantList(ilTestParticipantList $access_filtered_participant_list)
const SCORE_BEST_PASS
getPassScoring()
Gets the pass scoring type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHeaderRow()

ilTestExportAbstract::getHeaderRow ( ilLanguage  $lng,
ilObjTest  $test_obj 
)

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

References ilObjTest\getAnonymity(), ILIAS\Repository\lng(), and ilLanguage\txt().

Referenced by getDatarows(), and ilExcelTestExport\withResultsPage().

201  : array
202  {
203  if ($test_obj->getAnonymity()) {
204  $datarow[] = $lng->txt("counter");
205  } else {
206  $datarow[] = $lng->txt("name");
207  $datarow[] = $lng->txt("login");
208  }
209  if (count($this->additionalFields)) {
210  foreach ($this->additionalFields as $fieldname) {
211  if (strcmp($fieldname, "exam_id") === 0) {
212  $datarow[] = $lng->txt('exam_id_label');
213  continue;
214  }
215  $datarow[] = $lng->txt($fieldname);
216  }
217  }
218  $datarow[] = $this->lng->txt("tst_stat_result_resultspoints");
219  $datarow[] = $lng->txt("maximum_points");
220  $datarow[] = $lng->txt("tst_stat_result_resultsmarks");
221  $datarow[] = $lng->txt("tst_stat_result_qworkedthrough");
222  $datarow[] = $lng->txt("tst_stat_result_qmax");
223  $datarow[] = $lng->txt("tst_stat_result_pworkedthrough");
224  $datarow[] = $lng->txt("tst_stat_result_timeofwork");
225  $datarow[] = $lng->txt("tst_stat_result_atimeofwork");
226  $datarow[] = $lng->txt("tst_stat_result_firstvisit");
227  $datarow[] = $lng->txt("tst_stat_result_lastvisit");
228  $datarow[] = $lng->txt("tst_stat_result_mark_median");
229  $datarow[] = $lng->txt("tst_stat_result_rank_participant");
230  $datarow[] = $lng->txt("tst_stat_result_rank_median");
231  $datarow[] = $lng->txt("tst_stat_result_total_participants");
232  $datarow[] = $lng->txt("tst_stat_result_median");
233  $datarow[] = $lng->txt("tst_tbl_col_started_passes");
234  $datarow[] = $lng->txt("tst_tbl_col_finished_passes");
235  $datarow[] = $lng->txt("scored_pass");
236  $datarow[] = $lng->txt("pass");
237 
238  return $datarow;
239  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ orderQuestions()

ilTestExportAbstract::orderQuestions ( array  $questions)
protected

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

References Vendor\Package\$a, Vendor\Package\$b, and ILIAS\LTI\ToolProvider\$key.

Referenced by getDatarows().

241  : array
242  {
243  $key = $this->test_obj->isRandomTest() ? 'qid' : 'sequence';
244  usort(
245  $questions,
246  static function ($a, $b) use ($key) {
247  if (isset($a[$key], $b[$key]) && $a[$key] > $b[$key]) {
248  return 1;
249  }
250  return -1;
251  }
252  );
253  return $questions;
254  }
string $key
Consumer key/client ID value.
Definition: System.php:193
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the caller graph for this function:

Field Documentation

◆ $additionalFields

array ilTestExportAbstract::$additionalFields
protected

Definition at line 28 of file class.ilTestExportAbstract.php.

◆ $aggregated_data

array ilTestExportAbstract::$aggregated_data
protected

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

◆ $complete_data

ilTestEvaluationData ilTestExportAbstract::$complete_data
protected

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

◆ $lng

ilLanguage ilTestExportAbstract::$lng
protected

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

Referenced by ilExcelTestExport\__construct().


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