Example #1
0
 function handlerCharacterData($a_xml_parser, $a_data)
 {
     if ($this->in_meta_data) {
         parent::handlerCharacterData($a_xml_parser, $a_data);
         return true;
     }
 }
 /**
  * handler for character data
  *
  * @param	resource	$a_xml_parser		xml parser
  * @param	string		$a_data				character data
  */
 public function handlerCharacterData($a_xml_parser, $a_data)
 {
     if ($this->in_metadata) {
         parent::handlerCharacterData($a_xml_parser, $a_data);
     }
     if ($a_data != "\n") {
         // Replace multiple tabs with one space
         $a_data = preg_replace("/\t+/", " ", $a_data);
         $this->cdata .= $a_data;
     }
 }
 /**
  * send all cached tags to the meta data parser and
  * clear the cache
  */
 function emptyMediaMetaCache(&$a_xml_parser)
 {
     foreach ($this->media_meta_cache as $cache_entry) {
         switch ($cache_entry["type"]) {
             case "handlerBeginTag":
                 parent::handlerBeginTag($a_xml_parser, $cache_entry["par1"], $cache_entry["par2"]);
                 break;
             case "handlerEndTag":
                 parent::handlerEndTag($a_xml_parser, $cache_entry["par1"]);
                 break;
             case "handlerCharacterData":
                 parent::handlerCharacterData($a_xml_parser, $cache_entry["par1"]);
                 break;
         }
     }
     $this->media_meta_start = false;
     $this->media_meta_cache[] = array();
 }
 /**
  * handler for end of element
  */
 function handlerEndTag($a_xml_parser, $a_name)
 {
     switch ($a_name) {
         case "surveyobject":
             if (is_object($this->survey)) {
                 $this->survey->setStatus($this->survey_status);
                 $this->survey->saveToDb();
                 // write question blocks
                 if (count($this->questionblocks)) {
                     foreach ($this->questionblocks as $data) {
                         $questionblock = $data["questions"];
                         $title = $data["title"];
                         $qblock = array();
                         foreach ($questionblock as $question_id) {
                             array_push($qblock, $this->questions[$question_id]);
                         }
                         $this->survey->createQuestionblock($title, $this->showQuestiontext, false, $qblock);
                     }
                 }
                 // #13878 - write constraints
                 if (count($this->constraints)) {
                     $relations = $this->survey->getAllRelations(TRUE);
                     foreach ($this->constraints as $constraint) {
                         $constraint_id = $this->survey->addConstraint($this->questions[$constraint["destref"]], $relations[$constraint["relation"]]["id"], $constraint["value"], $constraint["conjunction"]);
                         $this->survey->addConstraintToQuestion($this->questions[$constraint["sourceref"]], $constraint_id);
                     }
                 }
                 // write textblocks
                 if (count($this->textblocks)) {
                     foreach ($this->textblocks as $original_id => $textblock) {
                         $this->survey->saveHeading($textblock, $this->questions[$original_id]);
                     }
                 }
             }
             break;
         case "survey":
             $this->in_survey = FALSE;
             if (is_object($this->survey)) {
                 if (strcmp($this->surveyaccess, "free") == 0) {
                     $this->survey->setAnonymize(2);
                 } else {
                     if ($this->anonymisation == 0) {
                         $this->survey->setAnonymize(0);
                     } else {
                         $this->survey->setAnonymize(1);
                     }
                 }
             }
             break;
         case "startingtime":
             if (preg_match("/(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2})-(\\d{2})-(\\d{2}).*/", $this->characterbuffer, $matches)) {
                 if (is_object($this->survey)) {
                     $this->survey->setStartDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
                     $this->survey->setStartDateEnabled(1);
                 }
             }
             break;
         case "endingtime":
             if (preg_match("/(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2})-(\\d{2})-(\\d{2}).*/", $this->characterbuffer, $matches)) {
                 if (is_object($this->survey)) {
                     $this->survey->setEndDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
                     $this->survey->setEndDateEnabled(1);
                 }
             }
             break;
         case "description":
             if ($this->in_survey) {
                 if (is_object($this->survey)) {
                     $this->survey->setDescription($this->characterbuffer);
                 }
             } else {
                 if (is_object($this->activequestion)) {
                     $this->activequestion->setDescription($this->characterbuffer);
                 }
             }
             break;
         case "question":
             if (is_object($this->activequestion)) {
                 if (strlen($this->textblock)) {
                     $this->textblocks[$this->original_question_id] = $this->textblock;
                 }
                 $this->activequestion->saveToDb();
                 // duplicate the question for the survey (if pool is to be used)
                 if (is_object($this->survey) && $this->spl_id > 0) {
                     $question_id = $this->activequestion->duplicate(TRUE);
                 } else {
                     $question_id = $this->activequestion->getId();
                 }
                 $this->survey->addQuestion($question_id);
                 $this->questions[$this->original_question_id] = $question_id;
                 $this->activequestion = NULL;
             }
             $this->textblock = "";
             break;
         case "author":
             if ($this->in_survey) {
                 if (is_object($this->survey)) {
                     $this->survey->setAuthor($this->characterbuffer);
                 }
             } else {
                 if (is_object($this->activequestion)) {
                     $this->activequestion->setAuthor($this->characterbuffer);
                 }
             }
             break;
         case "mattext":
             $this->material[count($this->material) - 1]["text"] = $this->characterbuffer;
             break;
         case "matimage":
             $this->material[count($this->material) - 1]["image"] = $this->characterbuffer;
             break;
         case "material":
             if ($this->in_survey) {
                 if (strcmp($this->getParent($a_xml_parser), "objectives") == 0) {
                     if (strcmp($this->material[0]["label"], "introduction") == 0) {
                         if (is_object($this->survey)) {
                             $this->survey->setIntroduction($this->material[0]["text"]);
                         }
                     }
                     if (strcmp($this->material[0]["label"], "outro") == 0) {
                         if (is_object($this->survey)) {
                             $this->survey->setOutro($this->material[0]["text"]);
                         }
                     }
                     $this->material = array();
                 }
             } else {
                 if (strcmp($this->getParent($a_xml_parser), "question") == 0) {
                     $this->activequestion->setMaterial($this->material[0]["text"], TRUE, $this->material[0]["label"]);
                 }
             }
             break;
         case "questiontext":
             if (is_object($this->activequestion)) {
                 $questiontext = "";
                 foreach ($this->material as $matarray) {
                     $questiontext .= $matarray["text"];
                 }
                 $this->activequestion->setQuestiontext($questiontext);
             }
             $this->material = array();
             break;
         case "fieldlabel":
             $this->metadata[count($this->metadata) - 1]["label"] = $this->characterbuffer;
             break;
         case "fieldentry":
             $this->metadata[count($this->metadata) - 1]["entry"] = $this->characterbuffer;
             break;
         case "metadata":
             if (strcmp($this->getParent($a_xml_parser), "question") == 0) {
                 if (is_object($this->activequestion)) {
                     $this->activequestion->importAdditionalMetadata($this->metadata);
                 }
             }
             if (strcmp($this->getParent($a_xml_parser), "survey") == 0) {
                 foreach ($this->metadata as $key => $value) {
                     switch ($value["label"]) {
                         case "SCORM":
                             if (strlen($value["entry"])) {
                                 if (is_object($this->survey)) {
                                     include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
                                     include_once "./Services/MetaData/classes/class.ilMD.php";
                                     $md_sax_parser = new ilMDSaxParser();
                                     $md_sax_parser->setXMLContent($value["entry"]);
                                     $md_sax_parser->setMDObject($tmp = new ilMD($this->survey->getId(), 0, "svy"));
                                     $md_sax_parser->enableMDParsing(true);
                                     $md_sax_parser->startParsing();
                                     $this->survey->MDUpdateListener("General");
                                 }
                             }
                             break;
                         case "display_question_titles":
                             if ($value["entry"] == 1) {
                                 $this->survey->showQuestionTitles();
                             } else {
                                 $this->survey->hideQuestionTitles();
                             }
                             break;
                         case "status":
                             $this->survey_status = $value["entry"];
                             break;
                         case "evaluation_access":
                             $this->survey->setEvaluationAccess($value["entry"]);
                             break;
                         case "pool_usage":
                             $this->survey->setPoolUsage($value["entry"]);
                             break;
                         case "own_results_view":
                             $this->survey->setViewOwnResults($value["entry"]);
                             break;
                         case "own_results_mail":
                             $this->survey->setMailOwnResults($value["entry"]);
                             break;
                         case "mode_360":
                             $this->survey->set360Mode($value["entry"]);
                             break;
                         case "mode_360_self_eval":
                             $this->survey->set360SelfEvaluation($value["entry"]);
                             break;
                         case "mode_360_self_rate":
                             $this->survey->set360SelfRaters($value["entry"]);
                             break;
                         case "mode_360_self_appr":
                             $this->survey->set360SelfAppraisee($value["entry"]);
                             break;
                         case "mode_360_results":
                             $this->survey->set360Results($value["entry"]);
                             break;
                         case "mode_360_skill_service":
                             $this->survey->set360SkillService($value["entry"]);
                             break;
                     }
                 }
             }
             if (!$this->spl_exists) {
                 if (strcmp($this->getParent($a_xml_parser), "surveyquestions") == 0) {
                     foreach ($this->metadata as $key => $value) {
                         if (strcmp($value["label"], "SCORM") == 0) {
                             if (strlen($value["entry"])) {
                                 if ($this->spl_id > 0) {
                                     include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
                                     include_once "./Services/MetaData/classes/class.ilMD.php";
                                     include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
                                     $md_sax_parser = new ilMDSaxParser();
                                     $md_sax_parser->setXMLContent($value["entry"]);
                                     $md_sax_parser->setMDObject($tmp = new ilMD($this->spl_id, 0, "spl"));
                                     $md_sax_parser->enableMDParsing(true);
                                     $md_sax_parser->startParsing();
                                     $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
                                     $spl->MDUpdateListener("General");
                                 }
                             }
                         }
                     }
                 }
             }
             break;
         case "responses":
             if (is_object($this->activequestion)) {
                 $this->activequestion->importResponses($this->responses);
             }
             $this->is_matrix = FALSE;
             break;
         case "variable":
             array_push($this->variables, $this->characterbuffer);
             break;
         case "variables":
             if (is_object($this->activequestion)) {
                 $this->activequestion->importVariables($this->variables);
             }
             break;
         case "response_single":
         case "response_multiple":
         case "response_text":
         case "response_num":
         case "response_time":
             $this->responses[$this->response_id]["material"] = $this->material;
             break;
         case "adjective":
             $this->adjectives[count($this->adjectives) - 1]["text"] = $this->characterbuffer;
             break;
         case "bipolar_adjectives":
             if (is_object($this->activequestion)) {
                 $this->activequestion->importAdjectives($this->adjectives);
             }
             break;
         case "matrixrow":
             $row = "";
             foreach ($this->material as $material) {
                 $row .= $material["text"];
             }
             $this->matrix[count($this->matrix) - 1] = array('title' => $row, 'id' => $this->matrixrowattribs['id'], 'label' => $this->matrixrowattribs['label'], 'other' => $this->matrixrowattribs['other']);
             break;
         case "matrix":
             if (is_object($this->activequestion)) {
                 $this->activequestion->importMatrix($this->matrix);
             }
             break;
         case "textblock":
             $this->textblock = $this->characterbuffer;
             break;
         case "questionblocktitle":
             $this->questionblocktitle = $this->characterbuffer;
             break;
         case "questionblock":
             $this->in_questionblock = FALSE;
             array_push($this->questionblocks, array("title" => $this->questionblocktitle, "questions" => $this->questionblock));
             break;
     }
     $this->depth[$a_xml_parser]--;
 }
 /**
  * handler for end of element
  */
 function handlerEndTag($a_xml_parser, $a_name)
 {
     switch ($a_name) {
         case "questestinterop":
             if (is_object($this->survey)) {
                 // write constraints
                 if (count($this->constraints)) {
                     $relations = $this->survey->getAllRelations(TRUE);
                     foreach ($this->constraints as $constraint) {
                         $this->survey->addConstraint($this->questions[$constraint["sourceref"]], $this->questions[$constraint["destref"]], $relations[$constraint["relation"]]["id"], $constraint["value"]);
                     }
                 }
                 // write question blocks
                 if (count($this->questionblocks)) {
                     foreach ($this->questionblocks as $data) {
                         $questionblock = $data["questions"];
                         $title = $data["title"];
                         $qblock = array();
                         foreach ($questionblock as $question_id) {
                             array_push($qblock, $this->questions[$question_id]);
                         }
                         $this->survey->createQuestionblock($title, TRUE, $qblock);
                     }
                 }
                 $this->survey->saveToDb();
                 // write textblocks
                 if (count($this->textblocks)) {
                     foreach ($this->textblocks as $original_id => $textblock) {
                         $this->survey->saveHeading($textblock, $this->questions[$original_id]);
                     }
                 }
             }
             break;
         case "survey":
             $this->in_survey = FALSE;
             break;
         case "item":
             if (is_object($this->activequestion)) {
                 $this->activequestion->setTitle($this->question_title);
                 $this->activequestion->setDescription($this->question_description);
                 $this->activequestion->saveToDb();
                 if (is_object($this->survey)) {
                     // duplicate the question for the survey
                     $question_id = $this->activequestion->duplicate(TRUE);
                     $this->survey->addQuestion($question_id);
                     $this->questions[$this->original_question_id] = $question_id;
                 }
             }
             $this->in_question = FALSE;
             $this->question_description = "";
             $this->activequestion = NULL;
             break;
         case "qticomment":
             if (strcmp($this->getParent($a_xml_parser), "item") == 0) {
                 if (preg_match("/Questiontype\\=(.*)/", $this->characterbuffer, $matches)) {
                     $questiontype = $matches[1];
                     switch ($matches[1]) {
                         case METRIC_QUESTION_IDENTIFIER:
                             $questiontype = "SurveyMetricQuestion";
                             break;
                         case NOMINAL_QUESTION_IDENTIFIER:
                             $questiontype = "SurveyMultipleChoiceQuestion";
                             break;
                         case ORDINAL_QUESTION_IDENTIFIER:
                             $questiontype = "SurveySingleChoiceQuestion";
                             break;
                         case TEXT_QUESTION_IDENTIFIER:
                             $questiontype = "SurveyTextQuestion";
                             break;
                     }
                     if (strlen($questiontype)) {
                         include_once "./Modules/SurveyQuestionPool/classes/class.{$questiontype}.php";
                         $this->activequestion = new $questiontype();
                         $this->activequestion->setObjId($this->spl_id);
                     } else {
                         $this->activequestion = NULL;
                     }
                 } else {
                     if (preg_match("/Author\\=(.*)/", $this->characterbuffer, $matches)) {
                         if (is_object($this->activequestion)) {
                             $this->activequestion->setAuthor($matches[1]);
                         }
                     } else {
                         if (preg_match("/ILIAS Version\\=(.*)/", $this->characterbuffer, $matches)) {
                         } else {
                             $this->question_description = $this->characterbuffer;
                         }
                     }
                 }
             }
             if (strcmp($this->getParent($a_xml_parser), "survey") == 0) {
                 if (preg_match("/Author\\=(.*)/", $this->characterbuffer, $matches)) {
                     if (is_object($this->survey)) {
                         $this->survey->setAuthor($matches[1]);
                     }
                 } else {
                     if (preg_match("/ILIAS Version\\=(.*)/", $this->characterbuffer, $matches)) {
                     } else {
                         if (is_object($this->survey)) {
                             $this->survey->setDescription($this->characterbuffer);
                         }
                     }
                 }
             }
             break;
         case "fieldlabel":
             $this->metadata[count($this->metadata) - 1]["label"] = $this->characterbuffer;
             break;
         case "fieldentry":
             $this->metadata[count($this->metadata) - 1]["entry"] = $this->characterbuffer;
             break;
         case "qtimetadata":
             if (strcmp($this->getParent($a_xml_parser), "section") == 0) {
                 foreach ($this->metadata as $meta) {
                     switch ($meta["label"]) {
                         case "SCORM":
                             if (!$this->spl_exists) {
                                 include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
                                 include_once "./Services/MetaData/classes/class.ilMD.php";
                                 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
                                 $md_sax_parser = new ilMDSaxParser();
                                 $md_sax_parser->setXMLContent($value["entry"]);
                                 $md_sax_parser->setMDObject($tmp = new ilMD($this->spl_id, 0, "spl"));
                                 $md_sax_parser->enableMDParsing(true);
                                 $md_sax_parser->startParsing();
                                 $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
                                 $spl->MDUpdateListener("General");
                                 break;
                             }
                     }
                 }
             }
             if (is_object($this->activequestion)) {
                 foreach ($this->metadata as $meta) {
                     switch ($this->activequestion->getQuestionType()) {
                         case "SurveyMultipleQuestion":
                             switch ($meta["label"]) {
                                 case "obligatory":
                                     $this->activequestion->setObligatory($meta["entry"]);
                                     break;
                                 case "orientation":
                                     $this->activequestion->setOrientation($meta["entry"]);
                                     break;
                             }
                             break;
                         case "SurveySingleChoiceQuestion":
                             switch ($meta["label"]) {
                                 case "obligatory":
                                     $this->activequestion->setObligatory($meta["entry"]);
                                     break;
                                 case "orientation":
                                     $this->activequestion->setOrientation($meta["entry"]);
                                     break;
                             }
                             break;
                         case "SurveyMetricQuestion":
                             switch ($meta["label"]) {
                                 case "obligatory":
                                     $this->activequestion->setObligatory($meta["entry"]);
                                     break;
                                 case "subtype":
                                     $this->activequestion->setSubtype($meta["entry"]);
                                     break;
                             }
                             break;
                         case "SurveyTextQuestion":
                             switch ($meta["label"]) {
                                 case "obligatory":
                                     $this->activequestion->setObligatory($meta["entry"]);
                                     break;
                                 case "maxchars":
                                     if (strlen($meta["entry"])) {
                                         $this->activequestion->setMaxChars($meta["entry"]);
                                     }
                                     break;
                             }
                             break;
                     }
                 }
             }
             if (is_object($this->survey)) {
                 foreach ($this->metadata as $meta) {
                     switch ($meta["label"]) {
                         case "SCORM":
                             if (strcmp($this->getParent($a_xml_parser), "survey") == 0) {
                                 include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
                                 include_once "./Services/MetaData/classes/class.ilMD.php";
                                 $md_sax_parser = new ilMDSaxParser();
                                 $md_sax_parser->setXMLContent($meta["entry"]);
                                 $md_sax_parser->setMDObject($tmp = new ilMD($this->survey->getId(), 0, "svy"));
                                 $md_sax_parser->enableMDParsing(TRUE);
                                 $md_sax_parser->startParsing();
                                 $this->survey->MDUpdateListener("General");
                             }
                             break;
                         case "author":
                             $this->survey->setAuthor($meta["entry"]);
                             break;
                         case "description":
                             $this->survey->setDescription($meta["entry"]);
                             break;
                         case "evaluation_access":
                             $this->survey->setEvaluationAccess($meta["entry"]);
                             break;
                         case "evaluation_access":
                             $this->survey->setEvaluationAccess($meta["entry"]);
                             break;
                         case "anonymize":
                             $this->survey->setAnonymize($meta["entry"]);
                             break;
                         case "status":
                             $this->survey->setStatus($meta["entry"]);
                             break;
                         case "startdate":
                             if (preg_match("/P(\\d+)Y(\\d+)M(\\d+)DT0H0M0S/", $meta["entry"], $matches)) {
                                 $this->survey->setStartDate(sprintf("%04d-%02d-%02d", $matches[1], $matches[2], $matches[3]));
                                 $this->survey->setStartDateEnabled(1);
                             }
                             break;
                         case "enddate":
                             if (preg_match("/P(\\d+)Y(\\d+)M(\\d+)DT0H0M0S/", $meta["entry"], $matches)) {
                                 $this->survey->setEndDate(sprintf("%04d-%02d-%02d", $matches[1], $matches[2], $matches[3]));
                                 $this->survey->setEndDateEnabled(1);
                             }
                             break;
                         case "display_question_titles":
                             if ($meta["entry"]) {
                                 $this->survey->showQuestionTitles();
                             }
                             break;
                     }
                     if (preg_match("/questionblock_(\\d+)/", $meta["label"], $matches)) {
                         // handle questionblocks
                         $qb = $meta["entry"];
                         preg_match("/<title>(.*?)<\\/title>/", $qb, $matches);
                         $qb_title = $matches[1];
                         preg_match("/<questions>(.*?)<\\/questions>/", $qb, $matches);
                         $qb_questions = $matches[1];
                         $qb_questions_array = explode(",", $qb_questions);
                         array_push($this->questionblocks, array("title" => $qb_title, "questions" => $qb_questions_array));
                     }
                     if (preg_match("/constraint_(\\d+)/", $meta["label"], $matches)) {
                         $constraint = $meta["entry"];
                         $constraint_array = explode(",", $constraint);
                         if (count($constraint_array) == 3) {
                             array_push($this->constraints, array("sourceref" => $matches[1], "destref" => $constraint_array[0], "relation" => $constraint_array[1], "value" => $constraint_array[2]));
                         }
                     }
                     if (preg_match("/heading_(\\d+)/", $meta["label"], $matches)) {
                         $heading = $meta["entry"];
                         $this->textblocks[$matches[1]] = $heading;
                     }
                 }
             }
             break;
         case "mattext":
             $this->material[count($this->material) - 1]["text"] = $this->characterbuffer;
             break;
         case "matimage":
             $this->material[count($this->material) - 1]["image"] = $this->characterbuffer;
             break;
         case "material":
             if ($this->in_survey) {
                 if (strcmp($this->getParent($a_xml_parser), "objectives") == 0) {
                     if (strcmp($this->material[0]["label"], "introduction") == 0) {
                         if (is_object($this->survey)) {
                             $this->survey->setIntroduction($this->material[0]["text"]);
                         }
                     }
                     if (strcmp($this->material[0]["label"], "outro") == 0) {
                         if (is_object($this->survey)) {
                             $this->survey->setOutro($this->material[0]["text"]);
                         }
                     }
                     $this->material = array();
                 }
             } else {
                 switch ($this->getParent($a_xml_parser)) {
                     case "response_num":
                     case "response_lid":
                     case "response_str":
                         if (is_object($this->activequestion)) {
                             $this->activequestion->setMaterial($this->material[0]["text"], TRUE, $this->material[0]["label"]);
                         }
                         break;
                     case "flow":
                         if (is_object($this->activequestion)) {
                             $this->activequestion->setQuestiontext($this->material[0]["text"]);
                         }
                         break;
                 }
                 if (is_object($this->activequestion)) {
                     if ($this->in_response) {
                         switch ($this->activequestion->getQuestiontype()) {
                             case "SurveyMultipleChoiceQuestion":
                             case "SurveySingleChoiceQuestion":
                                 $this->activequestion->categories->addCategory($this->material[0]["text"]);
                                 break;
                         }
                     }
                 }
             }
             break;
         case "response_label":
             $this->in_response = FALSE;
             break;
     }
     $this->depth[$a_xml_parser]--;
 }