Survey Question Import Parser. More...
Inheritance diagram for SurveyImportParserPre38:
Collaboration diagram for SurveyImportParserPre38:Survey Question Import Parser.
Definition at line 43 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::getErrorCode | ( | ) |
Definition at line 678 of file class.SurveyImportParserPre38.php.
{
return $this->error_code;
}
| SurveyImportParserPre38::getErrorColumn | ( | ) |
Definition at line 688 of file class.SurveyImportParserPre38.php.
{
return $this->error_col;
}
| SurveyImportParserPre38::getErrorLine | ( | ) |
Definition at line 683 of file class.SurveyImportParserPre38.php.
{
return $this->error_line;
}
| SurveyImportParserPre38::getErrorMessage | ( | ) |
Definition at line 693 of file class.SurveyImportParserPre38.php.
{
return $this->error_msg;
}
| SurveyImportParserPre38::getFullError | ( | ) |
Definition at line 698 of file class.SurveyImportParserPre38.php.
{
return "Error: ".$this->error_msg." at line:".$this->error_line ." column:".$this->error_col;
}
| SurveyImportParserPre38::getParent | ( | $ | a_xml_parser | ) |
Definition at line 194 of file class.SurveyImportParserPre38.php.
Referenced by handlerEndTag().
{
if ($this->depth[$a_xml_parser] > 0)
{
return $this->path[$this->depth[$a_xml_parser]-1];
}
else
{
return "";
}
}
Here is the caller graph for this function:| SurveyImportParserPre38::getXMLAttributes | ( | ) |
Definition at line 713 of file class.SurveyImportParserPre38.php.
{
return $this->attributes;
}
| SurveyImportParserPre38::getXMLElements | ( | ) |
Definition at line 708 of file class.SurveyImportParserPre38.php.
{
return $this->elements;
}
| SurveyImportParserPre38::getXMLSize | ( | ) |
Definition at line 703 of file class.SurveyImportParserPre38.php.
{
return $this->size;
}
| SurveyImportParserPre38::getXMLTextSections | ( | ) |
Definition at line 718 of file class.SurveyImportParserPre38.php.
{
return $this->texts;
}
| SurveyImportParserPre38::getXMLTextSize | ( | ) |
Definition at line 723 of file class.SurveyImportParserPre38.php.
{
return $this->text_size;
}
| SurveyImportParserPre38::handlerBeginTag | ( | $ | a_xml_parser, | |
| $ | a_name, | |||
| $ | a_attribs | |||
| ) |
handler for begin of element
Definition at line 209 of file class.SurveyImportParserPre38.php.
{
$this->depth[$a_xml_parser]++;
$this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
$this->characterbuffer = "";
$this->activetag = $a_name;
$this->elements++;
$this->attributes+=count($a_attribs);
switch ($a_name)
{
case "survey":
$this->in_survey = TRUE;
if (is_object($this->survey))
{
if (strlen($a_attribs["title"]))
{
$this->survey->setTitle($a_attribs["title"]);
}
}
break;
case "section":
$this->spl->setTitle($a_attribs["title"]);
break;
case "item":
$this->original_question_id = $a_attribs["ident"];
$this->question_title = $a_attribs["title"];
$this->in_question = TRUE;
break;
case "qtimetadata":
$this->metadata = array();
break;
case "qtimetadatafield":
array_push($this->metadata, array("label" => "", "entry" => ""));
break;
case "material":
$this->material = array();
array_push($this->material, array("text" => "", "image" => "", "label" => $a_attribs["label"]));
break;
case "render_fib":
if (is_object($this->activequestion))
{
if (strlen($a_attribs["minnumber"]))
{
$this->activequestion->setMinimum($a_attribs["minnumber"]);
}
if (strlen($a_attribs["maxnumber"]))
{
$this->activequestion->setMaximum($a_attribs["maxnumber"]);
}
}
break;
case "response_lid":
if (is_object($this->activequestion))
{
if (strcmp($this->activequestion->getQuestiontype(), "SurveyNominalQuestion") == 0)
{
switch (strtolower($a_attribs["rcardinality"]))
{
case "single":
$this->activequestion->setSubtype(1);
break;
case "multiple":
$this->activequestion->setSubtype(2);
break;
}
}
}
break;
case "response_label":
$this->in_response = TRUE;
break;
}
}
| SurveyImportParserPre38::handlerCharacterData | ( | $ | a_xml_parser, | |
| $ | a_data | |||
| ) |
handler for character data
Definition at line 286 of file class.SurveyImportParserPre38.php.
{
$this->texts++;
$this->text_size+=strlen($a_data);
$this->characterbuffer .= $a_data;
$a_data = $this->characterbuffer;
}
| SurveyImportParserPre38::handlerEndTag | ( | $ | a_xml_parser, | |
| $ | a_name | |||
| ) |
handler for end of element
Definition at line 297 of file class.SurveyImportParserPre38.php.
References $data, $questionblock, $textblock, $title, and getParent().
{
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 = "SurveyNominalQuestion";
break;
case ORDINAL_QUESTION_IDENTIFIER:
$questiontype = "SurveyOrdinalQuestion";
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->getId());
}
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";
$md_sax_parser = new ilMDSaxParser();
$md_sax_parser->setXMLContent($meta["entry"]);
$md_sax_parser->setMDObject($tmp = new ilMD($this->spl->getId(), 0, "spl"));
$md_sax_parser->enableMDParsing(TRUE);
$md_sax_parser->startParsing();
$this->spl->MDUpdateListener("General");
break;
}
}
}
}
if (is_object($this->activequestion))
{
foreach ($this->metadata as $meta)
{
switch ($this->activequestion->getQuestionType())
{
case "SurveyNominalQuestion":
switch ($meta["label"])
{
case "obligatory":
$this->activequestion->setObligatory($meta["entry"]);
break;
case "orientation":
$this->activequestion->setOrientation($meta["entry"]);
break;
}
break;
case "SurveyOrdinalQuestion":
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 "SurveyNominalQuestion":
case "SurveyOrdinalQuestion":
$this->activequestion->categories->addCategory($this->material[0]["text"]);
break;
}
}
}
}
break;
case "response_label":
$this->in_response = FALSE;
break;
}
$this->depth[$a_xml_parser]--;
}
Here is the call graph for this function:| SurveyImportParserPre38::hasError | ( | ) |
Definition at line 728 of file class.SurveyImportParserPre38.php.
{
return $this->has_error;
}
| SurveyImportParserPre38::parse | ( | $ | a_xml_parser, | |
| $ | a_fp = null | |||
| ) |
parse xml file
private
Reimplemented from ilSaxParser.
Definition at line 165 of file class.SurveyImportParserPre38.php.
References $data, ilSaxParser::getInputType(), and ilSaxParser::getXMLContent().
{
switch($this->getInputType())
{
case 'file':
while($data = fread($a_fp,4096))
{
$parseOk = xml_parse($a_xml_parser,$data,feof($a_fp));
}
break;
case 'string':
$parseOk = xml_parse($a_xml_parser,$this->getXMLContent());
break;
}
if(!$parseOk
&& (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE))
{
$this->error_code = xml_get_error_code($a_xml_parser);
$this->error_line = xml_get_current_line_number($a_xml_parser);
$this->error_col = xml_get_current_column_number($a_xml_parser);
$this->error_msg = xml_error_string($a_xml_parser);
$this->has_error = TRUE;
return false;
}
return true;
}
Here is the call graph for this function:| SurveyImportParserPre38::setHandlers | ( | $ | a_xml_parser | ) |
set event handler should be overwritten by inherited class private
Reimplemented from ilSaxParser.
Definition at line 145 of file class.SurveyImportParserPre38.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,'handlerCharacterData');
}
| SurveyImportParserPre38::setSurveyObject | ( | &$ | a_svy | ) |
Sets a reference to a survey object public.
Definition at line 135 of file class.SurveyImportParserPre38.php.
{
$this->survey =& $a_svy;
}
| SurveyImportParserPre38::startParsing | ( | ) |
start the parser
Reimplemented from ilSaxParser.
Definition at line 155 of file class.SurveyImportParserPre38.php.
{
parent::startParsing();
}
| SurveyImportParserPre38::SurveyImportParserPre38 | ( | &$ | a_spl, | |
| $ | a_xml_file = '', |
|||
| $ | spl_exists = FALSE | |||
| ) |
Constructor.
| string | $a_xml_file xml file |
public
Definition at line 95 of file class.SurveyImportParserPre38.php.
References $spl_exists, and ilSaxParser::ilSaxParser().
{
parent::ilSaxParser($a_xml_file);
$this->spl =& $a_spl;
$this->has_error = FALSE;
$this->characterbuffer = "";
$this->activetag = "";
$this->material = array();
$this->depth = array();
$this->path = array();
$this->metadata = array();
$this->responses = array();
$this->response_id = "";
$this->matrix = array();
$this->is_matrix = FALSE;
$this->adjectives = array();
$this->spl_exists = $spl_exists;
$this->survey = NULL;
$this->in_survey = FALSE;
$this->anonymisation = 0;
$this->surveyaccess = "restricted";
$this->questions = array();
$this->original_question_id = "";
$this->constraints = array();
$this->textblock = "";
$this->textblocks = array();
$this->in_questionblock = FALSE;
$this->questionblocks = array();
$this->questionblock = array();
$this->questionblocktitle = "";
$this->question_title = "";
$this->in_question = FALSE;
$this->in_response = FALSE;
$this->question_description = "";
}
Here is the call graph for this function:| SurveyImportParserPre38::$activequestion |
Definition at line 47 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$activetag |
Definition at line 60 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$adjectives |
Definition at line 67 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$anonymisation |
Definition at line 71 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$attributes |
Definition at line 56 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$characterbuffer |
Definition at line 59 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$constraints |
Definition at line 75 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$depth |
Definition at line 46 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$elements |
Definition at line 55 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$error_code |
Definition at line 49 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$error_col |
Definition at line 51 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$error_line |
Definition at line 50 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$error_msg |
Definition at line 52 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$has_error |
Definition at line 53 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$in_question |
Definition at line 84 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$in_questionblock |
Definition at line 78 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$in_reponse |
Definition at line 85 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$in_survey |
Definition at line 69 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$is_matrix |
Definition at line 66 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$material |
Definition at line 61 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$matrix |
Definition at line 65 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$metadata |
Definition at line 62 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$original_question_id |
Definition at line 74 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$path |
Definition at line 45 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$question_description |
Definition at line 86 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$question_title |
Definition at line 83 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$questionblock |
Definition at line 79 of file class.SurveyImportParserPre38.php.
Referenced by handlerEndTag().
| SurveyImportParserPre38::$questionblocks |
Definition at line 80 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$questionblocktitle |
Definition at line 81 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$questions |
Definition at line 73 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$response_id |
Definition at line 64 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$responses |
Definition at line 63 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$size |
Definition at line 54 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$spl |
Definition at line 48 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$spl_exists |
Definition at line 68 of file class.SurveyImportParserPre38.php.
Referenced by SurveyImportParserPre38().
| SurveyImportParserPre38::$survey |
Definition at line 70 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$surveyaccess |
Definition at line 72 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$text_size |
Definition at line 58 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$textblock |
Definition at line 76 of file class.SurveyImportParserPre38.php.
Referenced by handlerEndTag().
| SurveyImportParserPre38::$textblocks |
Definition at line 77 of file class.SurveyImportParserPre38.php.
| SurveyImportParserPre38::$texts |
Definition at line 57 of file class.SurveyImportParserPre38.php.
1.7.1