ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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;
38  public $error_code;
42  public $error_line;
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->activequestion = null;
90  $this->spl_id = $a_spl_id;
91  $this->has_error = false;
92  $this->characterbuffer = "";
93  $this->survey_status = false;
94  $this->activetag = "";
95  $this->material = [];
96  $this->depth = 0;
97  $this->path = array();
98  $this->metadata = array();
99  $this->responses = array();
100  $this->variables = array();
101  $this->response_id = "";
102  $this->matrix = array();
103  $this->is_matrix = false;
104  $this->adjectives = array();
105  $this->spl_exists = $spl_exists;
106  $this->survey = null;
107  $this->in_survey = false;
108  $this->anonymisation = 0;
109  $this->surveyaccess = "restricted";
110  $this->questions = array();
111  $this->original_question_id = "";
112  $this->constraints = array();
113  $this->textblock = "";
114  $this->textblocks = array();
115  $this->in_questionblock = false;
116  $this->questionblocks = array();
117  $this->questionblock = array();
118  $this->showQuestiontext = 1;
119  $this->showBlocktitle = 0;
120  $this->compressView = 0;
121  $this->questionblocktitle = "";
122  $this->mapping = $a_mapping;
123  $this->session_repo = $DIC->surveyQuestionPool()->internal()
124  ->repo()->import();
125  }
126 
127  public function setSurveyObject(ilObjSurvey $a_svy): void
128  {
129  $this->survey = $a_svy;
130  }
131 
132  public function setHandlers($a_xml_parser): void
133  {
134  xml_set_object($a_xml_parser, $this);
135  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
136  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
137  }
138 
143  public function parse($a_xml_parser, $a_fp = null): void
144  {
145  switch ($this->getInputType()) {
146  case 'file':
147 
148  while ($data = fread($a_fp, 4096)) {
149  $parseOk = xml_parse($a_xml_parser, $data, feof($a_fp));
150  }
151  break;
152 
153  case 'string':
154  $parseOk = xml_parse($a_xml_parser, $this->getXMLContent());
155  break;
156  }
157  if (!$parseOk
158  && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE)) {
159  $this->error_code = xml_get_error_code($a_xml_parser);
160  $this->error_line = xml_get_current_line_number($a_xml_parser);
161  $this->error_col = xml_get_current_column_number($a_xml_parser);
162  $this->error_msg = xml_error_string($this->error_code);
163  $this->has_error = true;
164  }
165  }
166 
167  public function getParent(): string
168  {
169  if ($this->depth > 0) {
170  return $this->path[$this->depth - 1];
171  }
172 
173  return "";
174  }
175 
179  public function handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs): void
180  {
181  $a_attribs = $this->trimAndStripAttribs($a_attribs);
182  $this->depth++;
183  $this->path[$this->depth] = strtolower($a_name);
184  $this->characterbuffer = "";
185  $this->activetag = $a_name;
186  $this->elements++;
187  $this->attributes += count($a_attribs);
188  switch ($a_name) {
189  case "questionblock":
190  $this->in_questionblock = true;
191  $this->questionblock = array();
192  $this->questionblocktitle = "";
193  $this->showQuestiontext = 1;
194  $this->showBlocktitle = 0;
195  $this->compressView = 0;
196  foreach ($a_attribs as $attrib => $value) {
197  switch ($attrib) {
198  case "showQuestiontext":
199  $this->showQuestiontext = (int) $value;
200  break;
201  case "showBlocktitle":
202  $this->showBlocktitle = (int) $value;
203  break;
204  case "compressView":
205  $this->compressView = (int) $value;
206  break;
207  }
208  }
209  break;
210  case "surveyquestions":
211  foreach ($a_attribs as $attrib => $value) {
212  switch ($attrib) {
213  case "online":
214  if ($this->spl_id > 0) {
215  $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
216  $spl->setOfflineStatus(!$value);
217  $spl->saveToDb();
218  }
219  break;
220  case "label":
221  $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
222  $spl->setTitle($value);
223  $spl->saveToDb();
224  break;
225  }
226  }
227  break;
228  case "survey":
229  $this->in_survey = true;
230  foreach ($a_attribs as $attrib => $value) {
231  switch ($attrib) {
232  case "title":
233  if (is_object($this->survey)) {
234  $this->survey->setTitle($value);
235  $this->survey->update(true);
236  }
237  break;
238  }
239  }
240  break;
241  case "anonymisation":
242  foreach ($a_attribs as $attrib => $value) {
243  switch ($attrib) {
244  case "enabled":
245  $this->anonymisation = $value;
246  break;
247  }
248  }
249  break;
250  case "access":
251  foreach ($a_attribs as $attrib => $value) {
252  switch ($attrib) {
253  case "type":
254  $this->surveyaccess = $value;
255  break;
256  }
257  }
258  break;
259  case "constraint":
260  $this->constraints[] = array(
261  "sourceref" => $a_attribs["sourceref"],
262  "destref" => $a_attribs["destref"],
263  "relation" => $a_attribs["relation"],
264  "value" => $a_attribs["value"],
265 
266  // might be missing in old export files
267  "conjunction" => (int) ($a_attribs["conjuction"] ?? 0)
268  );
269  break;
270  case "question":
271  // start with a new survey question
272  $type = $a_attribs["type"];
273  // patch due to changes in question types
274  switch ($type) {
275  case 'SurveyNominalQuestion':
276  $type = 'SurveyMultipleChoiceQuestion';
277  foreach ($a_attribs as $key => $value) {
278  switch ($key) {
279  case "subtype":
280  if ($value == 1) {
281  $type = 'SurveySingleChoiceQuestion';
282  } else {
283  $type = 'SurveyMultipleChoiceQuestion';
284  }
285  break;
286  }
287  }
288  break;
289  case 'SurveyOrdinalQuestion':
290  $type = 'SurveySingleChoiceQuestion';
291  break;
292  }
293  if (strlen($type ?? "")) {
294  $this->activequestion = new $type();
295  // if no pool is given, question will reference survey
296  $q_obj_id = $this->spl_id;
297  if ($this->spl_id < 0) {
298  $q_obj_id = $this->survey->getId();
299  }
300  $this->activequestion->setObjId($q_obj_id);
301  } else {
302  $this->activequestion = null;
303  }
304  $this->original_question_id = $a_attribs["id"];
305  if ($this->in_questionblock) {
306  $this->questionblock[] = $this->original_question_id;
307  }
308  if (is_object($this->activequestion)) {
309  foreach ($a_attribs as $key => $value) {
310  switch ($key) {
311  case "title":
312  $this->activequestion->setTitle($value);
313  break;
314  case "subtype":
315  $this->activequestion->setSubtype($value);
316  break;
317  case "obligatory":
318  $this->activequestion->setObligatory($value);
319  break;
320  }
321  }
322  }
323  break;
324  case "material":
325  switch ($this->getParent()) {
326  case "question":
327  case "questiontext":
328  $this->material = [];
329  break;
330  }
331  $this->material[] = array("text" => "", "image" => "", "label" => $a_attribs["label"] ?? "");
332  break;
333  case "matimage":
334  case "label":
335  if (array_key_exists("label", $a_attribs)) {
336  if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $a_attribs["label"] ?? "", $matches)) {
337  // import an mediaobject which was inserted using tiny mce
338  $this->session_repo->addMob(
339  $a_attribs["label"] ?? "",
340  $a_attribs["uri"],
341  $a_attribs["type"],
342  $a_attribs["id"]
343  );
344  }
345  }
346  break;
347  case "metadata":
348  $this->metadata = array();
349  break;
350  case "metadatafield":
351  $this->metadata[] = array("label" => "", "entry" => "");
352  break;
353  case "matrix":
354  $this->is_matrix = true;
355  $this->matrix = array();
356  break;
357  case "matrixrow":
358  $this->material = [];
359  $this->matrix[] = "";
360  $this->matrixrowattribs = array("id" => $a_attribs["id"], "label" => $a_attribs["label"] ?? "", "other" => $a_attribs["other"] ?? "");
361  break;
362  case "responses":
363  $this->material = [];
364  $this->responses = array();
365  break;
366  case "variables":
367  $this->variables = array();
368  break;
369  case "response_single":
370  $this->material = [];
371  $this->responses[$a_attribs["id"]] = array("type" => "single",
372  "id" => $a_attribs["id"],
373  "label" => $a_attribs["label"] ?? "",
374  "other" => $a_attribs["other"] ?? "",
375  "neutral" => $a_attribs["neutral"] ?? "",
376  "scale" => $a_attribs["scale"] ?? "");
377  $this->response_id = $a_attribs["id"];
378  break;
379  case "response_multiple":
380  $this->material = [];
381  $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"] ?? "");
382  $this->response_id = $a_attribs["id"];
383  break;
384  case "response_text":
385  $this->material = [];
386  $this->responses[$a_attribs["id"]] = array("type" => "text", "id" => $a_attribs["id"], "columns" => $a_attribs["columns"] ?? null, "maxlength" => $a_attribs["maxlength"] ?? null, "rows" => $a_attribs["rows"] ?? null, "label" => $a_attribs["label"] ?? "");
387  $this->response_id = $a_attribs["id"];
388  break;
389  case "response_num":
390  $this->material = [];
391  $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"] ?? "");
392  $this->response_id = $a_attribs["id"];
393  break;
394  case "response_time":
395  $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"] ?? "");
396  $this->response_id = $a_attribs["id"];
397  break;
398  case "bipolar_adjectives":
399  $this->adjectives = array();
400  break;
401  case "adjective":
402  $this->adjectives[] = array("label" => $a_attribs["label"] ?? "", "text" => "");
403  break;
404  }
405  }
406 
410  public function handlerCharacterData($a_xml_parser, string $a_data): void
411  {
412  $this->texts++;
413  $this->text_size += strlen($a_data ?? "");
414  $this->characterbuffer .= $a_data;
415  $a_data = $this->characterbuffer;
416  }
417 
418  protected function getCharacterBuffer($use_purifier = false): string
419  {
420  if ($use_purifier) {
421  $purifier = new ilSvyStandardPurifier();
422  return $purifier->purify((string) $this->characterbuffer);
423  }
424  return $this->trimAndStrip((string) $this->characterbuffer);
425  }
426 
430  public function handlerEndTag($a_xml_parser, string $a_name): void
431  {
432  switch ($a_name) {
433  case "surveyobject":
434  if (is_object($this->survey)) {
435  $this->survey->setOfflineStatus(!$this->survey_status);
436  $this->survey->saveToDb();
437 
438  // write question blocks
439  if (count($this->questionblocks)) {
440  foreach ($this->questionblocks as $data) {
441  $questionblock = $data["questions"];
442  $title = $data["title"];
443  $qblock = array();
444  foreach ($questionblock as $question_id) {
445  $qblock[] = $this->questions[$question_id];
446  }
447  $this->survey->createQuestionblock(
448  $title,
449  $this->showQuestiontext,
450  $this->showBlocktitle,
451  $qblock,
452  $this->compressView
453  );
454  }
455  }
456 
457  // #13878 - write constraints
458  if (count($this->constraints)) {
459  $relations = $this->survey->getAllRelations(true);
460  foreach ($this->constraints as $constraint) {
461  $constraint_id = $this->survey->addConstraint($this->questions[$constraint["destref"]], $relations[$constraint["relation"]]["id"], $constraint["value"], $constraint["conjunction"]);
462  $this->survey->addConstraintToQuestion($this->questions[$constraint["sourceref"]], $constraint_id);
463  }
464  }
465 
466  // write textblocks
467  if (count($this->textblocks)) {
468  foreach ($this->textblocks as $original_id => $textblock) {
469  $this->survey->saveHeading($textblock, $this->questions[$original_id]);
470  }
471  }
472  }
473  break;
474  case "survey":
475  $this->in_survey = false;
476  if (is_object($this->survey)) {
477  if (strcmp($this->surveyaccess, "free") == 0) {
478  $this->survey->setAnonymize(2);
479  } else {
480  if ($this->anonymisation == 0) {
481  $this->survey->setAnonymize(0);
482  } else {
483  $this->survey->setAnonymize(1);
484  }
485  }
486  }
487  break;
488  case "startingtime":
489  if (preg_match("/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->getCharacterBuffer(), $matches)) {
490  if (is_object($this->survey)) {
491  $this->survey->setStartDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
492  }
493  }
494  break;
495  case "endingtime":
496  if (preg_match("/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->getCharacterBuffer(), $matches)) {
497  if (is_object($this->survey)) {
498  $this->survey->setEndDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
499  }
500  }
501  break;
502  case "description":
503  if ($this->in_survey) {
504  if (is_object($this->survey)) {
505  $this->survey->setDescription($this->getCharacterBuffer());
506  $this->survey->update(true);
507  }
508  } else {
509  if (is_object($this->activequestion)) {
510  $this->activequestion->setDescription($this->getCharacterBuffer());
511  }
512  }
513  break;
514  case "question":
515  if (is_object($this->activequestion)) {
516  if (strlen($this->textblock ?? "")) {
517  $this->textblocks[$this->original_question_id] = $this->textblock;
518  }
519  $this->activequestion->saveToDb();
520  // duplicate the question for the survey (if pool is to be used)
521  if (is_object($this->survey) &&
522  $this->spl_id > 0) {
523  $question_id = $this->activequestion->duplicate(true, "", "", 0, $this->survey->getId());
524  } else {
525  $question_id = $this->activequestion->getId();
526  }
527  if (is_object($this->survey)) { // #15452
528  $this->survey->addQuestion($question_id);
529  }
530  $this->questions[$this->original_question_id] = $question_id;
531  if ($this->mapping) {
532  $this->mapping->addMapping("components/ILIAS/Survey", "svy_q", $this->original_question_id, $question_id);
533  }
534  $this->activequestion = null;
535  }
536  $this->textblock = "";
537  break;
538  case "author":
539  if ($this->in_survey) {
540  if (is_object($this->survey)) {
541  $this->survey->setAuthor($this->getCharacterBuffer());
542  }
543  } else {
544  if (is_object($this->activequestion)) {
545  $this->activequestion->setAuthor($this->getCharacterBuffer());
546  }
547  }
548  break;
549  case "mattext":
550  $this->material[count($this->material) - 1]["text"] = $this->getCharacterBuffer(true);
551  break;
552  case "matimage":
553  $this->material[count($this->material) - 1]["image"] = $this->getCharacterBuffer();
554  break;
555  case "material":
556  if ($this->in_survey) {
557  if (strcmp($this->getParent(), "objectives") == 0) {
558  if (isset($this->material[0]) && strcmp($this->material[0]["label"], "introduction") == 0) {
559  if (is_object($this->survey)) {
560  $this->survey->setIntroduction($this->material[0]["text"]);
561  }
562  }
563  if (isset($this->material[0]) && strcmp($this->material[0]["label"], "outro") == 0) {
564  if (is_object($this->survey)) {
565  $this->survey->setOutro($this->material[0]["text"]);
566  }
567  }
568  $this->material = array();
569  }
570  } else {
571  if (strcmp($this->getParent(), "question") == 0) {
572  /*$this->activequestion->setMaterial($this->material[0]["text"], true,
573  $this->material[0]["label"]);*/
574  }
575  }
576  break;
577  case "questiontext":
578  if (is_object($this->activequestion)) {
579  $questiontext = "";
580  foreach ($this->material as $matarray) {
581  $questiontext .= $matarray["text"];
582  }
583  $this->activequestion->setQuestiontext($questiontext);
584  }
585  $this->material = array();
586  break;
587  case "fieldlabel":
588  $this->metadata[count($this->metadata) - 1]["label"] = $this->getCharacterBuffer();
589  break;
590  case "fieldentry":
591  $this->metadata[count($this->metadata) - 1]["entry"] = $this->characterbuffer;
592  break;
593  case "metadata":
594  if (strcmp($this->getParent(), "question") == 0) {
595  if (is_object($this->activequestion)) {
596  $this->activequestion->importAdditionalMetadata($this->metadata);
597  }
598  }
599  if (strcmp($this->getParent(), "survey") == 0) {
600  foreach ($this->metadata as $key => $value) {
601  switch ($value["label"]) {
602  case "SCORM":
603  if (strlen($value["entry"] ?? "")) {
604  if (is_object($this->survey)) {
605  $md_sax_parser = new ilMDSaxParser();
606  $md_sax_parser->setXMLContent($value["entry"]);
607  $md_sax_parser->setMDObject($tmp = new ilMD($this->survey->getId(), 0, "svy"));
608  $md_sax_parser->enableMDParsing(true);
609  $md_sax_parser->startParsing();
610  $this->survey->MDUpdateListener("General");
611  }
612  }
613  break;
614  case "display_question_titles":
615  if ($value["entry"] == 1) {
616  $this->survey->setShowQuestionTitles(true);
617  } else {
618  $this->survey->setShowQuestionTitles(false);
619  }
620  break;
621  case "status":
622  $this->survey_status = (bool) $value["entry"];
623  break;
624  case "evaluation_access":
625  $this->survey->setEvaluationAccess($value["entry"]);
626  break;
627  case "pool_usage":
628  $this->survey->setPoolUsage($value["entry"]);
629  break;
630  case "own_results_mail":
631  $this->survey->setMailOwnResults($value["entry"]);
632  break;
633  case "confirmation_mail":
634  $this->survey->setMailConfirmation($value["entry"]);
635  break;
636  case "anon_user_list":
637  $this->survey->setAnonymousUserList($value["entry"]);
638  break;
639  case "mode":
640  $this->survey->setMode($value["entry"]);
641  break;
642  case "mode_360_self_eval":
643  $this->survey->set360SelfEvaluation($value["entry"]);
644  break;
645  case "mode_360_self_rate":
646  $this->survey->set360SelfRaters($value["entry"]);
647  break;
648  case "mode_360_self_appr":
649  $this->survey->set360SelfAppraisee($value["entry"]);
650  break;
651  case "mode_360_results":
652  $this->survey->set360Results($value["entry"]);
653  break;
654  case "mode_self_eval_results":
655  $this->survey->setSelfEvaluationResults($value["entry"]);
656  break;
657  case "mode_skill_service":
658  $this->survey->setSkillService($value["entry"]);
659  break;
660  }
661  }
662  }
663  if (!$this->spl_exists) {
664  if (strcmp($this->getParent(), "surveyquestions") == 0) {
665  foreach ($this->metadata as $key => $value) {
666  if (strcmp($value["label"], "SCORM") == 0) {
667  if (strlen($value["entry"] ?? "")) {
668  if ($this->spl_id > 0) {
669  $md_sax_parser = new ilMDSaxParser();
670  $md_sax_parser->setXMLContent($value["entry"]);
671  $md_sax_parser->setMDObject($tmp = new ilMD($this->spl_id, 0, "spl"));
672  $md_sax_parser->enableMDParsing(true);
673  $md_sax_parser->startParsing();
674  $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
675  $spl->MDUpdateListener("General");
676  }
677  }
678  }
679  }
680  }
681  }
682  break;
683  case "responses":
684  if (is_object($this->activequestion)) {
685  $this->activequestion->importResponses($this->responses);
686  }
687  $this->is_matrix = false;
688  break;
689  case "variable":
690  $this->variables[] = $this->getCharacterBuffer();
691  break;
692  case "variables":
693  if (is_object($this->activequestion)) {
694  $this->activequestion->importVariables($this->variables);
695  }
696  break;
697  case "response_single":
698  case "response_multiple":
699  case "response_text":
700  case "response_num":
701  case "response_time":
702  $this->responses[$this->response_id]["material"] = $this->material;
703  break;
704  case "adjective":
705  $this->adjectives[count($this->adjectives) - 1]["text"] = $this->getCharacterBuffer();
706  break;
707  case "bipolar_adjectives":
708  if (is_object($this->activequestion)) {
709  $this->activequestion->importAdjectives($this->adjectives);
710  }
711  break;
712  case "matrixrow":
713  $row = "";
714  foreach ($this->material as $material) {
715  $row .= $material["text"];
716  }
717  $this->matrix[count($this->matrix) - 1] = array('title' => $row, 'id' => $this->matrixrowattribs['id'], 'label' => $this->matrixrowattribs['label'], 'other' => $this->matrixrowattribs['other']);
718  break;
719  case "matrix":
720  if (is_object($this->activequestion)) {
721  $this->activequestion->importMatrix($this->matrix);
722  }
723  break;
724  case "textblock":
725  $this->textblock = $this->getCharacterBuffer();
726  break;
727  case "questionblocktitle":
728  $this->questionblocktitle = $this->getCharacterBuffer();
729  break;
730  case "questionblock":
731  $this->in_questionblock = false;
732  $this->questionblocks[] = array("title" => $this->questionblocktitle,
733  "questions" => $this->questionblock
734  );
735  break;
736  }
737  $this->depth--;
738  }
739 
740  public function getErrorCode(): ?int
741  {
742  return $this->error_code;
743  }
744 
745  public function getErrorLine(): ?int
746  {
747  return $this->error_line;
748  }
749 
750  public function getErrorColumn(): ?int
751  {
752  return $this->error_col;
753  }
754 
755  public function getErrorMessage(): ?string
756  {
757  return $this->error_msg;
758  }
759 
760  public function getFullError(): string
761  {
762  return "Error: " . $this->error_msg . " at line:" . $this->error_line . " column:" . $this->error_col;
763  }
764 
765  public function getXMLElements(): int
766  {
767  return $this->elements;
768  }
769 
770  public function getXMLAttributes(): int
771  {
772  return $this->attributes;
773  }
774 
775  public function getXMLTextSections(): int
776  {
777  return $this->texts;
778  }
779 
780  public function getXMLTextSize(): int
781  {
782  return $this->text_size;
783  }
784 
785  public function hasError(): bool
786  {
787  return $this->has_error;
788  }
789 
790  protected function trimAndStripAttribs(array $attribs): array
791  {
792  $ret = [];
793  foreach ($attribs as $k => $v) {
794  $ret[$k] = ((string) $v !== "<>")
795  ? $this->trimAndStrip((string) $v)
796  : "<>";
797  }
798  return $ret;
799  }
800 
801  protected function trimAndStrip(string $input): string
802  {
803  return ilUtil::stripSlashes(trim($input));
804  }
805 }
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
ILIAS SurveyQuestionPool Export ImportSessionRepository $session_repo
handlerEndTag($a_xml_parser, string $a_name)
parse($a_xml_parser, $a_fp=null)
Class ilObjSurveyQuestionPool.
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="")
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...
global $DIC
Definition: shib_login.php:25
__construct(int $a_spl_id, ?string $a_xml_file='', bool $spl_exists=false, ?ilImportMapping $a_mapping=null)
trimAndStripAttribs(array $attribs)
__construct(Container $dic, ilPlugin $plugin)
handlerCharacterData($a_xml_parser, string $a_data)
getCharacterBuffer($use_purifier=false)
$attrib
Regular expression to match HTML/XML attribute pairs within a tag.
Definition: Sanitizer.php:42
setSurveyObject(ilObjSurvey $a_svy)