ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Test\Logging\TestLoggingDatabaseRepository Class Reference
+ Inheritance diagram for ILIAS\Test\Logging\TestLoggingDatabaseRepository:
+ Collaboration diagram for ILIAS\Test\Logging\TestLoggingDatabaseRepository:

Public Member Functions

 __construct (private readonly Factory $factory, private readonly \ilDBInterface $db)
 
 storeTestAdministrationInteraction (TestAdministrationInteraction $interaction)
 
 storeQuestionAdministrationInteraction (TestQuestionAdministrationInteraction $interaction)
 
 storeParticipantInteraction (TestParticipantInteraction $interaction)
 
 storeScoringInteraction (TestScoringInteraction $interaction)
 
 storeError (TestError $interaction)
 
 getLogs (array $valid_types, ?array $test_filter, ?\ILIAS\Data\Range $range=null, ?\ILIAS\Data\Order $order=null, ?int $from_filter=null, ?int $to_filter=null, ?array $admin_filter=null, ?array $pax_filter=null, ?array $question_filter=null, ?string $ip_filter=null, ?array $log_entry_type_filter=null, ?array $interaction_type_filter=null)
 
 getLogsCount (array $valid_types, ?array $test_filter=null, ?int $from_filter=null, ?int $to_filter=null, ?array $admin_filter=null, ?array $pax_filter=null, ?array $question_filter=null, ?string $ip_filter=null, ?array $log_entry_type_filter=null, ?array $interaction_type_filter=null)
 
 getLogsByUniqueIdentifiers (array $unique_ids)
 
 getLog (string $unique_id)
 
 deleteLogs (array $unique_ids)
 
 testHasParticipantInteractions (int $ref_id)
 
 deleteParticipantInteractionsForTest (int $ref_id)
 
 getLegacyLogsForObjId (?int $obj_id)
 
- Public Member Functions inherited from ILIAS\Test\Logging\TestLoggingRepository
 storeTestAdministrationInteraction (TestAdministrationInteraction $interaction)
 
 storeQuestionAdministrationInteraction (TestQuestionAdministrationInteraction $interaction)
 
 storeParticipantInteraction (TestParticipantInteraction $interaction)
 
 storeScoringInteraction (TestScoringInteraction $interaction)
 
 storeError (TestError $interaction)
 
 getLogs (array $valid_types, ?array $test_filter, ?Range $range=null, ?Order $order=null, ?int $from_filter=null, ?int $to_filter=null, ?array $admin_filter=null, ?array $pax_filter=null, ?array $question_filter=null, ?string $ip_filter=null, ?array $log_entry_type_filter=null, ?array $interaction_type_filter=null)
 
 getLogsCount (array $valid_types, ?array $test_filter, ?int $from_filter=null, ?int $to_filter=null, ?array $admin_filter=null, ?array $pax_filter=null, ?array $question_filter=null, ?string $ip_filter=null, ?array $log_entry_type_filter=null, ?array $interaction_type_filter=null)
 
 getLogsByUniqueIdentifiers (array $unique_identifiers)
 
 getLog (string $unique_identifier)
 
 deleteLogs (array $unique_identifiers)
 
 testHasParticipantInteractions (int $ref_id)
 
 deleteParticipantInteractionsForTest (int $ref_id)
 
 getLegacyLogsForObjId (?int $obj_id)
 

Data Fields

const TEST_ADMINISTRATION_LOG_TABLE = 'tst_tst_admin_log'
 
const QUESTION_ADMINISTRATION_LOG_TABLE = 'tst_qst_admin_log'
 
const PARTICIPANT_LOG_TABLE = 'tst_pax_log'
 
const SCORING_LOG_TABLE = 'tst_mark_log'
 
const ERROR_LOG_TABLE = 'tst_error_log'
 

Private Member Functions

 buildUserInteractionForUniqueIdentifier (string $unique_id)
 
 buildTestAdministrationInteractionFromId (int $id)
 
 buildQuestionAdministrationInteractionFromId (int $id)
 
 buildParticipantInteractionFromId (int $id)
 
 buildScoringInteractionFromId (int $id)
 
 buildErrorFromId (int $id)
 
 retrieveInteractions (array $valid_types, ?Range $range, ?Order $order, ?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $log_entry_type_filter, ?array $interaction_type_filter)
 
 fetchInteractionForResult (\ilDBStatement $result)
 
 buildSelectStatementForId (int $id, string $table_name)
 
 buildDeleteQueryForUniqueIds (array $unique_ids)
 
 buildInteractionsStatementWithLimitAndOrder (array $valid_types, ?Range $range, ?Order $order, ?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $log_entry_type_filter, ?array $interaction_type_filter)
 
 buildCountQuery (array $valid_types, ?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $log_entry_type_filter, ?array $interaction_type_filter)
 
 buildInteractionsQuery (array $valid_types, ?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $log_entry_type_filter, ?array $interaction_type_filter)
 
 buildTableQueryFromFilterValues (string $type, ?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $interaction_type_filter)
 
 buildSelectForTable (string $table_name, string $type)
 
 buildWhereFromFilterValues (?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $interaction_type_filter)
 
 isFilterValid (array $valid_types, ?array $log_entry_types, ?array $interaction_types)
 
 areLogEntryTypesValid (array $valid_types, array $filter_log_types)
 
 areInteractionTypesValid (array $valid_types, ?array $filter_log_types, array $filter_interaction_types)
 
 parseUniqueIdsToTypeArray (array $unique_ids)
 
 getTableNameForTypeIdentifier (string $identifier)
 

Private Attributes

const LEGACY_LOG_TABLE = 'ass_log'
 
const VIEW_TABLE_TO_DB_TABLES
 

Detailed Description

Definition at line 27 of file TestLoggingDatabaseRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::__construct ( private readonly Factory  $factory,
private readonly \ilDBInterface  $db 
)

Definition at line 47 of file TestLoggingDatabaseRepository.php.

50 {
51 }

Member Function Documentation

◆ areInteractionTypesValid()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::areInteractionTypesValid ( array  $valid_types,
?array  $filter_log_types,
array  $filter_interaction_types 
)
private

Definition at line 660 of file TestLoggingDatabaseRepository.php.

664 : bool {
665 if ($filter_log_types !== null
666 && $filter_log_types !== []) {
667 $valid_types = array_filter(
668 $valid_types,
669 fn(string $key): bool => in_array($key, $filter_log_types),
670 ARRAY_FILTER_USE_KEY
671 );
672 }
673 $valid_interaction_types = array_reduce(
674 $valid_types,
675 fn(array $et, array $it): array => [...$et, ...$it],
676 []
677 );
678
679 if (
680 array_intersect($filter_interaction_types, $valid_interaction_types)
681 === $filter_interaction_types
682 ) {
683 return true;
684 }
685
686 return false;
687 }

◆ areLogEntryTypesValid()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::areLogEntryTypesValid ( array  $valid_types,
array  $filter_log_types 
)
private

Definition at line 650 of file TestLoggingDatabaseRepository.php.

653 : bool {
654 return array_intersect(
655 $filter_log_types,
656 array_keys($valid_types)
657 ) === $filter_log_types;
658 }

◆ buildCountQuery()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildCountQuery ( array  $valid_types,
?int  $from_filter,
?int  $to_filter,
?array  $test_filter,
?array  $admin_filter,
?array  $pax_filter,
?array  $question_filter,
?string  $ip_filter,
?array  $log_entry_type_filter,
?array  $interaction_type_filter 
)
private

Definition at line 438 of file TestLoggingDatabaseRepository.php.

449 : ?string {
450 $tables_query = $this->buildInteractionsQuery(
451 $valid_types,
452 $from_filter,
453 $to_filter,
454 $test_filter,
455 $admin_filter,
456 $pax_filter,
457 $question_filter,
458 $ip_filter,
459 $log_entry_type_filter,
460 $interaction_type_filter
461 );
462 if ($tables_query === '') {
463 return '';
464 }
465 return 'SELECT COUNT(*) AS cnt FROM (' . PHP_EOL . $tables_query . PHP_EOL . ') x';
466 }
buildInteractionsQuery(array $valid_types, ?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $log_entry_type_filter, ?array $interaction_type_filter)

◆ buildDeleteQueryForUniqueIds()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildDeleteQueryForUniqueIds ( array  $unique_ids)
private

Definition at line 376 of file TestLoggingDatabaseRepository.php.

376 : string
377 {
378 if ($unique_ids[0] === 'ALL_OBJECTS') {
379 return 'TUNCATE TABLE ' . self::TEST_ADMINISTRATION_LOG_TABLE . ';'
380 . 'TUNCATE TABLE ' . self::QUESTION_ADMINISTRATION_LOG_TABLE . ';'
381 . 'TUNCATE TABLE ' . self::PARTICIPANT_LOG_TABLE . ';'
382 . 'TUNCATE TABLE ' . self::SCORING_LOG_TABLE . ';'
383 . 'TUNCATE TABLE ' . self::ERROR_LOG_TABLE . ';';
384 }
385 $query = '';
386 foreach ($this->parseUniqueIdsToTypeArray($unique_ids) as $type => $values) {
387 $query .= "DELETE FROM {$this->getTableNameForTypeIdentifier($type)} WHERE "
388 . $this->db->in('id', $values, false, \ilDBConstants::T_INTEGER) . ';' . PHP_EOL;
389 }
390 return $query;
391 }

References ilDBConstants\T_INTEGER.

◆ buildErrorFromId()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildErrorFromId ( int  $id)
private

Definition at line 303 of file TestLoggingDatabaseRepository.php.

303 : ?TestError
304 {
305 $query = $this->buildSelectStatementForId($id, self::ERROR_LOG_TABLE);
306 if ($this->db->numRows($query) === 0) {
307 return null;
308 }
309
310 return $this->factory->buildErrorFromDBValues($this->db->fetchObject($query));
311 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
factory()

References $id, and factory().

+ Here is the call graph for this function:

◆ buildInteractionsQuery()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildInteractionsQuery ( array  $valid_types,
?int  $from_filter,
?int  $to_filter,
?array  $test_filter,
?array  $admin_filter,
?array  $pax_filter,
?array  $question_filter,
?string  $ip_filter,
?array  $log_entry_type_filter,
?array  $interaction_type_filter 
)
private

Definition at line 468 of file TestLoggingDatabaseRepository.php.

479 : string {
480 $log_entry_types_to_fetch = array_keys($valid_types);
481
482 $query = [];
483 foreach ($log_entry_types_to_fetch as $type) {
484 if ($log_entry_type_filter !== null
485 && !in_array($type, $log_entry_type_filter)
486 || $interaction_type_filter !== null
487 && array_intersect(
488 $valid_types[$type],
489 $interaction_type_filter
490 ) === []
491 ) {
492 continue;
493 }
494 $query[] = $this->buildTableQueryFromFilterValues(
495 $type,
496 $from_filter,
497 $to_filter,
498 $test_filter,
499 $admin_filter,
500 $pax_filter,
501 $question_filter,
502 $ip_filter,
503 $interaction_type_filter
504 );
505 }
506
507 return implode(
508 PHP_EOL . 'UNION' . PHP_EOL,
509 array_filter(
510 $query,
511 static fn(?string $select): bool => $select !== null
512 )
513 );
514 }
buildTableQueryFromFilterValues(string $type, ?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $interaction_type_filter)

◆ buildInteractionsStatementWithLimitAndOrder()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildInteractionsStatementWithLimitAndOrder ( array  $valid_types,
?Range  $range,
?Order  $order,
?int  $from_filter,
?int  $to_filter,
?array  $test_filter,
?array  $admin_filter,
?array  $pax_filter,
?array  $question_filter,
?string  $ip_filter,
?array  $log_entry_type_filter,
?array  $interaction_type_filter 
)
private

Definition at line 393 of file TestLoggingDatabaseRepository.php.

407 $query = $this->buildInteractionsQuery(
408 $valid_types,
409 $from_filter,
410 $to_filter,
411 $test_filter,
412 $admin_filter,
413 $pax_filter,
414 $question_filter,
415 $ip_filter,
416 $log_entry_type_filter,
417 $interaction_type_filter
418 );
419
420 $init = PHP_EOL . 'ORDER BY ';
421 $order_by_string = $order?->join(
422 $init,
423 static fn(string $ret, string $key, string $value): string => "{$ret} "
424 . self::VIEW_TABLE_TO_DB_TABLES[$key] . " {$value}, ",
425 );
426 if ($order_by_string !== null
427 && $order_by_string !== $init) {
428 $query .= mb_substr($order_by_string, 0, -2);
429 }
430
431 if ($range !== null) {
432 $query .= PHP_EOL . 'LIMIT ' . $range->getStart() . ', ' . $range->getLength();
433 }
434
435 return $this->db->query($query);
436 }
Interface ilDBStatement.

◆ buildParticipantInteractionFromId()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildParticipantInteractionFromId ( int  $id)
private

Definition at line 283 of file TestLoggingDatabaseRepository.php.

284 {
285 $query = $this->buildSelectStatementForId($id, self::PARTICIPANT_LOG_TABLE);
286 if ($this->db->numRows($query) === 0) {
287 return null;
288 }
289
290 return $this->factory->buildParticipantInteractionFromDBValues($this->db->fetchObject($query));
291 }

References $id, and factory().

+ Here is the call graph for this function:

◆ buildQuestionAdministrationInteractionFromId()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildQuestionAdministrationInteractionFromId ( int  $id)
private

Definition at line 273 of file TestLoggingDatabaseRepository.php.

274 {
275 $query = $this->buildSelectStatementForId($id, self::QUESTION_ADMINISTRATION_LOG_TABLE);
276 if ($this->db->numRows($query) === 0) {
277 return null;
278 }
279
280 return $this->factory->buildQuestionAdministrationInteractionFromDBValues($this->db->fetchObject($query));
281 }

References $id, and factory().

+ Here is the call graph for this function:

◆ buildScoringInteractionFromId()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildScoringInteractionFromId ( int  $id)
private

Definition at line 293 of file TestLoggingDatabaseRepository.php.

294 {
295 $query = $this->buildSelectStatementForId($id, self::SCORING_LOG_TABLE);
296 if ($this->db->numRows($query) === 0) {
297 return null;
298 }
299
300 return $this->factory->buildScoringInteractionFromDBValues($this->db->fetchObject($query));
301 }

References $id, and factory().

+ Here is the call graph for this function:

◆ buildSelectForTable()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildSelectForTable ( string  $table_name,
string  $type 
)
private

Definition at line 557 of file TestLoggingDatabaseRepository.php.

557 : string
558 {
559 switch ($table_name) {
561 return "SELECT '{$type}' AS type, id, ref_id, NULL AS qst_id, admin_id, "
562 . 'NULL AS pax_id, NULL AS source_ip, interaction_type, modification_ts, '
563 . "additional_data FROM {$table_name}";
565 return "SELECT '{$type}' AS type, id, ref_id, qst_id, admin_id, "
566 . 'NULL AS pax_id, NULL AS source_ip, interaction_type, modification_ts, '
567 . "additional_data FROM {$table_name}";
569 return "SELECT '{$type}' AS type, id, ref_id, qst_id, NULL AS admin_id, "
570 . 'pax_id, source_ip, interaction_type, modification_ts, '
571 . "additional_data FROM {$table_name}";
573 return "SELECT '{$type}' AS type, id, ref_id, qst_id, admin_id, "
574 . 'pax_id, NULL AS source_ip, interaction_type, modification_ts, '
575 . "additional_data FROM {$table_name}";
577 return "SELECT '{$type}' AS type, id, ref_id, qst_id, admin_id, "
578 . 'pax_id, NULL AS source_ip, interaction_type, modification_ts, '
579 . "error_message AS additional_data FROM {$table_name}";
580 default:
581 throw new \ErrorException('Unknown Database Table');
582 }
583 }

◆ buildSelectStatementForId()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildSelectStatementForId ( int  $id,
string  $table_name 
)
private

Definition at line 367 of file TestLoggingDatabaseRepository.php.

368 {
369 return $this->db->queryF(
370 "SELECT * FROM {$table_name} WHERE id=%s",
372 [$id]
373 );
374 }

References $id, and ilDBConstants\T_INTEGER.

◆ buildTableQueryFromFilterValues()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildTableQueryFromFilterValues ( string  $type,
?int  $from_filter,
?int  $to_filter,
?array  $test_filter,
?array  $admin_filter,
?array  $pax_filter,
?array  $question_filter,
?string  $ip_filter,
?array  $interaction_type_filter 
)
private

Definition at line 516 of file TestLoggingDatabaseRepository.php.

526 : ?string {
527 $table_name = $this->getTableNameForTypeIdentifier($type);
528 if ($pax_filter !== null
529 && ($table_name === self::TEST_ADMINISTRATION_LOG_TABLE
530 || $table_name === self::QUESTION_ADMINISTRATION_LOG_TABLE)
531 || $admin_filter !== null
532 && $table_name === self::PARTICIPANT_LOG_TABLE
533 || $ip_filter !== null
534 && $table_name !== self::PARTICIPANT_LOG_TABLE
535 || $question_filter !== null
536 && $table_name === self::TEST_ADMINISTRATION_LOG_TABLE
537 ) {
538 return null;
539 }
540
541 $query = $this->buildSelectForTable($table_name, $type);
542
543 $where = $this->buildWhereFromFilterValues(
544 $from_filter,
545 $to_filter,
546 $test_filter,
547 $admin_filter,
548 $pax_filter,
549 $question_filter,
550 $ip_filter,
551 $interaction_type_filter
552 );
553
554 return $query . $where;
555 }
buildWhereFromFilterValues(?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $interaction_type_filter)

◆ buildTestAdministrationInteractionFromId()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildTestAdministrationInteractionFromId ( int  $id)
private

Definition at line 263 of file TestLoggingDatabaseRepository.php.

264 {
265 $query = $this->buildSelectStatementForId($id, self::TEST_ADMINISTRATION_LOG_TABLE);
266 if ($this->db->numRows($query) === 0) {
267 return null;
268 }
269
270 return $this->factory->buildTestAdministrationInteractionFromDBValues($this->db->fetchObject($query));
271 }

References $id, and factory().

+ Here is the call graph for this function:

◆ buildUserInteractionForUniqueIdentifier()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildUserInteractionForUniqueIdentifier ( string  $unique_id)
private

Definition at line 235 of file TestLoggingDatabaseRepository.php.

235 : ?TestUserInteraction
236 {
237 $unique_id_array = explode('_', $unique_id);
238 if (count($unique_id_array) !== 2
239 || !is_numeric($unique_id_array[1])) {
240 return null;
241 }
242
243 switch ($unique_id_array[0]) {
245 return $this->buildTestAdministrationInteractionFromId((int) $unique_id_array[1]);
246
248 return $this->buildQuestionAdministrationInteractionFromId((int) $unique_id_array[1]);
249
251 return $this->buildParticipantInteractionFromId((int) $unique_id_array[1]);
252
254 return $this->buildScoringInteractionFromId((int) $unique_id_array[1]);
255
257 return $this->buildErrorFromId((int) $unique_id_array[1]);
258 }
259
260 return null;
261 }

◆ buildWhereFromFilterValues()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::buildWhereFromFilterValues ( ?int  $from_filter,
?int  $to_filter,
?array  $test_filter,
?array  $admin_filter,
?array  $pax_filter,
?array  $question_filter,
?string  $ip_filter,
?array  $interaction_type_filter 
)
private

Definition at line 585 of file TestLoggingDatabaseRepository.php.

594 : string {
595 $where = [];
596 if ($from_filter !== null) {
597 $where[] = 'modification_ts > ' . $from_filter;
598 }
599 if ($to_filter !== null) {
600 $where[] = 'modification_ts < ' . $to_filter;
601 }
602 if ($test_filter !== null) {
603 $where[] = $this->db->in('ref_id', $test_filter, false, \ilDBConstants::T_INTEGER);
604 }
605 if ($admin_filter !== null) {
606 $where[] = $this->db->in('admin_id', $admin_filter, false, \ilDBConstants::T_INTEGER);
607 }
608 if ($pax_filter !== null) {
609 $where[] = $this->db->in('pax_id', $pax_filter, false, \ilDBConstants::T_INTEGER);
610 }
611 if ($question_filter !== null) {
612 $where[] = $this->db->in('qst_id', $question_filter, false, \ilDBConstants::T_INTEGER);
613 }
614 if ($ip_filter !== null) {
615 $where[] = $this->db->like('source_ip', \ilDBConstants::T_TEXT, $ip_filter);
616 }
617 if ($interaction_type_filter !== null) {
618 $where[] = $this->db->in('interaction_type', $interaction_type_filter, false, \ilDBConstants::T_TEXT);
619 }
620
621 if ($where === []) {
622 return '';
623 }
624
625 return ' WHERE ' . implode(' AND ', $where);
626 }

◆ deleteLogs()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::deleteLogs ( array  $unique_ids)
Parameters
array<string>$unique_ids

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 178 of file TestLoggingDatabaseRepository.php.

180 : void {
181 $this->db->manipulate(
182 $this->buildDeleteQueryForUniqueIds($unique_ids)
183 );
184 }

◆ deleteParticipantInteractionsForTest()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::deleteParticipantInteractionsForTest ( int  $ref_id)

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 196 of file TestLoggingDatabaseRepository.php.

196 : void
197 {
198 $this->db->manipulateF(
199 'DELETE FROM ' . self::PARTICIPANT_LOG_TABLE . ' WHERE ref_id=%s',
201 [$ref_id]
202 );
203 }
$ref_id
Definition: ltiauth.php:66

References $ref_id, and ilDBConstants\T_INTEGER.

◆ fetchInteractionForResult()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::fetchInteractionForResult ( \ilDBStatement  $result)
private

Definition at line 344 of file TestLoggingDatabaseRepository.php.

344 : \Generator
345 {
346 while ($interaction = $this->db->fetchObject($result)) {
347 switch ($interaction->type) {
349 yield $this->factory->buildTestAdministrationInteractionFromDBValues($interaction);
350 break;
352 yield $this->factory->buildQuestionAdministrationInteractionFromDBValues($interaction);
353 break;
355 yield $this->factory->buildParticipantInteractionFromDBValues($interaction);
356 break;
358 yield $this->factory->buildScoringInteractionFromDBValues($interaction);
359 break;
361 yield $this->factory->buildErrorFromDBValues($interaction);
362 break;
363 }
364 }
365 }

References factory().

+ Here is the call graph for this function:

◆ getLegacyLogsForObjId()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::getLegacyLogsForObjId ( ?int  $obj_id)

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 205 of file TestLoggingDatabaseRepository.php.

205 : array
206 {
207 $log = [];
208
209 $where = '';
210 if ($obj_id !== null) {
211 $where = ' WHERE obj_fi = ' . $obj_id;
212 }
213
214 $result = $this->db->query(
215 'SELECT * FROM ' . self::LEGACY_LOG_TABLE . $where . ' ORDER BY tstamp'
216 );
217
218 while ($row = $this->db->fetchAssoc($result)) {
219 if (!array_key_exists($row['tstamp'], $log)) {
220 $log[$row['tstamp']] = [];
221 }
222 $log[$row['tstamp']][] = $row;
223 }
224 krsort($log);
225 // flatten array
226 $log_array = [];
227 foreach ($log as $value) {
228 foreach ($value as $row) {
229 $log_array[] = $row;
230 }
231 }
232 return $log_array;
233 }
$log
Definition: ltiresult.php:34

References $log.

◆ getLog()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::getLog ( string  $unique_id)

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 169 of file TestLoggingDatabaseRepository.php.

171 : ?TestUserInteraction {
172 return $this->buildUserInteractionForUniqueIdentifier($unique_id);
173 }

◆ getLogs()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::getLogs ( array  $valid_types,
?array  $test_filter,
?\ILIAS\Data\Range  $range = null,
?\ILIAS\Data\Order  $order = null,
?int  $from_filter = null,
?int  $to_filter = null,
?array  $admin_filter = null,
?array  $pax_filter = null,
?array  $question_filter = null,
?string  $ip_filter = null,
?array  $log_entry_type_filter = null,
?array  $interaction_type_filter = null 
)

Definition at line 88 of file TestLoggingDatabaseRepository.php.

101 : \Generator {
102 if ($this->isFilterValid(
103 $valid_types,
104 $log_entry_type_filter,
105 $interaction_type_filter
106 )
107 ) {
108 yield from $this->retrieveInteractions(
109 $valid_types,
110 $range,
111 $order,
112 $from_filter,
113 $to_filter,
114 $test_filter,
115 $admin_filter,
116 $pax_filter,
117 $question_filter,
118 $ip_filter,
119 $log_entry_type_filter,
120 $interaction_type_filter
121 );
122 }
123 }
retrieveInteractions(array $valid_types, ?Range $range, ?Order $order, ?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $log_entry_type_filter, ?array $interaction_type_filter)
isFilterValid(array $valid_types, ?array $log_entry_types, ?array $interaction_types)

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from(), and ILIAS\Test\Logging\TestLoggingDatabaseRepository\retrieveInteractions().

+ Here is the call graph for this function:

◆ getLogsByUniqueIdentifiers()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::getLogsByUniqueIdentifiers ( array  $unique_identifiers)
Parameters
array<string>$unique_identifiers
Returns
array<\ILIAS\Test\Logging\TestUserInteraction>

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 158 of file TestLoggingDatabaseRepository.php.

160 : \Generator {
161 foreach ($this->parseUniqueIdsToTypeArray($unique_ids) as $type => $values) {
162 $query = "SELECT *, '{$type}' AS type FROM {$this->getTableNameForTypeIdentifier($type)} WHERE "
163 . $this->db->in('id', $values, false, \ilDBConstants::T_INTEGER);
164 $result = $this->db->query($query);
165 yield from $this->fetchInteractionForResult($result);
166 }
167 }

References ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from(), and ilDBConstants\T_INTEGER.

+ Here is the call graph for this function:

◆ getLogsCount()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::getLogsCount ( array  $valid_types,
?array  $test_filter = null,
?int  $from_filter = null,
?int  $to_filter = null,
?array  $admin_filter = null,
?array  $pax_filter = null,
?array  $question_filter = null,
?string  $ip_filter = null,
?array  $log_entry_type_filter = null,
?array  $interaction_type_filter = null 
)

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 125 of file TestLoggingDatabaseRepository.php.

136 : int {
137 $query = $this->buildCountQuery(
138 $valid_types,
139 $from_filter,
140 $to_filter,
141 $test_filter,
142 $admin_filter,
143 $pax_filter,
144 $question_filter,
145 $ip_filter,
146 $log_entry_type_filter,
147 $interaction_type_filter
148 );
149 if ($query === '') {
150 return 0;
151 }
152 $result = $this->db->query(
153 $query
154 );
155 return $this->db->fetchObject($result)->cnt;
156 }
buildCountQuery(array $valid_types, ?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $log_entry_type_filter, ?array $interaction_type_filter)

◆ getTableNameForTypeIdentifier()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::getTableNameForTypeIdentifier ( string  $identifier)
private

Definition at line 715 of file TestLoggingDatabaseRepository.php.

715 : string
716 {
717 switch ($identifier) {
720
723
726
729
732 default:
733 throw new \ErrorException('Unknown Identifier Type');
734 }
735 }

◆ isFilterValid()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::isFilterValid ( array  $valid_types,
?array  $log_entry_types,
?array  $interaction_types 
)
private

Definition at line 628 of file TestLoggingDatabaseRepository.php.

632 : bool {
633 if ($log_entry_types !== null
634 && !$this->areLogEntryTypesValid(
635 $valid_types,
636 $log_entry_types
637 )
638 || $interaction_types !== null
639 && !$this->areInteractionTypesValid(
640 $valid_types,
641 $log_entry_types,
642 $interaction_types
643 )
644 ) {
645 return false;
646 }
647 return true;
648 }
areLogEntryTypesValid(array $valid_types, array $filter_log_types)
areInteractionTypesValid(array $valid_types, ?array $filter_log_types, array $filter_interaction_types)

◆ parseUniqueIdsToTypeArray()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::parseUniqueIdsToTypeArray ( array  $unique_ids)
private
Parameters
array<int>$unique_ids
Returns
array<string, array<int>>

Definition at line 693 of file TestLoggingDatabaseRepository.php.

693 : array
694 {
695 return array_reduce(
696 $unique_ids,
697 function (array $type_array, string $unique_id): array {
698 $unique_id_array = explode('_', $unique_id);
699 if (count($unique_id_array) !== 2
700 || !is_numeric($unique_id_array[1])) {
701 return $type_array;
702 }
703
704 if (!array_key_exists($unique_id_array[0], $type_array)) {
705 $type_array[$unique_id_array[0]] = [];
706 }
707
708 $type_array[$unique_id_array[0]][] = $unique_id_array[1];
709 return $type_array;
710 },
711 []
712 );
713 }

◆ retrieveInteractions()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::retrieveInteractions ( array  $valid_types,
?Range  $range,
?Order  $order,
?int  $from_filter,
?int  $to_filter,
?array  $test_filter,
?array  $admin_filter,
?array  $pax_filter,
?array  $question_filter,
?string  $ip_filter,
?array  $log_entry_type_filter,
?array  $interaction_type_filter 
)
private

Definition at line 313 of file TestLoggingDatabaseRepository.php.

326 : \Generator {
328 $valid_types,
329 $range,
330 $order,
331 $from_filter,
332 $to_filter,
333 $test_filter,
334 $admin_filter,
335 $pax_filter,
336 $question_filter,
337 $ip_filter,
338 $log_entry_type_filter,
339 $interaction_type_filter
340 );
341 yield from $this->fetchInteractionForResult($result);
342 }
buildInteractionsStatementWithLimitAndOrder(array $valid_types, ?Range $range, ?Order $order, ?int $from_filter, ?int $to_filter, ?array $test_filter, ?array $admin_filter, ?array $pax_filter, ?array $question_filter, ?string $ip_filter, ?array $log_entry_type_filter, ?array $interaction_type_filter)

Referenced by ILIAS\Test\Logging\TestLoggingDatabaseRepository\getLogs().

+ Here is the caller graph for this function:

◆ storeError()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::storeError ( TestError  $interaction)

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 81 of file TestLoggingDatabaseRepository.php.

81 : void
82 {
83 $storage_array = $interaction->toStorage();
84 $storage_array['id'] = [\ilDBConstants::T_INTEGER, $this->db->nextId(self::ERROR_LOG_TABLE)];
85 $this->db->insert(self::ERROR_LOG_TABLE, $storage_array);
86 }

References ilDBConstants\T_INTEGER, and ILIAS\Test\Logging\TestError\toStorage().

+ Here is the call graph for this function:

◆ storeParticipantInteraction()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::storeParticipantInteraction ( TestParticipantInteraction  $interaction)

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 67 of file TestLoggingDatabaseRepository.php.

67 : void
68 {
69 $storage_array = $interaction->toStorage();
70 $storage_array['id'] = [\ilDBConstants::T_INTEGER, $this->db->nextId(self::PARTICIPANT_LOG_TABLE)];
71 $this->db->insert(self::PARTICIPANT_LOG_TABLE, $storage_array);
72 }

References ilDBConstants\T_INTEGER, and ILIAS\Test\Logging\TestParticipantInteraction\toStorage().

+ Here is the call graph for this function:

◆ storeQuestionAdministrationInteraction()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::storeQuestionAdministrationInteraction ( TestQuestionAdministrationInteraction  $interaction)

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 60 of file TestLoggingDatabaseRepository.php.

60 : void
61 {
62 $storage_array = $interaction->toStorage();
63 $storage_array['id'] = [\ilDBConstants::T_INTEGER, $this->db->nextId(self::QUESTION_ADMINISTRATION_LOG_TABLE)];
64 $this->db->insert(self::QUESTION_ADMINISTRATION_LOG_TABLE, $storage_array);
65 }

References ilDBConstants\T_INTEGER, and ILIAS\Test\Logging\TestQuestionAdministrationInteraction\toStorage().

+ Here is the call graph for this function:

◆ storeScoringInteraction()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::storeScoringInteraction ( TestScoringInteraction  $interaction)

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 74 of file TestLoggingDatabaseRepository.php.

74 : void
75 {
76 $storage_array = $interaction->toStorage();
77 $storage_array['id'] = [\ilDBConstants::T_INTEGER, $this->db->nextId(self::SCORING_LOG_TABLE)];
78 $this->db->insert(self::SCORING_LOG_TABLE, $storage_array);
79 }

References ilDBConstants\T_INTEGER, and ILIAS\Test\Logging\TestScoringInteraction\toStorage().

+ Here is the call graph for this function:

◆ storeTestAdministrationInteraction()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::storeTestAdministrationInteraction ( TestAdministrationInteraction  $interaction)

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 53 of file TestLoggingDatabaseRepository.php.

53 : void
54 {
55 $storage_array = $interaction->toStorage();
56 $storage_array['id'] = [\ilDBConstants::T_INTEGER, $this->db->nextId(self::TEST_ADMINISTRATION_LOG_TABLE)];
57 $this->db->insert(self::TEST_ADMINISTRATION_LOG_TABLE, $storage_array);
58 }

References ilDBConstants\T_INTEGER, and ILIAS\Test\Logging\TestAdministrationInteraction\toStorage().

+ Here is the call graph for this function:

◆ testHasParticipantInteractions()

ILIAS\Test\Logging\TestLoggingDatabaseRepository::testHasParticipantInteractions ( int  $ref_id)

Implements ILIAS\Test\Logging\TestLoggingRepository.

Definition at line 186 of file TestLoggingDatabaseRepository.php.

186 : bool
187 {
188 $query = $this->db->queryF(
189 'SELECT COUNT(id) AS cnt FROM ' . self::PARTICIPANT_LOG_TABLE . ' WHERE ref_id=%s',
191 [$ref_id]
192 );
193 return $this->db->fetchObject($query)->cnt > 0;
194 }

References $ref_id, and ilDBConstants\T_INTEGER.

Field Documentation

◆ ERROR_LOG_TABLE

const ILIAS\Test\Logging\TestLoggingDatabaseRepository::ERROR_LOG_TABLE = 'tst_error_log'

◆ LEGACY_LOG_TABLE

const ILIAS\Test\Logging\TestLoggingDatabaseRepository::LEGACY_LOG_TABLE = 'ass_log'
private

Definition at line 29 of file TestLoggingDatabaseRepository.php.

◆ PARTICIPANT_LOG_TABLE

const ILIAS\Test\Logging\TestLoggingDatabaseRepository::PARTICIPANT_LOG_TABLE = 'tst_pax_log'

◆ QUESTION_ADMINISTRATION_LOG_TABLE

const ILIAS\Test\Logging\TestLoggingDatabaseRepository::QUESTION_ADMINISTRATION_LOG_TABLE = 'tst_qst_admin_log'

◆ SCORING_LOG_TABLE

const ILIAS\Test\Logging\TestLoggingDatabaseRepository::SCORING_LOG_TABLE = 'tst_mark_log'

◆ TEST_ADMINISTRATION_LOG_TABLE

const ILIAS\Test\Logging\TestLoggingDatabaseRepository::TEST_ADMINISTRATION_LOG_TABLE = 'tst_tst_admin_log'

◆ VIEW_TABLE_TO_DB_TABLES

const ILIAS\Test\Logging\TestLoggingDatabaseRepository::VIEW_TABLE_TO_DB_TABLES
private

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