ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
SurveyImportParser Class Reference

Survey Question Import Parser. More...

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

Public Member Functions

 SurveyImportParser ($a_spl_id, $a_xml_file='', $spl_exists=FALSE)
 Constructor. More...
 
 setSurveyObject (&$a_svy)
 Sets a reference to a survey object @access public. More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access 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
 ilSaxParser ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object @access 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 @access 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
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
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...
 
 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...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. 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

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

Member Function Documentation

◆ getErrorCode()

SurveyImportParser::getErrorCode ( )

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

References $error_code.

◆ getErrorColumn()

SurveyImportParser::getErrorColumn ( )

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

References $error_col.

◆ getErrorLine()

SurveyImportParser::getErrorLine ( )

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

References $error_line.

◆ getErrorMessage()

SurveyImportParser::getErrorMessage ( )

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

References $error_msg.

◆ getFullError()

SurveyImportParser::getFullError ( )

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

841 {
842 return "Error: ".$this->error_msg." at line:".$this->error_line ." column:".$this->error_col;
843 }

References $error_col.

◆ getParent()

SurveyImportParser::getParent (   $a_xml_parser)

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

184 {
185 if ($this->depth[$a_xml_parser] > 0)
186 {
187 return $this->path[$this->depth[$a_xml_parser]-1];
188 }
189 else
190 {
191 return "";
192 }
193 }

Referenced by handlerBeginTag(), and handlerEndTag().

+ Here is the caller graph for this function:

◆ getXMLAttributes()

SurveyImportParser::getXMLAttributes ( )

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

References $attributes.

◆ getXMLElements()

SurveyImportParser::getXMLElements ( )

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

References $elements.

◆ getXMLSize()

SurveyImportParser::getXMLSize ( )

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

846 {
847 return $this->size;
848 }

References $size.

◆ getXMLTextSections()

SurveyImportParser::getXMLTextSections ( )

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

References $texts.

◆ getXMLTextSize()

SurveyImportParser::getXMLTextSize ( )

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

References $text_size.

◆ handlerBeginTag()

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

handler for begin of element

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

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

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

+ Here is the call graph for this function:

◆ handlerCharacterData()

SurveyImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

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

References $characterbuffer.

◆ handlerEndTag()

SurveyImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

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

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

+ Here is the call graph for this function:

◆ hasError()

SurveyImportParser::hasError ( )

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

References $has_error.

◆ parse()

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

parse xml file

@access private

Reimplemented from ilSaxParser.

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

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

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

+ Here is the call graph for this function:

◆ setHandlers()

SurveyImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class @access private

Reimplemented from ilSaxParser.

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

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

◆ setSurveyObject()

SurveyImportParser::setSurveyObject ( $a_svy)

Sets a reference to a survey object @access public.

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

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

◆ startParsing()

SurveyImportParser::startParsing ( )

start the parser

Reimplemented from ilSaxParser.

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

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

◆ SurveyImportParser()

SurveyImportParser::SurveyImportParser (   $a_spl_id,
  $a_xml_file = '',
  $spl_exists = FALSE 
)

Constructor.

Parameters
string$a_xml_filexml file

@access public

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

86 {
87 parent::ilSaxParser($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 }

References $spl_exists.

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 SurveyImportParser().

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