ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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

Definition at line 10 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 60 of file class.SurveyImportParser.php.

References $spl_exists, and ILIAS\GlobalScreen\Provider\__construct().

61  {
62  parent::__construct($a_xml_file);
63  $this->spl_id = $a_spl_id;
64  $this->has_error = false;
65  $this->characterbuffer = "";
66  $this->survey_status = 0;
67  $this->activetag = "";
68  $this->material = array();
69  $this->depth = array();
70  $this->path = array();
71  $this->metadata = array();
72  $this->responses = array();
73  $this->variables = array();
74  $this->response_id = "";
75  $this->matrix = array();
76  $this->is_matrix = false;
77  $this->adjectives = array();
78  $this->spl_exists = $spl_exists;
79  $this->survey = null;
80  $this->in_survey = false;
81  $this->anonymisation = 0;
82  $this->surveyaccess = "restricted";
83  $this->questions = array();
84  $this->original_question_id = "";
85  $this->constraints = array();
86  $this->textblock = "";
87  $this->textblocks = array();
88  $this->in_questionblock = false;
89  $this->questionblocks = array();
90  $this->questionblock = array();
91  $this->showQuestiontext = 1;
92  $this->questionblocktitle = "";
93  $this->mapping = $a_mapping;
94  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getErrorCode()

SurveyImportParser::getErrorCode ( )

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

References $error_code.

702  {
703  return $this->error_code;
704  }

◆ getErrorColumn()

SurveyImportParser::getErrorColumn ( )

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

References $error_col.

712  {
713  return $this->error_col;
714  }

◆ getErrorLine()

SurveyImportParser::getErrorLine ( )

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

References $error_line.

707  {
708  return $this->error_line;
709  }

◆ getErrorMessage()

SurveyImportParser::getErrorMessage ( )

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

References $error_msg.

717  {
718  return $this->error_msg;
719  }

◆ getFullError()

SurveyImportParser::getFullError ( )

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

References $error_col.

722  {
723  return "Error: " . $this->error_msg . " at line:" . $this->error_line . " column:" . $this->error_col;
724  }

◆ getParent()

SurveyImportParser::getParent (   $a_xml_parser)

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

Referenced by handlerBeginTag(), and handlerEndTag().

157  {
158  if ($this->depth[$a_xml_parser] > 0) {
159  return $this->path[$this->depth[$a_xml_parser] - 1];
160  } else {
161  return "";
162  }
163  }
+ Here is the caller graph for this function:

◆ getXMLAttributes()

SurveyImportParser::getXMLAttributes ( )

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

References $attributes.

737  {
738  return $this->attributes;
739  }

◆ getXMLElements()

SurveyImportParser::getXMLElements ( )

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

References $elements.

732  {
733  return $this->elements;
734  }

◆ getXMLSize()

SurveyImportParser::getXMLSize ( )

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

References $size.

727  {
728  return $this->size;
729  }

◆ getXMLTextSections()

SurveyImportParser::getXMLTextSections ( )

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

References $texts.

742  {
743  return $this->texts;
744  }

◆ getXMLTextSize()

SurveyImportParser::getXMLTextSize ( )

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

References $text_size.

747  {
748  return $this->text_size;
749  }

◆ handlerBeginTag()

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

handler for begin of element

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

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

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

◆ handlerCharacterData()

SurveyImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

References $characterbuffer.

387  {
388  $this->texts++;
389  $this->text_size += strlen($a_data);
390  $this->characterbuffer .= $a_data;
391  $a_data = $this->characterbuffer;
392  }

◆ handlerEndTag()

SurveyImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

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

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

◆ hasError()

SurveyImportParser::hasError ( )

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

References $has_error.

752  {
753  return $this->has_error;
754  }

◆ parse()

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

parse xml file

private

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

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

131  {
132  switch ($this->getInputType()) {
133  case 'file':
134 
135  while ($data = fread($a_fp, 4096)) {
136  $parseOk = xml_parse($a_xml_parser, $data, feof($a_fp));
137  }
138  break;
139 
140  case 'string':
141  $parseOk = xml_parse($a_xml_parser, $this->getXMLContent());
142  break;
143  }
144  if (!$parseOk
145  && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE)) {
146  $this->error_code = xml_get_error_code($a_xml_parser);
147  $this->error_line = xml_get_current_line_number($a_xml_parser);
148  $this->error_col = xml_get_current_column_number($a_xml_parser);
149  $this->error_msg = xml_error_string($a_xml_parser);
150  $this->has_error = true;
151  return false;
152  }
153  return true;
154  }
$data
Definition: storeScorm.php:23
+ 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 110 of file class.SurveyImportParser.php.

111  {
112  xml_set_object($a_xml_parser, $this);
113  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
114  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
115  }

◆ setSurveyObject()

SurveyImportParser::setSurveyObject (   $a_svy)

Sets a reference to a survey object public.

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

101  {
102  $this->survey = $a_svy;
103  }

◆ startParsing()

SurveyImportParser::startParsing ( )

start the parser

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

121  {
122  parent::startParsing();
123  }

Field Documentation

◆ $activequestion

SurveyImportParser::$activequestion

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

◆ $activetag

SurveyImportParser::$activetag

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

◆ $adjectives

SurveyImportParser::$adjectives

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

◆ $anonymisation

SurveyImportParser::$anonymisation

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

◆ $attributes

SurveyImportParser::$attributes

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

Referenced by getXMLAttributes().

◆ $characterbuffer

SurveyImportParser::$characterbuffer

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

Referenced by handlerCharacterData(), and handlerEndTag().

◆ $constraints

SurveyImportParser::$constraints

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

◆ $depth

SurveyImportParser::$depth

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

◆ $elements

SurveyImportParser::$elements

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

Referenced by getXMLElements().

◆ $error_code

SurveyImportParser::$error_code

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

Referenced by getErrorCode().

◆ $error_col

SurveyImportParser::$error_col

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

Referenced by getErrorColumn(), and getFullError().

◆ $error_line

SurveyImportParser::$error_line

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

Referenced by getErrorLine().

◆ $error_msg

SurveyImportParser::$error_msg

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

Referenced by getErrorMessage().

◆ $has_error

SurveyImportParser::$has_error

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

Referenced by hasError().

◆ $in_questionblock

SurveyImportParser::$in_questionblock

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

◆ $in_survey

SurveyImportParser::$in_survey

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

◆ $is_matrix

SurveyImportParser::$is_matrix

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

◆ $material

SurveyImportParser::$material

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

Referenced by handlerEndTag().

◆ $matrix

SurveyImportParser::$matrix

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

◆ $matrixrowattribs

SurveyImportParser::$matrixrowattribs

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

◆ $metadata

SurveyImportParser::$metadata

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

◆ $original_question_id

SurveyImportParser::$original_question_id

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

Referenced by handlerEndTag().

◆ $path

SurveyImportParser::$path

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

◆ $questionblock

SurveyImportParser::$questionblock

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

Referenced by handlerEndTag().

◆ $questionblocks

SurveyImportParser::$questionblocks

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

◆ $questionblocktitle

SurveyImportParser::$questionblocktitle

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

◆ $questions

SurveyImportParser::$questions

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

◆ $response_id

SurveyImportParser::$response_id

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

Referenced by handlerEndTag().

◆ $responses

SurveyImportParser::$responses

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

◆ $size

SurveyImportParser::$size

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

Referenced by getXMLSize().

◆ $spl

SurveyImportParser::$spl

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

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $spl_exists

SurveyImportParser::$spl_exists

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

Referenced by __construct().

◆ $survey

SurveyImportParser::$survey

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

◆ $survey_status

SurveyImportParser::$survey_status

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

◆ $surveyaccess

SurveyImportParser::$surveyaccess

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

◆ $text_size

SurveyImportParser::$text_size

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

Referenced by getXMLTextSize().

◆ $textblock

SurveyImportParser::$textblock

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

Referenced by handlerEndTag().

◆ $textblocks

SurveyImportParser::$textblocks

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

◆ $texts

SurveyImportParser::$texts

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

Referenced by getXMLTextSections().

◆ $variables

SurveyImportParser::$variables

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


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