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

Public Member Functions

 __construct (private int $test_id, private ilDBInterface $db, private bool $anonymized=false)
 
 isIncludeRandomTestQuestionsEnabled ()
 
 setIncludeRandomTestQuestionsEnabled (bool $include_random_test_questions_enabled)
 
 getXML ()
 
 xmlDumpMem (bool $format=true)
 
 xmlDumpFile (string $file, bool $format=true)
 
- 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 ()
 
 exportTestTimes ()
 

Protected Attributes

bool $include_random_test_questions_enabled = false
 

Private Attributes

 $active_ids
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References ILIAS\GlobalScreen\Provider\__construct().

31  {
33  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ exportActiveIDs()

ilTestResultsToXML::exportActiveIDs ( )
protected

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

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

Referenced by getXML().

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

◆ exportPassResult()

ilTestResultsToXML::exportPassResult ( )
protected

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

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

Referenced by getXML().

92  : void
93  {
94  $query = 'SELECT * FROM tst_pass_result WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY active_fi, pass';
95  $result = $this->db->query($query);
96  $this->xmlStartTag('tst_pass_result', null);
97  while ($row = $this->db->fetchAssoc($result)) {
98  $attrs = [
99  'active_fi' => $row['active_fi'],
100  'pass' => $row['pass'] ?? '',
101  'points' => $row['points'] ?? '',
102  'maxpoints' => $row['maxpoints'] ?? '',
103  'questioncount' => $row['questioncount'] ?? '',
104  'answeredquestions' => $row['answeredquestions'] ?? '',
105  'workingtime' => $row['workingtime'] ?? '',
106  'tstamp' => $row['tstamp'] ?? ''
107  ];
108  $this->xmlElement('row', $attrs);
109  }
110  $this->xmlEndTag('tst_pass_result');
111  }
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportRandomTestQuestions()

ilTestResultsToXML::exportRandomTestQuestions ( )
protected

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

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

Referenced by getXML().

175  : void
176  {
177  $result = $this->db->query("
178  SELECT * FROM tst_test_rnd_qst
179  WHERE {$this->db->in('active_fi', $this->active_ids, false, 'integer')}
180  ORDER BY test_random_question_id
181  ");
182 
183  $this->xmlStartTag('tst_test_rnd_qst', null);
184  while ($row = $this->db->fetchAssoc($result)) {
185  $attrs = [];
186 
187  foreach ($row as $field => $value) {
188  $attrs[$field] = $value;
189  }
190 
191  $this->xmlElement('row', $attrs);
192  }
193  $this->xmlEndTag('tst_test_rnd_qst');
194  }
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportResultCache()

ilTestResultsToXML::exportResultCache ( )
protected

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

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

Referenced by getXML().

113  : void
114  {
115  $query = 'SELECT * FROM tst_result_cache WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY active_fi';
116  $result = $this->db->query($query);
117  $this->xmlStartTag('tst_result_cache', null);
118  while ($row = $this->db->fetchAssoc($result)) {
119  $attrs = [
120  'active_fi' => $row['active_fi'],
121  'pass' => $row['pass'],
122  'max_points' => $row['max_points'],
123  'reached_points' => $row['reached_points'],
124  'mark_short' => $row['mark_short'],
125  'mark_official' => $row['mark_official'],
126  'passed' => $row['passed'],
127  'failed' => $row['failed'],
128  'tstamp' => $row['tstamp']
129  ];
130  $this->xmlElement('row', $attrs);
131  }
132  $this->xmlEndTag('tst_result_cache');
133  }
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestResults()

ilTestResultsToXML::exportTestResults ( )
protected

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

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

Referenced by getXML().

197  : void
198  {
199  $query = 'SELECT * FROM tst_test_result WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY active_fi';
200  $result = $this->db->query($query);
201  $this->xmlStartTag('tst_test_result', null);
202  while ($row = $this->db->fetchAssoc($result)) {
203  $attrs = [
204  'test_result_id' => $row['test_result_id'],
205  'active_fi' => $row['active_fi'],
206  'question_fi' => $row['question_fi'],
207  'points' => $row['points'] ?? '',
208  'pass' => $row['pass'] ?? '',
209  'manual' => $row['manual'] ?? '',
210  'tstamp' => $row['tstamp'] ?? ''
211  ];
212  $this->xmlElement('row', $attrs);
213  }
214  $this->xmlEndTag('tst_test_result');
215  }
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestSequence()

ilTestResultsToXML::exportTestSequence ( )
protected

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

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

Referenced by getXML().

135  : void
136  {
137  $query = 'SELECT * FROM tst_sequence WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY active_fi, pass';
138  $result = $this->db->query($query);
139  $this->xmlStartTag('tst_sequence', null);
140  while ($row = $this->db->fetchAssoc($result)) {
141  $attrs = [
142  'active_fi' => $row['active_fi'],
143  'pass' => $row['pass'] ?? '',
144  'sequence' => $row['sequence'] ?? '',
145  'postponed' => $row['postponed'] ?? '',
146  'hidden' => $row['hidden'] ?? '',
147  'tstamp' => $row['tstamp'] ?? ''
148  ];
149  $this->xmlElement('row', $attrs);
150  }
151  $this->xmlEndTag('tst_sequence');
152  }
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestSolutions()

ilTestResultsToXML::exportTestSolutions ( )
protected

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

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

Referenced by getXML().

154  : void
155  {
156  $query = 'SELECT * FROM tst_solutions WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY solution_id';
157  $result = $this->db->query($query);
158  $this->xmlStartTag('tst_solutions', null);
159  while ($row = $this->db->fetchAssoc($result)) {
160  $attrs = [
161  'solution_id' => $row['solution_id'],
162  'active_fi' => $row['active_fi'],
163  'question_fi' => $row['question_fi'],
164  'points' => $row['points'] ?? '',
165  'pass' => $row['pass'] ?? '',
166  'value1' => $row['value1'] ?? '',
167  'value2' => $row['value2'] ?? '',
168  'tstamp' => $row['tstamp'] ?? ''
169  ];
170  $this->xmlElement('row', $attrs);
171  }
172  $this->xmlEndTag('tst_solutions');
173  }
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestTimes()

ilTestResultsToXML::exportTestTimes ( )
protected

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

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

Referenced by getXML().

217  : void
218  {
219  $query = 'SELECT * FROM tst_times WHERE ' . $this->db->in('active_fi', $this->active_ids, false, 'integer') . ' ORDER BY active_fi';
220  $result = $this->db->query($query);
221  $this->xmlStartTag('tst_times', null);
222  while ($row = $this->db->fetchAssoc($result)) {
223  $attrs = [
224  'times_id' => $row['times_id'],
225  'active_fi' => $row['active_fi'],
226  'started' => $row['started'],
227  'finished' => $row['finished'],
228  'pass' => $row['pass'],
229  'tstamp' => $row['tstamp']
230  ];
231  $this->xmlElement('row', $attrs);
232  }
233  $this->xmlEndTag('tst_times');
234  }
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXML()

ilTestResultsToXML::getXML ( )

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

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

Referenced by xmlDumpFile(), and xmlDumpMem().

236  : void
237  {
238  $this->active_ids = [];
239  $this->xmlHeader();
240  $attrs = ['version' => '4.1.0'];
241  $this->xmlStartTag('results', $attrs);
242  $this->exportActiveIDs();
243 
245  $this->exportRandomTestQuestions();
246  }
247 
248  $this->exportPassResult();
249  $this->exportResultCache();
250  $this->exportTestSequence();
251  $this->exportTestSolutions();
252  $this->exportTestResults();
253  $this->exportTestTimes();
254  $this->xmlEndTag('results');
255  }
xmlEndTag(string $tag)
Writes an endtag.
xmlHeader()
Writes xml header.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isIncludeRandomTestQuestionsEnabled()

ilTestResultsToXML::isIncludeRandomTestQuestionsEnabled ( )

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

References $include_random_test_questions_enabled.

Referenced by getXML().

35  : bool
36  {
38  }
+ Here is the caller graph for this function:

◆ setIncludeRandomTestQuestionsEnabled()

ilTestResultsToXML::setIncludeRandomTestQuestionsEnabled ( bool  $include_random_test_questions_enabled)

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

References $include_random_test_questions_enabled.

40  : void
41  {
42  $this->include_random_test_questions_enabled = $include_random_test_questions_enabled;
43  }

◆ xmlDumpFile()

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

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

References getXML().

263  : void
264  {
265  $this->getXML();
266  parent::xmlDumpFile($file, $format);
267  }
+ Here is the call graph for this function:

◆ xmlDumpMem()

ilTestResultsToXML::xmlDumpMem ( bool  $format = true)

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

References getXML().

257  : string
258  {
259  $this->getXML();
260  return parent::xmlDumpMem($format);
261  }
+ Here is the call graph for this function:

Field Documentation

◆ $active_ids

ilTestResultsToXML::$active_ids
private

Definition at line 23 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: