ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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.

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

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  }
global $DIC
Definition: shib_login.php:25
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getCharacterBuffer()

SurveyImportParser::getCharacterBuffer (   $use_purifier = false)
protected

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

References trimAndStrip().

Referenced by handlerEndTag().

418  : 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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorCode()

SurveyImportParser::getErrorCode ( )

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

References $error_code.

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

◆ getErrorColumn()

SurveyImportParser::getErrorColumn ( )

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

References $error_col.

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

◆ getErrorLine()

SurveyImportParser::getErrorLine ( )

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

References $error_line.

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

◆ getErrorMessage()

SurveyImportParser::getErrorMessage ( )

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

References $error_msg.

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

◆ getFullError()

SurveyImportParser::getFullError ( )

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

References $error_col.

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

◆ getParent()

SurveyImportParser::getParent ( )

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

Referenced by handlerBeginTag(), and handlerEndTag().

167  : string
168  {
169  if ($this->depth > 0) {
170  return $this->path[$this->depth - 1];
171  }
172 
173  return "";
174  }
+ Here is the caller graph for this function:

◆ getXMLAttributes()

SurveyImportParser::getXMLAttributes ( )

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

References $attributes.

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

◆ getXMLElements()

SurveyImportParser::getXMLElements ( )

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

References $elements.

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

◆ getXMLTextSections()

SurveyImportParser::getXMLTextSections ( )

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

References $texts.

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

◆ getXMLTextSize()

SurveyImportParser::getXMLTextSize ( )

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

References $text_size.

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

◆ handlerBeginTag()

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

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

References $attrib, $depth, $original_question_id, $spl_id, getParent(), ILIAS\Repository\int(), and trimAndStripAttribs().

179  : 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  }
Class ilObjSurveyQuestionPool.
trimAndStripAttribs(array $attribs)
$attrib
Regular expression to match HTML/XML attribute pairs within a tag.
Definition: Sanitizer.php:42
+ 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 410 of file class.SurveyImportParser.php.

References $characterbuffer.

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

◆ handlerEndTag()

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

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

References $characterbuffer, $data, $material, $original_question_id, $response_id, $textblock, getCharacterBuffer(), and getParent().

430  : 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  }
Class ilObjSurveyQuestionPool.
getCharacterBuffer($use_purifier=false)
+ Here is the call graph for this function:

◆ hasError()

SurveyImportParser::hasError ( )

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

References $has_error.

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

◆ parse()

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

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

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

143  : 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  }
+ Here is the call graph for this function:

◆ setHandlers()

SurveyImportParser::setHandlers (   $a_xml_parser)

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

132  : 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  }

◆ setSurveyObject()

SurveyImportParser::setSurveyObject ( ilObjSurvey  $a_svy)

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

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

◆ trimAndStrip()

SurveyImportParser::trimAndStrip ( string  $input)
protected

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

References ilUtil\stripSlashes().

Referenced by getCharacterBuffer(), and trimAndStripAttribs().

801  : string
802  {
803  return ilUtil::stripSlashes(trim($input));
804  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ 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 790 of file class.SurveyImportParser.php.

References trimAndStrip().

Referenced by handlerBeginTag().

790  : 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  }
+ 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.

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