ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTestResultsToXML Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilTestResultsToXML:
+ Collaboration diagram for ilTestResultsToXML:

Public Member Functions

 __construct ($test_id, $anonymized=false)
 
 isIncludeRandomTestQuestionsEnabled ()
 
 setIncludeRandomTestQuestionsEnabled (bool $includeRandomTestQuestionsEnabled)
 
 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 $includeRandomTestQuestionsEnabled = false
 

Private Attributes

int $test_id = 0
 
bool $anonymized = false
 
 $active_ids
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

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

Constructor & Destructor Documentation

◆ __construct()

ilTestResultsToXML::__construct (   $test_id,
  $anonymized = false 
)

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

References $anonymized, $test_id, and ILIAS\GlobalScreen\Provider\__construct().

28  {
30  $this->test_id = $test_id;
31  $this->anonymized = $anonymized;
32  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ exportActiveIDs()

ilTestResultsToXML::exportActiveIDs ( )
protected

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

References $DIC, $ilDB, $ilSetting, ilObjTestAccess\_getParticipantData(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

44  : void
45  {
46  global $DIC;
47  $ilDB = $DIC['ilDB'];
48  $ilSetting = $DIC['ilSetting'];
49  $assessmentSetting = new ilSetting("assessment");
50  $user_criteria = $assessmentSetting->get("user_criteria");
51  if (!$user_criteria || $user_criteria === '') {
52  $user_criteria = 'usr_id';
53  }
54 
55  if ($this->anonymized) {
56  $result = $ilDB->queryF(
57  "SELECT * FROM tst_active WHERE test_fi = %s",
58  array('integer'),
59  array($this->test_id)
60  );
61  } else {
62  $result = $ilDB->queryF(
63  "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",
64  array('integer'),
65  array($this->test_id)
66  );
67  }
68  $this->xmlStartTag("tst_active", null);
69  while ($row = $ilDB->fetchAssoc($result)) {
70  $attrs = array(
71  'active_id' => $row['active_id'],
72  'user_fi' => $row['user_fi'] ?? '',
73  'anonymous_id' => $row['anonymous_id'] ?? '',
74  'test_fi' => $row['test_fi'],
75  'lastindex' => $row['lastindex'] ?? '',
76  'tries' => $row['tries'] ?? '',
77  'last_started_pass' => $row['last_started_pass'] ?? '',
78  'last_finished_pass' => $row['last_finished_pass'] ?? '',
79  'submitted' => $row['submitted'] ?? '',
80  'submittimestamp' => $row['submittimestamp'] ?? '',
81  'tstamp' => $row['tstamp'] ?? ''
82  );
83  $attrs['fullname'] = ilObjTestAccess::_getParticipantData($row['active_id']);
84  if (!$this->anonymized) {
85  $attrs['user_criteria'] = $user_criteria;
86  $attrs[$user_criteria] = $row[$user_criteria];
87  }
88  array_push($this->active_ids, $row['active_id']);
89  $this->xmlElement("row", $attrs);
90  }
91  $this->xmlEndTag("tst_active");
92  }
static _getParticipantData($active_id)
Retrieves a participant name from active id.
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: feed.php:28
global $ilSetting
Definition: privfeed.php:17
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 94 of file class.ilTestResultsToXML.php.

References $DIC, $ilDB, $query, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

94  : void
95  {
96  global $DIC;
97  $ilDB = $DIC['ilDB'];
98 
99  $query = "SELECT * FROM tst_pass_result WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi, pass";
100  $result = $ilDB->query($query);
101  $this->xmlStartTag("tst_pass_result", null);
102  while ($row = $ilDB->fetchAssoc($result)) {
103  $attrs = array(
104  'active_fi' => $row['active_fi'],
105  'pass' => $row['pass'] ?? '',
106  'points' => $row['points'] ?? '',
107  'maxpoints' => $row['maxpoints'] ?? '',
108  'questioncount' => $row['questioncount'] ?? '',
109  'answeredquestions' => $row['answeredquestions'] ?? '',
110  'workingtime' => $row['workingtime'] ?? '',
111  'tstamp' => $row['tstamp'] ?? ''
112  );
113  $this->xmlElement("row", $attrs);
114  }
115  $this->xmlEndTag("tst_pass_result");
116  }
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: feed.php:28
$query
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 189 of file class.ilTestResultsToXML.php.

References $DIC, $ilDB, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

189  : void
190  {
191  global $DIC;
192  $ilDB = $DIC['ilDB'];
193 
194  $result = $ilDB->query("
195  SELECT * FROM tst_test_rnd_qst
196  WHERE {$ilDB->in('active_fi', $this->active_ids, false, 'integer')}
197  ORDER BY test_random_question_id
198  ");
199 
200  $this->xmlStartTag('tst_test_rnd_qst', null);
201  while ($row = $ilDB->fetchAssoc($result)) {
202  $attrs = array();
203 
204  foreach ($row as $field => $value) {
205  $attrs[$field] = $value;
206  }
207 
208  $this->xmlElement('row', $attrs);
209  }
210  $this->xmlEndTag('tst_test_rnd_qst');
211  }
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: feed.php:28
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 118 of file class.ilTestResultsToXML.php.

References $DIC, $ilDB, $query, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

118  : void
119  {
120  global $DIC;
121  $ilDB = $DIC['ilDB'];
122 
123  $query = "SELECT * FROM tst_result_cache WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi";
124  $result = $ilDB->query($query);
125  $this->xmlStartTag("tst_result_cache", null);
126  while ($row = $ilDB->fetchAssoc($result)) {
127  $attrs = array(
128  'active_fi' => $row['active_fi'],
129  'pass' => $row['pass'],
130  'max_points' => $row['max_points'],
131  'reached_points' => $row['reached_points'],
132  'mark_short' => $row['mark_short'],
133  'mark_official' => $row['mark_official'],
134  'passed' => $row['passed'],
135  'failed' => $row['failed'],
136  'tstamp' => $row['tstamp']
137  );
138  $this->xmlElement("row", $attrs);
139  }
140  $this->xmlEndTag("tst_result_cache");
141  }
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: feed.php:28
$query
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 214 of file class.ilTestResultsToXML.php.

References $DIC, $ilDB, $query, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

214  : void
215  {
216  global $DIC;
217  $ilDB = $DIC['ilDB'];
218 
219  $query = "SELECT * FROM tst_test_result WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi";
220  $result = $ilDB->query($query);
221  $this->xmlStartTag("tst_test_result", null);
222  while ($row = $ilDB->fetchAssoc($result)) {
223  $attrs = array(
224  'test_result_id' => $row['test_result_id'],
225  'active_fi' => $row['active_fi'],
226  'question_fi' => $row['question_fi'],
227  'points' => $row['points'] ?? '',
228  'pass' => $row['pass'] ?? '',
229  'manual' => $row['manual'] ?? '',
230  'tstamp' => $row['tstamp'] ?? ''
231  );
232  $this->xmlElement("row", $attrs);
233  }
234  $this->xmlEndTag("tst_test_result");
235  }
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: feed.php:28
$query
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 143 of file class.ilTestResultsToXML.php.

References $DIC, $ilDB, $query, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

143  : void
144  {
145  global $DIC;
146  $ilDB = $DIC['ilDB'];
147 
148  $query = "SELECT * FROM tst_sequence WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi, pass";
149  $result = $ilDB->query($query);
150  $this->xmlStartTag("tst_sequence", null);
151  while ($row = $ilDB->fetchAssoc($result)) {
152  $attrs = array(
153  'active_fi' => $row['active_fi'],
154  'pass' => $row['pass'] ?? '',
155  'sequence' => $row['sequence'] ?? '',
156  'postponed' => $row['postponed'] ?? '',
157  'hidden' => $row['hidden'] ?? '',
158  'tstamp' => $row['tstamp'] ?? ''
159  );
160  $this->xmlElement("row", $attrs);
161  }
162  $this->xmlEndTag("tst_sequence");
163  }
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: feed.php:28
$query
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 165 of file class.ilTestResultsToXML.php.

References $DIC, $ilDB, $query, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

165  : void
166  {
167  global $DIC;
168  $ilDB = $DIC['ilDB'];
169 
170  $query = "SELECT * FROM tst_solutions WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY solution_id";
171  $result = $ilDB->query($query);
172  $this->xmlStartTag("tst_solutions", null);
173  while ($row = $ilDB->fetchAssoc($result)) {
174  $attrs = array(
175  'solution_id' => $row['solution_id'],
176  'active_fi' => $row['active_fi'],
177  'question_fi' => $row['question_fi'],
178  'points' => $row['points'] ?? '',
179  'pass' => $row['pass'] ?? '',
180  'value1' => $row['value1'] ?? '',
181  'value2' => $row['value2'] ?? '',
182  'tstamp' => $row['tstamp'] ?? ''
183  );
184  $this->xmlElement("row", $attrs);
185  }
186  $this->xmlEndTag("tst_solutions");
187  }
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: feed.php:28
$query
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 237 of file class.ilTestResultsToXML.php.

References $DIC, $ilDB, $query, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

237  : void
238  {
239  global $DIC;
240  $ilDB = $DIC['ilDB'];
241 
242  $query = "SELECT * FROM tst_times WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi";
243  $result = $ilDB->query($query);
244  $this->xmlStartTag("tst_times", null);
245  while ($row = $ilDB->fetchAssoc($result)) {
246  $attrs = array(
247  'times_id' => $row['times_id'],
248  'active_fi' => $row['active_fi'],
249  'started' => $row['started'],
250  'finished' => $row['finished'],
251  'pass' => $row['pass'],
252  'tstamp' => $row['tstamp']
253  );
254  $this->xmlElement("row", $attrs);
255  }
256  $this->xmlEndTag("tst_times");
257  }
xmlEndTag(string $tag)
Writes an endtag.
global $DIC
Definition: feed.php:28
$query
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 259 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().

259  : void
260  {
261  $this->active_ids = array();
262  $this->xmlHeader();
263  $attrs = array("version" => "4.1.0");
264  $this->xmlStartTag("results", $attrs);
265  $this->exportActiveIDs();
266 
268  $this->exportRandomTestQuestions();
269  }
270 
271  $this->exportPassResult();
272  $this->exportResultCache();
273  $this->exportTestSequence();
274  $this->exportTestSolutions();
275  $this->exportTestResults();
276  $this->exportTestTimes();
277  $this->xmlEndTag("results");
278  }
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 34 of file class.ilTestResultsToXML.php.

References $includeRandomTestQuestionsEnabled.

Referenced by getXML().

34  : bool
35  {
37  }
+ Here is the caller graph for this function:

◆ setIncludeRandomTestQuestionsEnabled()

ilTestResultsToXML::setIncludeRandomTestQuestionsEnabled ( bool  $includeRandomTestQuestionsEnabled)

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

References $includeRandomTestQuestionsEnabled.

Referenced by ilTestExport\buildExportFileXML().

39  : void
40  {
41  $this->includeRandomTestQuestionsEnabled = $includeRandomTestQuestionsEnabled;
42  }
+ Here is the caller graph for this function:

◆ xmlDumpFile()

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

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

References $format, and getXML().

286  : void
287  {
288  $this->getXML();
289  parent::xmlDumpFile($file, $format);
290  }
$format
Definition: metadata.php:235
+ Here is the call graph for this function:

◆ xmlDumpMem()

ilTestResultsToXML::xmlDumpMem ( bool  $format = true)

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

References $format, and getXML().

280  : string
281  {
282  $this->getXML();
283  return parent::xmlDumpMem($format);
284  }
$format
Definition: metadata.php:235
+ 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.

◆ $anonymized

bool ilTestResultsToXML::$anonymized = false
private

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

Referenced by __construct().

◆ $includeRandomTestQuestionsEnabled

bool ilTestResultsToXML::$includeRandomTestQuestionsEnabled = false
protected

◆ $test_id

int ilTestResultsToXML::$test_id = 0
private

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

Referenced by __construct().


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