ILIAS  release_8 Revision v8.24
class.SurveyImportParser.php
Go to the documentation of this file.
1<?php
2
25{
26 protected \ILIAS\SurveyQuestionPool\Export\ImportSessionRepository $session_repo;
27 protected ?ilImportMapping $mapping = null;
28 protected int $spl_id = 0;
29 protected int $showQuestiontext;
30 protected int $showBlocktitle;
31 protected int $compressView;
32 public array $path = [];
33 public int $depth = 0;
46 public $error_col;
47 public ?string $error_msg;
48 public bool $has_error = false;
49 public int $elements = 0;
50 public int $attributes = 0;
51 public int $texts = 0;
52 public int $text_size = 0;
53 public string $characterbuffer = "";
54 public string $activetag = "";
55 public array $material = [];
56 public array $metadata = [];
57 public array $responses = [];
58 public array $variables = [];
59 public string $response_id = "";
60 public array $matrix = [];
61 public array $matrixrowattribs = [];
62 public bool $is_matrix = false;
63 public array $adjectives = [];
64 public bool $spl_exists = false;
65 public bool $in_survey = false;
66 public ?ilObjSurvey $survey = null;
67 public int $anonymisation = 0;
68 public string $surveyaccess = "";
69 public array $questions = [];
70 public string $original_question_id = "";
71 public array $constraints = [];
72 public string $textblock = "";
73 public array $textblocks = [];
74 public bool $survey_status = false;
75 public bool $in_questionblock = false;
76 public array $questionblock = [];
77 public array $questionblocks = [];
78 public string $questionblocktitle = "";
79
80 public function __construct(
81 int $a_spl_id,
82 ?string $a_xml_file = '',
83 bool $spl_exists = false,
84 ?ilImportMapping $a_mapping = null
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 }
125
126 public function setSurveyObject(ilObjSurvey $a_svy): void
127 {
128 $this->survey = $a_svy;
129 }
130
131 public function setHandlers($a_xml_parser): 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 }
137
142 public function parse($a_xml_parser, $a_fp = null): 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 }
165
166 public function getParent(): string
167 {
168 if ($this->depth > 0) {
169 return $this->path[$this->depth - 1];
170 }
171
172 return "";
173 }
174
178 public function handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs): 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 }
405
409 public function handlerCharacterData($a_xml_parser, string $a_data): void
410 {
411 $this->texts++;
412 $this->text_size += strlen($a_data);
413 $this->characterbuffer .= $a_data;
414 $a_data = $this->characterbuffer;
415 }
416
417 protected function getCharacterBuffer($use_purifier = false): 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 }
425
429 public function handlerEndTag($a_xml_parser, string $a_name): 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 }
740
741 public function getErrorCode(): ?int
742 {
743 return $this->error_code;
744 }
745
746 public function getErrorLine(): ?int
747 {
748 return $this->error_line;
749 }
750
751 public function getErrorColumn(): ?int
752 {
753 return $this->error_col;
754 }
755
756 public function getErrorMessage(): ?string
757 {
758 return $this->error_msg;
759 }
760
761 public function getFullError(): string
762 {
763 return "Error: " . $this->error_msg . " at line:" . $this->error_line . " column:" . $this->error_col;
764 }
765
766 public function getXMLElements(): int
767 {
768 return $this->elements;
769 }
770
771 public function getXMLAttributes(): int
772 {
773 return $this->attributes;
774 }
775
776 public function getXMLTextSections(): int
777 {
778 return $this->texts;
779 }
780
781 public function getXMLTextSize(): int
782 {
783 return $this->text_size;
784 }
785
786 public function hasError(): bool
787 {
788 return $this->has_error;
789 }
790
791 protected function trimAndStripAttribs(array $attribs): 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 }
801
802 protected function trimAndStrip(string $input): string
803 {
804 return ilUtil::stripSlashes(trim($input));
805 }
806}
$attrib
Regular expression to match HTML/XML attribute pairs within a tag.
Definition: Sanitizer.php:42
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
handlerCharacterData($a_xml_parser, string $a_data)
getCharacterBuffer($use_purifier=false)
trimAndStripAttribs(array $attribs)
setSurveyObject(ilObjSurvey $a_svy)
ILIAS SurveyQuestionPool Export ImportSessionRepository $session_repo
handlerEndTag($a_xml_parser, string $a_name)
parse($a_xml_parser, $a_fp=null)
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
__construct(int $a_spl_id, ?string $a_xml_file='', bool $spl_exists=false, ?ilImportMapping $a_mapping=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193
$type