11include_once(
"./Services/Xml/classes/class.ilSaxParser.php");
 
   31        $this->tst_obj = &$test_object;
 
   33        $this->active_id_mapping = array();
 
   34        $this->question_id_mapping = array();
 
   35        $this->user_criteria_checked = 
false;
 
   36        $this->src_pool_def_id_mapping = array();
 
   78        xml_set_object($a_xml_parser, $this);
 
   79        xml_set_element_handler($a_xml_parser, 
'handlerBeginTag', 
'handlerEndTag');
 
   80        xml_set_character_data_handler($a_xml_parser, 
'handlerParseCharacterData');
 
   91        $this->sametag = 
false;
 
   92        $this->characterbuffer = 
"";
 
   93        $this->depth[$a_xml_parser]++;
 
   94        $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
 
   95        $this->qti_element = $a_name;
 
   97        switch (strtolower($a_name)) {
 
  101                switch ($this->table) {
 
  103                        if (!$this->user_criteria_checked) {
 
  104                            $this->user_criteria_checked = 
true;
 
  105                            if (
$ilDB->tableColumnExists(
'usr_data', $a_attribs[
'user_criteria'])) {
 
  107                                $info = $analyzer->getFieldInformation(
'usr_data');
 
  108                                $this->user_criteria_field = $a_attribs[
'user_criteria'];
 
  109                                $this->user_criteria_type = $info[$a_attribs[
'user_criteria']][
'type'];
 
  113                        if (strlen($this->user_criteria_field)) {
 
  115                                "SELECT usr_id FROM usr_data WHERE " . $this->user_criteria_field . 
" =  %s",
 
  116                                array($this->user_criteria_type),
 
  117                                array($a_attribs[$this->user_criteria_field])
 
  121                                $usr_id = $row[
'usr_id'];
 
  124                        $next_id = 
$ilDB->nextId(
'tst_active');
 
  126                        $ilDB->insert(
'tst_active', array(
 
  127                            'active_id' => array(
'integer', $next_id),
 
  128                            'user_fi' => array(
'integer', $usr_id),
 
  129                            'anonymous_id' => array(
'text', strlen($a_attribs[
'anonymous_id']) ? $a_attribs[
'anonymous_id'] : 
null),
 
  130                            'test_fi' => array(
'integer', $this->tst_obj->getTestId()),
 
  131                            'lastindex' => array(
'integer', $a_attribs[
'lastindex']),
 
  132                            'tries' => array(
'integer', $a_attribs[
'tries']),
 
  133                            'submitted' => array(
'integer', $a_attribs[
'submitted']),
 
  134                            'submittimestamp' => array(
'timestamp', strlen($a_attribs[
'submittimestamp']) ? $a_attribs[
'submittimestamp'] : 
null),
 
  135                            'tstamp' => array(
'integer', $a_attribs[
'tstamp']),
 
  136                            'importname' => array(
'text', $a_attribs[
'fullname']),
 
  139                            'answerstatusfilter' => array(
'integer', $this->
fetchAttribute($a_attribs, 
'answer_status_filter')),
 
  140                            'objective_container' => array(
'integer', $this->
fetchAttribute($a_attribs, 
'objective_container'))
 
  142                        $this->active_id_mapping[$a_attribs[
'active_id']] = $next_id;
 
  144                    case 'tst_test_rnd_qst':
 
  145                        $nextId = 
$ilDB->nextId(
'tst_test_rnd_qst');
 
  146                        $newActiveId = $this->active_id_mapping[$a_attribs[
'active_fi']];
 
  147                        $newQuestionId = $this->question_id_mapping[$a_attribs[
'question_fi']];
 
  148                        $newSrcPoolDefId = $this->src_pool_def_id_mapping[$a_attribs[
'src_pool_def_fi']];
 
  149                        $ilDB->insert(
'tst_test_rnd_qst', array(
 
  150                            'test_random_question_id' => array(
'integer', $nextId),
 
  151                            'active_fi' => array(
'integer', $newActiveId),
 
  152                            'question_fi' => array(
'integer', $newQuestionId),
 
  153                            'sequence' => array(
'integer', $a_attribs[
'sequence']),
 
  154                            'pass' => array(
'integer', $a_attribs[
'pass']),
 
  155                            'tstamp' => array(
'integer', $a_attribs[
'tstamp']),
 
  156                            'src_pool_def_fi' => array(
'integer', $newSrcPoolDefId)
 
  159                    case 'tst_pass_result':
 
  160                        $affectedRows = 
$ilDB->manipulateF(
 
  161                            "INSERT INTO tst_pass_result (active_fi, pass, points, maxpoints, questioncount, answeredquestions, workingtime, tstamp) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
 
  173                                $this->active_id_mapping[$a_attribs[
'active_fi']],
 
  174                                strlen($a_attribs[
'pass']) ? $a_attribs[
'pass'] : 0,
 
  175                                ($a_attribs[
"points"]) ? $a_attribs[
"points"] : 0,
 
  176                                ($a_attribs[
"maxpoints"]) ? $a_attribs[
"maxpoints"] : 0,
 
  177                                $a_attribs[
"questioncount"],
 
  178                                $a_attribs[
"answeredquestions"],
 
  179                                ($a_attribs[
"workingtime"]) ? $a_attribs[
"workingtime"] : 0,
 
  184                    case 'tst_result_cache':
 
  185                        $affectedRows = 
$ilDB->manipulateF(
 
  186                            "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)",
 
  199                                $this->active_id_mapping[$a_attribs[
'active_fi']],
 
  200                                strlen($a_attribs[
'pass']) ? $a_attribs[
'pass'] : 0,
 
  201                                ($a_attribs[
"max_points"]) ? $a_attribs[
"max_points"] : 0,
 
  202                                ($a_attribs[
"reached_points"]) ? $a_attribs[
"reached_points"] : 0,
 
  203                                strlen($a_attribs[
"mark_short"]) ? $a_attribs[
"mark_short"] : 
" ",
 
  204                                strlen($a_attribs[
"mark_official"]) ? $a_attribs[
"mark_official"] : 
" ",
 
  205                                ($a_attribs[
"passed"]) ? 1 : 0,
 
  206                                ($a_attribs[
"failed"]) ? 1 : 0,
 
  212                        $affectedRows = 
$ilDB->insert(
"tst_sequence", array(
 
  213                            "active_fi" => array(
"integer", $this->active_id_mapping[$a_attribs[
'active_fi']]),
 
  214                            "pass" => array(
"integer", $a_attribs[
'pass']),
 
  215                            "sequence" => array(
"clob", $a_attribs[
'sequence']),
 
  216                            "postponed" => array(
"text", (strlen($a_attribs[
'postponed'])) ? $a_attribs[
'postponed'] : 
null),
 
  217                            "hidden" => array(
"text", (strlen($a_attribs[
'hidden'])) ? $a_attribs[
'hidden'] : 
null),
 
  218                            "tstamp" => array(
"integer", $a_attribs[
'tstamp'])
 
  221                    case 'tst_solutions':
 
  222                        $next_id = 
$ilDB->nextId(
'tst_solutions');
 
  223                        $affectedRows = 
$ilDB->insert(
"tst_solutions", array(
 
  224                            "solution_id" => array(
"integer", $next_id),
 
  225                            "active_fi" => array(
"integer", $this->active_id_mapping[$a_attribs[
'active_fi']]),
 
  226                            "question_fi" => array(
"integer", $this->question_id_mapping[$a_attribs[
'question_fi']]),
 
  227                            "value1" => array(
"clob", (strlen($a_attribs[
'value1'])) ? $a_attribs[
'value1'] : 
null),
 
  228                            "value2" => array(
"clob", (strlen($a_attribs[
'value2'])) ? $a_attribs[
'value2'] : 
null),
 
  229                            "pass" => array(
"integer", $a_attribs[
'pass']),
 
  230                            "tstamp" => array(
"integer", $a_attribs[
'tstamp'])
 
  233                    case 'tst_test_result':
 
  234                        $next_id = 
$ilDB->nextId(
'tst_test_result');
 
  235                        $affectedRows = 
$ilDB->manipulateF(
 
  236                            "INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
 
  237                            array(
'integer', 
'integer',
'integer', 
'float', 
'integer', 
'integer',
'integer'),
 
  238                            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'])
 
  242                        $next_id = 
$ilDB->nextId(
'tst_times');
 
  243                        $affectedRows = 
$ilDB->manipulateF(
 
  244                            "INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
 
  245                            array(
'integer', 
'integer', 
'timestamp', 
'timestamp', 
'integer', 
'integer'),
 
  246                            array($next_id, $this->active_id_mapping[$a_attribs[
'active_fi']], $a_attribs[
'started'], $a_attribs[
'finished'], $a_attribs[
'pass'], $a_attribs[
'tstamp'])
 
  252                $this->table = $a_name;
 
  262        switch (strtolower($a_name)) {
 
  265                $ilLog = 
$DIC[
'ilLog'];
 
  266                $ilLog->write(
"active id mapping: " . print_r($this->active_id_mapping, 
true));
 
  268            case "tst_test_question":
 
  270                $ilLog = 
$DIC[
'ilLog'];
 
  271                $ilLog->write(
"question id mapping: " . print_r($this->question_id_mapping, 
true));
 
  295        if (isset($attribs[
'last_finished_pass'])) {
 
  296            return $attribs[
'last_finished_pass'];
 
  299        if ($attribs[
'tries'] > 0) {
 
  300            return $attribs[
'tries'] - 1;
 
  308        if (isset($attribs[
'last_started_pass'])) {
 
  309            return $attribs[
'last_started_pass'];
 
  312        if ($attribs[
'tries'] > 0) {
 
  313            return $attribs[
'tries'] - 1;
 
An exception for terminatinating execution or to throw for unit testing.
This class gives all kind of DB information using the database manager and reverse module.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
Test results import parser.
setHandlers($a_xml_parser)
set event handler should be overwritten by inherited class @access private
fetchLastStartedPass($attribs)
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element parser
handlerParseCharacterData($a_xml_parser, $a_data)
handler for character data
setSrcPoolDefIdMapping($src_pool_def_id_mapping)
setQuestionIdMapping($question_id_mapping)
__construct($a_xml_file, &$test_object)
Constructor.
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
fetchLastFinishedPass($attribs)
fetchAttribute($attributes, $name)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc