ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestResultsImportParser Class Reference

Test results import parser. More...

+ Inheritance diagram for ilTestResultsImportParser:
+ Collaboration diagram for ilTestResultsImportParser:

Public Member Functions

 __construct ($a_xml_file, &$test_object)
 Constructor.
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element parser
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element
 handlerParseCharacterData ($a_xml_parser, $a_data)
 handler for character data
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file= '', $throwException=false)
 Constructor setup ILIAS global object public.
 setXMLContent ($a_xml_content)
 getXMLContent ()
 getInputType ()
 startParsing ()
 stores xml data in array
 createParser ()
 create parser
 setOptions ($a_xml_parser)
 set parser options
 openXMLFile ()
 open xml file
 parse ($a_xml_parser, $a_fp=null)
 parse xml file
 freeParser ($a_xml_parser)
 free xml parser handle
 setThrowException ($throwException)
 set error handling
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

Private Attributes

 $tst_obj
 $table
 $active_id_mapping
 $question_id_mapping
 $user_criteria_field
 $user_criteria_type
 $user_criteria_checked = false

Additional Inherited Members

- Data Fields inherited from ilSaxParser
 $input_type = null
 $xml_content = ''
 $ilias
 $lng
 $xml_file
 $throwException = false
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle

Detailed Description

Test results import parser.

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

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

Constructor & Destructor Documentation

ilTestResultsImportParser::__construct (   $a_xml_file,
$test_object 
)

Constructor.

Definition at line 26 of file class.ilTestResultsImportParser.php.

{
parent::__construct($a_xml_file, true);
$this->tst_obj = &$test_object;
$this->table = '';
$this->active_id_mapping = array();
$this->question_id_mapping = array();
$this->user_criteria_checked = false;
}

Member Function Documentation

ilTestResultsImportParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element parser

Definition at line 51 of file class.ilTestResultsImportParser.php.

References $ilLog, $result, $row, and $usr_id.

{
global $ilDB;
$this->sametag = FALSE;
$this->characterbuffer = "";
$this->depth[$a_xml_parser]++;
$this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
$this->qti_element = $a_name;
switch (strtolower($a_name))
{
case "results":
break;
case "row":
switch ($this->table)
{
case 'tst_active':
if (!$this->user_criteria_checked)
{
$this->user_criteria_checked = true;
if ($ilDB->tableColumnExists('usr_data', $a_attribs['user_criteria']))
{
include_once './Services/Database/classes/class.ilDBAnalyzer.php';
$analyzer = new ilDBAnalyzer();
$info = $analyzer->getFieldInformation('usr_data');
$this->user_criteria_field = $a_attribs['user_criteria'];
$this->user_criteria_type = $info[$a_attribs['user_criteria']]['type'];
}
}
$usr_id = ANONYMOUS_USER_ID;
if (strlen($this->user_criteria_field))
{
$result = $ilDB->queryF("SELECT usr_id FROM usr_data WHERE " . $this->user_criteria_field . " = %s",
array($this->user_criteria_type),
array($a_attribs[$this->user_criteria_field])
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$usr_id = $row['usr_id'];
}
}
$next_id = $ilDB->nextId('tst_active');
$affectedRows = $ilDB->manipulateF("INSERT INTO tst_active (active_id, user_fi, anonymous_id, test_fi, lastindex, tries, submitted, submittimestamp, tstamp, importname) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
array('integer', 'integer', 'text', 'integer', 'integer', 'integer', 'integer', 'timestamp', 'integer', 'text'),
array(
$next_id,
strlen($a_attribs['anonymous_id']) ? $a_attribs['anonymous_id'] : NULL,
$this->tst_obj->getTestId(),
$a_attribs['lastindex'],
$a_attribs['tries'],
$a_attribs['submitted'],
(strlen($a_attribs['submittimestamp'])) ? $a_attribs['submittimestamp'] : NULL,
$a_attribs['tstamp'],
$a_attribs['fullname']
)
);
$this->active_id_mapping[$a_attribs['active_id']] = $next_id;
break;
case 'tst_test_question':
$questions = $this->tst_obj->getQuestions();
$id = $questions[$a_attribs['sequence']];
if ($id > 0)
{
$this->question_id_mapping[$a_attribs['question_fi']] = $id;
}
else
{
$this->question_id_mapping[$a_attribs['question_fi']] = $a_attribs['question_fi'];
global $ilLog;
$ilLog->write("Error: Could not find question for sequence " . $a_attribs['sequence'] . " of test id " . $this->tst_obj->getTestId());
}
break;
case 'tst_pass_result':
$affectedRows = $ilDB->manipulateF("INSERT INTO tst_pass_result (active_fi, pass, points, maxpoints, questioncount, answeredquestions, workingtime, tstamp) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
array(
'integer',
'integer',
'float',
'float',
'integer',
'integer',
'integer',
'integer'
),
array(
$this->active_id_mapping[$a_attribs['active_fi']],
strlen($a_attribs['pass']) ? $a_attribs['pass'] : 0,
($a_attribs["points"]) ? $a_attribs["points"] : 0,
($a_attribs["maxpoints"]) ? $a_attribs["maxpoints"] : 0,
$a_attribs["questioncount"],
$a_attribs["answeredquestions"],
($a_attribs["workingtime"]) ? $a_attribs["workingtime"] : 0,
$a_attribs["tstamp"]
)
);
break;
case 'tst_result_cache':
$affectedRows = $ilDB->manipulateF("INSERT INTO tst_result_cache (active_fi, pass, max_points, reached_points, mark_short, mark_official, passed, failed, tstamp) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)",
array(
'integer',
'integer',
'float',
'float',
'text',
'text',
'integer',
'integer',
'integer'
),
array(
$this->active_id_mapping[$a_attribs['active_fi']],
strlen($a_attribs['pass']) ? $a_attribs['pass'] : 0,
($a_attribs["max_points"]) ? $a_attribs["max_points"] : 0,
($a_attribs["reached_points"]) ? $a_attribs["reached_points"] : 0,
strlen($a_attribs["mark_short"]) ? $a_attribs["mark_short"] : " ",
strlen($a_attribs["mark_official"]) ? $a_attribs["mark_official"] : " ",
($a_attribs["passed"]) ? 1 : 0,
($a_attribs["failed"]) ? 1 : 0,
$a_attribs["tstamp"]
)
);
break;
case 'tst_sequence':
$affectedRows = $ilDB->insert("tst_sequence", array(
"active_fi" => array("integer", $this->active_id_mapping[$a_attribs['active_fi']]),
"pass" => array("integer", $a_attribs['pass']),
"sequence" => array("clob", $a_attribs['sequence']),
"postponed" => array("text", (strlen($a_attribs['postponed'])) ? $a_attribs['postponed'] : NULL),
"hidden" => array("text", (strlen($a_attribs['hidden'])) ? $a_attribs['hidden'] : NULL),
"tstamp" => array("integer", $a_attribs['tstamp'])
));
break;
case 'tst_solutions':
$next_id = $ilDB->nextId('tst_solutions');
$affectedRows = $ilDB->insert("tst_solutions", array(
"solution_id" => array("integer", $next_id),
"active_fi" => array("integer", $this->active_id_mapping[$a_attribs['active_fi']]),
"question_fi" => array("integer", $this->question_id_mapping[$a_attribs['question_fi']]),
"value1" => array("clob", (strlen($a_attribs['value1'])) ? $a_attribs['value1'] : NULL),
"value2" => array("clob", (strlen($a_attribs['value2'])) ? $a_attribs['value2'] : NULL),
"pass" => array("integer", $a_attribs['pass']),
"tstamp" => array("integer", $a_attribs['tstamp'])
));
break;
case 'tst_test_result':
$next_id = $ilDB->nextId('tst_test_result');
$affectedRows = $ilDB->manipulateF("INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
array('integer', 'integer','integer', 'float', 'integer', 'integer','integer'),
array($next_id, $this->active_id_mapping[$a_attribs['active_fi']], $this->question_id_mapping[$a_attribs['question_fi']], $a_attribs['points'], $a_attribs['pass'], (strlen($a_attribs['manual'])) ? $a_attribs['manual'] : 0, $a_attribs['tstamp'])
);
break;
case 'tst_times':
$next_id = $ilDB->nextId('tst_times');
$affectedRows = $ilDB->manipulateF("INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
array('integer', 'integer', 'timestamp', 'timestamp', 'integer', 'integer'),
array($next_id, $this->active_id_mapping[$a_attribs['active_fi']], $a_attribs['started'], $a_attribs['finished'], $a_attribs['pass'], $a_attribs['tstamp'])
);
break;
}
break;
default:
$this->table = $a_name;
break;
}
}
ilTestResultsImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Definition at line 223 of file class.ilTestResultsImportParser.php.

References $ilLog.

{
switch (strtolower($a_name))
{
case "tst_active":
global $ilLog;
$ilLog->write("active id mapping: " . print_r($this->active_id_mapping, true));
break;
case "tst_test_question":
global $ilLog;
$ilLog->write("question id mapping: " . print_r($this->question_id_mapping, true));
break;
}
}
ilTestResultsImportParser::handlerParseCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 241 of file class.ilTestResultsImportParser.php.

{
// do nothing
}
ilTestResultsImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Reimplemented from ilSaxParser.

Definition at line 41 of file class.ilTestResultsImportParser.php.

{
xml_set_object($a_xml_parser,$this);
xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
xml_set_character_data_handler($a_xml_parser,'handlerParseCharacterData');
}

Field Documentation

ilTestResultsImportParser::$active_id_mapping
private

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

ilTestResultsImportParser::$question_id_mapping
private

Definition at line 18 of file class.ilTestResultsImportParser.php.

ilTestResultsImportParser::$table
private

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

ilTestResultsImportParser::$tst_obj
private

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

ilTestResultsImportParser::$user_criteria_checked = false
private

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

ilTestResultsImportParser::$user_criteria_field
private

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

ilTestResultsImportParser::$user_criteria_type
private

Definition at line 20 of file class.ilTestResultsImportParser.php.


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