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

Public Member Functions

 __construct (ilObjTest $test_obj, string $filter_key_participants=ilTestEvaluationData::FILTER_BY_NONE, string $filtertext='', bool $passedonly=false, bool $scoredonly=true, ilLanguage $lng=null)
 
 withResultsPage ()
 
 getContent ()
 
 withUserPages ()
 
 withAggregatedResultsPage ()
 
 deliver (string $title)
 
- Public Member Functions inherited from ilTestExportAbstract
 deliver (string $title)
 
 getContent ()
 
 getDatarows (ilObjTest $test_obj)
 
 getHeaderRow (ilLanguage $lng, ilObjTest $test_obj)
 

Protected Attributes

ilAssExcelFormatHelper $worksheet
 
- Protected Attributes inherited from ilTestExportAbstract
ilTestEvaluationData $complete_data
 
array $aggregated_data
 
array $additionalFields
 
ilLanguage $lng
 

Additional Inherited Members

- Protected Member Functions inherited from ilTestExportAbstract
 orderQuestions (array $questions)
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

ilExcelTestExport::__construct ( ilObjTest  $test_obj,
string  $filter_key_participants = ilTestEvaluationData::FILTER_BY_NONE,
string  $filtertext = '',
bool  $passedonly = false,
bool  $scoredonly = true,
ilLanguage  $lng = null 
)

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

References ilTestExportAbstract\$lng, and ILIAS\MetaData\Repository\Validation\Data\__construct().

35  {
36  $this->scoredonly = $scoredonly;
37  $this->worksheet = new ilAssExcelFormatHelper();
38  parent::__construct($test_obj, $filter_key_participants, $filtertext, $passedonly, $scoredonly, $lng);
39  }
__construct(VocabulariesInterface $vocabularies)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Member Function Documentation

◆ deliver()

ilExcelTestExport::deliver ( string  $title)
Exceptions

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

References ilFileUtils\getASCIIFilename().

216  : void
217  {
218  $testname = ilFileUtils::getASCIIFilename(preg_replace("/\s/", "_", $title)) . '.xlsx';
219  $this->worksheet->sendToClient($testname);
220  }
static getASCIIFilename(string $a_filename)
+ Here is the call graph for this function:

◆ getContent()

ilExcelTestExport::getContent ( )

Definition at line 86 of file class.ilExcelTestExport.php.

References $worksheet.

87  {
88  return $this->worksheet;
89  }
ilAssExcelFormatHelper $worksheet
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ withAggregatedResultsPage()

ilExcelTestExport::withAggregatedResultsPage ( )

Definition at line 167 of file class.ilExcelTestExport.php.

References ILIAS\LTI\ToolProvider\$key, and ILIAS\Repository\lng().

167  : self
168  {
169  $this->worksheet->addSheet($this->lng->txt('tst_results_aggregated'));
170 
171  $row = 1;
172  $col = 0;
173  $this->worksheet->setCell($row, $col++, $this->lng->txt('result'));
174  $this->worksheet->setCell($row, $col++, $this->lng->txt('value'));
175 
176  $this->worksheet->setBold('A' . $row . ':' . $this->worksheet->getColumnCoord($col - 1) . $row);
177 
178  $row++;
179  foreach ($this->aggregated_data['overview'] as $key => $value) {
180  $col = 0;
181  $this->worksheet->setCell($row, $col++, $key);
182  $this->worksheet->setCell($row, $col++, $value);
183  $row++;
184  }
185 
186  $row++;
187  $col = 0;
188 
189  $this->worksheet->setCell($row, $col++, $this->lng->txt('question_id'));
190  $this->worksheet->setCell($row, $col++, $this->lng->txt('question_title'));
191  $this->worksheet->setCell($row, $col++, $this->lng->txt('average_reached_points'));
192  $this->worksheet->setCell($row, $col++, $this->lng->txt('points'));
193  $this->worksheet->setCell($row, $col++, $this->lng->txt('percentage'));
194  $this->worksheet->setCell($row, $col++, $this->lng->txt('number_of_answers'));
195 
196  $this->worksheet->setBold('A' . $row . ':' . $this->worksheet->getColumnCoord($col - 1) . $row);
197 
198  $row++;
199  foreach ($this->aggregated_data['questions'] as $key => $value) {
200  $col = 0;
201  $this->worksheet->setCell($row, $col++, $key);
202  $this->worksheet->setCell($row, $col++, $value[0]);
203  $this->worksheet->setCell($row, $col++, $value[4]);
204  $this->worksheet->setCell($row, $col++, $value[5]);
205  $this->worksheet->setCell($row, $col++, $value[6]);
206  $this->worksheet->setCell($row, $col++, $value[3]);
207  $row++;
208  }
209 
210  return $this;
211  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ withResultsPage()

ilExcelTestExport::withResultsPage ( )

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

References $data, ilTestExportAbstract\getDatarows(), ilTestExportAbstract\getHeaderRow(), and ILIAS\Repository\lng().

41  : self
42  {
43  $this->worksheet->addSheet($this->lng->txt('tst_results'));
44 
45  $row = 1;
46  $header_row = $this->getHeaderRow($this->lng, $this->test_obj);
47  foreach ($header_row as $col => $value) {
48  $this->worksheet->setFormattedExcelTitle($this->worksheet->getColumnCoord($col) . $row, $value);
49  }
50  $this->worksheet->setBold('A' . $row . ':' . $this->worksheet->getColumnCoord(count($header_row) + 1) . $row);
51 
52  $datarows = $this->getDatarows($this->test_obj);
53  foreach ($datarows as $row => $data) {
54  if ($this->test_obj->isRandomTest()) {
55  if ($row % 2 === 0) {
56  foreach ($data as $col => $value) {
57  if ($value !== "" && $col >= count($header_row)) {
58  $this->worksheet->setFormattedExcelTitle(
59  $this->worksheet->getColumnCoord($col) . $row + 1,
60  $value
61  );
62  } else {
63  $this->worksheet->setCellByCoordinates($this->worksheet->getColumnCoord($col) . $row + 1, $value);
64  }
65  }
66  } elseif ($row % 2 === 1) {
67  if ($row !== 1) {
68  for ($col = 0, $colMax = count($header_row); $col < $colMax - 1; $col++) {
69  $data[$col] = "";
70  }
71  }
72  foreach ($data as $col => $value) {
73  $this->worksheet->setCellByCoordinates($this->worksheet->getColumnCoord($col) . $row + 1, $value);
74  }
75  }
76  } else {
77  foreach ($data as $col => $value) {
78  $this->worksheet->setCellByCoordinates($this->worksheet->getColumnCoord($col) . $row + 1, $value);
79  }
80  }
81  }
82 
83  return $this;
84  }
getDatarows(ilObjTest $test_obj)
getHeaderRow(ilLanguage $lng, ilObjTest $test_obj)
+ Here is the call graph for this function:

◆ withUserPages()

ilExcelTestExport::withUserPages ( )

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

References Vendor\Package\$a, Vendor\Package\$b, assQuestion\instantiateQuestion(), and ILIAS\Repository\lng().

91  : self
92  {
93  $row = 1;
94  $usernames = [];
95  $allusersheet = false;
96  $pages = 0;
97  // test participant result export
98  $participantcount = count($this->complete_data->getParticipants());
99  foreach ($this->complete_data->getParticipants() as $active_id => $userdata) {
100  $username = (!is_null($userdata) && $userdata->getName()) ? $userdata->getName() : "ID $active_id";
101  $username = mb_substr($username, 0, 26);
102  $username_to_lower = strtolower($username);
103  if (array_key_exists($username_to_lower, $usernames)) {
104  $usernames[$username_to_lower]++;
105  $username .= " (" . $usernames[$username_to_lower] . ")";
106  } else {
107  $usernames[$username_to_lower] = 0;
108  }
109 
110  if ($participantcount > 250) {
111  if (!$allusersheet || ($pages - 1) < floor($row / 64000)) {
112  $this->worksheet->addSheet(
113  $this->lng->txt("eval_all_users") . (($pages > 0) ? " (" . ($pages + 1) . ")" : "")
114  );
115  $allusersheet = true;
116  $row = 1;
117  $pages++;
118  }
119  } else {
120  $resultsheet = $this->worksheet->addSheet($username);
121  }
122  if ($this->scoredonly) {
123  $passes = [$userdata->getScoredPassObject()];
124  } else {
125  $passes = $userdata->getPasses();
126  }
127  $col = 0;
128  foreach ($passes as $pass) {
129  $passCount = $pass->getPass();
130  $row = ($allusersheet) ? $row : 1;
131  $title = sprintf(
132  $this->lng->txt("tst_result_user_name_pass"),
133  $passCount + 1,
134  $userdata->getName()
135  ) .
136  (!$this->scoredonly && $userdata->getScoredPass() === $passCount ? " " .
137  $this->lng->txt("exp_scored_test_run") .
138  " (" . ($this->test_obj->getPassScoring() ? $this->lng->txt(
139  'tst_pass_scoring_best'
140  ) : $this->lng->txt('tst_pass_scoring_last')) . ")" : "");
141  $this->worksheet->setCell(
142  $row,
143  $col,
144  $title
145  );
146  $this->worksheet->setBold($this->worksheet->getColumnCoord($col) . $row);
147  $row += 2;
148  if (is_object($userdata) && is_array($userdata->getQuestions($passCount))) {
149  $questions = $userdata->getQuestions($passCount);
150  usort($questions, static function ($a, $b) {
151  return $a['sequence'] - $b['sequence'];
152  });
153  foreach ($questions as $question) {
154  $question = assQuestion::instantiateQuestion((int) $question["id"]);
155  if (is_object($question)) {
156  $row = $question->setExportDetailsXLSX($this->worksheet, $row, $col, $active_id, $passCount);
157  }
158  }
159  }
160  $col += 3;
161  }
162  }
163 
164  return $this;
165  }
static instantiateQuestion(int $question_id)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:

Field Documentation

◆ $worksheet

ilAssExcelFormatHelper ilExcelTestExport::$worksheet
protected

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

Referenced by getContent().


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