ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilTestResultsToXML Class Reference

Test results to XML class. More...

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

Public Member Functions

 __construct ($test_id, $anonymized=false)
 
 isIncludeRandomTestQuestionsEnabled ()
 
 setIncludeRandomTestQuestionsEnabled ($includeRandomTestQuestionsEnabled)
 
 getXML ()
 
 xmlDumpMem ($format=true)
 
 xmlDumpFile ($file, $format=true)
 
- Public Member Functions inherited from ilXmlWriter
 __construct ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. More...
 
 xmlEncodeData ($data)
 Encodes text from input encoding into output encoding. More...
 
 xmlFormatData ($data)
 Indents text for better reading. More...
 
 xmlFormatElement ($array)
 Callback function for xmlFormatData; do not invoke directly. More...
 
 xmlHeader ()
 Writes xml header public. More...
 
 xmlStartTag ($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
 Writes a starttag. More...
 
 xmlEndTag ($tag)
 Writes an endtag. More...
 
 xmlComment ($comment)
 Writes a comment. More...
 
 xmlData ($data, $encode=true, $escape=true)
 Writes data. More...
 
 xmlElement ($tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile ($file, $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem ($format=true)
 Returns xml document from memory. More...
 
 appendXML ($a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr public More...
 

Protected Member Functions

 exportActiveIDs ()
 
 exportPassResult ()
 
 exportResultCache ()
 
 exportTestSequence ()
 
 exportTestSolutions ()
 
 exportRandomTestQuestions ()
 
 exportTestResults ()
 
 exportTestTimes ()
 

Protected Attributes

 $includeRandomTestQuestionsEnabled = false
 

Private Attributes

 $test_id = 0
 
 $anonymized = false
 
 $active_ids
 

Additional Inherited Members

- Static Public Member Functions inherited from ilXmlWriter
static _xmlEscapeData ($data)
 Escapes reserved characters. More...
 
- Data Fields inherited from ilXmlWriter
 $xmlStr
 
 $version
 
 $outEnc
 
 $inEnc
 
 $dtdDef = ""
 
 $stSheet = ""
 
 $genCmt = "Generated by ILIAS XmlWriter"
 

Detailed Description

Test results to XML class.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $anonymized, and $test_id.

22  {
23  parent::__construct();
24  $this->test_id = $test_id;
25  $this->anonymized = $anonymized;
26  }

Member Function Documentation

◆ exportActiveIDs()

ilTestResultsToXML::exportActiveIDs ( )
protected

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

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

Referenced by getXML().

45  {
46  global $ilDB, $ilSetting;
47 
48  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
49  $assessmentSetting = new ilSetting("assessment");
50  $user_criteria = $assessmentSetting->get("user_criteria");
51  if (strlen($user_criteria) == 0) {
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  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
static _getParticipantData($active_id)
Retrieves a participant name from active id.
$result
xmlEndTag($tag)
Writes an endtag.
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilSetting
Definition: privfeed.php:17
global $ilDB
+ 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 $ilDB, $query, $result, $row, array, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

95  {
96  global $ilDB;
97 
98  $query = "SELECT * FROM tst_pass_result WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi, pass";
99  $result = $ilDB->query($query);
100  $this->xmlStartTag("tst_pass_result", null);
101  while ($row = $ilDB->fetchAssoc($result)) {
102  $attrs = array(
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  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$result
xmlEndTag($tag)
Writes an endtag.
$query
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportRandomTestQuestions()

ilTestResultsToXML::exportRandomTestQuestions ( )
protected

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

References $ilDB, $result, $row, array, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

186  {
187  global $ilDB;
188 
189  $result = $ilDB->query("
190  SELECT * FROM tst_test_rnd_qst
191  WHERE {$ilDB->in('active_fi', $this->active_ids, false, 'integer')}
192  ORDER BY test_random_question_id
193  ");
194 
195  $this->xmlStartTag('tst_test_rnd_qst', null);
196  while ($row = $ilDB->fetchAssoc($result)) {
197  $attrs = array();
198 
199  foreach ($row as $field => $value) {
200  $attrs[$field] = $value;
201  }
202 
203  $this->xmlElement('row', $attrs);
204  }
205  $this->xmlEndTag('tst_test_rnd_qst');
206  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$result
xmlEndTag($tag)
Writes an endtag.
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilDB
+ 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.

References $ilDB, $query, $result, $row, array, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

118  {
119  global $ilDB;
120 
121  $query = "SELECT * FROM tst_result_cache WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi";
122  $result = $ilDB->query($query);
123  $this->xmlStartTag("tst_result_cache", null);
124  while ($row = $ilDB->fetchAssoc($result)) {
125  $attrs = array(
126  'active_fi' => $row['active_fi'],
127  'pass' => $row['pass'],
128  'max_points' => $row['max_points'],
129  'reached_points' => $row['reached_points'],
130  'mark_short' => $row['mark_short'],
131  'mark_official' => $row['mark_official'],
132  'passed' => $row['passed'],
133  'failed' => $row['failed'],
134  'tstamp' => $row['tstamp']
135  );
136  $this->xmlElement("row", $attrs);
137  }
138  $this->xmlEndTag("tst_result_cache");
139  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$result
xmlEndTag($tag)
Writes an endtag.
$query
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestResults()

ilTestResultsToXML::exportTestResults ( )
protected

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

References $ilDB, $query, $result, $row, array, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

210  {
211  global $ilDB;
212 
213  $query = "SELECT * FROM tst_test_result WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi";
214  $result = $ilDB->query($query);
215  $this->xmlStartTag("tst_test_result", null);
216  while ($row = $ilDB->fetchAssoc($result)) {
217  $attrs = array(
218  'test_result_id' => $row['test_result_id'],
219  'active_fi' => $row['active_fi'],
220  'question_fi' => $row['question_fi'],
221  'points' => $row['points'],
222  'pass' => $row['pass'],
223  'manual' => $row['manual'],
224  'tstamp' => $row['tstamp']
225  );
226  $this->xmlElement("row", $attrs);
227  }
228  $this->xmlEndTag("tst_test_result");
229  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$result
xmlEndTag($tag)
Writes an endtag.
$query
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestSequence()

ilTestResultsToXML::exportTestSequence ( )
protected

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

References $ilDB, $query, $result, $row, array, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

142  {
143  global $ilDB;
144 
145  $query = "SELECT * FROM tst_sequence WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi, pass";
146  $result = $ilDB->query($query);
147  $this->xmlStartTag("tst_sequence", null);
148  while ($row = $ilDB->fetchAssoc($result)) {
149  $attrs = array(
150  'active_fi' => $row['active_fi'],
151  'pass' => $row['pass'],
152  'sequence' => $row['sequence'],
153  'postponed' => $row['postponed'],
154  'hidden' => $row['hidden'],
155  'tstamp' => $row['tstamp']
156  );
157  $this->xmlElement("row", $attrs);
158  }
159  $this->xmlEndTag("tst_sequence");
160  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$result
xmlEndTag($tag)
Writes an endtag.
$query
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestSolutions()

ilTestResultsToXML::exportTestSolutions ( )
protected

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

References $ilDB, $query, $result, $row, array, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

163  {
164  global $ilDB;
165 
166  $query = "SELECT * FROM tst_solutions WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY solution_id";
167  $result = $ilDB->query($query);
168  $this->xmlStartTag("tst_solutions", null);
169  while ($row = $ilDB->fetchAssoc($result)) {
170  $attrs = array(
171  'solution_id' => $row['solution_id'],
172  'active_fi' => $row['active_fi'],
173  'question_fi' => $row['question_fi'],
174  'points' => $row['points'],
175  'pass' => $row['pass'],
176  'value1' => $row['value1'],
177  'value2' => $row['value2'],
178  'tstamp' => $row['tstamp']
179  );
180  $this->xmlElement("row", $attrs);
181  }
182  $this->xmlEndTag("tst_solutions");
183  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$result
xmlEndTag($tag)
Writes an endtag.
$query
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportTestTimes()

ilTestResultsToXML::exportTestTimes ( )
protected

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

References $ilDB, $query, $result, $row, array, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by getXML().

232  {
233  global $ilDB;
234 
235  $query = "SELECT * FROM tst_times WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi";
236  $result = $ilDB->query($query);
237  $this->xmlStartTag("tst_times", null);
238  while ($row = $ilDB->fetchAssoc($result)) {
239  $attrs = array(
240  'times_id' => $row['times_id'],
241  'active_fi' => $row['active_fi'],
242  'started' => $row['started'],
243  'finished' => $row['finished'],
244  'pass' => $row['pass'],
245  'tstamp' => $row['tstamp']
246  );
247  $this->xmlElement("row", $attrs);
248  }
249  $this->xmlEndTag("tst_times");
250  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$result
xmlEndTag($tag)
Writes an endtag.
$query
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXML()

ilTestResultsToXML::getXML ( )

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

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

Referenced by xmlDumpFile(), and xmlDumpMem().

253  {
254  $this->active_ids = array();
255  $this->xmlHeader();
256  $attrs = array("version" => "4.1.0");
257  $this->xmlStartTag("results", $attrs);
258  $this->exportActiveIDs();
259 
261  $this->exportRandomTestQuestions();
262  }
263 
264  $this->exportPassResult();
265  $this->exportResultCache();
266  $this->exportTestSequence();
267  $this->exportTestSolutions();
268  $this->exportTestResults();
269  $this->exportTestTimes();
270  $this->xmlEndTag("results");
271  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
xmlHeader()
Writes xml header public.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isIncludeRandomTestQuestionsEnabled()

ilTestResultsToXML::isIncludeRandomTestQuestionsEnabled ( )
Returns
boolean

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

References $includeRandomTestQuestionsEnabled.

Referenced by getXML().

+ Here is the caller graph for this function:

◆ setIncludeRandomTestQuestionsEnabled()

ilTestResultsToXML::setIncludeRandomTestQuestionsEnabled (   $includeRandomTestQuestionsEnabled)
Parameters
boolean$includeRandomTestQuestionsEnabled

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

References $includeRandomTestQuestionsEnabled.

Referenced by ilTestExport\buildExportFileXML().

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

◆ xmlDumpFile()

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

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

References $file, $format, and getXML().

280  {
281  $this->getXML();
282  return parent::xmlDumpFile($file, $format);
283  }
$format
Definition: metadata.php:141
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:

◆ xmlDumpMem()

ilTestResultsToXML::xmlDumpMem (   $format = true)

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

References $format, and getXML().

274  {
275  $this->getXML();
276  return parent::xmlDumpMem($format);
277  }
$format
Definition: metadata.php:141
+ Here is the call graph for this function:

Field Documentation

◆ $active_ids

ilTestResultsToXML::$active_ids
private

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

◆ $anonymized

ilTestResultsToXML::$anonymized = false
private

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

Referenced by __construct().

◆ $includeRandomTestQuestionsEnabled

ilTestResultsToXML::$includeRandomTestQuestionsEnabled = false
protected

◆ $test_id

ilTestResultsToXML::$test_id = 0
private

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

Referenced by __construct().


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