ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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)
 Returns xml document from memory. More...
 
 xmlDumpFile ($file, $format=true)
 Dumps xml document from memory into a file. More...
 
- Public Member Functions inherited from ilXmlWriter
 __construct ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor @access 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 @access 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 @access 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.

22 {
24 $this->test_id = $test_id;
25 $this->anonymized = $anonymized;
26 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ exportActiveIDs()

ilTestResultsToXML::exportActiveIDs ( )
protected

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

45 {
46 global $DIC;
47 $ilDB = $DIC['ilDB'];
48 $ilSetting = $DIC['ilSetting'];
49
50 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
51 $assessmentSetting = new ilSetting("assessment");
52 $user_criteria = $assessmentSetting->get("user_criteria");
53 if (strlen($user_criteria) == 0) {
54 $user_criteria = 'usr_id';
55 }
56
57 if ($this->anonymized) {
58 $result = $ilDB->queryF(
59 "SELECT * FROM tst_active WHERE test_fi = %s",
60 array('integer'),
61 array($this->test_id)
62 );
63 } else {
64 $result = $ilDB->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 array('integer'),
67 array($this->test_id)
68 );
69 }
70 $this->xmlStartTag("tst_active", null);
71 while ($row = $ilDB->fetchAssoc($result)) {
72 $attrs = array(
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 }
$result
static _getParticipantData($active_id)
Retrieves a participant name from active id.
ILIAS Setting Class.
xmlEndTag($tag)
Writes an endtag.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
global $ilSetting
Definition: privfeed.php:17
global $ilDB
$DIC
Definition: xapitoken.php:46

References $DIC, $ilDB, $ilSetting, $result, 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:

◆ exportPassResult()

ilTestResultsToXML::exportPassResult ( )
protected

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

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

References $DIC, $ilDB, $query, $result, 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 191 of file class.ilTestResultsToXML.php.

192 {
193 global $DIC;
194 $ilDB = $DIC['ilDB'];
195
196 $result = $ilDB->query("
197 SELECT * FROM tst_test_rnd_qst
198 WHERE {$ilDB->in('active_fi', $this->active_ids, false, 'integer')}
199 ORDER BY test_random_question_id
200 ");
201
202 $this->xmlStartTag('tst_test_rnd_qst', null);
203 while ($row = $ilDB->fetchAssoc($result)) {
204 $attrs = array();
205
206 foreach ($row as $field => $value) {
207 $attrs[$field] = $value;
208 }
209
210 $this->xmlElement('row', $attrs);
211 }
212 $this->xmlEndTag('tst_test_rnd_qst');
213 }

References $DIC, $ilDB, $result, 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 120 of file class.ilTestResultsToXML.php.

121 {
122 global $DIC;
123 $ilDB = $DIC['ilDB'];
124
125 $query = "SELECT * FROM tst_result_cache WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi";
126 $result = $ilDB->query($query);
127 $this->xmlStartTag("tst_result_cache", null);
128 while ($row = $ilDB->fetchAssoc($result)) {
129 $attrs = array(
130 'active_fi' => $row['active_fi'],
131 'pass' => $row['pass'],
132 'max_points' => $row['max_points'],
133 'reached_points' => $row['reached_points'],
134 'mark_short' => $row['mark_short'],
135 'mark_official' => $row['mark_official'],
136 'passed' => $row['passed'],
137 'failed' => $row['failed'],
138 'tstamp' => $row['tstamp']
139 );
140 $this->xmlElement("row", $attrs);
141 }
142 $this->xmlEndTag("tst_result_cache");
143 }

References $DIC, $ilDB, $query, $result, 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 216 of file class.ilTestResultsToXML.php.

217 {
218 global $DIC;
219 $ilDB = $DIC['ilDB'];
220
221 $query = "SELECT * FROM tst_test_result WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi";
222 $result = $ilDB->query($query);
223 $this->xmlStartTag("tst_test_result", null);
224 while ($row = $ilDB->fetchAssoc($result)) {
225 $attrs = array(
226 'test_result_id' => $row['test_result_id'],
227 'active_fi' => $row['active_fi'],
228 'question_fi' => $row['question_fi'],
229 'points' => $row['points'],
230 'pass' => $row['pass'],
231 'manual' => $row['manual'],
232 'tstamp' => $row['tstamp']
233 );
234 $this->xmlElement("row", $attrs);
235 }
236 $this->xmlEndTag("tst_test_result");
237 }

References $DIC, $ilDB, $query, $result, 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 145 of file class.ilTestResultsToXML.php.

146 {
147 global $DIC;
148 $ilDB = $DIC['ilDB'];
149
150 $query = "SELECT * FROM tst_sequence WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi, pass";
151 $result = $ilDB->query($query);
152 $this->xmlStartTag("tst_sequence", null);
153 while ($row = $ilDB->fetchAssoc($result)) {
154 $attrs = array(
155 'active_fi' => $row['active_fi'],
156 'pass' => $row['pass'],
157 'sequence' => $row['sequence'],
158 'postponed' => $row['postponed'],
159 'hidden' => $row['hidden'],
160 'tstamp' => $row['tstamp']
161 );
162 $this->xmlElement("row", $attrs);
163 }
164 $this->xmlEndTag("tst_sequence");
165 }

References $DIC, $ilDB, $query, $result, 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 167 of file class.ilTestResultsToXML.php.

168 {
169 global $DIC;
170 $ilDB = $DIC['ilDB'];
171
172 $query = "SELECT * FROM tst_solutions WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY solution_id";
173 $result = $ilDB->query($query);
174 $this->xmlStartTag("tst_solutions", null);
175 while ($row = $ilDB->fetchAssoc($result)) {
176 $attrs = array(
177 'solution_id' => $row['solution_id'],
178 'active_fi' => $row['active_fi'],
179 'question_fi' => $row['question_fi'],
180 'points' => $row['points'],
181 'pass' => $row['pass'],
182 'value1' => $row['value1'],
183 'value2' => $row['value2'],
184 'tstamp' => $row['tstamp']
185 );
186 $this->xmlElement("row", $attrs);
187 }
188 $this->xmlEndTag("tst_solutions");
189 }

References $DIC, $ilDB, $query, $result, 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 239 of file class.ilTestResultsToXML.php.

240 {
241 global $DIC;
242 $ilDB = $DIC['ilDB'];
243
244 $query = "SELECT * FROM tst_times WHERE " . $ilDB->in('active_fi', $this->active_ids, false, 'integer') . " ORDER BY active_fi";
245 $result = $ilDB->query($query);
246 $this->xmlStartTag("tst_times", null);
247 while ($row = $ilDB->fetchAssoc($result)) {
248 $attrs = array(
249 'times_id' => $row['times_id'],
250 'active_fi' => $row['active_fi'],
251 'started' => $row['started'],
252 'finished' => $row['finished'],
253 'pass' => $row['pass'],
254 'tstamp' => $row['tstamp']
255 );
256 $this->xmlElement("row", $attrs);
257 }
258 $this->xmlEndTag("tst_times");
259 }

References $DIC, $ilDB, $query, $result, 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 261 of file class.ilTestResultsToXML.php.

262 {
263 $this->active_ids = array();
264 $this->xmlHeader();
265 $attrs = array("version" => "4.1.0");
266 $this->xmlStartTag("results", $attrs);
267 $this->exportActiveIDs();
268
271 }
272
273 $this->exportPassResult();
274 $this->exportResultCache();
275 $this->exportTestSequence();
276 $this->exportTestSolutions();
277 $this->exportTestResults();
278 $this->exportTestTimes();
279 $this->xmlEndTag("results");
280 }
xmlHeader()
Writes xml header @access public.

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 ( )
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.

40 {
41 $this->includeRandomTestQuestionsEnabled = $includeRandomTestQuestionsEnabled;
42 }

References $includeRandomTestQuestionsEnabled.

◆ xmlDumpFile()

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

Dumps xml document from memory into a file.

Parameters
stringfile name (full path)
booleanindent text (TRUE) or not (FALSE) @access public

Reimplemented from ilXmlWriter.

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

289 {
290 $this->getXML();
291 return parent::xmlDumpFile($file, $format);
292 }
$format
Definition: metadata.php:218

References $format, and getXML().

+ Here is the call graph for this function:

◆ xmlDumpMem()

ilTestResultsToXML::xmlDumpMem (   $format = true)

Returns xml document from memory.

Parameters
booleanindent text (TRUE) or not (FALSE)
Returns
string xml document @access public

Reimplemented from ilXmlWriter.

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

283 {
284 $this->getXML();
285 return parent::xmlDumpMem($format);
286 }

References $format, and getXML().

+ 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: