ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SurveyImportParser Class Reference

Survey Question Import Parser. More...

+ Inheritance diagram for SurveyImportParser:
+ Collaboration diagram for SurveyImportParser:

Public Member Functions

 __construct ($a_spl_id, $a_xml_file='', $spl_exists=false, $a_mapping=null)
 Constructor. More...
 
 setSurveyObject ($a_svy)
 Sets a reference to a survey object public. More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 startParsing ()
 start the parser More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 getParent ($a_xml_parser)
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 getErrorCode ()
 
 getErrorLine ()
 
 getErrorColumn ()
 
 getErrorMessage ()
 
 getFullError ()
 
 getXMLSize ()
 
 getXMLElements ()
 
 getXMLAttributes ()
 
 getXMLTextSections ()
 
 getXMLTextSize ()
 
 hasError ()
 
- Public Member Functions inherited from ilSaxParser
 __construct ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
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. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $path
 
 $depth
 
 $activequestion
 
 $spl
 
 $error_code
 
 $error_line
 
 $error_col
 
 $error_msg
 
 $has_error
 
 $size
 
 $elements
 
 $attributes
 
 $texts
 
 $text_size
 
 $characterbuffer
 
 $activetag
 
 $material
 
 $metadata
 
 $responses
 
 $variables
 
 $response_id
 
 $matrix
 
 $matrixrowattribs
 
 $is_matrix
 
 $adjectives
 
 $spl_exists
 
 $in_survey
 
 $survey
 
 $anonymisation
 
 $surveyaccess
 
 $questions
 
 $original_question_id
 
 $constraints
 
 $textblock
 
 $textblocks
 
 $survey_status
 
 $in_questionblock
 
 $questionblock
 
 $questionblocks
 
 $questionblocktitle
 
- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Additional Inherited Members

- Static Public Member Functions inherited from PEAR
static & 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. More...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Detailed Description

Survey Question Import Parser.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 35 of file class.SurveyImportParser.php.

Constructor & Destructor Documentation

◆ __construct()

SurveyImportParser::__construct (   $a_spl_id,
  $a_xml_file = '',
  $spl_exists = false,
  $a_mapping = null 
)

Constructor.

Parameters
string$a_xml_filexml file

public

Definition at line 85 of file class.SurveyImportParser.php.

References $spl_exists.

86  {
87  parent::__construct($a_xml_file);
88  $this->spl_id = $a_spl_id;
89  $this->has_error = false;
90  $this->characterbuffer = "";
91  $this->survey_status = 0;
92  $this->activetag = "";
93  $this->material = array();
94  $this->depth = array();
95  $this->path = array();
96  $this->metadata = array();
97  $this->responses = array();
98  $this->variables = array();
99  $this->response_id = "";
100  $this->matrix = array();
101  $this->is_matrix = false;
102  $this->adjectives = array();
103  $this->spl_exists = $spl_exists;
104  $this->survey = null;
105  $this->in_survey = false;
106  $this->anonymisation = 0;
107  $this->surveyaccess = "restricted";
108  $this->questions = array();
109  $this->original_question_id = "";
110  $this->constraints = array();
111  $this->textblock = "";
112  $this->textblocks = array();
113  $this->in_questionblock = false;
114  $this->questionblocks = array();
115  $this->questionblock = array();
116  $this->showQuestiontext = 1;
117  $this->questionblocktitle = "";
118  $this->mapping = $a_mapping;
119  }

Member Function Documentation

◆ getErrorCode()

SurveyImportParser::getErrorCode ( )

Definition at line 733 of file class.SurveyImportParser.php.

References $error_code.

734  {
735  return $this->error_code;
736  }

◆ getErrorColumn()

SurveyImportParser::getErrorColumn ( )

Definition at line 743 of file class.SurveyImportParser.php.

References $error_col.

744  {
745  return $this->error_col;
746  }

◆ getErrorLine()

SurveyImportParser::getErrorLine ( )

Definition at line 738 of file class.SurveyImportParser.php.

References $error_line.

739  {
740  return $this->error_line;
741  }

◆ getErrorMessage()

SurveyImportParser::getErrorMessage ( )

Definition at line 748 of file class.SurveyImportParser.php.

References $error_msg.

749  {
750  return $this->error_msg;
751  }

◆ getFullError()

SurveyImportParser::getFullError ( )

Definition at line 753 of file class.SurveyImportParser.php.

References $error_col.

754  {
755  return "Error: " . $this->error_msg . " at line:" . $this->error_line . " column:" . $this->error_col;
756  }

◆ getParent()

SurveyImportParser::getParent (   $a_xml_parser)

Definition at line 181 of file class.SurveyImportParser.php.

Referenced by handlerBeginTag(), and handlerEndTag().

182  {
183  if ($this->depth[$a_xml_parser] > 0) {
184  return $this->path[$this->depth[$a_xml_parser] - 1];
185  } else {
186  return "";
187  }
188  }
+ Here is the caller graph for this function:

◆ getXMLAttributes()

SurveyImportParser::getXMLAttributes ( )

Definition at line 768 of file class.SurveyImportParser.php.

References $attributes.

769  {
770  return $this->attributes;
771  }

◆ getXMLElements()

SurveyImportParser::getXMLElements ( )

Definition at line 763 of file class.SurveyImportParser.php.

References $elements.

764  {
765  return $this->elements;
766  }

◆ getXMLSize()

SurveyImportParser::getXMLSize ( )

Definition at line 758 of file class.SurveyImportParser.php.

References $size.

759  {
760  return $this->size;
761  }

◆ getXMLTextSections()

SurveyImportParser::getXMLTextSections ( )

Definition at line 773 of file class.SurveyImportParser.php.

References $texts.

774  {
775  return $this->texts;
776  }

◆ getXMLTextSize()

SurveyImportParser::getXMLTextSize ( )

Definition at line 778 of file class.SurveyImportParser.php.

References $text_size.

779  {
780  return $this->text_size;
781  }

◆ handlerBeginTag()

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

handler for begin of element

Definition at line 193 of file class.SurveyImportParser.php.

References $_SESSION, $attrib, $key, $spl, $type, SurveyQuestion\_includeClass(), and getParent().

194  {
195  $this->depth[$a_xml_parser]++;
196  $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
197  $this->characterbuffer = "";
198  $this->activetag = $a_name;
199  $this->elements++;
200  $this->attributes += count($a_attribs);
201  switch ($a_name) {
202  case "questionblock":
203  $this->in_questionblock = true;
204  $this->questionblock = array();
205  $this->questionblocktitle = "";
206  $this->showQuestiontext = 1;
207  foreach ($a_attribs as $attrib => $value) {
208  switch ($attrib) {
209  case "showQuestiontext":
210  $this->showQuestiontext = $value;
211  break;
212  }
213  }
214  break;
215  case "surveyquestions":
216  foreach ($a_attribs as $attrib => $value) {
217  switch ($attrib) {
218  case "online":
219  if ($this->spl_id > 0) {
220  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
221  $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
222  $spl->setOnline($value);
223  $spl->saveToDb();
224  }
225  break;
226  }
227  }
228  break;
229  case "survey":
230  $this->in_survey = true;
231  foreach ($a_attribs as $attrib => $value) {
232  switch ($attrib) {
233  case "title":
234  if (is_object($this->survey)) {
235  $this->survey->setTitle($value);
236  $this->survey->update(true);
237  }
238  break;
239  }
240  }
241  break;
242  case "anonymisation":
243  foreach ($a_attribs as $attrib => $value) {
244  switch ($attrib) {
245  case "enabled":
246  $this->anonymisation = $value;
247  break;
248  }
249  }
250  break;
251  case "access":
252  foreach ($a_attribs as $attrib => $value) {
253  switch ($attrib) {
254  case "type":
255  $this->surveyaccess = $value;
256  break;
257  }
258  }
259  break;
260  case "constraint":
261  array_push(
262  $this->constraints,
263  array(
264  "sourceref" => $a_attribs["sourceref"],
265  "destref" => $a_attribs["destref"],
266  "relation" => $a_attribs["relation"],
267  "value" => $a_attribs["value"],
268 
269  // might be missing in old export files
270  "conjunction" => (int) $a_attribs["conjuction"]
271  )
272  );
273  break;
274  case "question":
275  // start with a new survey question
276  $type = $a_attribs["type"];
277  // patch due to changes in question types
278  switch ($type) {
279  case 'SurveyNominalQuestion':
280  $type = 'SurveyMultipleChoiceQuestion';
281  foreach ($a_attribs as $key => $value) {
282  switch ($key) {
283  case "subtype":
284  if ($value == 1) {
285  $type = 'SurveySingleChoiceQuestion';
286  } else {
287  $type = 'SurveyMultipleChoiceQuestion';
288  }
289  break;
290  }
291  }
292  break;
293  case 'SurveyOrdinalQuestion':
294  $type = 'SurveySingleChoiceQuestion';
295  break;
296  }
297  if (strlen($type)) {
298  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
300  $this->activequestion = new $type();
301 
302  // if no pool is given, question will reference survey
303  $q_obj_id = $this->spl_id;
304  if ($this->spl_id < 0) {
305  $q_obj_id = $this->survey->getId();
306  }
307 
308  $this->activequestion->setObjId($q_obj_id);
309  }
310  } else {
311  $this->activequestion = null;
312  }
313  $this->original_question_id = $a_attribs["id"];
314  if ($this->in_questionblock) {
315  array_push($this->questionblock, $this->original_question_id);
316  }
317  if (is_object($this->activequestion)) {
318  foreach ($a_attribs as $key => $value) {
319  switch ($key) {
320  case "title":
321  $this->activequestion->setTitle($value);
322  break;
323  case "subtype":
324  $this->activequestion->setSubtype($value);
325  break;
326  case "obligatory":
327  $this->activequestion->setObligatory($value);
328  break;
329  }
330  }
331  }
332  break;
333  case "material":
334  switch ($this->getParent($a_xml_parser)) {
335  case "question":
336  case "questiontext":
337  $this->material = array();
338  break;
339  }
340  array_push($this->material, array("text" => "", "image" => "", "label" => $a_attribs["label"]));
341  break;
342  case "matimage":
343  case "label":
344  if (array_key_exists("label", $a_attribs)) {
345  if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $a_attribs["label"], $matches)) {
346  // import an mediaobject which was inserted using tiny mce
347  if (!is_array($_SESSION["import_mob_xhtml"])) {
348  $_SESSION["import_mob_xhtml"] = array();
349  }
350  array_push($_SESSION["import_mob_xhtml"], array("mob" => $a_attribs["label"], "uri" => $a_attribs["uri"], "type" => $a_attribs["type"], "id" => $a_attribs["id"]));
351  }
352  }
353  break;
354  case "metadata":
355  $this->metadata = array();
356  break;
357  case "metadatafield":
358  array_push($this->metadata, array("label" => "", "entry" => ""));
359  break;
360  case "matrix":
361  $this->is_matrix = true;
362  $this->matrix = array();
363  break;
364  case "matrixrow":
365  $this->material = array();
366  array_push($this->matrix, "");
367  $this->matrixrowattribs = array("id" => $a_attribs["id"], "label" => $a_attribs["label"], "other" => $a_attribs["other"]);
368  break;
369  case "responses":
370  $this->material = array();
371  $this->responses = array();
372  break;
373  case "variables":
374  $this->variables = array();
375  break;
376  case "response_single":
377  $this->material = array();
378  $this->responses[$a_attribs["id"]] = array("type" => "single", "id" => $a_attribs["id"], "label" => $a_attribs["label"], "other" => $a_attribs["other"], "neutral" => $a_attribs["neutral"], "scale" => $a_attribs["scale"]);
379  $this->response_id = $a_attribs["id"];
380  break;
381  case "response_multiple":
382  $this->material = array();
383  $this->responses[$a_attribs["id"]] = array("type" => "multiple", "id" => $a_attribs["id"], "label" => $a_attribs["label"], "other" => $a_attribs["other"], "neutral" => $a_attribs["neutral"], "scale" => $a_attribs["scale"]);
384  $this->response_id = $a_attribs["id"];
385  break;
386  case "response_text":
387  $this->material = array();
388  $this->responses[$a_attribs["id"]] = array("type" => "text", "id" => $a_attribs["id"], "columns" => $a_attribs["columns"], "maxlength" => $a_attribs["maxlength"], "rows" => $a_attribs["rows"], "label" => $a_attribs["label"]);
389  $this->response_id = $a_attribs["id"];
390  break;
391  case "response_num":
392  $this->material = array();
393  $this->responses[$a_attribs["id"]] = array("type" => "num", "id" => $a_attribs["id"], "format" => $a_attribs["format"], "max" => $a_attribs["max"], "min" => $a_attribs["min"], "size" => $a_attribs["size"], "label" => $a_attribs["label"]);
394  $this->response_id = $a_attribs["id"];
395  break;
396  case "response_time":
397  $this->material = array();
398  $this->responses[$a_attribs["id"]] = array("type" => "time", "id" => $a_attribs["id"], "format" => $a_attribs["format"], "max" => $a_attribs["max"], "min" => $a_attribs["min"], "label" => $a_attribs["label"]);
399  $this->response_id = $a_attribs["id"];
400  break;
401  case "bipolar_adjectives":
402  $this->adjectives = array();
403  break;
404  case "adjective":
405  array_push($this->adjectives, array("label" => $a_attribs["label"], "text" => ""));
406  break;
407  }
408  }
$attrib
Regular expression to match HTML/XML attribute pairs within a tag.
Definition: Sanitizer.php:42
$_SESSION["AccountId"]
$type
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ handlerCharacterData()

SurveyImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 413 of file class.SurveyImportParser.php.

References $characterbuffer.

414  {
415  $this->texts++;
416  $this->text_size += strlen($a_data);
417  $this->characterbuffer .= $a_data;
418  $a_data = $this->characterbuffer;
419  }

◆ handlerEndTag()

SurveyImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Definition at line 424 of file class.SurveyImportParser.php.

References $characterbuffer, $data, $key, $material, $original_question_id, $questionblock, $response_id, $row, $spl, $textblock, $title, and getParent().

425  {
426  switch ($a_name) {
427  case "surveyobject":
428  if (is_object($this->survey)) {
429  $this->survey->setOfflineStatus(!$this->survey_status);
430  $this->survey->saveToDb();
431 
432  // write question blocks
433  if (count($this->questionblocks)) {
434  foreach ($this->questionblocks as $data) {
435  $questionblock = $data["questions"];
436  $title = $data["title"];
437  $qblock = array();
438  foreach ($questionblock as $question_id) {
439  array_push($qblock, $this->questions[$question_id]);
440  }
441  $this->survey->createQuestionblock($title, $this->showQuestiontext, false, $qblock);
442  }
443  }
444 
445  // #13878 - write constraints
446  if (count($this->constraints)) {
447  $relations = $this->survey->getAllRelations(true);
448  foreach ($this->constraints as $constraint) {
449  $constraint_id = $this->survey->addConstraint($this->questions[$constraint["destref"]], $relations[$constraint["relation"]]["id"], $constraint["value"], $constraint["conjunction"]);
450  $this->survey->addConstraintToQuestion($this->questions[$constraint["sourceref"]], $constraint_id);
451  }
452  }
453 
454  // write textblocks
455  if (count($this->textblocks)) {
456  foreach ($this->textblocks as $original_id => $textblock) {
457  $this->survey->saveHeading($textblock, $this->questions[$original_id]);
458  }
459  }
460  }
461  break;
462  case "survey":
463  $this->in_survey = false;
464  if (is_object($this->survey)) {
465  if (strcmp($this->surveyaccess, "free") == 0) {
466  $this->survey->setAnonymize(2);
467  } else {
468  if ($this->anonymisation == 0) {
469  $this->survey->setAnonymize(0);
470  } else {
471  $this->survey->setAnonymize(1);
472  }
473  }
474  }
475  break;
476  case "startingtime":
477  if (preg_match("/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->characterbuffer, $matches)) {
478  if (is_object($this->survey)) {
479  $this->survey->setStartDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
480  }
481  }
482  break;
483  case "endingtime":
484  if (preg_match("/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->characterbuffer, $matches)) {
485  if (is_object($this->survey)) {
486  $this->survey->setEndDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
487  }
488  }
489  break;
490  case "description":
491  if ($this->in_survey) {
492  if (is_object($this->survey)) {
493  $this->survey->setDescription($this->characterbuffer);
494  $this->survey->update(true);
495  }
496  } else {
497  if (is_object($this->activequestion)) {
498  $this->activequestion->setDescription($this->characterbuffer);
499  }
500  }
501  break;
502  case "question":
503  if (is_object($this->activequestion)) {
504  if (strlen($this->textblock)) {
505  $this->textblocks[$this->original_question_id] = $this->textblock;
506  }
507  $this->activequestion->saveToDb();
508  // duplicate the question for the survey (if pool is to be used)
509  if (is_object($this->survey) &&
510  $this->spl_id > 0) {
511  $question_id = $this->activequestion->duplicate(true, "", "", "", $this->survey->getId());
512  } else {
513  $question_id = $this->activequestion->getId();
514  }
515  if (is_object($this->survey)) { // #15452
516  $this->survey->addQuestion($question_id);
517  }
518  $this->questions[$this->original_question_id] = $question_id;
519  if ($this->mapping) {
520  $this->mapping->addMapping("Modules/Survey", "svy_q", $this->original_question_id, $question_id);
521  }
522  $this->activequestion = null;
523  }
524  $this->textblock = "";
525  break;
526  case "author":
527  if ($this->in_survey) {
528  if (is_object($this->survey)) {
529  $this->survey->setAuthor($this->characterbuffer);
530  }
531  } else {
532  if (is_object($this->activequestion)) {
533  $this->activequestion->setAuthor($this->characterbuffer);
534  }
535  }
536  break;
537  case "mattext":
538  $this->material[count($this->material) - 1]["text"] = $this->characterbuffer;
539  break;
540  case "matimage":
541  $this->material[count($this->material) - 1]["image"] = $this->characterbuffer;
542  break;
543  case "material":
544  if ($this->in_survey) {
545  if (strcmp($this->getParent($a_xml_parser), "objectives") == 0) {
546  if (strcmp($this->material[0]["label"], "introduction") == 0) {
547  if (is_object($this->survey)) {
548  $this->survey->setIntroduction($this->material[0]["text"]);
549  }
550  }
551  if (strcmp($this->material[0]["label"], "outro") == 0) {
552  if (is_object($this->survey)) {
553  $this->survey->setOutro($this->material[0]["text"]);
554  }
555  }
556  $this->material = array();
557  }
558  } else {
559  if (strcmp($this->getParent($a_xml_parser), "question") == 0) {
560  $this->activequestion->setMaterial($this->material[0]["text"], true, $this->material[0]["label"]);
561  }
562  }
563  break;
564  case "questiontext":
565  if (is_object($this->activequestion)) {
566  $questiontext = "";
567  foreach ($this->material as $matarray) {
568  $questiontext .= $matarray["text"];
569  }
570  $this->activequestion->setQuestiontext($questiontext);
571  }
572  $this->material = array();
573  break;
574  case "fieldlabel":
575  $this->metadata[count($this->metadata) - 1]["label"] = $this->characterbuffer;
576  break;
577  case "fieldentry":
578  $this->metadata[count($this->metadata) - 1]["entry"] = $this->characterbuffer;
579  break;
580  case "metadata":
581  if (strcmp($this->getParent($a_xml_parser), "question") == 0) {
582  if (is_object($this->activequestion)) {
583  $this->activequestion->importAdditionalMetadata($this->metadata);
584  }
585  }
586  if (strcmp($this->getParent($a_xml_parser), "survey") == 0) {
587  foreach ($this->metadata as $key => $value) {
588  switch ($value["label"]) {
589  case "SCORM":
590  if (strlen($value["entry"])) {
591  if (is_object($this->survey)) {
592  include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
593  include_once "./Services/MetaData/classes/class.ilMD.php";
594  $md_sax_parser = new ilMDSaxParser();
595  $md_sax_parser->setXMLContent($value["entry"]);
596  $md_sax_parser->setMDObject($tmp = new ilMD($this->survey->getId(), 0, "svy"));
597  $md_sax_parser->enableMDParsing(true);
598  $md_sax_parser->startParsing();
599  $this->survey->MDUpdateListener("General");
600  }
601  }
602  break;
603  case "display_question_titles":
604  if ($value["entry"] == 1) {
605  $this->survey->showQuestionTitles();
606  } else {
607  $this->survey->hideQuestionTitles();
608  }
609  break;
610  case "status":
611  $this->survey_status = $value["entry"];
612  break;
613  case "evaluation_access":
614  $this->survey->setEvaluationAccess($value["entry"]);
615  break;
616  case "pool_usage":
617  $this->survey->setPoolUsage($value["entry"]);
618  break;
619  case "own_results_view":
620  $this->survey->setViewOwnResults($value["entry"]);
621  break;
622  case "own_results_mail":
623  $this->survey->setMailOwnResults($value["entry"]);
624  break;
625  case "confirmation_mail":
626  $this->survey->setMailConfirmation($value["entry"]);
627  break;
628  case "anon_user_list":
629  $this->survey->setAnonymousUserList($value["entry"]);
630  break;
631  case "mode":
632  $this->survey->setMode($value["entry"]);
633  break;
634  case "mode_360_self_eval":
635  $this->survey->set360SelfEvaluation($value["entry"]);
636  break;
637  case "mode_360_self_rate":
638  $this->survey->set360SelfRaters($value["entry"]);
639  break;
640  case "mode_360_self_appr":
641  $this->survey->set360SelfAppraisee($value["entry"]);
642  break;
643  case "mode_360_results":
644  $this->survey->set360Results($value["entry"]);
645  break;
646  case "mode_self_eval_results":
647  $this->survey->setSelfEvaluationResults($value["entry"]);
648  break;
649  case "mode_skill_service":
650  $this->survey->setSkillService($value["entry"]);
651  break;
652  }
653  }
654  }
655  if (!$this->spl_exists) {
656  if (strcmp($this->getParent($a_xml_parser), "surveyquestions") == 0) {
657  foreach ($this->metadata as $key => $value) {
658  if (strcmp($value["label"], "SCORM") == 0) {
659  if (strlen($value["entry"])) {
660  if ($this->spl_id > 0) {
661  include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
662  include_once "./Services/MetaData/classes/class.ilMD.php";
663  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
664  $md_sax_parser = new ilMDSaxParser();
665  $md_sax_parser->setXMLContent($value["entry"]);
666  $md_sax_parser->setMDObject($tmp = new ilMD($this->spl_id, 0, "spl"));
667  $md_sax_parser->enableMDParsing(true);
668  $md_sax_parser->startParsing();
669  $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
670  $spl->MDUpdateListener("General");
671  }
672  }
673  }
674  }
675  }
676  }
677  break;
678  case "responses":
679  if (is_object($this->activequestion)) {
680  $this->activequestion->importResponses($this->responses);
681  }
682  $this->is_matrix = false;
683  break;
684  case "variable":
685  array_push($this->variables, $this->characterbuffer);
686  break;
687  case "variables":
688  if (is_object($this->activequestion)) {
689  $this->activequestion->importVariables($this->variables);
690  }
691  break;
692  case "response_single":
693  case "response_multiple":
694  case "response_text":
695  case "response_num":
696  case "response_time":
697  $this->responses[$this->response_id]["material"] = $this->material;
698  break;
699  case "adjective":
700  $this->adjectives[count($this->adjectives) - 1]["text"] = $this->characterbuffer;
701  break;
702  case "bipolar_adjectives":
703  if (is_object($this->activequestion)) {
704  $this->activequestion->importAdjectives($this->adjectives);
705  }
706  break;
707  case "matrixrow":
708  $row = "";
709  foreach ($this->material as $material) {
710  $row .= $material["text"];
711  }
712  $this->matrix[count($this->matrix) - 1] = array('title' => $row, 'id' => $this->matrixrowattribs['id'], 'label' => $this->matrixrowattribs['label'], 'other' => $this->matrixrowattribs['other']);
713  break;
714  case "matrix":
715  if (is_object($this->activequestion)) {
716  $this->activequestion->importMatrix($this->matrix);
717  }
718  break;
719  case "textblock":
720  $this->textblock = $this->characterbuffer;
721  break;
722  case "questionblocktitle":
723  $this->questionblocktitle = $this->characterbuffer;
724  break;
725  case "questionblock":
726  $this->in_questionblock = false;
727  array_push($this->questionblocks, array("title" => $this->questionblocktitle, "questions" => $this->questionblock));
728  break;
729  }
730  $this->depth[$a_xml_parser]--;
731  }
$row
$key
Definition: croninfo.php:18
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ hasError()

SurveyImportParser::hasError ( )

Definition at line 783 of file class.SurveyImportParser.php.

References $has_error.

784  {
785  return $this->has_error;
786  }

◆ parse()

SurveyImportParser::parse (   $a_xml_parser,
  $a_fp = null 
)

parse xml file

private

Definition at line 155 of file class.SurveyImportParser.php.

References $data, ilSaxParser\getInputType(), and ilSaxParser\getXMLContent().

156  {
157  switch ($this->getInputType()) {
158  case 'file':
159 
160  while ($data = fread($a_fp, 4096)) {
161  $parseOk = xml_parse($a_xml_parser, $data, feof($a_fp));
162  }
163  break;
164 
165  case 'string':
166  $parseOk = xml_parse($a_xml_parser, $this->getXMLContent());
167  break;
168  }
169  if (!$parseOk
170  && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE)) {
171  $this->error_code = xml_get_error_code($a_xml_parser);
172  $this->error_line = xml_get_current_line_number($a_xml_parser);
173  $this->error_col = xml_get_current_column_number($a_xml_parser);
174  $this->error_msg = xml_error_string($a_xml_parser);
175  $this->has_error = true;
176  return false;
177  }
178  return true;
179  }
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ setHandlers()

SurveyImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Definition at line 135 of file class.SurveyImportParser.php.

136  {
137  xml_set_object($a_xml_parser, $this);
138  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
139  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
140  }

◆ setSurveyObject()

SurveyImportParser::setSurveyObject (   $a_svy)

Sets a reference to a survey object public.

Definition at line 125 of file class.SurveyImportParser.php.

126  {
127  $this->survey = $a_svy;
128  }

◆ startParsing()

SurveyImportParser::startParsing ( )

start the parser

Definition at line 145 of file class.SurveyImportParser.php.

146  {
147  parent::startParsing();
148  }

Field Documentation

◆ $activequestion

SurveyImportParser::$activequestion

Definition at line 39 of file class.SurveyImportParser.php.

◆ $activetag

SurveyImportParser::$activetag

Definition at line 52 of file class.SurveyImportParser.php.

◆ $adjectives

SurveyImportParser::$adjectives

Definition at line 61 of file class.SurveyImportParser.php.

◆ $anonymisation

SurveyImportParser::$anonymisation

Definition at line 65 of file class.SurveyImportParser.php.

◆ $attributes

SurveyImportParser::$attributes

Definition at line 48 of file class.SurveyImportParser.php.

Referenced by getXMLAttributes().

◆ $characterbuffer

SurveyImportParser::$characterbuffer

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

Referenced by handlerCharacterData(), and handlerEndTag().

◆ $constraints

SurveyImportParser::$constraints

Definition at line 69 of file class.SurveyImportParser.php.

◆ $depth

SurveyImportParser::$depth

Definition at line 38 of file class.SurveyImportParser.php.

◆ $elements

SurveyImportParser::$elements

Definition at line 47 of file class.SurveyImportParser.php.

Referenced by getXMLElements().

◆ $error_code

SurveyImportParser::$error_code

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

Referenced by getErrorCode().

◆ $error_col

SurveyImportParser::$error_col

Definition at line 43 of file class.SurveyImportParser.php.

Referenced by getErrorColumn(), and getFullError().

◆ $error_line

SurveyImportParser::$error_line

Definition at line 42 of file class.SurveyImportParser.php.

Referenced by getErrorLine().

◆ $error_msg

SurveyImportParser::$error_msg

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

Referenced by getErrorMessage().

◆ $has_error

SurveyImportParser::$has_error

Definition at line 45 of file class.SurveyImportParser.php.

Referenced by hasError().

◆ $in_questionblock

SurveyImportParser::$in_questionblock

Definition at line 73 of file class.SurveyImportParser.php.

◆ $in_survey

SurveyImportParser::$in_survey

Definition at line 63 of file class.SurveyImportParser.php.

◆ $is_matrix

SurveyImportParser::$is_matrix

Definition at line 60 of file class.SurveyImportParser.php.

◆ $material

SurveyImportParser::$material

Definition at line 53 of file class.SurveyImportParser.php.

Referenced by handlerEndTag().

◆ $matrix

SurveyImportParser::$matrix

Definition at line 58 of file class.SurveyImportParser.php.

◆ $matrixrowattribs

SurveyImportParser::$matrixrowattribs

Definition at line 59 of file class.SurveyImportParser.php.

◆ $metadata

SurveyImportParser::$metadata

Definition at line 54 of file class.SurveyImportParser.php.

◆ $original_question_id

SurveyImportParser::$original_question_id

Definition at line 68 of file class.SurveyImportParser.php.

Referenced by handlerEndTag().

◆ $path

SurveyImportParser::$path

Definition at line 37 of file class.SurveyImportParser.php.

◆ $questionblock

SurveyImportParser::$questionblock

Definition at line 74 of file class.SurveyImportParser.php.

Referenced by handlerEndTag().

◆ $questionblocks

SurveyImportParser::$questionblocks

Definition at line 75 of file class.SurveyImportParser.php.

◆ $questionblocktitle

SurveyImportParser::$questionblocktitle

Definition at line 76 of file class.SurveyImportParser.php.

◆ $questions

SurveyImportParser::$questions

Definition at line 67 of file class.SurveyImportParser.php.

◆ $response_id

SurveyImportParser::$response_id

Definition at line 57 of file class.SurveyImportParser.php.

Referenced by handlerEndTag().

◆ $responses

SurveyImportParser::$responses

Definition at line 55 of file class.SurveyImportParser.php.

◆ $size

SurveyImportParser::$size

Definition at line 46 of file class.SurveyImportParser.php.

Referenced by getXMLSize().

◆ $spl

SurveyImportParser::$spl

Definition at line 40 of file class.SurveyImportParser.php.

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $spl_exists

SurveyImportParser::$spl_exists

Definition at line 62 of file class.SurveyImportParser.php.

Referenced by __construct().

◆ $survey

SurveyImportParser::$survey

Definition at line 64 of file class.SurveyImportParser.php.

◆ $survey_status

SurveyImportParser::$survey_status

Definition at line 72 of file class.SurveyImportParser.php.

◆ $surveyaccess

SurveyImportParser::$surveyaccess

Definition at line 66 of file class.SurveyImportParser.php.

◆ $text_size

SurveyImportParser::$text_size

Definition at line 50 of file class.SurveyImportParser.php.

Referenced by getXMLTextSize().

◆ $textblock

SurveyImportParser::$textblock

Definition at line 70 of file class.SurveyImportParser.php.

Referenced by handlerEndTag().

◆ $textblocks

SurveyImportParser::$textblocks

Definition at line 71 of file class.SurveyImportParser.php.

◆ $texts

SurveyImportParser::$texts

Definition at line 49 of file class.SurveyImportParser.php.

Referenced by getXMLTextSections().

◆ $variables

SurveyImportParser::$variables

Definition at line 56 of file class.SurveyImportParser.php.


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