26     protected \ILIAS\SurveyQuestionPool\Export\ImportSessionRepository 
$session_repo;
    82         ?
string $a_xml_file = 
'',
    83         bool $spl_exists = 
false,
    89         $this->spl_id = $a_spl_id;
    90         $this->has_error = 
false;
    91         $this->characterbuffer = 
"";
    92         $this->survey_status = 
false;
    93         $this->activetag = 
"";
    96         $this->path = array();
    97         $this->metadata = array();
    98         $this->responses = array();
    99         $this->variables = array();
   100         $this->response_id = 
"";
   101         $this->matrix = array();
   102         $this->is_matrix = 
false;
   103         $this->adjectives = array();
   105         $this->survey = null;
   106         $this->in_survey = 
false;
   107         $this->anonymisation = 0;
   108         $this->surveyaccess = 
"restricted";
   109         $this->questions = array();
   110         $this->original_question_id = 
"";
   111         $this->constraints = array();
   112         $this->textblock = 
"";
   113         $this->textblocks = array();
   114         $this->in_questionblock = 
false;
   115         $this->questionblocks = array();
   116         $this->questionblock = array();
   117         $this->showQuestiontext = 1;
   118         $this->showBlocktitle = 0;
   119         $this->compressView = 0;
   120         $this->questionblocktitle = 
"";
   121         $this->mapping = $a_mapping;
   122         $this->session_repo = $DIC->surveyQuestionPool()->internal()
   128         $this->survey = $a_svy;
   133         xml_set_object($a_xml_parser, $this);
   134         xml_set_element_handler($a_xml_parser, 
'handlerBeginTag', 
'handlerEndTag');
   135         xml_set_character_data_handler($a_xml_parser, 
'handlerCharacterData');
   142     public function parse($a_xml_parser, $a_fp = null): void
   147                 while (
$data = fread($a_fp, 4096)) {
   148                     $parseOk = xml_parse($a_xml_parser, 
$data, feof($a_fp));
   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;
   168         if ($this->depth > 0) {
   169             return $this->path[$this->depth - 1];
   178     public function handlerBeginTag($a_xml_parser, 
string $a_name, array $a_attribs): void
   183         $this->characterbuffer = 
"";
   184         $this->activetag = $a_name;
   186         $this->attributes += count($a_attribs);
   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) {
   197                         case "showQuestiontext":
   198                             $this->showQuestiontext = (
int) $value;
   200                         case "showBlocktitle":
   201                             $this->showBlocktitle = (
int) $value;
   204                             $this->compressView = (
int) $value;
   209             case "surveyquestions":
   210                 foreach ($a_attribs as 
$attrib => $value) {
   213                             if ($this->spl_id > 0) {
   215                                 $spl->setOnline($value);
   223                 $this->in_survey = 
true;
   224                 foreach ($a_attribs as 
$attrib => $value) {
   227                             if (is_object($this->survey)) {
   228                                 $this->survey->setTitle($value);
   229                                 $this->survey->update(
true);
   235             case "anonymisation":
   236                 foreach ($a_attribs as 
$attrib => $value) {
   239                             $this->anonymisation = $value;
   245                 foreach ($a_attribs as 
$attrib => $value) {
   248                             $this->surveyaccess = $value;
   254                 $this->constraints[] = array(
   255                     "sourceref" => $a_attribs[
"sourceref"],
   256                     "destref" => $a_attribs[
"destref"],
   257                     "relation" => $a_attribs[
"relation"],
   258                     "value" => $a_attribs[
"value"],
   261                     "conjunction" => (
int) ($a_attribs[
"conjuction"] ?? 0)
   266                 $type = $a_attribs[
"type"];
   269                     case 'SurveyNominalQuestion':
   270                         $type = 
'SurveyMultipleChoiceQuestion';
   271                         foreach ($a_attribs as 
$key => $value) {
   275                                         $type = 
'SurveySingleChoiceQuestion';
   277                                         $type = 
'SurveyMultipleChoiceQuestion';
   283                     case 'SurveyOrdinalQuestion':
   284                         $type = 
'SurveySingleChoiceQuestion';
   287                 if (strlen($type ?? 
"")) {
   289                         $this->activequestion = 
new $type();
   293                         if ($this->spl_id < 0) {
   294                             $q_obj_id = $this->survey->getId();
   297                         $this->activequestion->setObjId($q_obj_id);
   300                     $this->activequestion = null;
   302                 $this->original_question_id = $a_attribs[
"id"];
   303                 if ($this->in_questionblock) {
   306                 if (is_object($this->activequestion)) {
   307                     foreach ($a_attribs as 
$key => $value) {
   310                                 $this->activequestion->setTitle($value);
   313                                 $this->activequestion->setSubtype($value);
   316                                 $this->activequestion->setObligatory($value);
   326                         $this->material = [];
   329                 $this->material[] = array(
"text" => 
"", 
"image" => 
"", 
"label" => $a_attribs[
"label"] ?? 
"");
   333                 if (array_key_exists(
"label", $a_attribs)) {
   334                     if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $a_attribs[
"label"] ?? 
"", $matches)) {
   336                         $this->session_repo->addMob(
   337                             $a_attribs[
"label"] ?? 
"",
   346                 $this->metadata = array();
   348             case "metadatafield":
   349                 $this->metadata[] = array(
"label" => 
"", 
"entry" => 
"");
   352                 $this->is_matrix = 
true;
   353                 $this->matrix = array();
   356                 $this->material = [];
   357                 $this->matrix[] = 
"";
   358                 $this->matrixrowattribs = array(
"id" => $a_attribs[
"id"], 
"label" => $a_attribs[
"label"] ?? 
"", 
"other" => $a_attribs[
"other"] ?? 
"");
   361                 $this->material = [];
   362                 $this->responses = array();
   365                 $this->variables = array();
   367             case "response_single":
   368                 $this->material = [];
   369                 $this->responses[$a_attribs[
"id"]] = array(
"type" => 
"single",
   370                                                            "id" => $a_attribs[
"id"],
   371                                                            "label" => $a_attribs[
"label"] ?? 
"",
   372                                                            "other" => $a_attribs[
"other"] ?? 
"",
   373                                                            "neutral" => $a_attribs[
"neutral"] ?? 
"",
   374                                                            "scale" => $a_attribs[
"scale"] ?? 
"");
   375                 $this->response_id = $a_attribs[
"id"];
   377             case "response_multiple":
   378                 $this->material = [];
   379                 $this->responses[$a_attribs[
"id"]] = array(
"type" => 
"multiple", 
"id" => $a_attribs[
"id"], 
"label" => $a_attribs[
"label"] ?? 
"", 
"other" => $a_attribs[
"other"] ?? 
"", 
"neutral" => $a_attribs[
"neutral"] ?? 
"", 
"scale" => $a_attribs[
"scale"] ?? 
"");
   380                 $this->response_id = $a_attribs[
"id"];
   382             case "response_text":
   383                 $this->material = [];
   384                 $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"] ?? 
"");
   385                 $this->response_id = $a_attribs[
"id"];
   388                 $this->material = [];
   389                 $this->responses[$a_attribs[
"id"]] = array(
"type" => 
"num", 
"id" => $a_attribs[
"id"], 
"format" => $a_attribs[
"format"], 
"max" => $a_attribs[
"max"] ?? null, 
"min" => $a_attribs[
"min"] ?? null, 
"size" => $a_attribs[
"size"] ?? null, 
"label" => $a_attribs[
"label"] ?? 
"");
   390                 $this->response_id = $a_attribs[
"id"];
   392             case "response_time":
   393                 $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"] ?? 
"");
   394                 $this->response_id = $a_attribs[
"id"];
   396             case "bipolar_adjectives":
   397                 $this->adjectives = array();
   400                 $this->adjectives[] = array(
"label" => $a_attribs[
"label"] ?? 
"", 
"text" => 
"");
   411         $this->text_size += strlen($a_data ?? 
"");
   412         $this->characterbuffer .= $a_data;
   420             return $purifier->purify((
string) $this->characterbuffer);
   422         return $this->
trimAndStrip((
string) $this->characterbuffer);
   432                 if (is_object($this->survey)) {
   433                     $this->survey->setOfflineStatus(!$this->survey_status);
   434                     $this->survey->saveToDb();
   437                     if (count($this->questionblocks)) {
   438                         foreach ($this->questionblocks as 
$data) {
   439                             $questionblock = $data[
"questions"];
   440                             $title = $data[
"title"];
   442                             foreach ($questionblock as $question_id) {
   443                                 $qblock[] = $this->questions[$question_id];
   445                             $this->survey->createQuestionblock(
   447                                 $this->showQuestiontext,
   448                                 $this->showBlocktitle,
   456                     if (count($this->constraints)) {
   457                         $relations = $this->survey->getAllRelations(
true);
   458                         foreach ($this->constraints as $constraint) {
   459                             $constraint_id = $this->survey->addConstraint($this->questions[$constraint[
"destref"]], $relations[$constraint[
"relation"]][
"id"], $constraint[
"value"], $constraint[
"conjunction"]);
   460                             $this->survey->addConstraintToQuestion($this->questions[$constraint[
"sourceref"]], $constraint_id);
   465                     if (count($this->textblocks)) {
   466                         foreach ($this->textblocks as $original_id => $textblock) {
   467                             $this->survey->saveHeading($textblock, $this->questions[$original_id]);
   473                 $this->in_survey = 
false;
   474                 if (is_object($this->survey)) {
   475                     if (strcmp($this->surveyaccess, 
"free") == 0) {
   476                         $this->survey->setAnonymize(2);
   478                         if ($this->anonymisation == 0) {
   479                             $this->survey->setAnonymize(0);
   481                             $this->survey->setAnonymize(1);
   487                 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->
getCharacterBuffer(), $matches)) {
   488                     if (is_object($this->survey)) {
   489                         $this->survey->setStartDate(sprintf(
"%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
   494                 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).*/", $this->
getCharacterBuffer(), $matches)) {
   495                     if (is_object($this->survey)) {
   496                         $this->survey->setEndDate(sprintf(
"%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
   501                 if ($this->in_survey) {
   502                     if (is_object($this->survey)) {
   504                         $this->survey->update(
true);
   507                     if (is_object($this->activequestion)) {
   513                 if (is_object($this->activequestion)) {
   514                     if (strlen($this->textblock ?? 
"")) {
   517                     $this->activequestion->saveToDb();
   519                     if (is_object($this->survey) &&
   521                         $question_id = $this->activequestion->duplicate(
true, 
"", 
"", 0, $this->survey->getId());
   523                         $question_id = $this->activequestion->getId();
   525                     if (is_object($this->survey)) { 
   526                         $this->survey->addQuestion($question_id);
   529                     if ($this->mapping) {
   530                         $this->mapping->addMapping(
"Modules/Survey", 
"svy_q", $this->original_question_id, $question_id);
   532                     $this->activequestion = null;
   534                 $this->textblock = 
"";
   537                 if ($this->in_survey) {
   538                     if (is_object($this->survey)) {
   542                     if (is_object($this->activequestion)) {
   548                 $this->material[count($this->material) - 1][
"text"] = $this->
getCharacterBuffer(
true);
   554                 if ($this->in_survey) {
   555                     if (strcmp($this->
getParent(), 
"objectives") == 0) {
   556                         if (isset($this->material[0]) && strcmp($this->material[0][
"label"], 
"introduction") == 0) {
   557                             if (is_object($this->survey)) {
   558                                 $this->survey->setIntroduction($this->material[0][
"text"]);
   561                         if (isset($this->material[0]) && strcmp($this->material[0][
"label"], 
"outro") == 0) {
   562                             if (is_object($this->survey)) {
   563                                 $this->survey->setOutro($this->material[0][
"text"]);
   566                         $this->material = array();
   569                     if (strcmp($this->
getParent(), 
"question") == 0) {
   576                 if (is_object($this->activequestion)) {
   578                     foreach ($this->material as $matarray) {
   579                         $questiontext .= $matarray[
"text"];
   581                     $this->activequestion->setQuestiontext($questiontext);
   583                 $this->material = array();
   592                 if (strcmp($this->
getParent(), 
"question") == 0) {
   593                     if (is_object($this->activequestion)) {
   594                         $this->activequestion->importAdditionalMetadata($this->metadata);
   597                 if (strcmp($this->
getParent(), 
"survey") == 0) {
   598                     foreach ($this->metadata as 
$key => $value) {
   599                         switch ($value[
"label"]) {
   601                                 if (strlen($value[
"entry"] ?? 
"")) {
   602                                     if (is_object($this->survey)) {
   604                                         $md_sax_parser->setXMLContent($value[
"entry"]);
   605                                         $md_sax_parser->setMDObject($tmp = 
new ilMD($this->survey->getId(), 0, 
"svy"));
   606                                         $md_sax_parser->enableMDParsing(
true);
   607                                         $md_sax_parser->startParsing();
   608                                         $this->survey->MDUpdateListener(
"General");
   612                             case "display_question_titles":
   613                                 if ($value[
"entry"] == 1) {
   614                                     $this->survey->setShowQuestionTitles(
true);
   616                                     $this->survey->setShowQuestionTitles(
false);
   620                                 $this->survey_status = (bool) $value[
"entry"];
   622                             case "evaluation_access":
   623                                 $this->survey->setEvaluationAccess($value[
"entry"]);
   626                                 $this->survey->setPoolUsage($value[
"entry"]);
   628                             case "own_results_view":
   629                                 $this->survey->setViewOwnResults($value[
"entry"]);
   631                             case "own_results_mail":
   632                                 $this->survey->setMailOwnResults($value[
"entry"]);
   634                             case "confirmation_mail":
   635                                 $this->survey->setMailConfirmation($value[
"entry"]);
   637                             case "anon_user_list":
   638                                 $this->survey->setAnonymousUserList($value[
"entry"]);
   641                                 $this->survey->setMode($value[
"entry"]);
   643                             case "mode_360_self_eval":
   644                                 $this->survey->set360SelfEvaluation($value[
"entry"]);
   646                             case "mode_360_self_rate":
   647                                 $this->survey->set360SelfRaters($value[
"entry"]);
   649                             case "mode_360_self_appr":
   650                                 $this->survey->set360SelfAppraisee($value[
"entry"]);
   652                             case "mode_360_results":
   653                                 $this->survey->set360Results($value[
"entry"]);
   655                             case "mode_self_eval_results":
   656                                 $this->survey->setSelfEvaluationResults($value[
"entry"]);
   658                             case "mode_skill_service":
   659                                 $this->survey->setSkillService($value[
"entry"]);
   664                 if (!$this->spl_exists) {
   665                     if (strcmp($this->
getParent(), 
"surveyquestions") == 0) {
   666                         foreach ($this->metadata as 
$key => $value) {
   667                             if (strcmp($value[
"label"], 
"SCORM") == 0) {
   668                                 if (strlen($value[
"entry"] ?? 
"")) {
   669                                     if ($this->spl_id > 0) {
   671                                         $md_sax_parser->setXMLContent($value[
"entry"]);
   672                                         $md_sax_parser->setMDObject($tmp = 
new ilMD($this->spl_id, 0, 
"spl"));
   673                                         $md_sax_parser->enableMDParsing(
true);
   674                                         $md_sax_parser->startParsing();
   676                                         $spl->MDUpdateListener(
"General");
   685                 if (is_object($this->activequestion)) {
   686                     $this->activequestion->importResponses($this->responses);
   688                 $this->is_matrix = 
false;
   694                 if (is_object($this->activequestion)) {
   695                     $this->activequestion->importVariables($this->variables);
   698             case "response_single":
   699             case "response_multiple":
   700             case "response_text":
   702             case "response_time":
   706                 $this->adjectives[count($this->adjectives) - 1][
"text"] = $this->
getCharacterBuffer();
   708             case "bipolar_adjectives":
   709                 if (is_object($this->activequestion)) {
   710                     $this->activequestion->importAdjectives($this->adjectives);
   715                 foreach ($this->material as $material) {
   716                     $row .= $material[
"text"];
   718                 $this->matrix[count($this->matrix) - 1] = array(
'title' => $row, 
'id' => $this->matrixrowattribs[
'id'], 
'label' => $this->matrixrowattribs[
'label'], 
'other' => $this->matrixrowattribs[
'other']);
   721                 if (is_object($this->activequestion)) {
   722                     $this->activequestion->importMatrix($this->matrix);
   728             case "questionblocktitle":
   731             case "questionblock":
   732                 $this->in_questionblock = 
false;
   733                 $this->questionblocks[] = array(
"title" => $this->questionblocktitle,
   734                                                 "questions" => $this->questionblock
   763         return "Error: " . $this->error_msg . 
" at line:" . $this->error_line . 
" column:" . 
$this->error_col;
   794         foreach ($attribs as $k => $v) {
   795             $ret[$k] = ((string) $v !== 
"<>")
 
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
 
trimAndStrip(string $input)
 
ILIAS SurveyQuestionPool Export ImportSessionRepository $session_repo
 
handlerEndTag($a_xml_parser, string $a_name)
 
parse($a_xml_parser, $a_fp=null)
 
Class ilObjSurveyQuestionPool. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
SurveyQuestion $activequestion
 
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type. 
 
string $original_question_id
 
__construct(int $a_spl_id, ?string $a_xml_file='', bool $spl_exists=false, ?ilImportMapping $a_mapping=null)
 
trimAndStripAttribs(array $attribs)
 
string $questionblocktitle
 
handlerCharacterData($a_xml_parser, string $a_data)
 
setHandlers($a_xml_parser)
 
getCharacterBuffer($use_purifier=false)
 
$attrib
Regular expression to match HTML/XML attribute pairs within a tag. 
 
setSurveyObject(ilObjSurvey $a_svy)