ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Factory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Test\Logging;
22
24{
25 private const NONEXISTENT_TYPE_MSG = 'Invalid Interaction Type in Database for id %s with type %s';
26
28 int $ref_id,
29 int $admin_id,
31 array $additional_data
34 $ref_id,
35 $admin_id,
36 $type,
37 time(),
38 $additional_data
39 );
40 }
41
43 \stdClass $db_values
45 if (($type = TestAdministrationInteractionTypes::tryFrom($db_values->interaction_type)) === null) {
46 throw new \ilTestException(
47 sprintf(self::NONEXISTENT_TYPE_MSG, $db_values->id, $db_values->interaction_type)
48 );
49 }
51 $db_values->ref_id,
52 $db_values->admin_id,
53 $type,
54 $db_values->modification_ts,
55 json_decode($db_values->additional_data, true) ?? []
56 )
57 )->withId($db_values->id);
58 }
59
61 int $ref_id,
62 int $qst_id,
63 int $admin_id,
65 array $additional_data
68 $ref_id,
69 $qst_id,
70 $admin_id,
71 $type,
72 time(),
73 $additional_data
74 );
75 }
76
78 \stdClass $db_values
80 if (($type = TestQuestionAdministrationInteractionTypes::tryFrom($db_values->interaction_type)) === null) {
81 throw new \ilTestException(
82 sprintf(self::NONEXISTENT_TYPE_MSG, $db_values->id, $db_values->interaction_type)
83 );
84 }
86 $db_values->ref_id,
87 $db_values->qst_id,
88 $db_values->admin_id,
89 $type,
90 $db_values->modification_ts,
91 json_decode($db_values->additional_data, true) ?? []
92 ))->withId($db_values->id);
93 }
94
96 int $ref_id,
97 ?int $qst_id,
98 int $pax_id,
99 string $source_addr,
101 array $additional_data
104 $ref_id,
105 $qst_id,
106 $pax_id,
107 $source_addr,
108 $type,
109 time(),
110 $additional_data
111 );
112 }
113
115 \stdClass $db_values
117 if (($type = TestParticipantInteractionTypes::tryFrom($db_values->interaction_type)) === null) {
118 throw new \ilTestException(
119 sprintf(self::NONEXISTENT_TYPE_MSG, $db_values->id, $db_values->interaction_type)
120 );
121 }
122 return (new TestParticipantInteraction(
123 $db_values->ref_id,
124 $db_values->qst_id,
125 $db_values->pax_id,
126 $db_values->source_ip,
127 $type,
128 $db_values->modification_ts,
129 json_decode($db_values->additional_data, true) ?? []
130 ))->withId($db_values->id);
131 }
132
133 public function buildScoringInteraction(
134 int $ref_id,
135 int $qst_id,
136 int $admin_id,
137 int $pax_id,
139 array $additional_data
142 $ref_id,
143 $qst_id,
144 $admin_id,
145 $pax_id,
146 $type,
147 time(),
148 $additional_data
149 );
150 }
151
153 \stdClass $db_values
155 if (($type = TestScoringInteractionTypes::tryFrom($db_values->interaction_type)) === null) {
156 throw new \ilTestException(
157 sprintf(self::NONEXISTENT_TYPE_MSG, $db_values->id, $db_values->interaction_type)
158 );
159 }
160 return (new TestScoringInteraction(
161 $db_values->ref_id,
162 $db_values->qst_id,
163 $db_values->admin_id,
164 $db_values->pax_id,
165 $type,
166 $db_values->modification_ts,
167 json_decode($db_values->additional_data, true) ?? []
168 ))->withId($db_values->id);
169 }
170
171 public function buildError(
172 int $ref_id,
173 ?int $qst_id,
174 ?int $admin_id,
175 ?int $pax_id,
176 TestErrorTypes $type,
177 string $error_message
178 ): TestError {
179 return new TestError(
180 $ref_id,
181 $qst_id,
182 $admin_id,
183 $pax_id,
184 $type,
185 time(),
186 $error_message
187 );
188 }
189
190 public function buildErrorFromDBValues(\stdClass $db_values): TestError
191 {
192 if (($type = TestErrorTypes::tryFrom($db_values->interaction_type)) === null) {
193 throw new \ilTestException(
194 sprintf(self::NONEXISTENT_TYPE_MSG, $db_values->id, $db_values->interaction_type)
195 );
196 }
197
198 return (new TestError(
199 $db_values->ref_id,
200 $db_values->qst_id,
201 $db_values->admin_id,
202 $db_values->pax_id,
203 $type,
204 $db_values->modification_ts,
205 $db_values->error_message
206 ))->withId($db_values->id);
207 }
208}
buildScoringInteraction(int $ref_id, int $qst_id, int $admin_id, int $pax_id, TestScoringInteractionTypes $type, array $additional_data)
Definition: Factory.php:133
buildTestQuestionAdministrationInteraction(int $ref_id, int $qst_id, int $admin_id, TestQuestionAdministrationInteractionTypes $type, array $additional_data)
Definition: Factory.php:60
buildParticipantInteraction(int $ref_id, ?int $qst_id, int $pax_id, string $source_addr, TestParticipantInteractionTypes $type, array $additional_data)
Definition: Factory.php:95
buildErrorFromDBValues(\stdClass $db_values)
Definition: Factory.php:190
buildTestAdministrationInteractionFromDBValues(\stdClass $db_values)
Definition: Factory.php:42
buildQuestionAdministrationInteractionFromDBValues(\stdClass $db_values)
Definition: Factory.php:77
buildParticipantInteractionFromDBValues(\stdClass $db_values)
Definition: Factory.php:114
buildTestAdministrationInteraction(int $ref_id, int $admin_id, TestAdministrationInteractionTypes $type, array $additional_data)
Definition: Factory.php:27
buildError(int $ref_id, ?int $qst_id, ?int $admin_id, ?int $pax_id, TestErrorTypes $type, string $error_message)
Definition: Factory.php:171
buildScoringInteractionFromDBValues(\stdClass $db_values)
Definition: Factory.php:152
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))