ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SurveyImportParser Class Reference

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

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

Public Member Functions

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

Data Fields

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

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

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

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Survey Question Import Parser

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m

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

Constructor & Destructor Documentation

◆ __construct()

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

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

85 {
86 global $DIC;
87
88 parent::__construct($a_xml_file);
89 $this->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 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getCharacterBuffer()

SurveyImportParser::getCharacterBuffer (   $use_purifier = false)
protected

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

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

References trimAndStrip().

Referenced by handlerEndTag().

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

◆ getErrorCode()

SurveyImportParser::getErrorCode ( )

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

708 : ?int
709 {
710 return $this->error_code;
711 }

References $error_code.

◆ getErrorColumn()

SurveyImportParser::getErrorColumn ( )

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

718 : ?int
719 {
720 return $this->error_col;
721 }

References $error_col.

◆ getErrorLine()

SurveyImportParser::getErrorLine ( )

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

713 : ?int
714 {
715 return $this->error_line;
716 }

References $error_line.

◆ getErrorMessage()

SurveyImportParser::getErrorMessage ( )

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

723 : ?string
724 {
725 return $this->error_msg;
726 }

References $error_msg.

◆ getFullError()

SurveyImportParser::getFullError ( )

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

728 : string
729 {
730 return "Error: " . $this->error_msg . " at line:" . $this->error_line . " column:" . $this->error_col;
731 }

References $error_col.

◆ getParent()

SurveyImportParser::getParent ( )

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

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

Referenced by handlerBeginTag(), and handlerEndTag().

+ Here is the caller graph for this function:

◆ getXMLAttributes()

SurveyImportParser::getXMLAttributes ( )

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

738 : int
739 {
740 return $this->attributes;
741 }

References $attributes.

◆ getXMLElements()

SurveyImportParser::getXMLElements ( )

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

733 : int
734 {
735 return $this->elements;
736 }

References $elements.

◆ getXMLTextSections()

SurveyImportParser::getXMLTextSections ( )

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

743 : int
744 {
745 return $this->texts;
746 }

References $texts.

◆ getXMLTextSize()

SurveyImportParser::getXMLTextSize ( )

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

748 : int
749 {
750 return $this->text_size;
751 }

References $text_size.

◆ handlerBeginTag()

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

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

178 : void
179 {
180 $a_attribs = $this->trimAndStripAttribs($a_attribs);
181 $this->depth++;
182 $this->path[$this->depth] = strtolower($a_name);
183 $this->characterbuffer = "";
184 $this->activetag = $a_name;
185 $this->elements++;
186 $this->attributes += count($a_attribs);
187 switch ($a_name) {
188 case "questionblock":
189 $this->in_questionblock = true;
190 $this->questionblock = array();
191 $this->questionblocktitle = "";
192 $this->showQuestiontext = 1;
193 $this->showBlocktitle = 0;
194 $this->compressView = 0;
195 foreach ($a_attribs as $attrib => $value) {
196 switch ($attrib) {
197 case "showQuestiontext":
198 $this->showQuestiontext = (int) $value;
199 break;
200 case "showBlocktitle":
201 $this->showBlocktitle = (int) $value;
202 break;
203 case "compressView":
204 $this->compressView = (int) $value;
205 break;
206 }
207 }
208 break;
209 case "surveyquestions":
210 foreach ($a_attribs as $attrib => $value) {
211 switch ($attrib) {
212 case "online":
213 if ($this->spl_id > 0) {
214 $spl = new ilObjSurveyQuestionPool($this->spl_id, false);
215 $spl->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"] ?? null, "maxlength" => $a_attribs["maxlength"] ?? null, "rows" => $a_attribs["rows"] ?? null, "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 }
$attrib
Regular expression to match HTML/XML attribute pairs within a tag.
Definition: Sanitizer.php:34
trimAndStripAttribs(array $attribs)
Class ilObjSurveyQuestionPool.

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

Referenced by setHandlers().

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

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

References $characterbuffer.

Referenced by setHandlers().

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

429 : void
430 {
431 switch ($a_name) {
432 case "surveyobject":
433 if (is_object($this->survey)) {
434 $this->survey->setOfflineStatus(!$this->survey_status);
435 $this->survey->saveToDb();
436
437 // write question blocks
438 if (count($this->questionblocks)) {
439 foreach ($this->questionblocks as $data) {
440 $questionblock = $data["questions"];
441 $title = $data["title"];
442 $qblock = array();
443 foreach ($questionblock as $question_id) {
444 $qblock[] = $this->questions[$question_id];
445 }
446 $this->survey->createQuestionblock(
447 $title,
448 $this->showQuestiontext,
449 $this->showBlocktitle,
450 $qblock,
451 $this->compressView
452 );
453 }
454 }
455
456 // #13878 - write constraints
457 if (count($this->constraints)) {
458 $relations = $this->survey->getAllRelations(true);
459 foreach ($this->constraints as $constraint) {
460 $constraint_id = $this->survey->addConstraint($this->questions[$constraint["destref"]], $relations[$constraint["relation"]]["id"], $constraint["value"], $constraint["conjunction"]);
461 $this->survey->addConstraintToQuestion($this->questions[$constraint["sourceref"]], $constraint_id);
462 }
463 }
464
465 // write textblocks
466 if (count($this->textblocks)) {
467 foreach ($this->textblocks as $original_id => $textblock) {
468 $this->survey->saveHeading($textblock, $this->questions[$original_id]);
469 }
470 }
471 }
472 break;
473 case "survey":
474 $this->in_survey = false;
475 if (is_object($this->survey)) {
476 if (strcmp($this->surveyaccess, "free") == 0) {
477 $this->survey->setAnonymize(2);
478 } else {
479 if ($this->anonymisation == 0) {
480 $this->survey->setAnonymize(0);
481 } else {
482 $this->survey->setAnonymize(1);
483 }
484 }
485 }
486 break;
487 case "startingtime":
488 if (preg_match("/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->getCharacterBuffer(), $matches)) {
489 if (is_object($this->survey)) {
490 $this->survey->setStartDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
491 }
492 }
493 break;
494 case "endingtime":
495 if (preg_match("/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->getCharacterBuffer(), $matches)) {
496 if (is_object($this->survey)) {
497 $this->survey->setEndDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
498 }
499 }
500 break;
501 case "description":
502 if ($this->in_survey) {
503 if (is_object($this->survey)) {
504 $this->survey->setDescription($this->getCharacterBuffer());
505 $this->survey->update(true);
506 }
507 } else {
508 if (is_object($this->activequestion)) {
509 $this->activequestion->setDescription($this->getCharacterBuffer());
510 }
511 }
512 break;
513 case "question":
514 if (is_object($this->activequestion)) {
515 if (strlen($this->textblock ?? "")) {
517 }
518 $this->activequestion->saveToDb();
519 // duplicate the question for the survey (if pool is to be used)
520 if (is_object($this->survey) &&
521 $this->spl_id > 0) {
522 $question_id = $this->activequestion->duplicate(true, "", "", 0, $this->survey->getId());
523 } else {
524 $question_id = $this->activequestion->getId();
525 }
526 if (is_object($this->survey)) { // #15452
527 $this->survey->addQuestion($question_id);
528 }
529 $this->questions[$this->original_question_id] = $question_id;
530 if ($this->mapping) {
531 $this->mapping->addMapping("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 "display_question_titles":
602 if ($value["entry"] == 1) {
603 $this->survey->setShowQuestionTitles(true);
604 } else {
605 $this->survey->setShowQuestionTitles(false);
606 }
607 break;
608 case "status":
609 $this->survey_status = (bool) $value["entry"];
610 break;
611 case "evaluation_access":
612 $this->survey->setEvaluationAccess($value["entry"]);
613 break;
614 case "pool_usage":
615 $this->survey->setPoolUsage($value["entry"]);
616 break;
617 case "own_results_mail":
618 $this->survey->setMailOwnResults($value["entry"]);
619 break;
620 case "confirmation_mail":
621 $this->survey->setMailConfirmation($value["entry"]);
622 break;
623 case "anon_user_list":
624 $this->survey->setAnonymousUserList($value["entry"]);
625 break;
626 case "mode":
627 $this->survey->setMode($value["entry"]);
628 break;
629 case "mode_360_self_eval":
630 $this->survey->set360SelfEvaluation($value["entry"]);
631 break;
632 case "mode_360_self_rate":
633 $this->survey->set360SelfRaters($value["entry"]);
634 break;
635 case "mode_360_self_appr":
636 $this->survey->set360SelfAppraisee($value["entry"]);
637 break;
638 case "mode_360_results":
639 $this->survey->set360Results($value["entry"]);
640 break;
641 case "mode_self_eval_results":
642 $this->survey->setSelfEvaluationResults($value["entry"]);
643 break;
644 case "mode_skill_service":
645 $this->survey->setSkillService($value["entry"]);
646 break;
647 }
648 }
649 }
650 break;
651 case "responses":
652 if (is_object($this->activequestion)) {
653 $this->activequestion->importResponses($this->responses);
654 }
655 $this->is_matrix = false;
656 break;
657 case "variable":
658 $this->variables[] = $this->getCharacterBuffer();
659 break;
660 case "variables":
661 if (is_object($this->activequestion)) {
662 $this->activequestion->importVariables($this->variables);
663 }
664 break;
665 case "response_single":
666 case "response_multiple":
667 case "response_text":
668 case "response_num":
669 case "response_time":
670 $this->responses[$this->response_id]["material"] = $this->material;
671 break;
672 case "adjective":
673 $this->adjectives[count($this->adjectives) - 1]["text"] = $this->getCharacterBuffer();
674 break;
675 case "bipolar_adjectives":
676 if (is_object($this->activequestion)) {
677 $this->activequestion->importAdjectives($this->adjectives);
678 }
679 break;
680 case "matrixrow":
681 $row = "";
682 foreach ($this->material as $material) {
683 $row .= $material["text"];
684 }
685 $this->matrix[count($this->matrix) - 1] = array('title' => $row, 'id' => $this->matrixrowattribs['id'], 'label' => $this->matrixrowattribs['label'], 'other' => $this->matrixrowattribs['other']);
686 break;
687 case "matrix":
688 if (is_object($this->activequestion)) {
689 $this->activequestion->importMatrix($this->matrix);
690 }
691 break;
692 case "textblock":
693 $this->textblock = $this->getCharacterBuffer();
694 break;
695 case "questionblocktitle":
696 $this->questionblocktitle = $this->getCharacterBuffer();
697 break;
698 case "questionblock":
699 $this->in_questionblock = false;
700 $this->questionblocks[] = array("title" => $this->questionblocktitle,
701 "questions" => $this->questionblock
702 );
703 break;
704 }
705 $this->depth--;
706 }
getCharacterBuffer($use_purifier=false)

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

Referenced by setHandlers().

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

◆ hasError()

SurveyImportParser::hasError ( )

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

753 : bool
754 {
755 return $this->has_error;
756 }

References $has_error.

◆ parse()

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

Reimplemented from ilSaxParser.

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

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

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

+ Here is the call graph for this function:

◆ setHandlers()

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

Reimplemented from ilSaxParser.

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

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 }
handlerCharacterData($a_xml_parser, string $a_data)
handlerEndTag($a_xml_parser, string $a_name)
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)

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

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

769 : string
770 {
771 return ilUtil::stripSlashes(trim($input));
772 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References ilUtil\stripSlashes().

Referenced by getCharacterBuffer(), and trimAndStripAttribs().

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

◆ trimAndStripAttribs()

SurveyImportParser::trimAndStripAttribs ( array  $attribs)
protected

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

758 : array
759 {
760 $ret = [];
761 foreach ($attribs as $k => $v) {
762 $ret[$k] = ((string) $v !== "<>")
763 ? $this->trimAndStrip((string) $v)
764 : "<>";
765 }
766 return $ret;
767 }

References trimAndStrip().

Referenced by handlerBeginTag().

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

Field Documentation

◆ $activequestion

SurveyQuestion SurveyImportParser::$activequestion

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

◆ $activetag

string SurveyImportParser::$activetag = ""

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

◆ $adjectives

array SurveyImportParser::$adjectives = []

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

◆ $anonymisation

int SurveyImportParser::$anonymisation = 0

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

◆ $attributes

int SurveyImportParser::$attributes = 0

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

Referenced by getXMLAttributes().

◆ $characterbuffer

string SurveyImportParser::$characterbuffer = ""

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

Referenced by handlerCharacterData(), and handlerEndTag().

◆ $compressView

int SurveyImportParser::$compressView
protected

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

◆ $constraints

array SurveyImportParser::$constraints = []

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

◆ $depth

int SurveyImportParser::$depth = 0

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

Referenced by handlerBeginTag().

◆ $elements

int SurveyImportParser::$elements = 0

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

Referenced by getXMLElements().

◆ $error_code

SurveyImportParser::$error_code

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

Referenced by getErrorCode().

◆ $error_col

SurveyImportParser::$error_col

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

Referenced by getErrorColumn(), and getFullError().

◆ $error_line

SurveyImportParser::$error_line

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

Referenced by getErrorLine().

◆ $error_msg

string SurveyImportParser::$error_msg

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

Referenced by getErrorMessage().

◆ $has_error

bool SurveyImportParser::$has_error = false

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

Referenced by hasError().

◆ $in_questionblock

bool SurveyImportParser::$in_questionblock = false

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

◆ $in_survey

bool SurveyImportParser::$in_survey = false

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

◆ $is_matrix

bool SurveyImportParser::$is_matrix = false

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

◆ $mapping

ilImportMapping SurveyImportParser::$mapping = null
protected

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

◆ $material

array SurveyImportParser::$material = []

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

Referenced by handlerEndTag().

◆ $matrix

array SurveyImportParser::$matrix = []

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

◆ $matrixrowattribs

array SurveyImportParser::$matrixrowattribs = []

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

◆ $metadata

array SurveyImportParser::$metadata = []

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

◆ $original_question_id

string SurveyImportParser::$original_question_id = ""

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

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $path

array SurveyImportParser::$path = []

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

◆ $questionblock

array SurveyImportParser::$questionblock = []

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

Referenced by handlerEndTag().

◆ $questionblocks

array SurveyImportParser::$questionblocks = []

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

◆ $questionblocktitle

string SurveyImportParser::$questionblocktitle = ""

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

◆ $questions

array SurveyImportParser::$questions = []

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

◆ $response_id

string SurveyImportParser::$response_id = ""

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

Referenced by handlerEndTag().

◆ $responses

array SurveyImportParser::$responses = []

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

◆ $session_repo

ILIAS SurveyQuestionPool Export ImportSessionRepository SurveyImportParser::$session_repo
protected

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

◆ $showBlocktitle

int SurveyImportParser::$showBlocktitle
protected

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

◆ $showQuestiontext

int SurveyImportParser::$showQuestiontext
protected

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

◆ $spl_exists

bool SurveyImportParser::$spl_exists = false

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

Referenced by __construct().

◆ $spl_id

int SurveyImportParser::$spl_id = 0
protected

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

Referenced by handlerBeginTag().

◆ $survey

ilObjSurvey SurveyImportParser::$survey = null

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

◆ $survey_status

bool SurveyImportParser::$survey_status = false

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

◆ $surveyaccess

string SurveyImportParser::$surveyaccess = ""

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

◆ $text_size

int SurveyImportParser::$text_size = 0

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

Referenced by getXMLTextSize().

◆ $textblock

string SurveyImportParser::$textblock = ""

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

Referenced by handlerEndTag().

◆ $textblocks

array SurveyImportParser::$textblocks = []

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

◆ $texts

int SurveyImportParser::$texts = 0

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

Referenced by getXMLTextSections().

◆ $variables

array SurveyImportParser::$variables = []

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


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