ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 728 of file class.SurveyImportParser.php.

References $error_code.

729  {
730  return $this->error_code;
731  }

◆ getErrorColumn()

SurveyImportParser::getErrorColumn ( )

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

References $error_col.

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

◆ getErrorLine()

SurveyImportParser::getErrorLine ( )

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

References $error_line.

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

◆ getErrorMessage()

SurveyImportParser::getErrorMessage ( )

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

References $error_msg.

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

◆ getFullError()

SurveyImportParser::getFullError ( )

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

References $error_col.

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

◆ getParent()

SurveyImportParser::getParent (   $a_xml_parser)

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

Referenced by handlerBeginTag(), and handlerEndTag().

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

◆ getXMLAttributes()

SurveyImportParser::getXMLAttributes ( )

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

References $attributes.

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

◆ getXMLElements()

SurveyImportParser::getXMLElements ( )

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

References $elements.

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

◆ getXMLSize()

SurveyImportParser::getXMLSize ( )

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

References $size.

754  {
755  return $this->size;
756  }

◆ getXMLTextSections()

SurveyImportParser::getXMLTextSections ( )

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

References $texts.

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

◆ getXMLTextSize()

SurveyImportParser::getXMLTextSize ( )

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

References $text_size.

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

◆ handlerBeginTag()

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

handler for begin of element

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

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

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

◆ handlerCharacterData()

SurveyImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

References $characterbuffer.

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

◆ handlerEndTag()

SurveyImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

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

424  {
425  switch ($a_name) {
426  case "surveyobject":
427  if (is_object($this->survey)) {
428  $this->survey->setStatus($this->survey_status);
429  $this->survey->saveToDb();
430 
431  // write question blocks
432  if (count($this->questionblocks)) {
433  foreach ($this->questionblocks as $data) {
434  $questionblock = $data["questions"];
435  $title = $data["title"];
436  $qblock = array();
437  foreach ($questionblock as $question_id) {
438  array_push($qblock, $this->questions[$question_id]);
439  }
440  $this->survey->createQuestionblock($title, $this->showQuestiontext, false, $qblock);
441  }
442  }
443 
444  // #13878 - write constraints
445  if (count($this->constraints)) {
446  $relations = $this->survey->getAllRelations(true);
447  foreach ($this->constraints as $constraint) {
448  $constraint_id= $this->survey->addConstraint($this->questions[$constraint["destref"]], $relations[$constraint["relation"]]["id"], $constraint["value"], $constraint["conjunction"]);
449  $this->survey->addConstraintToQuestion($this->questions[$constraint["sourceref"]], $constraint_id);
450  }
451  }
452 
453  // write textblocks
454  if (count($this->textblocks)) {
455  foreach ($this->textblocks as $original_id => $textblock) {
456  $this->survey->saveHeading($textblock, $this->questions[$original_id]);
457  }
458  }
459  }
460  break;
461  case "survey":
462  $this->in_survey = false;
463  if (is_object($this->survey)) {
464  if (strcmp($this->surveyaccess, "free") == 0) {
465  $this->survey->setAnonymize(2);
466  } else {
467  if ($this->anonymisation == 0) {
468  $this->survey->setAnonymize(0);
469  } else {
470  $this->survey->setAnonymize(1);
471  }
472  }
473  }
474  break;
475  case "startingtime":
476  if (preg_match("/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->characterbuffer, $matches)) {
477  if (is_object($this->survey)) {
478  $this->survey->setStartDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
479  }
480  }
481  break;
482  case "endingtime":
483  if (preg_match("/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->characterbuffer, $matches)) {
484  if (is_object($this->survey)) {
485  $this->survey->setEndDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
486  }
487  }
488  break;
489  case "description":
490  if ($this->in_survey) {
491  if (is_object($this->survey)) {
492  $this->survey->setDescription($this->characterbuffer);
493  }
494  } else {
495  if (is_object($this->activequestion)) {
496  $this->activequestion->setDescription($this->characterbuffer);
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->characterbuffer);
528  }
529  } else {
530  if (is_object($this->activequestion)) {
531  $this->activequestion->setAuthor($this->characterbuffer);
532  }
533  }
534  break;
535  case "mattext":
536  $this->material[count($this->material)-1]["text"] = $this->characterbuffer;
537  break;
538  case "matimage":
539  $this->material[count($this->material)-1]["image"] = $this->characterbuffer;
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->characterbuffer;
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  include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
591  include_once "./Services/MetaData/classes/class.ilMD.php";
592  $md_sax_parser = new ilMDSaxParser();
593  $md_sax_parser->setXMLContent($value["entry"]);
594  $md_sax_parser->setMDObject($tmp = new ilMD($this->survey->getId(), 0, "svy"));
595  $md_sax_parser->enableMDParsing(true);
596  $md_sax_parser->startParsing();
597  $this->survey->MDUpdateListener("General");
598  }
599  }
600  break;
601  case "display_question_titles":
602  if ($value["entry"] == 1) {
603  $this->survey->showQuestionTitles();
604  } else {
605  $this->survey->hideQuestionTitles();
606  }
607  break;
608  case "status":
609  $this->survey_status = $value["entry"];
610  break;
611  case "evaluation_access":
612  $this->survey->setEvaluationAccess($value["entry"]);
613  break;
614  case "pool_usage":
615  $this->survey->setPoolUsage($value["entry"]);
616  break;
617  case "own_results_view":
618  $this->survey->setViewOwnResults($value["entry"]);
619  break;
620  case "own_results_mail":
621  $this->survey->setMailOwnResults($value["entry"]);
622  break;
623  case "confirmation_mail":
624  $this->survey->setMailConfirmation($value["entry"]);
625  break;
626  case "anon_user_list":
627  $this->survey->setAnonymousUserList($value["entry"]);
628  break;
629  case "mode_360":
630  $this->survey->set360Mode($value["entry"]);
631  break;
632  case "mode_360_self_eval":
633  $this->survey->set360SelfEvaluation($value["entry"]);
634  break;
635  case "mode_360_self_rate":
636  $this->survey->set360SelfRaters($value["entry"]);
637  break;
638  case "mode_360_self_appr":
639  $this->survey->set360SelfAppraisee($value["entry"]);
640  break;
641  case "mode_360_results":
642  $this->survey->set360Results($value["entry"]);
643  break;
644  case "mode_360_skill_service":
645  $this->survey->set360SkillService($value["entry"]);
646  break;
647  }
648  }
649  }
650  if (!$this->spl_exists) {
651  if (strcmp($this->getParent($a_xml_parser), "surveyquestions") == 0) {
652  foreach ($this->metadata as $key => $value) {
653  if (strcmp($value["label"], "SCORM") == 0) {
654  if (strlen($value["entry"])) {
655  if ($this->spl_id > 0) {
656  include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
657  include_once "./Services/MetaData/classes/class.ilMD.php";
658  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
659  $md_sax_parser = new ilMDSaxParser();
660  $md_sax_parser->setXMLContent($value["entry"]);
661  $md_sax_parser->setMDObject($tmp = new ilMD($this->spl_id, 0, "spl"));
662  $md_sax_parser->enableMDParsing(true);
663  $md_sax_parser->startParsing();
664  $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
665  $spl->MDUpdateListener("General");
666  }
667  }
668  }
669  }
670  }
671  }
672  break;
673  case "responses":
674  if (is_object($this->activequestion)) {
675  $this->activequestion->importResponses($this->responses);
676  }
677  $this->is_matrix = false;
678  break;
679  case "variable":
680  array_push($this->variables, $this->characterbuffer);
681  break;
682  case "variables":
683  if (is_object($this->activequestion)) {
684  $this->activequestion->importVariables($this->variables);
685  }
686  break;
687  case "response_single":
688  case "response_multiple":
689  case "response_text":
690  case "response_num":
691  case "response_time":
692  $this->responses[$this->response_id]["material"] = $this->material;
693  break;
694  case "adjective":
695  $this->adjectives[count($this->adjectives)-1]["text"] = $this->characterbuffer;
696  break;
697  case "bipolar_adjectives":
698  if (is_object($this->activequestion)) {
699  $this->activequestion->importAdjectives($this->adjectives);
700  }
701  break;
702  case "matrixrow":
703  $row = "";
704  foreach ($this->material as $material) {
705  $row .= $material["text"];
706  }
707  $this->matrix[count($this->matrix)-1] = array('title' => $row, 'id' => $this->matrixrowattribs['id'], 'label' => $this->matrixrowattribs['label'], 'other' => $this->matrixrowattribs['other']);
708  break;
709  case "matrix":
710  if (is_object($this->activequestion)) {
711  $this->activequestion->importMatrix($this->matrix);
712  }
713  break;
714  case "textblock":
715  $this->textblock = $this->characterbuffer;
716  break;
717  case "questionblocktitle":
718  $this->questionblocktitle = $this->characterbuffer;
719  break;
720  case "questionblock":
721  $this->in_questionblock = false;
722  array_push($this->questionblocks, array("title" => $this->questionblocktitle, "questions" => $this->questionblock));
723  break;
724  }
725  $this->depth[$a_xml_parser]--;
726  }
Create styles array
The data for the language used.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ hasError()

SurveyImportParser::hasError ( )

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

References $has_error.

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

◆ parse()

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

parse xml file

private

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

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

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

◆ setHandlers()

SurveyImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

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

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

◆ setSurveyObject()

SurveyImportParser::setSurveyObject (   $a_svy)

Sets a reference to a survey object public.

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

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

◆ startParsing()

SurveyImportParser::startParsing ( )

start the parser

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

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

Field Documentation

◆ $activequestion

SurveyImportParser::$activequestion

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

◆ $activetag

SurveyImportParser::$activetag

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

◆ $adjectives

SurveyImportParser::$adjectives

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

◆ $anonymisation

SurveyImportParser::$anonymisation

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

◆ $attributes

SurveyImportParser::$attributes

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

Referenced by getXMLAttributes().

◆ $characterbuffer

SurveyImportParser::$characterbuffer

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

Referenced by handlerCharacterData(), and handlerEndTag().

◆ $constraints

SurveyImportParser::$constraints

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

◆ $depth

SurveyImportParser::$depth

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

◆ $elements

SurveyImportParser::$elements

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

Referenced by getXMLElements().

◆ $error_code

SurveyImportParser::$error_code

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

Referenced by getErrorCode().

◆ $error_col

SurveyImportParser::$error_col

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

Referenced by getErrorColumn(), and getFullError().

◆ $error_line

SurveyImportParser::$error_line

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

Referenced by getErrorLine().

◆ $error_msg

SurveyImportParser::$error_msg

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

Referenced by getErrorMessage().

◆ $has_error

SurveyImportParser::$has_error

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

Referenced by hasError().

◆ $in_questionblock

SurveyImportParser::$in_questionblock

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

◆ $in_survey

SurveyImportParser::$in_survey

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

◆ $is_matrix

SurveyImportParser::$is_matrix

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

◆ $material

SurveyImportParser::$material

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

Referenced by handlerEndTag().

◆ $matrix

SurveyImportParser::$matrix

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

◆ $matrixrowattribs

SurveyImportParser::$matrixrowattribs

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

◆ $metadata

SurveyImportParser::$metadata

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

◆ $original_question_id

SurveyImportParser::$original_question_id

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

Referenced by handlerEndTag().

◆ $path

SurveyImportParser::$path

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

◆ $questionblock

SurveyImportParser::$questionblock

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

Referenced by handlerEndTag().

◆ $questionblocks

SurveyImportParser::$questionblocks

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

◆ $questionblocktitle

SurveyImportParser::$questionblocktitle

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

◆ $questions

SurveyImportParser::$questions

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

◆ $response_id

SurveyImportParser::$response_id

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

Referenced by handlerEndTag().

◆ $responses

SurveyImportParser::$responses

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

◆ $size

SurveyImportParser::$size

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

Referenced by getXMLSize().

◆ $spl

SurveyImportParser::$spl

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

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $spl_exists

SurveyImportParser::$spl_exists

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

Referenced by __construct().

◆ $survey

SurveyImportParser::$survey

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

◆ $survey_status

SurveyImportParser::$survey_status

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

◆ $surveyaccess

SurveyImportParser::$surveyaccess

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

◆ $text_size

SurveyImportParser::$text_size

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

Referenced by getXMLTextSize().

◆ $textblock

SurveyImportParser::$textblock

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

Referenced by handlerEndTag().

◆ $textblocks

SurveyImportParser::$textblocks

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

◆ $texts

SurveyImportParser::$texts

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

Referenced by getXMLTextSections().

◆ $variables

SurveyImportParser::$variables

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


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