ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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, ILIAS\GlobalScreen\Provider\__construct(), and 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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
__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 417 of file class.SurveyImportParser.php.

References trimAndStrip().

Referenced by handlerEndTag().

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

◆ getErrorCode()

SurveyImportParser::getErrorCode ( )

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

References $error_code.

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

◆ getErrorColumn()

SurveyImportParser::getErrorColumn ( )

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

References $error_col.

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

◆ getErrorLine()

SurveyImportParser::getErrorLine ( )

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

References $error_line.

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

◆ getErrorMessage()

SurveyImportParser::getErrorMessage ( )

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

References $error_msg.

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

◆ getFullError()

SurveyImportParser::getFullError ( )

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

References $error_col.

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

◆ getParent()

SurveyImportParser::getParent ( )

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

Referenced by handlerBeginTag(), and handlerEndTag().

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

◆ getXMLAttributes()

SurveyImportParser::getXMLAttributes ( )

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

References $attributes.

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

◆ getXMLElements()

SurveyImportParser::getXMLElements ( )

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

References $elements.

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

◆ getXMLTextSections()

SurveyImportParser::getXMLTextSections ( )

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

References $texts.

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

◆ getXMLTextSize()

SurveyImportParser::getXMLTextSize ( )

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

References $text_size.

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

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

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

Referenced by setHandlers().

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->setOfflineStatus(!$value);
216  $spl->saveToDb();
217  }
218  break;
219  case "label":
220  $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
221  $spl->setTitle($value);
222  $spl->saveToDb();
223  break;
224  }
225  }
226  break;
227  case "survey":
228  $this->in_survey = true;
229  foreach ($a_attribs as $attrib => $value) {
230  switch ($attrib) {
231  case "title":
232  if (is_object($this->survey)) {
233  $this->survey->setTitle($value);
234  $this->survey->update(true);
235  }
236  break;
237  }
238  }
239  break;
240  case "anonymisation":
241  foreach ($a_attribs as $attrib => $value) {
242  switch ($attrib) {
243  case "enabled":
244  $this->anonymisation = $value;
245  break;
246  }
247  }
248  break;
249  case "access":
250  foreach ($a_attribs as $attrib => $value) {
251  switch ($attrib) {
252  case "type":
253  $this->surveyaccess = $value;
254  break;
255  }
256  }
257  break;
258  case "constraint":
259  $this->constraints[] = array(
260  "sourceref" => $a_attribs["sourceref"],
261  "destref" => $a_attribs["destref"],
262  "relation" => $a_attribs["relation"],
263  "value" => $a_attribs["value"],
264 
265  // might be missing in old export files
266  "conjunction" => (int) ($a_attribs["conjuction"] ?? 0)
267  );
268  break;
269  case "question":
270  // start with a new survey question
271  $type = $a_attribs["type"];
272  // patch due to changes in question types
273  switch ($type) {
274  case 'SurveyNominalQuestion':
275  $type = 'SurveyMultipleChoiceQuestion';
276  foreach ($a_attribs as $key => $value) {
277  switch ($key) {
278  case "subtype":
279  if ($value == 1) {
280  $type = 'SurveySingleChoiceQuestion';
281  } else {
282  $type = 'SurveyMultipleChoiceQuestion';
283  }
284  break;
285  }
286  }
287  break;
288  case 'SurveyOrdinalQuestion':
289  $type = 'SurveySingleChoiceQuestion';
290  break;
291  }
292  if (strlen($type ?? "")) {
293  $this->activequestion = new $type();
294  // if no pool is given, question will reference survey
295  $q_obj_id = $this->spl_id;
296  if ($this->spl_id < 0) {
297  $q_obj_id = $this->survey->getId();
298  }
299  $this->activequestion->setObjId($q_obj_id);
300  } else {
301  $this->activequestion = null;
302  }
303  $this->original_question_id = $a_attribs["id"];
304  if ($this->in_questionblock) {
305  $this->questionblock[] = $this->original_question_id;
306  }
307  if (is_object($this->activequestion)) {
308  foreach ($a_attribs as $key => $value) {
309  switch ($key) {
310  case "title":
311  $this->activequestion->setTitle($value);
312  break;
313  case "subtype":
314  $this->activequestion->setSubtype($value);
315  break;
316  case "obligatory":
317  $this->activequestion->setObligatory($value);
318  break;
319  }
320  }
321  }
322  break;
323  case "material":
324  switch ($this->getParent()) {
325  case "question":
326  case "questiontext":
327  $this->material = [];
328  break;
329  }
330  $this->material[] = array("text" => "", "image" => "", "label" => $a_attribs["label"] ?? "");
331  break;
332  case "matimage":
333  case "label":
334  if (array_key_exists("label", $a_attribs)) {
335  if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $a_attribs["label"] ?? "", $matches)) {
336  // import an mediaobject which was inserted using tiny mce
337  $this->session_repo->addMob(
338  $a_attribs["label"] ?? "",
339  $a_attribs["uri"],
340  $a_attribs["type"],
341  $a_attribs["id"]
342  );
343  }
344  }
345  break;
346  case "metadata":
347  $this->metadata = array();
348  break;
349  case "metadatafield":
350  $this->metadata[] = array("label" => "", "entry" => "");
351  break;
352  case "matrix":
353  $this->is_matrix = true;
354  $this->matrix = array();
355  break;
356  case "matrixrow":
357  $this->material = [];
358  $this->matrix[] = "";
359  $this->matrixrowattribs = array("id" => $a_attribs["id"], "label" => $a_attribs["label"] ?? "", "other" => $a_attribs["other"] ?? "");
360  break;
361  case "responses":
362  $this->material = [];
363  $this->responses = array();
364  break;
365  case "variables":
366  $this->variables = array();
367  break;
368  case "response_single":
369  $this->material = [];
370  $this->responses[$a_attribs["id"]] = array("type" => "single",
371  "id" => $a_attribs["id"],
372  "label" => $a_attribs["label"] ?? "",
373  "other" => $a_attribs["other"] ?? "",
374  "neutral" => $a_attribs["neutral"] ?? "",
375  "scale" => $a_attribs["scale"] ?? "");
376  $this->response_id = $a_attribs["id"];
377  break;
378  case "response_multiple":
379  $this->material = [];
380  $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"] ?? "");
381  $this->response_id = $a_attribs["id"];
382  break;
383  case "response_text":
384  $this->material = [];
385  $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"] ?? "");
386  $this->response_id = $a_attribs["id"];
387  break;
388  case "response_num":
389  $this->material = [];
390  $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"] ?? "");
391  $this->response_id = $a_attribs["id"];
392  break;
393  case "response_time":
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  }
Class ilObjSurveyQuestionPool.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
trimAndStripAttribs(array $attribs)
$attrib
Regular expression to match HTML/XML attribute pairs within a tag.
Definition: Sanitizer.php:34
+ Here is the call graph for this function:
+ Here is the caller 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.

References $characterbuffer.

Referenced by setHandlers().

409  : void
410  {
411  $this->texts++;
412  $this->text_size += strlen($a_data ?? "");
413  $this->characterbuffer .= $a_data;
414  $a_data = $this->characterbuffer;
415  }
+ Here is the caller graph for this function:

◆ handlerEndTag()

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

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

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

Referenced by setHandlers().

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 ?? "")) {
516  $this->textblocks[$this->original_question_id] = $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("components/ILIAS/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 (isset($this->material[0]) && 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 (isset($this->material[0]) && 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,
572  $this->material[0]["label"]);*/
573  }
574  }
575  break;
576  case "questiontext":
577  if (is_object($this->activequestion)) {
578  $questiontext = "";
579  foreach ($this->material as $matarray) {
580  $questiontext .= $matarray["text"];
581  }
582  $this->activequestion->setQuestiontext($questiontext);
583  }
584  $this->material = array();
585  break;
586  case "fieldlabel":
587  $this->metadata[count($this->metadata) - 1]["label"] = $this->getCharacterBuffer();
588  break;
589  case "fieldentry":
590  $this->metadata[count($this->metadata) - 1]["entry"] = $this->characterbuffer;
591  break;
592  case "metadata":
593  if (strcmp($this->getParent(), "question") == 0) {
594  if (is_object($this->activequestion)) {
595  $this->activequestion->importAdditionalMetadata($this->metadata);
596  }
597  }
598  if (strcmp($this->getParent(), "survey") == 0) {
599  foreach ($this->metadata as $key => $value) {
600  switch ($value["label"]) {
601  case "SCORM":
602  if (strlen($value["entry"] ?? "")) {
603  if (is_object($this->survey)) {
604  $md_sax_parser = new ilMDSaxParser();
605  $md_sax_parser->setXMLContent($value["entry"]);
606  $md_sax_parser->setMDObject($tmp = new ilMD($this->survey->getId(), 0, "svy"));
607  $md_sax_parser->enableMDParsing(true);
608  $md_sax_parser->startParsing();
609  $this->survey->MDUpdateListener("General");
610  }
611  }
612  break;
613  case "display_question_titles":
614  if ($value["entry"] == 1) {
615  $this->survey->setShowQuestionTitles(true);
616  } else {
617  $this->survey->setShowQuestionTitles(false);
618  }
619  break;
620  case "status":
621  $this->survey_status = (bool) $value["entry"];
622  break;
623  case "evaluation_access":
624  $this->survey->setEvaluationAccess($value["entry"]);
625  break;
626  case "pool_usage":
627  $this->survey->setPoolUsage($value["entry"]);
628  break;
629  case "own_results_mail":
630  $this->survey->setMailOwnResults($value["entry"]);
631  break;
632  case "confirmation_mail":
633  $this->survey->setMailConfirmation($value["entry"]);
634  break;
635  case "anon_user_list":
636  $this->survey->setAnonymousUserList($value["entry"]);
637  break;
638  case "mode":
639  $this->survey->setMode($value["entry"]);
640  break;
641  case "mode_360_self_eval":
642  $this->survey->set360SelfEvaluation($value["entry"]);
643  break;
644  case "mode_360_self_rate":
645  $this->survey->set360SelfRaters($value["entry"]);
646  break;
647  case "mode_360_self_appr":
648  $this->survey->set360SelfAppraisee($value["entry"]);
649  break;
650  case "mode_360_results":
651  $this->survey->set360Results($value["entry"]);
652  break;
653  case "mode_self_eval_results":
654  $this->survey->setSelfEvaluationResults($value["entry"]);
655  break;
656  case "mode_skill_service":
657  $this->survey->setSkillService($value["entry"]);
658  break;
659  }
660  }
661  }
662  if (!$this->spl_exists) {
663  if (strcmp($this->getParent(), "surveyquestions") == 0) {
664  foreach ($this->metadata as $key => $value) {
665  if (strcmp($value["label"], "SCORM") == 0) {
666  if (strlen($value["entry"] ?? "")) {
667  if ($this->spl_id > 0) {
668  $md_sax_parser = new ilMDSaxParser();
669  $md_sax_parser->setXMLContent($value["entry"]);
670  $md_sax_parser->setMDObject($tmp = new ilMD($this->spl_id, 0, "spl"));
671  $md_sax_parser->enableMDParsing(true);
672  $md_sax_parser->startParsing();
673  $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
674  $spl->MDUpdateListener("General");
675  }
676  }
677  }
678  }
679  }
680  }
681  break;
682  case "responses":
683  if (is_object($this->activequestion)) {
684  $this->activequestion->importResponses($this->responses);
685  }
686  $this->is_matrix = false;
687  break;
688  case "variable":
689  $this->variables[] = $this->getCharacterBuffer();
690  break;
691  case "variables":
692  if (is_object($this->activequestion)) {
693  $this->activequestion->importVariables($this->variables);
694  }
695  break;
696  case "response_single":
697  case "response_multiple":
698  case "response_text":
699  case "response_num":
700  case "response_time":
701  $this->responses[$this->response_id]["material"] = $this->material;
702  break;
703  case "adjective":
704  $this->adjectives[count($this->adjectives) - 1]["text"] = $this->getCharacterBuffer();
705  break;
706  case "bipolar_adjectives":
707  if (is_object($this->activequestion)) {
708  $this->activequestion->importAdjectives($this->adjectives);
709  }
710  break;
711  case "matrixrow":
712  $row = "";
713  foreach ($this->material as $material) {
714  $row .= $material["text"];
715  }
716  $this->matrix[count($this->matrix) - 1] = array('title' => $row, 'id' => $this->matrixrowattribs['id'], 'label' => $this->matrixrowattribs['label'], 'other' => $this->matrixrowattribs['other']);
717  break;
718  case "matrix":
719  if (is_object($this->activequestion)) {
720  $this->activequestion->importMatrix($this->matrix);
721  }
722  break;
723  case "textblock":
724  $this->textblock = $this->getCharacterBuffer();
725  break;
726  case "questionblocktitle":
727  $this->questionblocktitle = $this->getCharacterBuffer();
728  break;
729  case "questionblock":
730  $this->in_questionblock = false;
731  $this->questionblocks[] = array("title" => $this->questionblocktitle,
732  "questions" => $this->questionblock
733  );
734  break;
735  }
736  $this->depth--;
737  }
Class ilObjSurveyQuestionPool.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getCharacterBuffer($use_purifier=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasError()

SurveyImportParser::hasError ( )

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

References $has_error.

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

◆ parse()

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

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

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

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

◆ setHandlers()

SurveyImportParser::setHandlers (   $a_xml_parser)

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

References handlerBeginTag(), handlerCharacterData(), and handlerEndTag().

132  : void
133  {
134  xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
135  xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
136  }
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
handlerEndTag($a_xml_parser, string $a_name)
handlerCharacterData($a_xml_parser, string $a_data)
+ Here is the call graph for this function:

◆ 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 800 of file class.SurveyImportParser.php.

References ilUtil\stripSlashes().

Referenced by getCharacterBuffer(), and trimAndStripAttribs().

800  : string
801  {
802  return ilUtil::stripSlashes(trim($input));
803  }
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 789 of file class.SurveyImportParser.php.

References trimAndStrip().

Referenced by handlerBeginTag().

789  : array
790  {
791  $ret = [];
792  foreach ($attribs as $k => $v) {
793  $ret[$k] = ((string) $v !== "<>")
794  ? $this->trimAndStrip((string) $v)
795  : "<>";
796  }
797  return $ret;
798  }
+ 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: