ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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, and array.

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  }
Create styles array
The data for the language used.

Member Function Documentation

◆ getErrorCode()

SurveyImportParser::getErrorCode ( )

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

References $error_code.

832  {
833  return $this->error_code;
834  }

◆ getErrorColumn()

SurveyImportParser::getErrorColumn ( )

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

References $error_col.

842  {
843  return $this->error_col;
844  }

◆ getErrorLine()

SurveyImportParser::getErrorLine ( )

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

References $error_line.

837  {
838  return $this->error_line;
839  }

◆ getErrorMessage()

SurveyImportParser::getErrorMessage ( )

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

References $error_msg.

847  {
848  return $this->error_msg;
849  }

◆ getFullError()

SurveyImportParser::getFullError ( )

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

References $error_col.

852  {
853  return "Error: ".$this->error_msg." at line:".$this->error_line ." column:".$this->error_col;
854  }

◆ getParent()

SurveyImportParser::getParent (   $a_xml_parser)

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

Referenced by handlerBeginTag(), and handlerEndTag().

185  {
186  if ($this->depth[$a_xml_parser] > 0)
187  {
188  return $this->path[$this->depth[$a_xml_parser]-1];
189  }
190  else
191  {
192  return "";
193  }
194  }
+ Here is the caller graph for this function:

◆ getXMLAttributes()

SurveyImportParser::getXMLAttributes ( )

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

References $attributes.

867  {
868  return $this->attributes;
869  }

◆ getXMLElements()

SurveyImportParser::getXMLElements ( )

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

References $elements.

862  {
863  return $this->elements;
864  }

◆ getXMLSize()

SurveyImportParser::getXMLSize ( )

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

References $size.

857  {
858  return $this->size;
859  }

◆ getXMLTextSections()

SurveyImportParser::getXMLTextSections ( )

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

References $texts.

872  {
873  return $this->texts;
874  }

◆ getXMLTextSize()

SurveyImportParser::getXMLTextSize ( )

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

References $text_size.

877  {
878  return $this->text_size;
879  }

◆ handlerBeginTag()

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

handler for begin of element

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

References $_SESSION, $attrib, SurveyQuestion\_includeClass(), array, and getParent().

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

◆ handlerCharacterData()

SurveyImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

References $characterbuffer.

447  {
448  $this->texts++;
449  $this->text_size+=strlen($a_data);
450  $this->characterbuffer .= $a_data;
451  $a_data = $this->characterbuffer;
452  }

◆ handlerEndTag()

SurveyImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

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

458  {
459  switch ($a_name)
460  {
461  case "surveyobject":
462  if (is_object($this->survey))
463  {
464  $this->survey->setStatus($this->survey_status);
465  $this->survey->saveToDb();
466 
467  // write question blocks
468  if (count($this->questionblocks))
469  {
470  foreach ($this->questionblocks as $data)
471  {
472  $questionblock = $data["questions"];
473  $title = $data["title"];
474  $qblock = array();
475  foreach ($questionblock as $question_id)
476  {
477  array_push($qblock, $this->questions[$question_id]);
478  }
479  $this->survey->createQuestionblock($title, $this->showQuestiontext, false, $qblock);
480  }
481  }
482 
483  // #13878 - write constraints
484  if (count($this->constraints))
485  {
486  $relations = $this->survey->getAllRelations(TRUE);
487  foreach ($this->constraints as $constraint)
488  {
489  $constraint_id= $this->survey->addConstraint($this->questions[$constraint["destref"]], $relations[$constraint["relation"]]["id"], $constraint["value"], $constraint["conjunction"]);
490  $this->survey->addConstraintToQuestion($this->questions[$constraint["sourceref"]], $constraint_id);
491  }
492  }
493 
494  // write textblocks
495  if (count($this->textblocks))
496  {
497  foreach ($this->textblocks as $original_id => $textblock)
498  {
499  $this->survey->saveHeading($textblock, $this->questions[$original_id]);
500  }
501  }
502  }
503  break;
504  case "survey":
505  $this->in_survey = FALSE;
506  if (is_object($this->survey))
507  {
508  if (strcmp($this->surveyaccess, "free") == 0)
509  {
510  $this->survey->setAnonymize(2);
511  }
512  else
513  {
514  if ($this->anonymisation == 0)
515  {
516  $this->survey->setAnonymize(0);
517  }
518  else
519  {
520  $this->survey->setAnonymize(1);
521  }
522  }
523  }
524  break;
525  case "startingtime":
526  if (preg_match("/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->characterbuffer, $matches))
527  {
528  if (is_object($this->survey))
529  {
530  $this->survey->setStartDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
531  }
532  }
533  break;
534  case "endingtime":
535  if (preg_match("/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->characterbuffer, $matches))
536  {
537  if (is_object($this->survey))
538  {
539  $this->survey->setEndDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
540  }
541  }
542  break;
543  case "description":
544  if ($this->in_survey)
545  {
546  if (is_object($this->survey))
547  {
548  $this->survey->setDescription($this->characterbuffer);
549  }
550  }
551  else
552  {
553  if (is_object($this->activequestion))
554  {
555  $this->activequestion->setDescription($this->characterbuffer);
556  }
557  }
558  break;
559  case "question":
560  if (is_object($this->activequestion))
561  {
562  if (strlen($this->textblock))
563  {
564  $this->textblocks[$this->original_question_id] = $this->textblock;
565  }
566  $this->activequestion->saveToDb();
567  // duplicate the question for the survey (if pool is to be used)
568  if (is_object($this->survey) &&
569  $this->spl_id > 0)
570  {
571  $question_id = $this->activequestion->duplicate(TRUE, "", "", "", $this->survey->getId());
572  }
573  else
574  {
575  $question_id = $this->activequestion->getId();
576  }
577  if (is_object($this->survey)) // #15452
578  {
579  $this->survey->addQuestion($question_id);
580  }
581  $this->questions[$this->original_question_id] = $question_id;
582  if($this->mapping)
583  {
584  $this->mapping->addMapping("Modules/Survey", "svy_q", $this->original_question_id, $question_id);
585  }
586  $this->activequestion = NULL;
587  }
588  $this->textblock = "";
589  break;
590  case "author":
591  if ($this->in_survey)
592  {
593  if (is_object($this->survey))
594  {
595  $this->survey->setAuthor($this->characterbuffer);
596  }
597  }
598  else
599  {
600  if (is_object($this->activequestion))
601  {
602  $this->activequestion->setAuthor($this->characterbuffer);
603  }
604  }
605  break;
606  case "mattext":
607  $this->material[count($this->material)-1]["text"] = $this->characterbuffer;
608  break;
609  case "matimage":
610  $this->material[count($this->material)-1]["image"] = $this->characterbuffer;
611  break;
612  case "material":
613  if ($this->in_survey)
614  {
615  if (strcmp($this->getParent($a_xml_parser), "objectives") == 0)
616  {
617  if (strcmp($this->material[0]["label"], "introduction") == 0)
618  {
619  if (is_object($this->survey))
620  {
621  $this->survey->setIntroduction($this->material[0]["text"]);
622  }
623  }
624  if (strcmp($this->material[0]["label"], "outro") == 0)
625  {
626  if (is_object($this->survey))
627  {
628  $this->survey->setOutro($this->material[0]["text"]);
629  }
630  }
631  $this->material = array();
632  }
633  }
634  else
635  {
636  if (strcmp($this->getParent($a_xml_parser), "question") == 0)
637  {
638  $this->activequestion->setMaterial($this->material[0]["text"], TRUE, $this->material[0]["label"]);
639  }
640  }
641  break;
642  case "questiontext":
643  if (is_object($this->activequestion))
644  {
645  $questiontext = "";
646  foreach ($this->material as $matarray)
647  {
648  $questiontext .= $matarray["text"];
649  }
650  $this->activequestion->setQuestiontext($questiontext);
651  }
652  $this->material = array();
653  break;
654  case "fieldlabel":
655  $this->metadata[count($this->metadata)-1]["label"] = $this->characterbuffer;
656  break;
657  case "fieldentry":
658  $this->metadata[count($this->metadata)-1]["entry"] = $this->characterbuffer;
659  break;
660  case "metadata":
661  if (strcmp($this->getParent($a_xml_parser), "question") == 0)
662  {
663  if (is_object($this->activequestion))
664  {
665  $this->activequestion->importAdditionalMetadata($this->metadata);
666  }
667  }
668  if (strcmp($this->getParent($a_xml_parser), "survey") == 0)
669  {
670  foreach ($this->metadata as $key => $value)
671  {
672  switch ($value["label"])
673  {
674  case "SCORM":
675  if (strlen($value["entry"]))
676  {
677  if (is_object($this->survey))
678  {
679  include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
680  include_once "./Services/MetaData/classes/class.ilMD.php";
681  $md_sax_parser = new ilMDSaxParser();
682  $md_sax_parser->setXMLContent($value["entry"]);
683  $md_sax_parser->setMDObject($tmp = new ilMD($this->survey->getId(),0, "svy"));
684  $md_sax_parser->enableMDParsing(true);
685  $md_sax_parser->startParsing();
686  $this->survey->MDUpdateListener("General");
687  }
688  }
689  break;
690  case "display_question_titles":
691  if ($value["entry"] == 1)
692  {
693  $this->survey->showQuestionTitles();
694  }
695  else
696  {
697  $this->survey->hideQuestionTitles();
698  }
699  break;
700  case "status":
701  $this->survey_status = $value["entry"];
702  break;
703  case "evaluation_access":
704  $this->survey->setEvaluationAccess($value["entry"]);
705  break;
706  case "pool_usage":
707  $this->survey->setPoolUsage($value["entry"]);
708  break;
709  case "own_results_view":
710  $this->survey->setViewOwnResults($value["entry"]);
711  break;
712  case "own_results_mail":
713  $this->survey->setMailOwnResults($value["entry"]);
714  break;
715  case "confirmation_mail":
716  $this->survey->setMailConfirmation($value["entry"]);
717  break;
718  case "anon_user_list":
719  $this->survey->setAnonymousUserList($value["entry"]);
720  break;
721  case "mode_360":
722  $this->survey->set360Mode($value["entry"]);
723  break;
724  case "mode_360_self_eval":
725  $this->survey->set360SelfEvaluation($value["entry"]);
726  break;
727  case "mode_360_self_rate":
728  $this->survey->set360SelfRaters($value["entry"]);
729  break;
730  case "mode_360_self_appr":
731  $this->survey->set360SelfAppraisee($value["entry"]);
732  break;
733  case "mode_360_results":
734  $this->survey->set360Results($value["entry"]);
735  break;
736  case "mode_360_skill_service":
737  $this->survey->set360SkillService($value["entry"]);
738  break;
739  }
740  }
741  }
742  if (!$this->spl_exists)
743  {
744  if (strcmp($this->getParent($a_xml_parser), "surveyquestions") == 0)
745  {
746  foreach ($this->metadata as $key => $value)
747  {
748  if (strcmp($value["label"], "SCORM") == 0)
749  {
750  if (strlen($value["entry"]))
751  {
752  if ($this->spl_id > 0)
753  {
754  include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
755  include_once "./Services/MetaData/classes/class.ilMD.php";
756  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
757  $md_sax_parser = new ilMDSaxParser();
758  $md_sax_parser->setXMLContent($value["entry"]);
759  $md_sax_parser->setMDObject($tmp = new ilMD($this->spl_id,0, "spl"));
760  $md_sax_parser->enableMDParsing(true);
761  $md_sax_parser->startParsing();
762  $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
763  $spl->MDUpdateListener("General");
764  }
765  }
766  }
767  }
768  }
769  }
770  break;
771  case "responses":
772  if (is_object($this->activequestion))
773  {
774  $this->activequestion->importResponses($this->responses);
775  }
776  $this->is_matrix = FALSE;
777  break;
778  case "variable":
779  array_push($this->variables, $this->characterbuffer);
780  break;
781  case "variables":
782  if (is_object($this->activequestion))
783  {
784  $this->activequestion->importVariables($this->variables);
785  }
786  break;
787  case "response_single":
788  case "response_multiple":
789  case "response_text":
790  case "response_num":
791  case "response_time":
792  $this->responses[$this->response_id]["material"] = $this->material;
793  break;
794  case "adjective":
795  $this->adjectives[count($this->adjectives)-1]["text"] = $this->characterbuffer;
796  break;
797  case "bipolar_adjectives":
798  if (is_object($this->activequestion))
799  {
800  $this->activequestion->importAdjectives($this->adjectives);
801  }
802  break;
803  case "matrixrow":
804  $row = "";
805  foreach ($this->material as $material)
806  {
807  $row .= $material["text"];
808  }
809  $this->matrix[count($this->matrix)-1] = array('title' => $row, 'id' => $this->matrixrowattribs['id'], 'label' => $this->matrixrowattribs['label'], 'other' => $this->matrixrowattribs['other']);
810  break;
811  case "matrix":
812  if (is_object($this->activequestion))
813  {
814  $this->activequestion->importMatrix($this->matrix);
815  }
816  break;
817  case "textblock":
818  $this->textblock = $this->characterbuffer;
819  break;
820  case "questionblocktitle":
821  $this->questionblocktitle = $this->characterbuffer;
822  break;
823  case "questionblock":
824  $this->in_questionblock = FALSE;
825  array_push($this->questionblocks, array("title" => $this->questionblocktitle, "questions" => $this->questionblock));
826  break;
827  }
828  $this->depth[$a_xml_parser]--;
829  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ hasError()

SurveyImportParser::hasError ( )

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

References $has_error.

882  {
883  return $this->has_error;
884  }

◆ 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  {
159  case 'file':
160 
161  while($data = fread($a_fp,4096))
162  {
163  $parseOk = xml_parse($a_xml_parser,$data,feof($a_fp));
164  }
165  break;
166 
167  case 'string':
168  $parseOk = xml_parse($a_xml_parser,$this->getXMLContent());
169  break;
170  }
171  if(!$parseOk
172  && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE))
173  {
174  $this->error_code = xml_get_error_code($a_xml_parser);
175  $this->error_line = xml_get_current_line_number($a_xml_parser);
176  $this->error_col = xml_get_current_column_number($a_xml_parser);
177  $this->error_msg = xml_error_string($a_xml_parser);
178  $this->has_error = TRUE;
179  return false;
180  }
181  return true;
182  }
+ 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.

◆ $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.

◆ $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: