/** * Get xml representation * * @param string entity * @param string target release * @param string id * @return string xml string */ public function getXmlRepresentation($a_entity, $a_schema_version, $a_id) { $refs = ilObject::_getAllReferences($a_id); $sql_ref_id = current($refs); include_once './Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php'; $spl = new ilObjSurveyQuestionPool($a_id, false); $spl->loadFromDb(); include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php"; $spl_exp = new ilSurveyQuestionpoolExport($spl, 'xml'); $zip = $spl_exp->buildExportFile(); $GLOBALS['ilLog']->write(__METHOD__ . ': Created zip file ' . $zip); }
/** * Get Form HTML * * @param array $questions * @param bool $a_has_previous_page * @param bool $a_has_next_page * @param bool $a_readonly * @return string */ function getPageNodes(array $a_questions, $a_has_previous_page = false, $a_has_next_page = false, $a_readonly = false) { global $ilCtrl, $lng; $ttpl = new ilTemplate("tpl.il_svy_svy_page_view_nodes.html", true, true, "Modules/Survey"); $has_clipboard = (bool) $_SESSION["survey_page_view"][$this->ref_id]["clipboard"]; // question block ? $first_question = $a_questions; $first_question = array_shift($first_question); if ($first_question["questionblock_id"]) { $menu = array(); if (!$a_readonly && !$has_clipboard) { $menu[] = array("cmd" => "editBlock", "text" => $lng->txt("edit")); } if ($first_question["questionblock_show_blocktitle"]) { $block_status = $lng->txt("survey_block_visible"); } else { $block_status = $lng->txt("survey_block_hidden"); } $this->renderPageNode($ttpl, "block", $first_question["questionblock_id"], $first_question["questionblock_title"] . " (" . $block_status . ")", $menu, false, false, $block_status); } // questions/headings include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; $questiontypes = ilObjSurveyQuestionPool::_getQuestiontypes(); $questionpools = array_keys($this->object->getQuestionpoolTitles(true)); $counter = $question_count; $block_done = null; foreach ($a_questions as $idx => $question) { // drop area $menu = array(); if (!$a_readonly) { if (!$has_clipboard) { foreach ($questiontypes as $trans => $item) { $menu[] = array("cmd" => "addQuestion_" . $item["questiontype_id"], "text" => sprintf($lng->txt("svy_page_add_question"), $trans)); } if ($this->object->isPoolActive()) { $menu[] = array("cmd" => "addPoolQuestion", "text" => $lng->txt("browse_for_questions")); } } else { $menu[] = array("cmd" => "paste", "text" => $lng->txt("survey_dnd_paste")); } } $this->renderPageNode($ttpl, "droparea", $question["question_id"], null, $menu, true); // question $question_gui = $this->object->getQuestionGUI($question["type_tag"], $question["question_id"]); $question_form = $question_gui->getWorkingForm(array(), $this->object->getShowQuestionTitles(), $question["questionblock_show_questiontext"], null, $this->object->getSurveyId()); $menu = array(); if (!$a_readonly && !$has_clipboard) { $menu[] = array("cmd" => "editQuestion", "text" => $lng->txt("edit")); $menu[] = array("cmd" => "cutQuestion", "text" => $lng->txt("cut")); $menu[] = array("cmd" => "copyQuestion", "text" => $lng->txt("copy")); if (sizeof($a_questions) > 1 && $idx > 0) { $menu[] = array("cmd" => "splitPage", "text" => $lng->txt("survey_dnd_split_page")); } if ($a_has_next_page) { $menu[] = array("cmd" => "moveNext", "text" => $lng->txt("survey_dnd_move_next")); } if ($a_has_previous_page) { $menu[] = array("cmd" => "movePrevious", "text" => $lng->txt("survey_dnd_move_previous")); } $menu[] = array("cmd" => "deleteQuestion", "text" => $lng->txt("delete")); // heading if ($question["heading"]) { $menu[] = array("cmd" => "editHeading", "text" => $lng->txt("survey_edit_heading")); $menu[] = array("cmd" => "deleteHeading", "text" => $lng->txt("survey_delete_heading")); } else { $menu[] = array("cmd" => "addHeading", "text" => $lng->txt("add_heading")); } } if ($first_question["questionblock_show_questiontext"]) { $question_title_status = $lng->txt("survey_question_text_visible"); } else { $question_title_status = $lng->txt("survey_question_text_hidden"); } $this->renderPageNode($ttpl, "question", $question["question_id"], $question_form, $menu, false, $question["title"], $question_title_status, $question["heading"]); $ilCtrl->setParameter($this, "eqid", ""); } // last position (no question id) $menu = array(); if (!$a_readonly) { if (!$has_clipboard) { foreach ($questiontypes as $trans => $item) { $menu[] = array("cmd" => "addQuestion_" . $item["questiontype_id"], "text" => sprintf($lng->txt("svy_page_add_question"), $trans)); } if ($this->object->isPoolActive()) { $menu[] = array("cmd" => "addPoolQuestion", "text" => $lng->txt("browse_for_questions")); } } else { $menu[] = array("cmd" => "paste", "text" => $lng->txt("survey_dnd_paste")); } } $this->renderPageNode($ttpl, "page", "end", null, $menu, true); return $ttpl->get(); }
/** * Init filter */ function initFilter() { global $lng, $rbacreview, $ilUser; // title include_once "./Services/Form/classes/class.ilTextInputGUI.php"; $ti = new ilTextInputGUI($lng->txt("survey_question_title"), "title"); $ti->setMaxLength(64); $ti->setValidationRegexp('/^[^%]+$/is'); $ti->setSize(20); $this->addFilterItem($ti); $ti->readFromSession(); $this->filter["title"] = $ti->getValue(); // description $ti = new ilTextInputGUI($lng->txt("description"), "description"); $ti->setMaxLength(64); $ti->setValidationRegexp('/^[^%]+$/is'); $ti->setSize(20); $this->addFilterItem($ti); $ti->readFromSession(); $this->filter["description"] = $ti->getValue(); // author $ti = new ilTextInputGUI($lng->txt("author"), "author"); $ti->setMaxLength(64); $ti->setValidationRegexp('/^[^%]+$/is'); $ti->setSize(20); $this->addFilterItem($ti); $ti->readFromSession(); $this->filter["author"] = $ti->getValue(); // questiontype include_once "./Services/Form/classes/class.ilSelectInputGUI.php"; include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; $types = ilObjSurveyQuestionPool::_getQuestionTypes(); $options = array(); $options[""] = $lng->txt('filter_all_question_types'); foreach ($types as $translation => $row) { $options[$row['type_tag']] = $translation; } $si = new ilSelectInputGUI($this->lng->txt("question_type"), "type"); $si->setOptions($options); $this->addFilterItem($si); $si->readFromSession(); $this->filter["type"] = $si->getValue(); // questionpool text $ti = new ilTextInputGUI($lng->txt("survey_question_pool_title"), "spl_txt"); $ti->setMaxLength(64); $ti->setSize(20); $this->addFilterItem($ti); $ti->readFromSession(); $this->filter["spl_txt"] = $ti->getValue(); // questionpool select $options = array(); $options[""] = $lng->txt('filter_all_questionpools'); natcasesort($this->questionpools); foreach ($this->questionpools as $obj_id => $title) { $options[$obj_id] = $title; } $si = new ilSelectInputGUI($this->lng->txt("survey_available_question_pools"), "spl"); $si->setOptions($options); $this->addFilterItem($si); $si->readFromSession(); $this->filter["type"] = $si->getValue(); }
/** * Calculates the data for the output of the question browser * * @access public */ function getQuestionsTable($arrFilter) { global $ilUser; global $ilDB; $where = ""; if (is_array($arrFilter)) { if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title'])) { $where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%"); } if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description'])) { $where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%"); } if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author'])) { $where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%"); } if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type'])) { $where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text'); } if (array_key_exists('spl', $arrFilter) && strlen($arrFilter['spl'])) { $where .= " AND svy_question.obj_fi = " . $ilDB->quote($arrFilter['spl'], 'integer'); } } $spls =& $this->getAvailableQuestionpools($use_obj_id = TRUE, $could_be_offline = FALSE, $showPath = FALSE); $forbidden = ""; $forbidden = " AND " . $ilDB->in('svy_question.obj_fi', array_keys($spls), false, 'integer'); $forbidden .= " AND svy_question.complete = " . $ilDB->quote("1", 'text'); $existing = ""; $existing_questions =& $this->getExistingQuestions(); if (count($existing_questions)) { $existing = " AND " . $ilDB->in('svy_question.question_id', $existing_questions, true, 'integer'); } include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; $trans = ilObjSurveyQuestionPool::_getQuestionTypeTranslations(); $query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id" . " FROM svy_question, svy_qtype, object_reference" . " WHERE svy_question.original_id IS NULL" . $forbidden . $existing . " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0" . " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where); $rows = array(); if ($query_result->numRows()) { while ($row = $ilDB->fetchAssoc($query_result)) { if (array_key_exists('spl_txt', $arrFilter) && strlen($arrFilter['spl_txt'])) { if (!stristr($spls[$row["obj_fi"]], $arrFilter['spl_txt'])) { continue; } } $row['ttype'] = $trans[$row['type_tag']]; if ($row["plugin"]) { if ($this->isPluginActive($row["type_tag"])) { array_push($rows, $row); } } else { array_push($rows, $row); } } } return $rows; }
/** * form for new survey object import */ public function importFileObject() { global $tpl, $ilErr; $parent_id = $_GET["ref_id"]; $new_type = $_REQUEST["new_type"]; // create permission is already checked in createObject. This check here is done to prevent hacking attempts if (!$this->checkPermissionBool("create", "", $new_type)) { $ilErr->raiseError($this->lng->txt("no_create_permission")); } $this->lng->loadLanguageModule($new_type); $this->ctrl->setParameter($this, "new_type", $new_type); $form = $this->initImportForm($new_type); if ($form->checkInput()) { include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; $newObj = new ilObjSurveyQuestionPool(); $newObj->setType($new_type); $newObj->setTitle("dummy"); $newObj->create(true); $this->putObjectInTree($newObj); $newObj->createImportDirectory(); // copy uploaded file to import directory $upload = $_FILES["importfile"]; $file = pathinfo($upload["name"]); $full_path = $newObj->getImportDirectory() . "/" . $upload["name"]; include_once "./Services/Utilities/classes/class.ilUtil.php"; ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"], $full_path); // import qti data $qtiresult = $newObj->importObject($full_path); ilUtil::sendSuccess($this->lng->txt("object_imported"), true); ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() . "&baseClass=ilObjSurveyQuestionPoolGUI"); } // display form to correct errors $form->setValuesByPost(); $tpl->setContent($form->getHtml()); }
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(); }
/** * Returns true if the question is writeable by a certain user * * @param integer $question_id The database id of the question * @param integer $user_id The database id of the user * @result boolean True, if the question exists, otherwise False * @access public */ function _isWriteable($question_id, $user_id) { global $ilDB; if ($question_id < 1 || $user_id < 1) { return false; } $result = $ilDB->queryF("SELECT obj_fi FROM svy_question WHERE question_id = %s", array('integer'), array($question_id)); if ($result->numRows() == 1) { $row = $ilDB->fetchAssoc($result); $qpl_object_id = $row["obj_fi"]; include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; return ilObjSurveyQuestionPool::_isWriteable($qpl_object_id, $user_id); } else { return false; } }
/** * handler for end of element */ function handlerEndTag($a_xml_parser, $a_name) { switch ($a_name) { case "surveyobject": if (is_object($this->survey)) { $this->survey->setStatus($this->survey_status); $this->survey->saveToDb(); // write question blocks if (count($this->questionblocks)) { foreach ($this->questionblocks as $data) { $questionblock = $data["questions"]; $title = $data["title"]; $qblock = array(); foreach ($questionblock as $question_id) { array_push($qblock, $this->questions[$question_id]); } $this->survey->createQuestionblock($title, $this->showQuestiontext, false, $qblock); } } // #13878 - write constraints if (count($this->constraints)) { $relations = $this->survey->getAllRelations(TRUE); foreach ($this->constraints as $constraint) { $constraint_id = $this->survey->addConstraint($this->questions[$constraint["destref"]], $relations[$constraint["relation"]]["id"], $constraint["value"], $constraint["conjunction"]); $this->survey->addConstraintToQuestion($this->questions[$constraint["sourceref"]], $constraint_id); } } // write textblocks if (count($this->textblocks)) { foreach ($this->textblocks as $original_id => $textblock) { $this->survey->saveHeading($textblock, $this->questions[$original_id]); } } } break; case "survey": $this->in_survey = FALSE; if (is_object($this->survey)) { if (strcmp($this->surveyaccess, "free") == 0) { $this->survey->setAnonymize(2); } else { if ($this->anonymisation == 0) { $this->survey->setAnonymize(0); } else { $this->survey->setAnonymize(1); } } } break; case "startingtime": if (preg_match("/(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2})-(\\d{2})-(\\d{2}).*/", $this->characterbuffer, $matches)) { if (is_object($this->survey)) { $this->survey->setStartDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $this->survey->setStartDateEnabled(1); } } break; case "endingtime": if (preg_match("/(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2})-(\\d{2})-(\\d{2}).*/", $this->characterbuffer, $matches)) { if (is_object($this->survey)) { $this->survey->setEndDate(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $this->survey->setEndDateEnabled(1); } } break; case "description": if ($this->in_survey) { if (is_object($this->survey)) { $this->survey->setDescription($this->characterbuffer); } } else { if (is_object($this->activequestion)) { $this->activequestion->setDescription($this->characterbuffer); } } break; case "question": if (is_object($this->activequestion)) { if (strlen($this->textblock)) { $this->textblocks[$this->original_question_id] = $this->textblock; } $this->activequestion->saveToDb(); // duplicate the question for the survey (if pool is to be used) if (is_object($this->survey) && $this->spl_id > 0) { $question_id = $this->activequestion->duplicate(TRUE); } else { $question_id = $this->activequestion->getId(); } $this->survey->addQuestion($question_id); $this->questions[$this->original_question_id] = $question_id; $this->activequestion = NULL; } $this->textblock = ""; break; case "author": if ($this->in_survey) { if (is_object($this->survey)) { $this->survey->setAuthor($this->characterbuffer); } } else { if (is_object($this->activequestion)) { $this->activequestion->setAuthor($this->characterbuffer); } } break; case "mattext": $this->material[count($this->material) - 1]["text"] = $this->characterbuffer; break; case "matimage": $this->material[count($this->material) - 1]["image"] = $this->characterbuffer; break; case "material": if ($this->in_survey) { if (strcmp($this->getParent($a_xml_parser), "objectives") == 0) { if (strcmp($this->material[0]["label"], "introduction") == 0) { if (is_object($this->survey)) { $this->survey->setIntroduction($this->material[0]["text"]); } } if (strcmp($this->material[0]["label"], "outro") == 0) { if (is_object($this->survey)) { $this->survey->setOutro($this->material[0]["text"]); } } $this->material = array(); } } else { if (strcmp($this->getParent($a_xml_parser), "question") == 0) { $this->activequestion->setMaterial($this->material[0]["text"], TRUE, $this->material[0]["label"]); } } break; case "questiontext": if (is_object($this->activequestion)) { $questiontext = ""; foreach ($this->material as $matarray) { $questiontext .= $matarray["text"]; } $this->activequestion->setQuestiontext($questiontext); } $this->material = array(); break; case "fieldlabel": $this->metadata[count($this->metadata) - 1]["label"] = $this->characterbuffer; break; case "fieldentry": $this->metadata[count($this->metadata) - 1]["entry"] = $this->characterbuffer; break; case "metadata": if (strcmp($this->getParent($a_xml_parser), "question") == 0) { if (is_object($this->activequestion)) { $this->activequestion->importAdditionalMetadata($this->metadata); } } if (strcmp($this->getParent($a_xml_parser), "survey") == 0) { foreach ($this->metadata as $key => $value) { switch ($value["label"]) { case "SCORM": if (strlen($value["entry"])) { if (is_object($this->survey)) { include_once "./Services/MetaData/classes/class.ilMDSaxParser.php"; include_once "./Services/MetaData/classes/class.ilMD.php"; $md_sax_parser = new ilMDSaxParser(); $md_sax_parser->setXMLContent($value["entry"]); $md_sax_parser->setMDObject($tmp = new ilMD($this->survey->getId(), 0, "svy")); $md_sax_parser->enableMDParsing(true); $md_sax_parser->startParsing(); $this->survey->MDUpdateListener("General"); } } break; case "display_question_titles": if ($value["entry"] == 1) { $this->survey->showQuestionTitles(); } else { $this->survey->hideQuestionTitles(); } break; case "status": $this->survey_status = $value["entry"]; break; case "evaluation_access": $this->survey->setEvaluationAccess($value["entry"]); break; case "pool_usage": $this->survey->setPoolUsage($value["entry"]); break; case "own_results_view": $this->survey->setViewOwnResults($value["entry"]); break; case "own_results_mail": $this->survey->setMailOwnResults($value["entry"]); break; case "mode_360": $this->survey->set360Mode($value["entry"]); break; case "mode_360_self_eval": $this->survey->set360SelfEvaluation($value["entry"]); break; case "mode_360_self_rate": $this->survey->set360SelfRaters($value["entry"]); break; case "mode_360_self_appr": $this->survey->set360SelfAppraisee($value["entry"]); break; case "mode_360_results": $this->survey->set360Results($value["entry"]); break; case "mode_360_skill_service": $this->survey->set360SkillService($value["entry"]); break; } } } if (!$this->spl_exists) { if (strcmp($this->getParent($a_xml_parser), "surveyquestions") == 0) { foreach ($this->metadata as $key => $value) { if (strcmp($value["label"], "SCORM") == 0) { if (strlen($value["entry"])) { if ($this->spl_id > 0) { include_once "./Services/MetaData/classes/class.ilMDSaxParser.php"; include_once "./Services/MetaData/classes/class.ilMD.php"; include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; $md_sax_parser = new ilMDSaxParser(); $md_sax_parser->setXMLContent($value["entry"]); $md_sax_parser->setMDObject($tmp = new ilMD($this->spl_id, 0, "spl")); $md_sax_parser->enableMDParsing(true); $md_sax_parser->startParsing(); $spl = new ilObjSurveyQuestionPool($this->spl_id, false); $spl->MDUpdateListener("General"); } } } } } } break; case "responses": if (is_object($this->activequestion)) { $this->activequestion->importResponses($this->responses); } $this->is_matrix = FALSE; break; case "variable": array_push($this->variables, $this->characterbuffer); break; case "variables": if (is_object($this->activequestion)) { $this->activequestion->importVariables($this->variables); } break; case "response_single": case "response_multiple": case "response_text": case "response_num": case "response_time": $this->responses[$this->response_id]["material"] = $this->material; break; case "adjective": $this->adjectives[count($this->adjectives) - 1]["text"] = $this->characterbuffer; break; case "bipolar_adjectives": if (is_object($this->activequestion)) { $this->activequestion->importAdjectives($this->adjectives); } break; case "matrixrow": $row = ""; foreach ($this->material as $material) { $row .= $material["text"]; } $this->matrix[count($this->matrix) - 1] = array('title' => $row, 'id' => $this->matrixrowattribs['id'], 'label' => $this->matrixrowattribs['label'], 'other' => $this->matrixrowattribs['other']); break; case "matrix": if (is_object($this->activequestion)) { $this->activequestion->importMatrix($this->matrix); } break; case "textblock": $this->textblock = $this->characterbuffer; break; case "questionblocktitle": $this->questionblocktitle = $this->characterbuffer; break; case "questionblock": $this->in_questionblock = FALSE; array_push($this->questionblocks, array("title" => $this->questionblocktitle, "questions" => $this->questionblock)); break; } $this->depth[$a_xml_parser]--; }
/** * Import data from DB */ protected function importData() { global $ilCtrl, $lng; $survey_questions = $this->object->getSurveyQuestions(); if (count($survey_questions) > 0) { include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; $questiontypes = ilObjSurveyQuestionPool::_getQuestiontypes(); $questionpools = $this->object->getQuestionpoolTitles(true); $table_data = array(); $last_questionblock_id = $position = $block_position = 0; foreach ($survey_questions as $question_id => $data) { // question block if ($data["questionblock_id"] > 0 && $data["questionblock_id"] != $last_questionblock_id) { $id = "qb_" . $data["questionblock_id"]; $table_data[$id] = array("id" => $id, "type" => "block", "title" => $data["questionblock_title"]); if (!$this->read_only) { // order if (sizeof($survey_questions) > 1) { $position += 10; $table_data[$id]["position"] = $position; } $table_data[$id]["url"] = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) . "&editblock=" . $data["questionblock_id"]; } $block_position = 0; } // question $id = $data["question_id"]; $table_data[$id] = array("id" => $id, "type" => "question", "heading" => $data["heading"], "title" => $data["title"], "description" => $data["description"], "author" => $data["author"], "block_id" => $data["questionblock_id"], "obligatory" => (bool) $data["obligatory"]); // question type foreach ($questiontypes as $trans => $typedata) { if (strcmp($typedata["type_tag"], $data["type_tag"]) == 0) { $table_data[$id]["question_type"] = $trans; } } // pool title if ($data["original_id"]) { if (isset($questionpools[$data["obj_fi"]])) { $table_data[$id]["pool"] = $questionpools[$data["obj_fi"]]; } else { // #11186 $table_data[$id]["pool"] = $this->lng->txt("status_no_permission"); } } if (!$this->read_only) { if ($data["obj_fi"] > 0) { // edit url $qpl_ref_id = current(ilObject::_getAllReferences($data["obj_fi"])); $table_data[$id]["url"] = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) . "&eqid=" . $id . "&eqpl=" . $qpl_ref_id; } // order if (sizeof($survey_questions) > 1) { if (!$data["questionblock_id"]) { $position += 10; $table_data[$id]["position"] = $position; } else { $block_position += 10; $table_data[$id]["position"] = $block_position; } } } $last_questionblock_id = $data["questionblock_id"]; } } $this->setData($table_data); }
/** * Get item properties * * @return array array of property arrays: * "alert" (boolean) => display as an alert property (usually in red) * "property" (string) => property name * "value" (string) => property value */ function getProperties() { global $lng, $ilUser; $props = array(); include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; if (!ilObjSurveyQuestionPool::_lookupOnline($this->obj_id)) { $props[] = array("alert" => true, "property" => $lng->txt("status"), "value" => $lng->txt("offline")); } return $props; }
/** * handler for end of element */ function handlerEndTag($a_xml_parser, $a_name) { switch ($a_name) { case "questestinterop": if (is_object($this->survey)) { // write constraints if (count($this->constraints)) { $relations = $this->survey->getAllRelations(TRUE); foreach ($this->constraints as $constraint) { $this->survey->addConstraint($this->questions[$constraint["sourceref"]], $this->questions[$constraint["destref"]], $relations[$constraint["relation"]]["id"], $constraint["value"]); } } // write question blocks if (count($this->questionblocks)) { foreach ($this->questionblocks as $data) { $questionblock = $data["questions"]; $title = $data["title"]; $qblock = array(); foreach ($questionblock as $question_id) { array_push($qblock, $this->questions[$question_id]); } $this->survey->createQuestionblock($title, TRUE, $qblock); } } $this->survey->saveToDb(); // write textblocks if (count($this->textblocks)) { foreach ($this->textblocks as $original_id => $textblock) { $this->survey->saveHeading($textblock, $this->questions[$original_id]); } } } break; case "survey": $this->in_survey = FALSE; break; case "item": if (is_object($this->activequestion)) { $this->activequestion->setTitle($this->question_title); $this->activequestion->setDescription($this->question_description); $this->activequestion->saveToDb(); if (is_object($this->survey)) { // duplicate the question for the survey $question_id = $this->activequestion->duplicate(TRUE); $this->survey->addQuestion($question_id); $this->questions[$this->original_question_id] = $question_id; } } $this->in_question = FALSE; $this->question_description = ""; $this->activequestion = NULL; break; case "qticomment": if (strcmp($this->getParent($a_xml_parser), "item") == 0) { if (preg_match("/Questiontype\\=(.*)/", $this->characterbuffer, $matches)) { $questiontype = $matches[1]; switch ($matches[1]) { case METRIC_QUESTION_IDENTIFIER: $questiontype = "SurveyMetricQuestion"; break; case NOMINAL_QUESTION_IDENTIFIER: $questiontype = "SurveyMultipleChoiceQuestion"; break; case ORDINAL_QUESTION_IDENTIFIER: $questiontype = "SurveySingleChoiceQuestion"; break; case TEXT_QUESTION_IDENTIFIER: $questiontype = "SurveyTextQuestion"; break; } if (strlen($questiontype)) { include_once "./Modules/SurveyQuestionPool/classes/class.{$questiontype}.php"; $this->activequestion = new $questiontype(); $this->activequestion->setObjId($this->spl_id); } else { $this->activequestion = NULL; } } else { if (preg_match("/Author\\=(.*)/", $this->characterbuffer, $matches)) { if (is_object($this->activequestion)) { $this->activequestion->setAuthor($matches[1]); } } else { if (preg_match("/ILIAS Version\\=(.*)/", $this->characterbuffer, $matches)) { } else { $this->question_description = $this->characterbuffer; } } } } if (strcmp($this->getParent($a_xml_parser), "survey") == 0) { if (preg_match("/Author\\=(.*)/", $this->characterbuffer, $matches)) { if (is_object($this->survey)) { $this->survey->setAuthor($matches[1]); } } else { if (preg_match("/ILIAS Version\\=(.*)/", $this->characterbuffer, $matches)) { } else { if (is_object($this->survey)) { $this->survey->setDescription($this->characterbuffer); } } } } break; case "fieldlabel": $this->metadata[count($this->metadata) - 1]["label"] = $this->characterbuffer; break; case "fieldentry": $this->metadata[count($this->metadata) - 1]["entry"] = $this->characterbuffer; break; case "qtimetadata": if (strcmp($this->getParent($a_xml_parser), "section") == 0) { foreach ($this->metadata as $meta) { switch ($meta["label"]) { case "SCORM": if (!$this->spl_exists) { include_once "./Services/MetaData/classes/class.ilMDSaxParser.php"; include_once "./Services/MetaData/classes/class.ilMD.php"; include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; $md_sax_parser = new ilMDSaxParser(); $md_sax_parser->setXMLContent($value["entry"]); $md_sax_parser->setMDObject($tmp = new ilMD($this->spl_id, 0, "spl")); $md_sax_parser->enableMDParsing(true); $md_sax_parser->startParsing(); $spl = new ilObjSurveyQuestionPool($this->spl_id, false); $spl->MDUpdateListener("General"); break; } } } } if (is_object($this->activequestion)) { foreach ($this->metadata as $meta) { switch ($this->activequestion->getQuestionType()) { case "SurveyMultipleQuestion": switch ($meta["label"]) { case "obligatory": $this->activequestion->setObligatory($meta["entry"]); break; case "orientation": $this->activequestion->setOrientation($meta["entry"]); break; } break; case "SurveySingleChoiceQuestion": switch ($meta["label"]) { case "obligatory": $this->activequestion->setObligatory($meta["entry"]); break; case "orientation": $this->activequestion->setOrientation($meta["entry"]); break; } break; case "SurveyMetricQuestion": switch ($meta["label"]) { case "obligatory": $this->activequestion->setObligatory($meta["entry"]); break; case "subtype": $this->activequestion->setSubtype($meta["entry"]); break; } break; case "SurveyTextQuestion": switch ($meta["label"]) { case "obligatory": $this->activequestion->setObligatory($meta["entry"]); break; case "maxchars": if (strlen($meta["entry"])) { $this->activequestion->setMaxChars($meta["entry"]); } break; } break; } } } if (is_object($this->survey)) { foreach ($this->metadata as $meta) { switch ($meta["label"]) { case "SCORM": if (strcmp($this->getParent($a_xml_parser), "survey") == 0) { include_once "./Services/MetaData/classes/class.ilMDSaxParser.php"; include_once "./Services/MetaData/classes/class.ilMD.php"; $md_sax_parser = new ilMDSaxParser(); $md_sax_parser->setXMLContent($meta["entry"]); $md_sax_parser->setMDObject($tmp = new ilMD($this->survey->getId(), 0, "svy")); $md_sax_parser->enableMDParsing(TRUE); $md_sax_parser->startParsing(); $this->survey->MDUpdateListener("General"); } break; case "author": $this->survey->setAuthor($meta["entry"]); break; case "description": $this->survey->setDescription($meta["entry"]); break; case "evaluation_access": $this->survey->setEvaluationAccess($meta["entry"]); break; case "evaluation_access": $this->survey->setEvaluationAccess($meta["entry"]); break; case "anonymize": $this->survey->setAnonymize($meta["entry"]); break; case "status": $this->survey->setStatus($meta["entry"]); break; case "startdate": if (preg_match("/P(\\d+)Y(\\d+)M(\\d+)DT0H0M0S/", $meta["entry"], $matches)) { $this->survey->setStartDate(sprintf("%04d-%02d-%02d", $matches[1], $matches[2], $matches[3])); $this->survey->setStartDateEnabled(1); } break; case "enddate": if (preg_match("/P(\\d+)Y(\\d+)M(\\d+)DT0H0M0S/", $meta["entry"], $matches)) { $this->survey->setEndDate(sprintf("%04d-%02d-%02d", $matches[1], $matches[2], $matches[3])); $this->survey->setEndDateEnabled(1); } break; case "display_question_titles": if ($meta["entry"]) { $this->survey->showQuestionTitles(); } break; } if (preg_match("/questionblock_(\\d+)/", $meta["label"], $matches)) { // handle questionblocks $qb = $meta["entry"]; preg_match("/<title>(.*?)<\\/title>/", $qb, $matches); $qb_title = $matches[1]; preg_match("/<questions>(.*?)<\\/questions>/", $qb, $matches); $qb_questions = $matches[1]; $qb_questions_array = explode(",", $qb_questions); array_push($this->questionblocks, array("title" => $qb_title, "questions" => $qb_questions_array)); } if (preg_match("/constraint_(\\d+)/", $meta["label"], $matches)) { $constraint = $meta["entry"]; $constraint_array = explode(",", $constraint); if (count($constraint_array) == 3) { array_push($this->constraints, array("sourceref" => $matches[1], "destref" => $constraint_array[0], "relation" => $constraint_array[1], "value" => $constraint_array[2])); } } if (preg_match("/heading_(\\d+)/", $meta["label"], $matches)) { $heading = $meta["entry"]; $this->textblocks[$matches[1]] = $heading; } } } break; case "mattext": $this->material[count($this->material) - 1]["text"] = $this->characterbuffer; break; case "matimage": $this->material[count($this->material) - 1]["image"] = $this->characterbuffer; break; case "material": if ($this->in_survey) { if (strcmp($this->getParent($a_xml_parser), "objectives") == 0) { if (strcmp($this->material[0]["label"], "introduction") == 0) { if (is_object($this->survey)) { $this->survey->setIntroduction($this->material[0]["text"]); } } if (strcmp($this->material[0]["label"], "outro") == 0) { if (is_object($this->survey)) { $this->survey->setOutro($this->material[0]["text"]); } } $this->material = array(); } } else { switch ($this->getParent($a_xml_parser)) { case "response_num": case "response_lid": case "response_str": if (is_object($this->activequestion)) { $this->activequestion->setMaterial($this->material[0]["text"], TRUE, $this->material[0]["label"]); } break; case "flow": if (is_object($this->activequestion)) { $this->activequestion->setQuestiontext($this->material[0]["text"]); } break; } if (is_object($this->activequestion)) { if ($this->in_response) { switch ($this->activequestion->getQuestiontype()) { case "SurveyMultipleChoiceQuestion": case "SurveySingleChoiceQuestion": $this->activequestion->categories->addCategory($this->material[0]["text"]); break; } } } } break; case "response_label": $this->in_response = FALSE; break; } $this->depth[$a_xml_parser]--; }
/** * Creates the questions form for the survey object */ public function questionsObject() { global $rbacsystem, $ilToolbar, $ilUser; $this->handleWriteAccess(); $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId()); include_once "./Services/Utilities/classes/class.ilUtil.php"; if (!$rbacsystem->checkAccess("read", $this->ref_id) && !$rbacsystem->checkAccess("write", $this->ref_id)) { // allow only read and write access ilUtil::sendInfo($this->lng->txt("cannot_edit_survey"), true); $path = $this->tree->getPathFull($this->object->getRefID()); ilUtil::redirect($this->getReturnLocation("cancel", "./ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id=" . $path[count($path) - 2]["child"])); return; } if ($_GET["new_id"] > 0) { // add a question to the survey previous created in a questionpool $existing = $this->object->getExistingQuestions(); if (!in_array($_GET["new_id"], $existing)) { $inserted = $this->object->insertQuestion($_GET["new_id"]); if (!$inserted) { ilUtil::sendFailure($this->lng->txt("survey_error_insert_incomplete_question")); } } } if ($_GET["eqid"] and $_GET["eqpl"]) { ilUtil::redirect("ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForSurvey&calling_survey=" . $_GET["ref_id"] . "&q_id=" . $_GET["eqid"]); } $_SESSION["calling_survey"] = $this->object->getRefId(); unset($_SESSION["survey_id"]); if ($_GET["editheading"]) { $this->addHeadingObject(false, $_GET["editheading"]); return; } /* if ($_GET["up"] > 0) { $this->object->moveUpQuestion($_GET["up"]); ilUtil::sendSuccess($this->lng->txt('msg_obj_modified')); } if ($_GET["down"] > 0) { $this->object->moveDownQuestion($_GET["down"]); ilUtil::sendSuccess($this->lng->txt('msg_obj_modified')); } if ($_GET["qbup"] > 0) { $this->object->moveUpQuestionblock($_GET["qbup"]); ilUtil::sendSuccess($this->lng->txt('msg_obj_modified')); } if ($_GET["qbdown"] > 0) { $this->object->moveDownQuestionblock($_GET["qbdown"]); ilUtil::sendSuccess($this->lng->txt('msg_obj_modified')); } */ if ($_GET["removeheading"]) { $this->confirmRemoveHeadingForm(); return; } if ($_GET["editblock"]) { $this->defineQuestionblock($_GET["editblock"]); return; } if ($_GET["add"]) { // called after a new question was created from a questionpool $selected_array = array(); array_push($selected_array, $_GET["add"]); ilUtil::sendQuestion($this->lng->txt("ask_insert_questions")); $this->insertQuestionsForm($selected_array); return; } $this->questionsSubtabs("questions"); $read_only = !$rbacsystem->checkAccess("write", $this->ref_id) || $hasDatasets; // toolbar if (!$read_only) { $qtypes = array(); include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php"; foreach (ilObjSurveyQuestionPool::_getQuestiontypes() as $translation => $data) { $qtypes[$data["type_tag"]] = $translation; } $ilToolbar->setFormAction($this->ctrl->getFormAction($this)); include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $types = new ilSelectInputGUI($this->lng->txt("create_new"), "sel_question_types"); $types->setOptions($qtypes); $ilToolbar->addInputItem($types, ""); $ilToolbar->addFormButton($this->lng->txt("svy_create_question"), "createQuestion"); if ($this->object->isPoolActive()) { $ilToolbar->addSeparator(); $cmd = $ilUser->getPref('svy_insert_type') == 1 || strlen($ilUser->getPref('svy_insert_type')) == 0 ? 'browseForQuestions' : 'browseForQuestionblocks'; $ilToolbar->addButton($this->lng->txt("browse_for_questions"), $this->ctrl->getLinkTarget($this, $cmd)); } $ilToolbar->addSeparator(); $ilToolbar->addButton($this->lng->txt("add_heading"), $this->ctrl->getLinkTarget($this, "addHeading")); } if ($hasDatasets) { // ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning")); $link = $this->ctrl->getLinkTarget($this, "maintenance"); $link = "<a href=\"" . $link . "\">" . $this->lng->txt("survey_has_datasets_warning_page_view_link") . "</a>"; ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning_page_view") . " " . $link); } // table gui include_once "Modules/Survey/classes/class.ilSurveyQuestionTableGUI.php"; $table = new ilSurveyQuestionTableGUI($this, "questions", $this->object, $read_only); $this->tpl->setContent($table->getHTML()); }