ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
TestQuestionAdministrationInteraction.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Test\Logging;
22 
30 
32 {
33  public const IDENTIFIER = 'qai';
34 
35  private int $id;
36 
40  public function __construct(
41  private int $test_ref_id,
42  private int $question_id,
43  private int $admin_id,
44  private TestQuestionAdministrationInteractionTypes $interaction_type,
45  private int $modification_timestamp,
46  private array $additional_data
47  ) {
48 
49  }
50 
51  public function getUniqueIdentifier(): ?string
52  {
53  return self::IDENTIFIER . '_' . $this->id;
54  }
55 
56  public function withId(int $id): self
57  {
58  $clone = clone $this;
59  $clone->id = $id;
60  return $clone;
61  }
62 
63  public function getLogEntryAsDataTableRow(
65  TitleColumnsBuilder $title_builder,
66  DataRowBuilder $row_builder,
67  array $environment
68  ): DataRow {
69  $values = [
70  'date_and_time' => \DateTimeImmutable::createFromFormat('U', (string) $this->modification_timestamp)
71  ->setTimezone($environment['timezone']),
72  'corresponding_test' => $title_builder->buildTestTitleAsLink(
73  $this->test_ref_id
74  ),
76  $this->admin_id,
77  false,
78  false,
79  '',
80  true
81  ),
82  'log_entry_type' => $lng->txt(self::LANG_VAR_PREFIX . self::IDENTIFIER),
83  'interaction_type' => $lng->txt(self::LANG_VAR_PREFIX . $this->interaction_type->value)
84  ];
85 
86  if ($this->question_id !== null) {
87  $values['question'] = $title_builder->buildQuestionTitleAsLink(
88  $this->question_id,
89  $this->test_ref_id
90  );
91  }
92  return $row_builder->buildDataRow(
93  $this->getUniqueIdentifier(),
94  $values
95  )->withDisabledAction(
97  $this->additional_data === []
98  );
99  }
100 
101  public function getLogEntryAsExportRow(
102  \ilLanguage $lng,
103  TitleColumnsBuilder $title_builder,
104  AdditionalInformationGenerator $additional_info,
105  array $environment
106  ): array {
107  return [
108  \DateTimeImmutable::createFromFormat('U', (string) $this->modification_timestamp)
109  ->setTimezone($environment['timezone'])
110  ->format($environment['date_format']),
111  $title_builder->buildTestTitleAsText($this->test_ref_id),
113  $this->admin_id,
114  false,
115  false,
116  '',
117  true
118  ),
119  '',
120  '',
121  $title_builder->buildQuestionTitleAsText($this->question_id),
122  $lng->txt(self::LANG_VAR_PREFIX . self::IDENTIFIER),
123  $lng->txt(self::LANG_VAR_PREFIX . $this->interaction_type->value),
124  $additional_info->parseForExport($this->additional_data, $environment)
125  ];
126  }
127 
129  AdditionalInformationGenerator $additional_info,
130  UIFactory $ui_factory,
131  array $environment
132  ): DescriptiveListing {
133  return $additional_info->parseForTable($this->additional_data, $environment);
134  }
135 
136  public function toStorage(): array
137  {
138  return [
139  'ref_id' => [\ilDBConstants::T_INTEGER , $this->test_ref_id],
140  'qst_id' => [\ilDBConstants::T_INTEGER , $this->question_id],
141  'admin_id' => [\ilDBConstants::T_INTEGER , $this->admin_id],
142  'interaction_type' => [\ilDBConstants::T_TEXT , $this->interaction_type->value],
143  'modification_ts' => [\ilDBConstants::T_INTEGER , $this->modification_timestamp],
144  'additional_data' => [\ilDBConstants::T_CLOB , json_encode($this->additional_data)]
145  ];
146  }
147 }
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...
getLogEntryAsExportRow(\ilLanguage $lng, TitleColumnsBuilder $title_builder, AdditionalInformationGenerator $additional_info, array $environment)
parseForExport(array $additional_info, array $environment)
buildDataRow(string $id, array $record)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getParsedAdditionalInformation(AdditionalInformationGenerator $additional_info, UIFactory $ui_factory, array $environment)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildQuestionTitleAsLink(int $question_id, int $test_ref_id)
__construct(private int $test_ref_id, private int $question_id, private int $admin_id, private TestQuestionAdministrationInteractionTypes $interaction_type, private int $modification_timestamp, private array $additional_data)
global $lng
Definition: privfeed.php:31
parseForTable(array $additional_info, array $environment)
getLogEntryAsDataTableRow(\ilLanguage $lng, TitleColumnsBuilder $title_builder, DataRowBuilder $row_builder, array $environment)