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

Public Member Functions

 __construct (private readonly TestLoggingRepository $logging_repository, private readonly TestLogger $logger, private readonly TitleColumnsBuilder $title_builder, private readonly GeneralQuestionPropertiesRepository $question_repository, private readonly ServerRequestInterface $request, private readonly RequestWrapper $request_wrapper, private readonly \ilUIService $ui_service, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly Refinery $refinery, private readonly \ilLanguage $lng, private \ilGlobalTemplateInterface $tpl, private readonly StreamDelivery $stream_delivery, private readonly \ilObjUser $current_user)
 
 getLogTable (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token, ?int $ref_id=null)
 
 executeLogTableAction (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token, ?int $ref_id=null)
 
 getLogExportForRefjId (int $ref_id)
 
 buildExcelWorkbookForLogs (\Generator $logs)
 
 buildUserDateTimeFormat ()
 
 getLegacyLogExportForObjId (?int $obj_id=null)
 
 buildQuestionTitleForLegacyLog (array $log)
 

Private Member Functions

 addRowsFromLogs (\Generator $logs, \ilExcel $workbook)
 
 getColumHeadingsForExport ()
 
 processCSVRow (mixed $row, bool $quote_all=false, string $separator=";")
 

Private Attributes

DataFactory $data_factory
 

Detailed Description

Definition at line 36 of file TestLogViewer.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Logging\TestLogViewer::__construct ( private readonly TestLoggingRepository  $logging_repository,
private readonly TestLogger  $logger,
private readonly TitleColumnsBuilder  $title_builder,
private readonly GeneralQuestionPropertiesRepository  $question_repository,
private readonly ServerRequestInterface  $request,
private readonly RequestWrapper  $request_wrapper,
private readonly \ilUIService  $ui_service,
private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private readonly Refinery  $refinery,
private readonly \ilLanguage  $lng,
private \ilGlobalTemplateInterface  $tpl,
private readonly StreamDelivery  $stream_delivery,
private readonly \ilObjUser  $current_user 
)

Definition at line 40 of file TestLogViewer.php.

55  {
56  $this->data_factory = new DataFactory();
57  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Member Function Documentation

◆ addRowsFromLogs()

ILIAS\Test\Logging\TestLogViewer::addRowsFromLogs ( \Generator  $logs,
\ilExcel  $workbook 
)
private

Definition at line 167 of file TestLogViewer.php.

References $log, ILIAS\Test\Logging\TestLogViewer\buildUserDateTimeFormat(), and ilExcel\setCell().

Referenced by ILIAS\Test\Logging\TestLogViewer\buildExcelWorkbookForLogs().

170  : \ilExcel {
171  $row = 1;
172  foreach ($logs as $log) {
173  $row++;
174  $column = 0;
175  foreach ($log->getLogEntryAsExportRow(
176  $this->lng,
177  $this->title_builder,
178  $this->logger->getAdditionalInformationGenerator(),
179  [
180  'timezone' => new \DateTimeZone($this->current_user->getTimeZone()),
181  'date_format' => $this->buildUserDateTimeFormat()->toString()
182  ]
183  ) as $cell_content) {
184  $workbook->setCell(
185  $row,
186  $column++,
187  $cell_content
188  );
189  }
190  }
191  return $workbook;
192  }
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
$log
Definition: result.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildExcelWorkbookForLogs()

ILIAS\Test\Logging\TestLogViewer::buildExcelWorkbookForLogs ( \Generator  $logs)

Definition at line 152 of file TestLogViewer.php.

References ILIAS\Test\Logging\TestLogViewer\addRowsFromLogs(), ILIAS\Test\Logging\TestLogViewer\getColumHeadingsForExport(), and ILIAS\Repository\lng().

Referenced by ILIAS\Test\Logging\TestLogViewer\getLogExportForRefjId().

152  : \ilExcel
153  {
154  $workbook = new \ilExcel();
155  $workbook->addSheet($this->lng->txt('history'));
156 
157  $column = 0;
158  foreach ($this->getColumHeadingsForExport() as $header_cell) {
159  $workbook->setCell(1, $column++, $header_cell);
160  }
161  $workbook->setBold('A' . 1 . ':' . $workbook->getColumnCoord($column - 1) . 1);
162  $workbook->setColors('A' . 1 . ':' . $workbook->getColumnCoord($column - 1) . 1, 'C0C0C0');
163 
164  return $this->addRowsFromLogs($logs, $workbook);
165  }
addRowsFromLogs(\Generator $logs, \ilExcel $workbook)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionTitleForLegacyLog()

ILIAS\Test\Logging\TestLogViewer::buildQuestionTitleForLegacyLog ( array  $log)

Definition at line 260 of file TestLogViewer.php.

References ILIAS\Repository\lng(), and null.

Referenced by ILIAS\Test\Logging\TestLogViewer\getLegacyLogExportForObjId().

260  : string
261  {
262  if (!$log['question_fi'] && !$log['original_fi']) {
263  return '';
264  }
265  $title = '';
266  if ($log['question_fi']) {
267  $title = $this->question_repository->getForQuestionId((int) $log['question_fi'])?->getTitle();
268  }
269 
270  if ($title === null && $log['original_fi']) {
271  $title = $this->question_repository->getForQuestionId((int) $log['original_fi'])?->getTitle();
272  }
273 
274  if ($title === null) {
275  return '';
276  }
277 
278  return $this->lng->txt('question') . ': ' . $title;
279  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$log
Definition: result.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildUserDateTimeFormat()

ILIAS\Test\Logging\TestLogViewer::buildUserDateTimeFormat ( )

Definition at line 209 of file TestLogViewer.php.

References ilCalendarSettings\TIME_FORMAT_24.

Referenced by ILIAS\Test\Logging\TestLogViewer\addRowsFromLogs().

209  : DateFormat
210  {
211  $user_format = $this->current_user->getDateFormat();
212  if ($this->current_user->getTimeFormat() == \ilCalendarSettings::TIME_FORMAT_24) {
213  return $this->data_factory->dateFormat()->amend(
214  $this->data_factory->dateFormat()->withTime24($user_format)
215  )->colon()->seconds()->get();
216  }
217  return $this->data_factory->dateFormat()->amend(
218  $user_format
219  )->space()->hours12()->colon()->minutes()->colon()->seconds()->meridiem()->get();
220  }
+ Here is the caller graph for this function:

◆ executeLogTableAction()

ILIAS\Test\Logging\TestLogViewer::executeLogTableAction ( URLBuilder  $url_builder,
URLBuilderToken  $action_parameter_token,
URLBuilderToken  $row_id_token,
?int  $ref_id = null 
)

Definition at line 90 of file TestLogViewer.php.

References $ref_id, ILIAS\UI\URLBuilderToken\getName(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), and ILIAS\Repository\refinery().

95  : void {
96  $log_table = new LogTable(
97  $this->logging_repository,
98  $this->logger,
99  $this,
100  $this->title_builder,
101  $this->question_repository,
102  $this->ui_service,
103  $this->ui_factory,
104  $this->ui_renderer,
105  $this->lng,
106  $this->tpl,
107  $url_builder,
108  $action_parameter_token,
109  $row_id_token,
110  $this->stream_delivery,
111  $this->current_user,
112  $ref_id,
113  );
114 
115  $action = $this->request_wrapper->retrieve(
116  $action_parameter_token->getName(),
117  $this->refinery->kindlyTo()->string()
118  );
119 
120  if ($action === '') {
121  return;
122  }
123 
124  $affected_items = [];
125  if ($this->request_wrapper->has($row_id_token->getName())) {
126  $affected_items = $this->request_wrapper->retrieve(
127  $row_id_token->getName(),
128  $this->refinery->byTrying(
129  [
130  $this->refinery->container()->mapValues(
131  $this->refinery->kindlyTo()->string()
132  ),
133  $this->refinery->always([])
134  ]
135  )
136  );
137  }
138 
139  $log_table->executeAction($action, $affected_items);
140  }
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:

◆ getColumHeadingsForExport()

ILIAS\Test\Logging\TestLogViewer::getColumHeadingsForExport ( )
private

Definition at line 194 of file TestLogViewer.php.

References ILIAS\Repository\lng().

Referenced by ILIAS\Test\Logging\TestLogViewer\buildExcelWorkbookForLogs().

194  : array
195  {
196  return [
197  $this->lng->txt('date_time'),
198  $this->lng->txt('test'),
199  $this->lng->txt('author'),
200  $this->lng->txt('tst_participant'),
201  $this->lng->txt('client_ip'),
202  $this->lng->txt('question'),
203  $this->lng->txt('log_entry_type'),
204  $this->lng->txt('interaction_type'),
205  $this->lng->txt('additional_info')
206  ];
207  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLegacyLogExportForObjId()

ILIAS\Test\Logging\TestLogViewer::getLegacyLogExportForObjId ( ?int  $obj_id = null)

Definition at line 224 of file TestLogViewer.php.

References $log, ilObjUser\_lookupName(), ILIAS\Test\Logging\TestLogViewer\buildQuestionTitleForLegacyLog(), IL_CAL_FKT_DATE, IL_CAL_UNIX, ILIAS\Repository\lng(), and ILIAS\Test\Logging\TestLogViewer\processCSVRow().

224  : string
225  {
226  $log_output = $this->logging_repository->getLegacyLogsForObjId($obj_id);
227 
228  $users = [];
229  $csv = [];
230  $separator = ';';
231  $header_row = [
232  $this->lng->txt('date_time'),
233  $this->lng->txt('user'),
234  $this->lng->txt('log_text'),
235  $this->lng->txt('question')
236  ];
237 
238  $csv[] = $this->processCSVRow($header_row);
239  foreach ($log_output as $log) {
240  if (!array_key_exists($log['user_fi'], $users)) {
241  $users[$log['user_fi']] = \ilObjUser::_lookupName((int) $log['user_fi']);
242  }
243 
244  $content_row = [];
245  $date = new \ilDateTime((int) $log['tstamp'], IL_CAL_UNIX);
246  $content_row[] = $date->get(IL_CAL_FKT_DATE, 'Y-m-d H:i');
247  $content_row[] = trim($users[$log['user_fi']]['title'] . ' '
248  . $users[$log['user_fi']]['firstname'] . ' ' . $users[$log['user_fi']]['lastname']);
249  $content_row[] = trim($log['logtext']);
250  $content_row[] = $this->buildQuestionTitleForLegacyLog($log);
251  $csv[] = $this->processCSVRow($content_row);
252  }
253  $csvoutput = '';
254  foreach ($csv as $row) {
255  $csvoutput .= implode($separator, $row) . "\n";
256  }
257  return $csvoutput;
258  }
static _lookupName(int $a_user_id)
lookup user name
const IL_CAL_UNIX
$log
Definition: result.php:32
const IL_CAL_FKT_DATE
processCSVRow(mixed $row, bool $quote_all=false, string $separator=";")
+ Here is the call graph for this function:

◆ getLogExportForRefjId()

ILIAS\Test\Logging\TestLogViewer::getLogExportForRefjId ( int  $ref_id)

Definition at line 142 of file TestLogViewer.php.

References $ref_id, and ILIAS\Test\Logging\TestLogViewer\buildExcelWorkbookForLogs().

142  : \ilExcel
143  {
144  return $this->buildExcelWorkbookForLogs(
145  $this->logging_repository->getLogs(
146  $this->logger->getInteractionTypes(),
147  [$ref_id]
148  )
149  );
150  }
$ref_id
Definition: ltiauth.php:65
buildExcelWorkbookForLogs(\Generator $logs)
+ Here is the call graph for this function:

◆ getLogTable()

ILIAS\Test\Logging\TestLogViewer::getLogTable ( URLBuilder  $url_builder,
URLBuilderToken  $action_parameter_token,
URLBuilderToken  $row_id_token,
?int  $ref_id = null 
)

Definition at line 59 of file TestLogViewer.php.

References $ref_id, ILIAS\Repository\lng(), and ILIAS\Repository\logger().

64  : array {
65  $log_table = new LogTable(
66  $this->logging_repository,
67  $this->logger,
68  $this,
69  $this->title_builder,
70  $this->question_repository,
71  $this->ui_service,
72  $this->ui_factory,
73  $this->ui_renderer,
74  $this->lng,
75  $this->tpl,
76  $url_builder,
77  $action_parameter_token,
78  $row_id_token,
79  $this->stream_delivery,
80  $this->current_user,
81  $ref_id,
82  );
83 
84  return [
85  $log_table->getFilter(),
86  $log_table->getTable()->withRequest($this->request)
87  ];
88  }
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:

◆ processCSVRow()

ILIAS\Test\Logging\TestLogViewer::processCSVRow ( mixed  $row,
bool  $quote_all = false,
string  $separator = ";" 
)
private

Definition at line 281 of file TestLogViewer.php.

Referenced by ILIAS\Test\Logging\TestLogViewer\getLegacyLogExportForObjId().

285  : array {
286  $resultarray = [];
287  foreach ($row as $rowindex => $entry) {
288  $surround = false;
289  if ($quote_all) {
290  $surround = true;
291  }
292  if (is_string($entry) && strpos($entry, "\"") !== false) {
293  $entry = str_replace("\"", "\"\"", $entry);
294  $surround = true;
295  }
296  if (is_string($entry) && strpos($entry, $separator) !== false) {
297  $surround = true;
298  }
299 
300  if (is_string($entry)) {
301  // replace all CR LF with LF (for Excel for Windows compatibility
302  $entry = str_replace(chr(13) . chr(10), chr(10), $entry);
303  }
304 
305  if ($surround) {
306  $entry = "\"" . $entry . "\"";
307  }
308 
309  $resultarray[$rowindex] = $entry;
310  }
311  return $resultarray;
312  }
+ Here is the caller graph for this function:

Field Documentation

◆ $data_factory

DataFactory ILIAS\Test\Logging\TestLogViewer::$data_factory
private

Definition at line 38 of file TestLogViewer.php.


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