ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilTestResultsToXML Class Reference
+ Inheritance diagram for ilTestResultsToXML:
+ Collaboration diagram for ilTestResultsToXML:

Public Member Functions

 __construct (private int $test_id, private ilDBInterface $db, private ResourceStorage $irss, private string $objects_export_directory, private bool $anonymized=false)
 
 isIncludeRandomTestQuestionsEnabled ()
 
 setIncludeRandomTestQuestionsEnabled (bool $include_random_test_questions_enabled)
 
 getXML ()
 
 xmlDumpMem (bool $format=true)
 Returns xml document from memory. More...
 
 xmlDumpFile (string $file, bool $format=true)
 Dumps xml document from memory into a file. More...
 
- Public Member Functions inherited from ilXmlWriter
 __construct (string $version="1.0", string $outEnc="utf-8", string $inEnc="utf-8")
 
 xmlSetDtdDef (string $dtdDef)
 Sets dtd definition. More...
 
 xmlSetGenCmt (string $genCmt)
 Sets generated comment. More...
 
 xmlFormatData (string $data)
 Indents text for better reading. More...
 
 xmlHeader ()
 Writes xml header. More...
 
 xmlStartTag (string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
 Writes a starttag. More...
 
 xmlEndTag (string $tag)
 Writes an endtag. More...
 
 xmlData (string $data, bool $encode=true, bool $escape=true)
 Writes data. More...
 
 xmlElement (string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile (string $file, bool $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem (bool $format=true)
 Returns xml document from memory. More...
 
 appendXML (string $a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr More...
 

Protected Member Functions

 exportActiveIDs ()
 
 exportPassResult ()
 
 exportResultCache ()
 
 exportTestSequence ()
 
 exportTestSolutions ()
 
 exportRandomTestQuestions ()
 
 exportTestResults ()
 
 exportParticipantUploadedFiles (array $uploaded_files)
 
 exportTestTimes ()
 

Protected Attributes

bool $include_random_test_questions_enabled = false
 

Private Attributes

 $active_ids
 

Detailed Description

Definition at line 23 of file class.ilTestResultsToXML.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestResultsToXML::__construct ( private int  $test_id,
private ilDBInterface  $db,
private ResourceStorage  $irss,
private string  $objects_export_directory,
private bool  $anonymized = false 
)

Definition at line 29 of file class.ilTestResultsToXML.php.

35 {
37 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ exportActiveIDs()

ilTestResultsToXML::exportActiveIDs ( )
protected

Definition at line 49 of file class.ilTestResultsToXML.php.

49 : void
50 {
51 $assessment_setting = new ilSetting('assessment');
52 $user_criteria = $assessment_setting->get('user_criteria');
53 if ($user_criteria === null || $user_criteria === '') {
54 $user_criteria = 'usr_id';
55 }
56
57 if ($this->anonymized) {
58 $result = $this->db->queryF(
59 'SELECT * FROM tst_active WHERE test_fi = %s',
60 ['integer'],
61 [$this->test_id]
62 );
63 } else {
64 $result = $this->db->queryF(
65 'SELECT tst_active.*, usr_data.' . $user_criteria . ' FROM tst_active, usr_data WHERE tst_active.test_fi = %s AND tst_active.user_fi = usr_data.usr_id',
66 ['integer'],
67 [$this->test_id]
68 );
69 }
70 $this->xmlStartTag('tst_active', null);
71 while ($row = $this->db->fetchAssoc($result)) {
72 $attrs = [
73 'active_id' => $row['active_id'],
74 'user_fi' => $row['user_fi'] ?? '',
75 'anonymous_id' => $row['anonymous_id'] ?? '',
76 'test_fi' => $row['test_fi'],
77 'lastindex' => $row['lastindex'] ?? '',
78 'tries' => $row['tries'] ?? '',
79 'last_started_pass' => $row['last_started_pass'] ?? '',
80 'last_finished_pass' => $row['last_finished_pass'] ?? '',
81 'submitted' => $row['submitted'] ?? '',
82 'submittimestamp' => $row['submittimestamp'] ?? '',
83 'tstamp' => $row['tstamp'] ?? ''
84 ];
85 $attrs['fullname'] = ilObjTestAccess::_getParticipantData($row['active_id']);
86 if (!$this->anonymized) {
87 $attrs['user_criteria'] = $user_criteria;
88 $attrs[$user_criteria] = $row[$user_criteria];
89 }
90 array_push($this->active_ids, $row['active_id']);
91 $this->xmlElement('row', $attrs);
92 }
93 $this->xmlEndTag('tst_active');
94 }
static _getParticipantData(int $active_id)
Retrieves a participant name from active id.
ILIAS Setting Class.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.

References ilObjTestAccess\_getParticipantData(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportParticipantUploadedFiles()

ilTestResultsToXML::exportParticipantUploadedFiles ( array  $uploaded_files)
protected
Parameters
array{value1string, value2: string} $uploaded_files

Definition at line 231 of file class.ilTestResultsToXML.php.

231 : void
232 {
233 foreach ($uploaded_files as $uploaded_file) {
234 if ($uploaded_file['value2'] !== 'rid') {
235 continue;
236 }
237
238 $rid_string = $uploaded_file['value1'];
239 $rid = $this->irss->manage()->find($rid_string);
240 if ($rid === null) {
241 continue;
242 }
243
244 $target_dir = "$this->objects_export_directory/resources/$rid_string";
245 ilFileUtils::makeDirParents($target_dir);
246 file_put_contents(
247 "$target_dir/{$this->irss->manage()->getCurrentRevision($rid)->getTitle()}",
248 $this->irss->consume()->stream($rid)->getStream(),
249 );
250 }
251 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.

References ilFileUtils\makeDirParents().

Referenced by exportTestResults().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportPassResult()

ilTestResultsToXML::exportPassResult ( )
protected

Definition at line 96 of file class.ilTestResultsToXML.php.

96 : void
97 {
98 $query = 'SELECT * FROM tst_pass_result WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY active_fi, pass';
99 $result = $this->db->query($query);
100 $this->xmlStartTag('tst_pass_result', null);
101 while ($row = $this->db->fetchAssoc($result)) {
102 $attrs = [
103 'active_fi' => $row['active_fi'],
104 'pass' => $row['pass'] ?? '',
105 'points' => $row['points'] ?? '',
106 'maxpoints' => $row['maxpoints'] ?? '',
107 'questioncount' => $row['questioncount'] ?? '',
108 'answeredquestions' => $row['answeredquestions'] ?? '',
109 'workingtime' => $row['workingtime'] ?? '',
110 'tstamp' => $row['tstamp'] ?? ''
111 ];
112 $this->xmlElement('row', $attrs);
113 }
114 $this->xmlEndTag('tst_pass_result');
115 }

References ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportRandomTestQuestions()

ilTestResultsToXML::exportRandomTestQuestions ( )
protected

Definition at line 179 of file class.ilTestResultsToXML.php.

179 : void
180 {
181 $result = $this->db->query("
182 SELECT * FROM tst_test_rnd_qst
183 WHERE {$this->db->in('active_fi', $this->active_ids, false, 'integer')}
184 ORDER BY test_random_question_id
185 ");
186
187 $this->xmlStartTag('tst_test_rnd_qst', null);
188 while ($row = $this->db->fetchAssoc($result)) {
189 $attrs = [];
190
191 foreach ($row as $field => $value) {
192 $attrs[$field] = $value;
193 }
194
195 $this->xmlElement('row', $attrs);
196 }
197 $this->xmlEndTag('tst_test_rnd_qst');
198 }

References ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportResultCache()

ilTestResultsToXML::exportResultCache ( )
protected

Definition at line 117 of file class.ilTestResultsToXML.php.

117 : void
118 {
119 $query = 'SELECT * FROM tst_result_cache WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY active_fi';
120 $result = $this->db->query($query);
121 $this->xmlStartTag('tst_result_cache', null);
122 while ($row = $this->db->fetchAssoc($result)) {
123 $attrs = [
124 'active_fi' => $row['active_fi'],
125 'pass' => $row['pass'],
126 'max_points' => $row['max_points'],
127 'reached_points' => $row['reached_points'],
128 'mark_short' => $row['mark_short'],
129 'mark_official' => $row['mark_official'],
130 'passed' => $row['passed'],
131 'failed' => $row['failed'],
132 'tstamp' => $row['tstamp']
133 ];
134 $this->xmlElement('row', $attrs);
135 }
136 $this->xmlEndTag('tst_result_cache');
137 }

References ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestResults()

ilTestResultsToXML::exportTestResults ( )
protected

Definition at line 201 of file class.ilTestResultsToXML.php.

201 : void
202 {
203 $query = 'SELECT * FROM tst_test_result WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY active_fi';
204 $result = $this->db->query($query);
205 $this->xmlStartTag('tst_test_result', null);
206 while ($row = $this->db->fetchAssoc($result)) {
207 $active_fi = $row['active_fi'];
208 $pass = $row['pass'] ?? '';
209 $attrs = [
210 'test_result_id' => $row['test_result_id'],
211 'active_fi' => $active_fi,
212 'question_fi' => $row['question_fi'],
213 'points' => $row['points'] ?? '',
214 'pass' => $pass,
215 'manual' => $row['manual'] ?? '',
216 'tstamp' => $row['tstamp'] ?? ''
217 ];
218
219 if (($question = assQuestion::instantiateQuestion($row['question_fi'])) instanceof assFileUpload) {
220 $this->exportParticipantUploadedFiles($question->getUploadedFiles($active_fi, $pass));
221 }
222
223 $this->xmlElement('row', $attrs);
224 }
225 $this->xmlEndTag('tst_test_result');
226 }
Class for file upload questions.
static instantiateQuestion(int $question_id)
exportParticipantUploadedFiles(array $uploaded_files)

References exportParticipantUploadedFiles(), assQuestion\instantiateQuestion(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestSequence()

ilTestResultsToXML::exportTestSequence ( )
protected

Definition at line 139 of file class.ilTestResultsToXML.php.

139 : void
140 {
141 $query = 'SELECT * FROM tst_sequence WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY active_fi, pass';
142 $result = $this->db->query($query);
143 $this->xmlStartTag('tst_sequence', null);
144 while ($row = $this->db->fetchAssoc($result)) {
145 $attrs = [
146 'active_fi' => $row['active_fi'],
147 'pass' => $row['pass'] ?? '',
148 'sequence' => $row['sequence'] ?? '',
149 'postponed' => $row['postponed'] ?? '',
150 'hidden' => $row['hidden'] ?? '',
151 'tstamp' => $row['tstamp'] ?? ''
152 ];
153 $this->xmlElement('row', $attrs);
154 }
155 $this->xmlEndTag('tst_sequence');
156 }

References ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestSolutions()

ilTestResultsToXML::exportTestSolutions ( )
protected

Definition at line 158 of file class.ilTestResultsToXML.php.

158 : void
159 {
160 $query = 'SELECT * FROM tst_solutions WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY solution_id';
161 $result = $this->db->query($query);
162 $this->xmlStartTag('tst_solutions', null);
163 while ($row = $this->db->fetchAssoc($result)) {
164 $attrs = [
165 'solution_id' => $row['solution_id'],
166 'active_fi' => $row['active_fi'],
167 'question_fi' => $row['question_fi'],
168 'points' => $row['points'] ?? '',
169 'pass' => $row['pass'] ?? '',
170 'value1' => $row['value1'] ?? '',
171 'value2' => $row['value2'] ?? '',
172 'tstamp' => $row['tstamp'] ?? ''
173 ];
174 $this->xmlElement('row', $attrs);
175 }
176 $this->xmlEndTag('tst_solutions');
177 }

References ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestTimes()

ilTestResultsToXML::exportTestTimes ( )
protected

Definition at line 253 of file class.ilTestResultsToXML.php.

253 : void
254 {
255 $query = 'SELECT * FROM tst_times WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY active_fi';
256 $result = $this->db->query($query);
257 $this->xmlStartTag('tst_times', null);
258 while ($row = $this->db->fetchAssoc($result)) {
259 $attrs = [
260 'times_id' => $row['times_id'],
261 'active_fi' => $row['active_fi'],
262 'started' => $row['started'],
263 'finished' => $row['finished'],
264 'pass' => $row['pass'],
265 'tstamp' => $row['tstamp']
266 ];
267 $this->xmlElement('row', $attrs);
268 }
269 $this->xmlEndTag('tst_times');
270 }

References ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXML()

ilTestResultsToXML::getXML ( )

Definition at line 272 of file class.ilTestResultsToXML.php.

272 : void
273 {
274 $this->active_ids = [];
275 $this->xmlHeader();
276 $attrs = ['version' => '4.1.0'];
277 $this->xmlStartTag('results', $attrs);
278 $this->exportActiveIDs();
279
282 }
283
284 $this->exportPassResult();
285 $this->exportResultCache();
286 $this->exportTestSequence();
287 $this->exportTestSolutions();
288 $this->exportTestResults();
289 $this->exportTestTimes();
290 $this->xmlEndTag('results');
291 }
xmlHeader()
Writes xml header.

References exportActiveIDs(), exportPassResult(), exportRandomTestQuestions(), exportResultCache(), exportTestResults(), exportTestSequence(), exportTestSolutions(), exportTestTimes(), isIncludeRandomTestQuestionsEnabled(), ilXmlWriter\xmlEndTag(), ilXmlWriter\xmlHeader(), and ilXmlWriter\xmlStartTag().

Referenced by xmlDumpFile(), and xmlDumpMem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isIncludeRandomTestQuestionsEnabled()

ilTestResultsToXML::isIncludeRandomTestQuestionsEnabled ( )

Definition at line 39 of file class.ilTestResultsToXML.php.

39 : bool
40 {
42 }

References $include_random_test_questions_enabled.

Referenced by getXML().

+ Here is the caller graph for this function:

◆ setIncludeRandomTestQuestionsEnabled()

ilTestResultsToXML::setIncludeRandomTestQuestionsEnabled ( bool  $include_random_test_questions_enabled)

Definition at line 44 of file class.ilTestResultsToXML.php.

44 : void
45 {
46 $this->include_random_test_questions_enabled = $include_random_test_questions_enabled;
47 }

References $include_random_test_questions_enabled.

◆ xmlDumpFile()

ilTestResultsToXML::xmlDumpFile ( string  $file,
bool  $format = true 
)

Dumps xml document from memory into a file.

Reimplemented from ilXmlWriter.

Definition at line 299 of file class.ilTestResultsToXML.php.

299 : void
300 {
301 $this->getXML();
302 parent::xmlDumpFile($file, $format);
303 }

References getXML().

+ Here is the call graph for this function:

◆ xmlDumpMem()

ilTestResultsToXML::xmlDumpMem ( bool  $format = true)

Returns xml document from memory.

Reimplemented from ilXmlWriter.

Definition at line 293 of file class.ilTestResultsToXML.php.

293 : string
294 {
295 $this->getXML();
296 return parent::xmlDumpMem($format);
297 }

References getXML().

+ Here is the call graph for this function:

Field Documentation

◆ $active_ids

ilTestResultsToXML::$active_ids
private

Definition at line 25 of file class.ilTestResultsToXML.php.

◆ $include_random_test_questions_enabled

bool ilTestResultsToXML::$include_random_test_questions_enabled = false
protected

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