protected function createQuestionPool($name = "dummy") { global $tree; $parent_ref = $tree->getParentId($this->object->getRefId()); include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; $qpl = new ilObjSurveyQuestionPool(); $qpl->setType("spl"); $qpl->setTitle($name); $qpl->setDescription(""); $qpl->create(); $qpl->createReference(); $qpl->putInTree($parent_ref); $qpl->setPermissions($parent_ref); $qpl->setOnline(1); // must be online to be available $qpl->saveToDb(); return $qpl->getRefId(); }
/** * handler for begin of element */ function handlerBeginTag($a_xml_parser, $a_name, $a_attribs) { $this->depth[$a_xml_parser]++; $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name); $this->characterbuffer = ""; $this->activetag = $a_name; $this->elements++; $this->attributes += count($a_attribs); switch ($a_name) { case "questionblock": $this->in_questionblock = TRUE; $this->questionblock = array(); $this->questionblocktitle = ""; $this->showQuestiontext = 1; foreach ($a_attribs as $attrib => $value) { switch ($attrib) { case "showQuestiontext": $this->showQuestiontext = $value; break; } } break; case "surveyquestions": foreach ($a_attribs as $attrib => $value) { switch ($attrib) { case "online": if ($this->spl_id > 0) { include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; $spl = new ilObjSurveyQuestionPool($this->spl_id, false); $spl->setOnline($value); $spl->saveToDb(); } break; } } break; case "survey": $this->in_survey = TRUE; foreach ($a_attribs as $attrib => $value) { switch ($attrib) { case "title": if (is_object($this->survey)) { $this->survey->setTitle($value); } break; } } break; case "anonymisation": foreach ($a_attribs as $attrib => $value) { switch ($attrib) { case "enabled": $this->anonymisation = $value; break; } } break; case "access": foreach ($a_attribs as $attrib => $value) { switch ($attrib) { case "type": $this->surveyaccess = $value; break; } } break; case "constraint": array_push($this->constraints, array("sourceref" => $a_attribs["sourceref"], "destref" => $a_attribs["destref"], "relation" => $a_attribs["relation"], "value" => $a_attribs["value"], "conjunction" => (int) $a_attribs["conjuction"])); break; case "question": // start with a new survey question $type = $a_attribs["type"]; // patch due to changes in question types switch ($type) { case 'SurveyNominalQuestion': $type = 'SurveyMultipleChoiceQuestion'; foreach ($a_attribs as $key => $value) { switch ($key) { case "subtype": if ($value == 1) { $type = 'SurveySingleChoiceQuestion'; } else { $type = 'SurveyMultipleChoiceQuestion'; } break; } } break; case 'SurveyOrdinalQuestion': $type = 'SurveySingleChoiceQuestion'; break; } if (strlen($type)) { include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; if (SurveyQuestion::_includeClass($type)) { $this->activequestion = new $type(); // if no pool is given, question will reference survey $q_obj_id = $this->spl_id; if ($this->spl_id < 0) { $q_obj_id = $this->survey->getId(); } $this->activequestion->setObjId($q_obj_id); } } else { $this->activequestion = NULL; } $this->original_question_id = $a_attribs["id"]; if ($this->in_questionblock) { array_push($this->questionblock, $this->original_question_id); } if (is_object($this->activequestion)) { foreach ($a_attribs as $key => $value) { switch ($key) { case "title": $this->activequestion->setTitle($value); break; case "subtype": $this->activequestion->setSubtype($value); break; case "obligatory": $this->activequestion->setObligatory($value); break; } } } break; case "material": switch ($this->getParent($a_xml_parser)) { case "question": case "questiontext": $this->material = array(); break; } array_push($this->material, array("text" => "", "image" => "", "label" => $a_attribs["label"])); break; case "matimage": case "label": if (array_key_exists("label", $a_attribs)) { if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $a_attribs["label"], $matches)) { // import an mediaobject which was inserted using tiny mce if (!is_array($_SESSION["import_mob_xhtml"])) { $_SESSION["import_mob_xhtml"] = array(); } array_push($_SESSION["import_mob_xhtml"], array("mob" => $a_attribs["label"], "uri" => $a_attribs["uri"], "type" => $a_attribs["type"], "id" => $a_attribs["id"])); } } break; case "metadata": $this->metadata = array(); break; case "metadatafield": array_push($this->metadata, array("label" => "", "entry" => "")); break; case "matrix": $this->is_matrix = TRUE; $this->matrix = array(); break; case "matrixrow": $this->material = array(); array_push($this->matrix, ""); $this->matrixrowattribs = array("id" => $a_attribs["id"], "label" => $a_attribs["label"], "other" => $a_attribs["other"]); break; case "responses": $this->material = array(); $this->responses = array(); break; case "variables": $this->variables = array(); break; case "response_single": $this->material = array(); $this->responses[$a_attribs["id"]] = array("type" => "single", "id" => $a_attribs["id"], "label" => $a_attribs["label"], "other" => $a_attribs["other"], "neutral" => $a_attribs["neutral"], "scale" => $a_attribs["scale"]); $this->response_id = $a_attribs["id"]; break; case "response_multiple": $this->material = array(); $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"]); $this->response_id = $a_attribs["id"]; break; case "response_text": $this->material = array(); $this->responses[$a_attribs["id"]] = array("type" => "text", "id" => $a_attribs["id"], "columns" => $a_attribs["columns"], "maxlength" => $a_attribs["maxlength"], "rows" => $a_attribs["rows"], "label" => $a_attribs["label"]); $this->response_id = $a_attribs["id"]; break; case "response_num": $this->material = array(); $this->responses[$a_attribs["id"]] = array("type" => "num", "id" => $a_attribs["id"], "format" => $a_attribs["format"], "max" => $a_attribs["max"], "min" => $a_attribs["min"], "size" => $a_attribs["size"], "label" => $a_attribs["label"]); $this->response_id = $a_attribs["id"]; break; case "response_time": $this->material = array(); $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"]); $this->response_id = $a_attribs["id"]; break; case "bipolar_adjectives": $this->adjectives = array(); break; case "adjective": array_push($this->adjectives, array("label" => $a_attribs["label"], "text" => "")); break; } }