ILIAS  release_7 Revision v7.30-3-g800a261c036
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()
 

Protected Member Functions

 getCharacterBuffer ()
 
 trimAndStripAttribs (array $attribs)
 
 trimAndStrip (string $input)
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Protected Attributes

 $showQuestiontext
 
 $showBlocktitle
 
 $compressView
 

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

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 63 of file class.SurveyImportParser.php.

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

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

Member Function Documentation

◆ getCharacterBuffer()

SurveyImportParser::getCharacterBuffer ( )
protected

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

References trimAndStrip().

Referenced by handlerEndTag().

408  : string
409  {
410  return $this->trimAndStrip((string) $this->characterbuffer);
411  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorCode()

SurveyImportParser::getErrorCode ( )

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

References $error_code.

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

◆ getErrorColumn()

SurveyImportParser::getErrorColumn ( )

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

References $error_col.

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

◆ getErrorLine()

SurveyImportParser::getErrorLine ( )

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

References $error_line.

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

◆ getErrorMessage()

SurveyImportParser::getErrorMessage ( )

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

References $error_msg.

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

◆ getFullError()

SurveyImportParser::getFullError ( )

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

References $error_col.

747  {
748  return "Error: " . $this->error_msg . " at line:" . $this->error_line . " column:" . $this->error_col;
749  }

◆ getParent()

SurveyImportParser::getParent (   $a_xml_parser)

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

Referenced by handlerBeginTag(), and handlerEndTag().

162  {
163  if ($this->depth[$a_xml_parser] > 0) {
164  return $this->path[$this->depth[$a_xml_parser] - 1];
165  } else {
166  return "";
167  }
168  }
+ Here is the caller graph for this function:

◆ getXMLAttributes()

SurveyImportParser::getXMLAttributes ( )

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

References $attributes.

762  {
763  return $this->attributes;
764  }

◆ getXMLElements()

SurveyImportParser::getXMLElements ( )

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

References $elements.

757  {
758  return $this->elements;
759  }

◆ getXMLSize()

SurveyImportParser::getXMLSize ( )

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

References $size.

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

◆ getXMLTextSections()

SurveyImportParser::getXMLTextSections ( )

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

References $texts.

767  {
768  return $this->texts;
769  }

◆ getXMLTextSize()

SurveyImportParser::getXMLTextSize ( )

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

References $text_size.

772  {
773  return $this->text_size;
774  }

◆ handlerBeginTag()

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

handler for begin of element

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

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

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

References $characterbuffer.

401  {
402  $this->texts++;
403  $this->text_size += strlen($a_data);
404  $this->characterbuffer .= $a_data;
405  $a_data = $this->characterbuffer;
406  }

◆ handlerEndTag()

SurveyImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

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

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

◆ hasError()

SurveyImportParser::hasError ( )

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

References $has_error.

777  {
778  return $this->has_error;
779  }

◆ parse()

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

parse xml file

private

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

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

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

116  {
117  xml_set_object($a_xml_parser, $this);
118  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
119  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
120  }

◆ setSurveyObject()

SurveyImportParser::setSurveyObject (   $a_svy)

Sets a reference to a survey object public.

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

106  {
107  $this->survey = $a_svy;
108  }

◆ startParsing()

SurveyImportParser::startParsing ( )

start the parser

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

126  {
127  parent::startParsing();
128  }

◆ trimAndStrip()

SurveyImportParser::trimAndStrip ( string  $input)
protected

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

References ilUtil\stripSlashes().

Referenced by getCharacterBuffer(), and trimAndStripAttribs().

790  : string
791  {
792  return ilUtil::stripSlashes(trim($input));
793  }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trimAndStripAttribs()

SurveyImportParser::trimAndStripAttribs ( array  $attribs)
protected

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

References $ret, and trimAndStrip().

Referenced by handlerBeginTag().

781  : array
782  {
783  $ret = [];
784  foreach ($attribs as $k => $v) {
785  $ret[$k] = $this->trimAndStrip((string) $v);
786  }
787  return $ret;
788  }
$ret
Definition: parser.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $activequestion

SurveyImportParser::$activequestion

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

◆ $activetag

SurveyImportParser::$activetag

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

◆ $adjectives

SurveyImportParser::$adjectives

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

◆ $anonymisation

SurveyImportParser::$anonymisation

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

◆ $attributes

SurveyImportParser::$attributes

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

Referenced by getXMLAttributes().

◆ $characterbuffer

SurveyImportParser::$characterbuffer

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

Referenced by handlerCharacterData(), and handlerEndTag().

◆ $compressView

SurveyImportParser::$compressView
protected

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

◆ $constraints

SurveyImportParser::$constraints

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

◆ $depth

SurveyImportParser::$depth

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

◆ $elements

SurveyImportParser::$elements

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

Referenced by getXMLElements().

◆ $error_code

SurveyImportParser::$error_code

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

Referenced by getErrorCode().

◆ $error_col

SurveyImportParser::$error_col

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

Referenced by getErrorColumn(), and getFullError().

◆ $error_line

SurveyImportParser::$error_line

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

Referenced by getErrorLine().

◆ $error_msg

SurveyImportParser::$error_msg

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

Referenced by getErrorMessage().

◆ $has_error

SurveyImportParser::$has_error

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

Referenced by hasError().

◆ $in_questionblock

SurveyImportParser::$in_questionblock

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

◆ $in_survey

SurveyImportParser::$in_survey

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

◆ $is_matrix

SurveyImportParser::$is_matrix

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

◆ $material

SurveyImportParser::$material

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

Referenced by handlerEndTag().

◆ $matrix

SurveyImportParser::$matrix

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

◆ $matrixrowattribs

SurveyImportParser::$matrixrowattribs

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

◆ $metadata

SurveyImportParser::$metadata

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

◆ $original_question_id

SurveyImportParser::$original_question_id

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

Referenced by handlerEndTag().

◆ $path

SurveyImportParser::$path

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

◆ $questionblock

SurveyImportParser::$questionblock

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

Referenced by handlerEndTag().

◆ $questionblocks

SurveyImportParser::$questionblocks

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

◆ $questionblocktitle

SurveyImportParser::$questionblocktitle

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

◆ $questions

SurveyImportParser::$questions

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

◆ $response_id

SurveyImportParser::$response_id

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

Referenced by handlerEndTag().

◆ $responses

SurveyImportParser::$responses

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

◆ $showBlocktitle

SurveyImportParser::$showBlocktitle
protected

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

◆ $showQuestiontext

SurveyImportParser::$showQuestiontext
protected

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

◆ $size

SurveyImportParser::$size

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

Referenced by getXMLSize().

◆ $spl

SurveyImportParser::$spl

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

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $spl_exists

SurveyImportParser::$spl_exists

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

Referenced by __construct().

◆ $survey

SurveyImportParser::$survey

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

◆ $survey_status

SurveyImportParser::$survey_status

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

◆ $surveyaccess

SurveyImportParser::$surveyaccess

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

◆ $text_size

SurveyImportParser::$text_size

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

Referenced by getXMLTextSize().

◆ $textblock

SurveyImportParser::$textblock

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

Referenced by handlerEndTag().

◆ $textblocks

SurveyImportParser::$textblocks

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

◆ $texts

SurveyImportParser::$texts

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

Referenced by getXMLTextSections().

◆ $variables

SurveyImportParser::$variables

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


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