ILIAS  release_8 Revision v8.24
SurveyImportParser Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (int $a_spl_id, ?string $a_xml_file='', bool $spl_exists=false, ?ilImportMapping $a_mapping=null)
 
 setSurveyObject (ilObjSurvey $a_svy)
 
 setHandlers ($a_xml_parser)
 
 parse ($a_xml_parser, $a_fp=null)
 
 getParent ()
 
 handlerBeginTag ($a_xml_parser, string $a_name, array $a_attribs)
 
 handlerCharacterData ($a_xml_parser, string $a_data)
 
 handlerEndTag ($a_xml_parser, string $a_name)
 
 getErrorCode ()
 
 getErrorLine ()
 
 getErrorColumn ()
 
 getErrorMessage ()
 
 getFullError ()
 
 getXMLElements ()
 
 getXMLAttributes ()
 
 getXMLTextSections ()
 
 getXMLTextSize ()
 
 hasError ()
 
- Public Member Functions inherited from ilSaxParser
 __construct (?string $path_to_file='', ?bool $throw_exception=false)
 
 setXMLContent (string $a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 
 setHandlers ($a_xml_parser)
 
 parse ($a_xml_parser, $a_fp=null)
 

Data Fields

array $path = []
 
int $depth = 0
 
SurveyQuestion $activequestion
 
 $error_code
 
 $error_line
 
 $error_col
 
string $error_msg
 
bool $has_error = false
 
int $elements = 0
 
int $attributes = 0
 
int $texts = 0
 
int $text_size = 0
 
string $characterbuffer = ""
 
string $activetag = ""
 
array $material = []
 
array $metadata = []
 
array $responses = []
 
array $variables = []
 
string $response_id = ""
 
array $matrix = []
 
array $matrixrowattribs = []
 
bool $is_matrix = false
 
array $adjectives = []
 
bool $spl_exists = false
 
bool $in_survey = false
 
ilObjSurvey $survey = null
 
int $anonymisation = 0
 
string $surveyaccess = ""
 
array $questions = []
 
string $original_question_id = ""
 
array $constraints = []
 
string $textblock = ""
 
array $textblocks = []
 
bool $survey_status = false
 
bool $in_questionblock = false
 
array $questionblock = []
 
array $questionblocks = []
 
string $questionblocktitle = ""
 
- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 

Protected Member Functions

 getCharacterBuffer ($use_purifier=false)
 
 trimAndStripAttribs (array $attribs)
 
 trimAndStrip (string $input)
 
- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 

Protected Attributes

ILIAS SurveyQuestionPool Export ImportSessionRepository $session_repo
 
ilImportMapping $mapping = null
 
int $spl_id = 0
 
int $showQuestiontext
 
int $showBlocktitle
 
int $compressView
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 24 of file class.SurveyImportParser.php.

Constructor & Destructor Documentation

◆ __construct()

SurveyImportParser::__construct ( int  $a_spl_id,
?string  $a_xml_file = '',
bool  $spl_exists = false,
?ilImportMapping  $a_mapping = null 
)

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

85 {
86 global $DIC;
87
88 parent::__construct($a_xml_file);
89 $this->spl_id = $a_spl_id;
90 $this->has_error = false;
91 $this->characterbuffer = "";
92 $this->survey_status = false;
93 $this->activetag = "";
94 $this->material = array();
95 $this->depth = 0;
96 $this->path = array();
97 $this->metadata = array();
98 $this->responses = array();
99 $this->variables = array();
100 $this->response_id = "";
101 $this->matrix = array();
102 $this->is_matrix = false;
103 $this->adjectives = array();
104 $this->spl_exists = $spl_exists;
105 $this->survey = null;
106 $this->in_survey = false;
107 $this->anonymisation = 0;
108 $this->surveyaccess = "restricted";
109 $this->questions = array();
110 $this->original_question_id = "";
111 $this->constraints = array();
112 $this->textblock = "";
113 $this->textblocks = array();
114 $this->in_questionblock = false;
115 $this->questionblocks = array();
116 $this->questionblock = array();
117 $this->showQuestiontext = 1;
118 $this->showBlocktitle = 0;
119 $this->compressView = 0;
120 $this->questionblocktitle = "";
121 $this->mapping = $a_mapping;
122 $this->session_repo = $DIC->surveyQuestionPool()->internal()
123 ->repo()->import();
124 }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getCharacterBuffer()

SurveyImportParser::getCharacterBuffer (   $use_purifier = false)
protected

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

417 : string
418 {
419 if ($use_purifier) {
420 $purifier = new ilSvyStandardPurifier();
421 return $purifier->purify((string) $this->characterbuffer);
422 }
423 return $this->trimAndStrip((string) $this->characterbuffer);
424 }

References trimAndStrip().

Referenced by handlerEndTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorCode()

SurveyImportParser::getErrorCode ( )

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

741 : ?int
742 {
743 return $this->error_code;
744 }

References $error_code.

◆ getErrorColumn()

SurveyImportParser::getErrorColumn ( )

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

751 : ?int
752 {
753 return $this->error_col;
754 }

References $error_col.

◆ getErrorLine()

SurveyImportParser::getErrorLine ( )

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

746 : ?int
747 {
748 return $this->error_line;
749 }

References $error_line.

◆ getErrorMessage()

SurveyImportParser::getErrorMessage ( )

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

756 : ?string
757 {
758 return $this->error_msg;
759 }

References $error_msg.

◆ getFullError()

SurveyImportParser::getFullError ( )

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

761 : string
762 {
763 return "Error: " . $this->error_msg . " at line:" . $this->error_line . " column:" . $this->error_col;
764 }

References $error_col.

◆ getParent()

SurveyImportParser::getParent ( )

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

166 : string
167 {
168 if ($this->depth > 0) {
169 return $this->path[$this->depth - 1];
170 }
171
172 return "";
173 }

Referenced by handlerBeginTag(), and handlerEndTag().

+ Here is the caller graph for this function:

◆ getXMLAttributes()

SurveyImportParser::getXMLAttributes ( )

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

771 : int
772 {
773 return $this->attributes;
774 }

References $attributes.

◆ getXMLElements()

SurveyImportParser::getXMLElements ( )

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

766 : int
767 {
768 return $this->elements;
769 }

References $elements.

◆ getXMLTextSections()

SurveyImportParser::getXMLTextSections ( )

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

776 : int
777 {
778 return $this->texts;
779 }

References $texts.

◆ getXMLTextSize()

SurveyImportParser::getXMLTextSize ( )

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

781 : int
782 {
783 return $this->text_size;
784 }

References $text_size.

◆ handlerBeginTag()

SurveyImportParser::handlerBeginTag (   $a_xml_parser,
string  $a_name,
array  $a_attribs 
)
Parameters
resource$a_xml_parser

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

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

References $attrib, $depth, ILIAS\LTI\ToolProvider\$key, $original_question_id, $spl_id, $type, SurveyQuestion\_includeClass(), getParent(), ILIAS\Repository\int(), and trimAndStripAttribs().

+ Here is the call graph for this function:

◆ handlerCharacterData()

SurveyImportParser::handlerCharacterData (   $a_xml_parser,
string  $a_data 
)
Parameters
resource$a_xml_parser

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

409 : void
410 {
411 $this->texts++;
412 $this->text_size += strlen($a_data);
413 $this->characterbuffer .= $a_data;
414 $a_data = $this->characterbuffer;
415 }

References $characterbuffer.

◆ handlerEndTag()

SurveyImportParser::handlerEndTag (   $a_xml_parser,
string  $a_name 
)
Parameters
resource$a_xml_parser

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

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

References $characterbuffer, $data, ILIAS\LTI\ToolProvider\$key, $material, $original_question_id, $questionblock, $response_id, $textblock, getCharacterBuffer(), and getParent().

+ Here is the call graph for this function:

◆ hasError()

SurveyImportParser::hasError ( )

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

786 : bool
787 {
788 return $this->has_error;
789 }

References $has_error.

◆ parse()

SurveyImportParser::parse (   $a_xml_parser,
  $a_fp = null 
)
Parameters
resource$a_xml_parser
resource | null$a_fp

Reimplemented from ilSaxParser.

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

142 : void
143 {
144 switch ($this->getInputType()) {
145 case 'file':
146
147 while ($data = fread($a_fp, 4096)) {
148 $parseOk = xml_parse($a_xml_parser, $data, feof($a_fp));
149 }
150 break;
151
152 case 'string':
153 $parseOk = xml_parse($a_xml_parser, $this->getXMLContent());
154 break;
155 }
156 if (!$parseOk
157 && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE)) {
158 $this->error_code = xml_get_error_code($a_xml_parser);
159 $this->error_line = xml_get_current_line_number($a_xml_parser);
160 $this->error_col = xml_get_current_column_number($a_xml_parser);
161 $this->error_msg = xml_error_string($this->error_code);
162 $this->has_error = true;
163 }
164 }

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

+ Here is the call graph for this function:

◆ setHandlers()

SurveyImportParser::setHandlers (   $a_xml_parser)
Parameters
XMLParser | resource$a_xml_parser
Returns
void

Reimplemented from ilSaxParser.

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

131 : void
132 {
133 xml_set_object($a_xml_parser, $this);
134 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
135 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
136 }

◆ setSurveyObject()

SurveyImportParser::setSurveyObject ( ilObjSurvey  $a_svy)

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

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

◆ trimAndStrip()

SurveyImportParser::trimAndStrip ( string  $input)
protected

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

802 : string
803 {
804 return ilUtil::stripSlashes(trim($input));
805 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References ilUtil\stripSlashes().

Referenced by getCharacterBuffer(), and trimAndStripAttribs().

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

791 : array
792 {
793 $ret = [];
794 foreach ($attribs as $k => $v) {
795 $ret[$k] = ((string) $v !== "<>")
796 ? $this->trimAndStrip((string) $v)
797 : "<>";
798 }
799 return $ret;
800 }

References trimAndStrip().

Referenced by handlerBeginTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $activequestion

SurveyQuestion SurveyImportParser::$activequestion

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

◆ $activetag

string SurveyImportParser::$activetag = ""

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

◆ $adjectives

array SurveyImportParser::$adjectives = []

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

◆ $anonymisation

int SurveyImportParser::$anonymisation = 0

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

◆ $attributes

int SurveyImportParser::$attributes = 0

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

Referenced by getXMLAttributes().

◆ $characterbuffer

string SurveyImportParser::$characterbuffer = ""

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

Referenced by handlerCharacterData(), and handlerEndTag().

◆ $compressView

int SurveyImportParser::$compressView
protected

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

◆ $constraints

array SurveyImportParser::$constraints = []

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

◆ $depth

int SurveyImportParser::$depth = 0

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

Referenced by handlerBeginTag().

◆ $elements

int SurveyImportParser::$elements = 0

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

Referenced by getXMLElements().

◆ $error_code

SurveyImportParser::$error_code

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

Referenced by getErrorCode().

◆ $error_col

SurveyImportParser::$error_col

Definition at line 46 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

string SurveyImportParser::$error_msg

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

Referenced by getErrorMessage().

◆ $has_error

bool SurveyImportParser::$has_error = false

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

Referenced by hasError().

◆ $in_questionblock

bool SurveyImportParser::$in_questionblock = false

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

◆ $in_survey

bool SurveyImportParser::$in_survey = false

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

◆ $is_matrix

bool SurveyImportParser::$is_matrix = false

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

◆ $mapping

ilImportMapping SurveyImportParser::$mapping = null
protected

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

◆ $material

array SurveyImportParser::$material = []

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

Referenced by handlerEndTag().

◆ $matrix

array SurveyImportParser::$matrix = []

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

◆ $matrixrowattribs

array SurveyImportParser::$matrixrowattribs = []

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

◆ $metadata

array SurveyImportParser::$metadata = []

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

◆ $original_question_id

string SurveyImportParser::$original_question_id = ""

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

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $path

array SurveyImportParser::$path = []

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

◆ $questionblock

array SurveyImportParser::$questionblock = []

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

Referenced by handlerEndTag().

◆ $questionblocks

array SurveyImportParser::$questionblocks = []

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

◆ $questionblocktitle

string SurveyImportParser::$questionblocktitle = ""

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

◆ $questions

array SurveyImportParser::$questions = []

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

◆ $response_id

string SurveyImportParser::$response_id = ""

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

Referenced by handlerEndTag().

◆ $responses

array SurveyImportParser::$responses = []

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

◆ $session_repo

ILIAS SurveyQuestionPool Export ImportSessionRepository SurveyImportParser::$session_repo
protected

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

◆ $showBlocktitle

int SurveyImportParser::$showBlocktitle
protected

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

◆ $showQuestiontext

int SurveyImportParser::$showQuestiontext
protected

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

◆ $spl_exists

bool SurveyImportParser::$spl_exists = false

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

Referenced by __construct().

◆ $spl_id

int SurveyImportParser::$spl_id = 0
protected

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

Referenced by handlerBeginTag().

◆ $survey

ilObjSurvey SurveyImportParser::$survey = null

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

◆ $survey_status

bool SurveyImportParser::$survey_status = false

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

◆ $surveyaccess

string SurveyImportParser::$surveyaccess = ""

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

◆ $text_size

int SurveyImportParser::$text_size = 0

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

Referenced by getXMLTextSize().

◆ $textblock

string SurveyImportParser::$textblock = ""

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

Referenced by handlerEndTag().

◆ $textblocks

array SurveyImportParser::$textblocks = []

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

◆ $texts

int SurveyImportParser::$texts = 0

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

Referenced by getXMLTextSections().

◆ $variables

array SurveyImportParser::$variables = []

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


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