protected function initItems(ilObjSurvey $a_survey) { global $lng; $this->structure = array(); $tbl_data = array(); $survey_questions = $a_survey->getSurveyQuestions(); $last_questionblock_id = 0; $counter = 1; foreach ($survey_questions as $data) { $title = $data["title"]; $show = true; if ($data["questionblock_id"] > 0) { $title = $data["questionblock_title"]; $type = $lng->txt("questionblock"); if ($data["questionblock_id"] != $last_questionblock_id) { $last_questionblock_id = $data["questionblock_id"]; $this->structure[$counter] = array(); array_push($this->structure[$counter], $data["question_id"]); } else { array_push($this->structure[$counter - 1], $data["question_id"]); $show = false; } } else { $this->structure[$counter] = array($data["question_id"]); $type = $lng->txt("question"); } if ($show) { $id = $content = $parsed = $conjunction = null; if ($counter == 1) { $content = $lng->txt("constraints_first_question_description"); } else { $constraints = $a_survey->getConstraints($data["question_id"]); if (count($constraints)) { $parsed = array(); foreach ($constraints as $constraint) { $parsed[] = array("id" => $constraint["id"], "title" => $survey_questions[$constraint["question"]]["title"] . " " . $constraint["short"] . " " . $constraint["valueoutput"]); } if (count($constraints) > 1) { $conjunction = $constraints[0]['conjunction'] ? $lng->txt('conjunction_or_title') : $lng->txt('conjunction_and_title'); } } } if ($counter != 1) { $id = $counter; } $icontype = "question.png"; if ($data["questionblock_id"] > 0) { $icontype = "questionblock.png"; } $tbl_data[] = array("counter" => $counter, "id" => $id, "title" => $title, "type" => $type, "icon" => ilUtil::getImagePath($icontype, "Modules/Survey"), "content" => $content, "constraints" => $parsed, "conjunction" => $conjunction); $counter++; } } $this->setData($tbl_data); }
/** * 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); $svy_ref_id = current($refs); include_once './Modules/Survey/classes/class.ilObjSurvey.php'; $svy = new ilObjSurvey($a_id, false); $svy->loadFromDb(); include_once "./Modules/Survey/classes/class.ilSurveyExport.php"; $svy_exp = new ilSurveyExport($svy, 'xml'); $zip = $svy_exp->buildExportFile(); // Unzip, since survey deletes this dir ilUtil::unzip($zip); $GLOBALS['ilLog']->write(__METHOD__ . ': Created zip file ' . $zip); }
public function run() { global $tree; include_once "Modules/Survey/classes/class.ilObjSurvey.php"; $status = ilCronJobResult::STATUS_NO_ACTION; $message = array(); $root = $tree->getNodeData(ROOT_FOLDER_ID); foreach ($tree->getSubTree($root, false, "svy") as $svy_ref_id) { $svy = new ilObjSurvey($svy_ref_id); if ($svy->checkReminder()) { $message[] = $svy_ref_id; $status = ilCronJobResult::STATUS_OK; } } $result = new ilCronJobResult(); $result->setStatus($status); if (sizeof($message)) { $result->setMessage("Ref-Ids: " . implode(", ", $message)); $result->setCode("#" . sizeof($message)); } return $result; }
/** * ilSurveyExecutionGUI constructor * * The constructor takes possible arguments an creates an instance of the ilSurveyExecutionGUI object. * * @param object $a_object Associated ilObjSurvey class * @access public */ function ilSurveyExecutionGUI($a_object) { global $lng, $tpl, $ilCtrl, $ilias, $tree; $this->lng =& $lng; $this->tpl =& $tpl; $this->ctrl =& $ilCtrl; $this->ilias =& $ilias; $this->object =& $a_object; $this->tree =& $tree; $this->external_rater_360 = false; if ($this->object->get360Mode() && $_SESSION["anonymous_id"][$this->object->getId()] && ilObjSurvey::validateExternalRaterCode($this->object->getRefId(), $_SESSION["anonymous_id"][$this->object->getId()])) { $this->external_rater_360 = true; } // stay in preview mode $this->preview = (bool) $_REQUEST["prvw"]; $this->ctrl->saveParameter($this, "prvw"); $this->ctrl->saveParameter($this, "pgov"); }
/** * Import data from DB */ protected function importData() { global $ilAccess, $lng; include_once "Modules/Survey/classes/class.ilObjSurvey.php"; $table_data = array(); foreach ($this->question->getCopyIds(true) as $survey_obj_id => $questions) { $survey_id = new ilObjSurvey($survey_obj_id, false); $survey_id->loadFromDB(); $survey_id = $survey_id->getSurveyId(); $ref_ids = ilObject::_getAllReferences($survey_obj_id); $message = ""; // check permissions for "parent" survey $can_write = false; if (!ilObjSurvey::_hasDatasets($survey_id)) { foreach ($ref_ids as $ref_id) { if ($ilAccess->checkAccess("edit", "", $ref_id)) { $can_write = true; break; } } if (!$can_write) { $message = $lng->txt("survey_sync_insufficient_permissions"); } } else { $message = $lng->txt("survey_has_datasets_warning"); } $survey_title = ilObject::_lookupTitle($survey_obj_id); $survey_path = $this->buildPath($ref_ids); foreach ($questions as $question_id) { $title = SurveyQuestion::_getTitle($question_id); if (!$can_write) { $question_id = null; } $table_data[] = array("id" => $question_id, "title" => $title, "path" => $survey_path, "message" => $message); } } $this->setData($table_data); }
/** * Clone object * * @access public * @param int ref_id of target container * @param int copy id * @return object new svy object */ public function cloneObject($a_target_id, $a_copy_id = 0) { global $ilDB; $this->loadFromDb(); // Copy settings $newObj = parent::cloneObject($a_target_id, $a_copy_id); $this->cloneMetaData($newObj); $newObj->updateMetaData(); $newObj->setAuthor($this->getAuthor()); $newObj->setIntroduction($this->getIntroduction()); $newObj->setOutro($this->getOutro()); $newObj->setStatus($this->getStatus()); $newObj->setEvaluationAccess($this->getEvaluationAccess()); $newObj->setStartDate($this->getStartDate()); $newObj->setEndDate($this->getEndDate()); $newObj->setInvitation($this->getInvitation()); $newObj->setInvitationMode($this->getInvitationMode()); $newObj->setAnonymize($this->getAnonymize()); $newObj->setShowQuestionTitles($this->getShowQuestionTitles()); $newObj->setTemplate($this->getTemplate()); // :;TODO: 360° ?! // reminder/notification $newObj->setReminderStatus($this->getReminderStatus()); $newObj->setReminderStart($this->getReminderStart()); $newObj->setReminderEnd($this->getReminderEnd()); $newObj->setReminderFrequency($this->getReminderFrequency()); $newObj->setReminderTarget($this->getReminderTarget()); // reminder_last_sent must not be copied! $newObj->setTutorNotificationStatus($this->getTutorNotificationStatus()); $newObj->setTutorNotificationRecipients($this->getTutorNotificationRecipients()); $newObj->setTutorNotificationTarget($this->getTutorNotificationTarget()); $question_pointer = array(); // clone the questions $mapping = array(); include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; foreach ($this->questions as $key => $question_id) { $question = ilObjSurvey::_instanciateQuestion($question_id); if ($question) { $question->id = -1; $original_id = SurveyQuestion::_getOriginalId($question_id); $question->saveToDb($original_id); $newObj->questions[$key] = $question->getId(); $question_pointer[$question_id] = $question->getId(); $mapping[$question_id] = $question->getId(); } } $newObj->saveToDb(); $newObj->cloneTextblocks($mapping); // clone the questionblocks $questionblocks = array(); $questionblock_questions = array(); $result = $ilDB->queryF("SELECT * FROM svy_qblk_qst WHERE survey_fi = %s", array('integer'), array($this->getSurveyId())); if ($result->numRows() > 0) { while ($row = $ilDB->fetchAssoc($result)) { array_push($questionblock_questions, $row); $questionblocks[$row["questionblock_fi"]] = $row["questionblock_fi"]; } } // create new questionblocks foreach ($questionblocks as $key => $value) { $questionblock = ilObjSurvey::_getQuestionblock($key); $questionblock_id = ilObjSurvey::_addQuestionblock($questionblock["title"], $questionblock["owner_fi"]); $questionblocks[$key] = $questionblock_id; } // create new questionblock questions foreach ($questionblock_questions as $key => $value) { if ($questionblocks[$value["questionblock_fi"]] && $question_pointer[$value["question_fi"]]) { $next_id = $ilDB->nextId('svy_qblk_qst'); $affectedRows = $ilDB->manipulateF("INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) " . "VALUES (%s, %s, %s, %s)", array('integer', 'integer', 'integer', 'integer'), array($next_id, $newObj->getSurveyId(), $questionblocks[$value["questionblock_fi"]], $question_pointer[$value["question_fi"]])); } } // clone the constraints $constraints = ilObjSurvey::_getConstraints($this->getSurveyId()); $newConstraints = array(); foreach ($constraints as $key => $constraint) { if ($question_pointer[$constraint["for_question"]] && $question_pointer[$constraint["question"]]) { if (!array_key_exists($constraint['id'], $newConstraints)) { $constraint_id = $newObj->addConstraint($question_pointer[$constraint["question"]], $constraint["relation_id"], $constraint["value"], $constraint['conjunction']); $newConstraints[$constraint['id']] = $constraint_id; } $newObj->addConstraintToQuestion($question_pointer[$constraint["for_question"]], $newConstraints[$constraint['id']]); } } // clone the obligatory states $result = $ilDB->queryF("SELECT * FROM svy_qst_oblig WHERE survey_fi = %s", array('integer'), array($this->getSurveyId())); if ($result->numRows() > 0) { while ($row = $ilDB->fetchAssoc($result)) { if ($question_pointer[$row["question_fi"]]) { $next_id = $ilDB->nextId('svy_qst_oblig'); $affectedRows = $ilDB->manipulateF("INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " . "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)", array('integer', 'integer', 'integer', 'text', 'integer'), array($next_id, $newObj->getSurveyId(), $question_pointer[$row["question_fi"]], $row["obligatory"], time())); } } } return $newObj; }
/** * Creates the detailed output of the cumulated results for the question * * @param integer $survey_id The database ID of the survey * @param integer $counter The counter of the question position in the survey * @return string HTML text with the cumulated results * @access private */ function getCumulatedResultsDetails($survey_id, $counter) { if (count($this->cumulated) == 0) { include_once "./Modules/Survey/classes/class.ilObjSurvey.php"; $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id); $this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users); } $output = ""; include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE, "Modules/Survey"); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("question")); $questiontext = $this->object->getQuestiontext(); $template->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE)); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("question_type")); $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType())); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("users_answered")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_ANSWERED"]); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_SKIPPED"]); $template->parseCurrentBlock(); /* $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("mode")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE"]); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("mode_nr_of_selections")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE_NR_OF_SELECTIONS"]); $template->parseCurrentBlock(); */ $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("categories")); $categories = ""; if (is_array($this->cumulated["variables"])) { foreach ($this->cumulated["variables"] as $key => $value) { $categories .= "<li>" . $value["title"] . ": n=" . $value["selected"] . " (" . sprintf("%.2f", 100 * $value["percentage"]) . "%)</li>"; } } $categories = "<ol>{$categories}</ol>"; $template->setVariable("TEXT_OPTION_VALUE", $categories); $template->parseCurrentBlock(); // add text answers to detailed results if (is_array($this->cumulated["textanswers"])) { $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("freetext_answers")); $html = ""; foreach ($this->cumulated["textanswers"] as $key => $answers) { $html .= $this->cumulated["variables"][$key]["title"] . "\n"; $html .= "<ul>\n"; foreach ($answers as $answer) { $html .= "<li>" . preg_replace("/\n/", "<br>\n", $answer) . "</li>\n"; } $html .= "</ul>\n"; } $template->setVariable("TEXT_OPTION_VALUE", $html); $template->parseCurrentBlock(); } // chart $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("chart")); $template->setVariable("TEXT_OPTION_VALUE", $this->renderChart("svy_ch_" . $this->object->getId(), $this->cumulated["variables"])); $template->parseCurrentBlock(); $template->setVariable("QUESTION_TITLE", "{$counter}. " . $this->object->getTitle()); return $template->get(); }
public function executeCopyQuestionsToPoolObject() { $question_ids = explode(";", $_POST["question_ids"]); $pool_id = ilObject::_lookupObjId($_POST["sel_spl"]); foreach ($question_ids as $qid) { // create copy (== pool "original") $new_question = ilObjSurvey::_instanciateQuestion($qid); $new_question->setId(); $new_question->setObjId($pool_id); $new_question->saveToDb(); // link "source" (survey) to copy (pool) SurveyQuestion::_changeOriginalId($qid, $new_question->getId(), $pool_id); } ilUtil::sendSuccess($this->lng->txt("survey_copy_to_questionpool_success"), true); $this->ctrl->redirect($this, "questions"); }
/** * Clone object * * @access public * @param int ref_id of target container * @param int copy id * @return object new svy object */ public function cloneObject($a_target_id, $a_copy_id = 0) { global $ilDB; $this->loadFromDb(); // Copy settings $newObj = parent::cloneObject($a_target_id, $a_copy_id); $this->cloneMetaData($newObj); $newObj->updateMetaData(); $newObj->setAuthor($this->getAuthor()); $newObj->setIntroduction($this->getIntroduction()); $newObj->setOutro($this->getOutro()); $newObj->setEvaluationAccess($this->getEvaluationAccess()); $newObj->setStartDate($this->getStartDate()); $newObj->setEndDate($this->getEndDate()); $newObj->setInvitation($this->getInvitation()); $newObj->setInvitationMode($this->getInvitationMode()); $newObj->setAnonymize($this->getAnonymize()); $newObj->setShowQuestionTitles($this->getShowQuestionTitles()); $newObj->setTemplate($this->getTemplate()); $newObj->setPoolUsage($this->getPoolUsage()); $newObj->setViewOwnResults($this->hasViewOwnResults()); $newObj->setMailOwnResults($this->hasMailOwnResults()); // #12661 if ($this->get360Mode()) { $newObj->set360Mode(true); $newObj->set360SelfEvaluation($this->get360SelfEvaluation()); $newObj->set360SelfAppraisee($this->get360SelfAppraisee()); $newObj->set360SelfRaters($this->get360SelfRaters()); $newObj->set360Results($this->get360Results()); $newObj->set360SkillService($this->get360SkillService()); } // reminder/notification $newObj->setReminderStatus($this->getReminderStatus()); $newObj->setReminderStart($this->getReminderStart()); $newObj->setReminderEnd($this->getReminderEnd()); $newObj->setReminderFrequency($this->getReminderFrequency()); $newObj->setReminderTarget($this->getReminderTarget()); // reminder_last_sent must not be copied! $newObj->setTutorNotificationStatus($this->getTutorNotificationStatus()); $newObj->setTutorNotificationRecipients($this->getTutorNotificationRecipients()); $newObj->setTutorNotificationTarget($this->getTutorNotificationTarget()); $question_pointer = array(); // clone the questions $mapping = array(); include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; foreach ($this->questions as $key => $question_id) { $question = ilObjSurvey::_instanciateQuestion($question_id); if ($question) { $question->id = -1; $original_id = SurveyQuestion::_getOriginalId($question_id, false); $question->saveToDb($original_id); $newObj->questions[$key] = $question->getId(); $question_pointer[$question_id] = $question->getId(); $mapping[$question_id] = $question->getId(); } } //copy online status if object is not the root copy object $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id); if (!$cp_options->isRootNode($this->getRefId())) { $newObj->setStatus($this->isOnline() ? self::STATUS_ONLINE : self::STATUS_OFFLINE); } $newObj->saveToDb(); $newObj->cloneTextblocks($mapping); // #14929 if ($this->get360Mode() && $this->get360SkillService()) { include_once "./Modules/Survey/classes/class.ilSurveySkill.php"; $src_skills = new ilSurveySkill($this); $tgt_skills = new ilSurveySkill($newObj); foreach ($mapping as $src_qst_id => $tgt_qst_id) { $qst_skill = $src_skills->getSkillForQuestion($src_qst_id); if ($qst_skill) { $tgt_skills->addQuestionSkillAssignment($tgt_qst_id, $qst_skill["base_skill_id"], $qst_skill["tref_id"]); } } } // clone the questionblocks $questionblocks = array(); $questionblock_questions = array(); $result = $ilDB->queryF("SELECT * FROM svy_qblk_qst WHERE survey_fi = %s", array('integer'), array($this->getSurveyId())); if ($result->numRows() > 0) { while ($row = $ilDB->fetchAssoc($result)) { array_push($questionblock_questions, $row); $questionblocks[$row["questionblock_fi"]] = $row["questionblock_fi"]; } } // create new questionblocks foreach ($questionblocks as $key => $value) { $questionblock = ilObjSurvey::_getQuestionblock($key); $questionblock_id = ilObjSurvey::_addQuestionblock($questionblock["title"], $questionblock["owner_fi"], $questionblock["show_questiontext"], $questionblock["show_blocktitle"]); $questionblocks[$key] = $questionblock_id; } // create new questionblock questions foreach ($questionblock_questions as $key => $value) { if ($questionblocks[$value["questionblock_fi"]] && $question_pointer[$value["question_fi"]]) { $next_id = $ilDB->nextId('svy_qblk_qst'); $affectedRows = $ilDB->manipulateF("INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) " . "VALUES (%s, %s, %s, %s)", array('integer', 'integer', 'integer', 'integer'), array($next_id, $newObj->getSurveyId(), $questionblocks[$value["questionblock_fi"]], $question_pointer[$value["question_fi"]])); } } // clone the constraints $constraints = ilObjSurvey::_getConstraints($this->getSurveyId()); $newConstraints = array(); foreach ($constraints as $key => $constraint) { if ($question_pointer[$constraint["for_question"]] && $question_pointer[$constraint["question"]]) { if (!array_key_exists($constraint['id'], $newConstraints)) { $constraint_id = $newObj->addConstraint($question_pointer[$constraint["question"]], $constraint["relation_id"], $constraint["value"], $constraint['conjunction']); $newConstraints[$constraint['id']] = $constraint_id; } $newObj->addConstraintToQuestion($question_pointer[$constraint["for_question"]], $newConstraints[$constraint['id']]); } } // clone the obligatory states $result = $ilDB->queryF("SELECT * FROM svy_qst_oblig WHERE survey_fi = %s", array('integer'), array($this->getSurveyId())); if ($result->numRows() > 0) { while ($row = $ilDB->fetchAssoc($result)) { if ($question_pointer[$row["question_fi"]]) { $next_id = $ilDB->nextId('svy_qst_oblig'); $affectedRows = $ilDB->manipulateF("INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " . "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)", array('integer', 'integer', 'integer', 'text', 'integer'), array($next_id, $newObj->getSurveyId(), $question_pointer[$row["question_fi"]], $row["obligatory"], time())); } } } return $newObj; }
/** * Print the survey evaluation for a selected user * * Print the survey evaluation for a selected user * * @access private */ function evaluationuser() { global $ilAccess, $ilToolbar; if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) { ilUtil::sendFailure($this->lng->txt("no_permission"), TRUE); $this->ctrl->redirectByClass("ilObjSurveyGUI", "infoScreen"); } include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "evaluationuser")); if ($this->object->get360Mode()) { $appr_id = $this->getAppraiseeId(); $this->addApprSelectionToToolbar(); } $tabledata = null; if (!$this->object->get360Mode() || $appr_id) { $format = new ilSelectInputGUI("", "export_format"); $format->setOptions(array(self::TYPE_XLS => $this->lng->txt('exp_type_excel'), self::TYPE_SPSS => $this->lng->txt('exp_type_csv'))); $ilToolbar->addInputItem($format); $label = new ilSelectInputGUI("", "export_label"); $label->setOptions(array('label_only' => $this->lng->txt('export_label_only'), 'title_only' => $this->lng->txt('export_title_only'), 'title_label' => $this->lng->txt('export_title_label'))); $ilToolbar->addInputItem($label); include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php"; $button = ilSubmitButton::getInstance(); $button->setCaption("export"); $button->setCommand('exportevaluationuser'); $button->setOmitPreventDoubleSubmission(true); $ilToolbar->addButtonInstance($button); $ilToolbar->addSeparator(); include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php"; $button = ilLinkButton::getInstance(); $button->setCaption("print"); $button->setOnClick("window.print(); return false;"); $button->setOmitPreventDoubleSubmission(true); $ilToolbar->addButtonInstance($button); $finished_ids = null; if ($appr_id) { $finished_ids = $this->object->getFinishedIdsForAppraiseeId($appr_id); if (!sizeof($finished_ids)) { $finished_ids = array(-1); } } $userResults =& $this->object->getUserSpecificResults($finished_ids); $questions =& $this->object->getSurveyQuestions(true); $participants =& $this->object->getSurveyParticipants($finished_ids); $tabledata = array(); $counter = -1; foreach ($participants as $data) { $questioncounter = 1; $question = ""; $results = ""; $first = true; foreach ($questions as $question_id => $question_data) { $found = $userResults[$question_id][$data["active_id"]]; $text = ""; if (is_array($found)) { $text = implode("<br />", $found); } else { $text = $found; } if (strlen($text) == 0) { $text = ilObjSurvey::getSurveySkippedValue(); } $wt = $this->object->getWorkingtimeForParticipant($data['active_id']); if ($first) { if ($data["finished"]) { $finished = $data["finished_tstamp"]; } else { $finished = false; } $tabledata[++$counter] = array('username' => $data["sortname"], 'question' => $questioncounter++ . ". " . $question_data["title"], 'results' => $text, 'workingtime' => $wt, 'finished' => $finished); $first = false; } else { $tabledata[$counter]["subitems"][] = array('username' => " ", 'question' => $questioncounter++ . ". " . $question_data["title"], 'results' => $text, 'workingtime' => null, 'finished' => null); } } } } $this->tpl->addCss("./Modules/Survey/templates/default/survey_print.css", "print"); $this->tpl->setCurrentBlock("generic_css"); $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./Modules/Survey/templates/default/evaluation_print.css"); $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print"); $this->tpl->parseCurrentBlock(); include_once "./Modules/Survey/classes/tables/class.ilSurveyResultsUserTableGUI.php"; $table_gui = new ilSurveyResultsUserTableGUI($this, 'evaluationuser', $this->object->hasAnonymizedResults()); $table_gui->setData($tabledata); $this->tpl->setContent($table_gui->getHTML()); }
/** * Creates the detailed output of the cumulated results for the question * * @param integer $survey_id The database ID of the survey * @param integer $counter The counter of the question position in the survey * @return string HTML text with the cumulated results * @access private */ function getCumulatedResultsDetails($survey_id, $counter, $finished_ids) { if (count($this->cumulated) == 0) { if (!$finished_ids) { include_once "./Modules/Survey/classes/class.ilObjSurvey.php"; $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id); } else { $nr_of_users = sizeof($finished_ids); } $this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids); } $output = ""; include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE, "Modules/Survey"); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("question")); $questiontext = $this->object->getQuestiontext(); $template->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE)); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("question_type")); $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType())); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("users_answered")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_ANSWERED"]); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_SKIPPED"]); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("subtype")); switch ($this->object->getSubType()) { case SurveyMetricQuestion::SUBTYPE_NON_RATIO: $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("non_ratio")); break; case SurveyMetricQuestion::SUBTYPE_RATIO_NON_ABSOLUTE: $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("ratio_non_absolute")); break; case SurveyMetricQuestion::SUBTYPE_RATIO_ABSOLUTE: $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("ratio_absolute")); break; } $template->parseCurrentBlock(); /* $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("mode")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE"]); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("mode_nr_of_selections")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE_NR_OF_SELECTIONS"]); $template->parseCurrentBlock(); */ $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("median")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MEDIAN"]); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("arithmetic_mean")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["ARITHMETIC_MEAN"]); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("values")); $values = ""; if (is_array($this->cumulated["values"])) { foreach ($this->cumulated["values"] as $key => $value) { $values .= "<li>" . $value["value"] . ": n=" . $value["selected"] . " (" . sprintf("%.2f", 100 * $value["percentage"]) . "%)</li>"; } } $values = "<ol>{$values}</ol>"; $template->setVariable("TEXT_OPTION_VALUE", $values); $template->parseCurrentBlock(); // chart $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("chart")); $template->setVariable("TEXT_OPTION_VALUE", $this->renderChart("svy_ch_" . $this->object->getId(), $this->cumulated["values"])); $template->parseCurrentBlock(); $template->setVariable("QUESTION_TITLE", "{$counter}. " . $this->object->getTitle()); return $template->get(); }
/** * Creates the detailed output of the cumulated results for the question * * @param integer $survey_id The database ID of the survey * @param integer $counter The counter of the question position in the survey * @return string HTML text with the cumulated results * @access private */ function getCumulatedResultsDetails($survey_id, $counter, $finished_ids) { if (count($this->cumulated) == 0) { if (!$finished_ids) { include_once "./Modules/Survey/classes/class.ilObjSurvey.php"; $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id); } else { $nr_of_users = sizeof($finished_ids); } $this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids); } $output = ""; include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE, "Modules/Survey"); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("question")); $questiontext = $this->object->getQuestiontext(); $template->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE)); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("question_type")); $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType())); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("users_answered")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_ANSWERED"]); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped")); $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_SKIPPED"]); $template->parseCurrentBlock(); $template->setCurrentBlock("detail_row"); $template->setVariable("TEXT_OPTION", $this->lng->txt("given_answers")); $textvalues = ""; if (is_array($this->cumulated["textvalues"])) { foreach ($this->cumulated["textvalues"] as $textvalue) { $textvalues .= "<li>" . preg_replace("/\n/", "<br>", $textvalue) . "</li>"; } } $textvalues = "<ul>{$textvalues}</ul>"; $template->setVariable("TEXT_OPTION_VALUE", $textvalues); $template->parseCurrentBlock(); $template->setVariable("QUESTION_TITLE", "{$counter}. " . $this->object->getTitle()); return $template->get(); }
/** * Paste from clipboard * * @param int $a_id target position */ protected function paste($a_id) { $data = $_SESSION["survey_page_view"][$this->ref_id]["clipboard"]; $pages = $this->object->getSurveyPages(); $source = $pages[$data["source"] - 1]; $target = $pages[$this->current_page - 1]; // #12558 - use order of source page $nodes = array(); foreach ($source as $src_qst) { if (in_array($src_qst["question_id"], $data["nodes"])) { $nodes[] = $src_qst["question_id"]; } } // append to last position? $pos = 0; if ($_REQUEST["il_hform_node"] == "page_end") { $a_id = $target; $a_id = array_pop($a_id); $a_id = $a_id["question_id"]; $pos = 1; } // cut if ($data["mode"] == "cut") { // special case: paste cut on same page (no block handling needed) if ($data["source"] == $this->current_page) { // re-order nodes in page if (sizeof($nodes) <= sizeof($source)) { $this->object->moveQuestions($nodes, $a_id, $pos); } $this->clearClipboard(); return; } else { // only if source has block $source_block_id = false; if (sizeof($source) > 1) { $source_block_id = $source; $source_block_id = array_shift($source_block_id); $source_block_id = $source_block_id["questionblock_id"]; // remove from block if (sizeof($source) > sizeof($nodes)) { foreach ($nodes as $qid) { $this->object->removeQuestionFromBlock($qid, $source_block_id); } } else { $this->object->unfoldQuestionblocks(array($source_block_id)); } } // page will be "deleted" by operation if (sizeof($source) == sizeof($nodes) && $data["source"] < $this->current_page) { $this->current_page--; } } } else { if ($data["mode"] == "copy") { $titles = array(); foreach ($this->object->getSurveyPages() as $page) { foreach ($page as $question) { $titles[] = $question["title"]; } } // copy questions $question_pointer = array(); foreach ($nodes as $qid) { // create new questions $question = ilObjSurvey::_instanciateQuestion($qid); // handle exisiting copies $title = $question->getTitle(); $max = 0; foreach ($titles as $existing_title) { if (preg_match("/" . preg_quote($title) . " \\(([0-9]+)\\)\$/", $existing_title, $match)) { $max = max($match[1], $max); } } if ($max) { $title .= " (" . ($max + 1) . ")"; } else { $title .= " (2)"; } $titles[] = $title; $question->setTitle($title); $question->id = -1; $question->saveToDb(); $question_pointer[$qid] = $question->getId(); $this->appendNewQuestionToSurvey($question->getId(), false); } // copy textblocks $this->object->cloneTextblocks($question_pointer); $this->object->loadQuestionsFromDb(); $nodes = array_values($question_pointer); } } // paste // create new block if (sizeof($target) == 1) { $nodes = array_merge(array($a_id), $nodes); // moveQuestions() is called within $this->object->createQuestionblock($this->getAutoBlockTitle(), true, false, $nodes); } else { $target_block_id = $target; $target_block_id = array_shift($target_block_id); $target_block_id = $target_block_id["questionblock_id"]; foreach ($nodes as $qid) { $this->object->addQuestionToBlock($qid, $target_block_id); } // move to new position $this->object->moveQuestions($nodes, $a_id, $pos); } $this->clearClipboard(); }
protected function &calculateCumulatedResults($survey_id, $finished_ids) { if (count($this->cumulated) == 0) { if (!$finished_ids) { include_once "./Modules/Survey/classes/class.ilObjSurvey.php"; $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id); } else { $nr_of_users = sizeof($finished_ids); } if ($nr_of_users) { $this->cumulated =& $this->getCumulatedResults($survey_id, $nr_of_users, $finished_ids); } } return $this->cumulated; }
/** * form for new survey object import */ 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/Survey/classes/class.ilObjSurvey.php"; $newObj = new ilObjSurvey(); $newObj->setType($new_type); $newObj->setTitle("dummy"); $newObj->setDescription("dummy"); $newObj->create(true); $this->putObjectInTree($newObj); // copy uploaded file to import directory $error = $newObj->importObject($_FILES["importfile"], $form->getInput("spl")); if (strlen($error)) { $newObj->delete(); $this->ilias->raiseError($error, $this->ilias->error_obj->MESSAGE); return; } ilUtil::sendSuccess($this->lng->txt("object_imported"), true); ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() . "&baseClass=ilObjSurveyGUI"); // using template? include_once "Services/Administration/classes/class.ilSettingsTemplate.php"; $templates = ilSettingsTemplate::getAllSettingsTemplates("svy"); if ($templates) { global $tpl; $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery.js"); // $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery-ui-min.js"); $this->tpl->setCurrentBlock("template_option"); $this->tpl->setVariable("VAL_TEMPLATE_OPTION", ""); $this->tpl->setVariable("TXT_TEMPLATE_OPTION", $this->lng->txt("none")); $this->tpl->parseCurrentBlock(); foreach ($templates as $item) { $this->tpl->setCurrentBlock("template_option"); $this->tpl->setVariable("VAL_TEMPLATE_OPTION", $item["id"]); $this->tpl->setVariable("TXT_TEMPLATE_OPTION", $item["title"]); $this->tpl->parseCurrentBlock(); $desc = str_replace("\n", "", nl2br($item["description"])); $desc = str_replace("\r", "", $desc); $this->tpl->setCurrentBlock("js_data"); $this->tpl->setVariable("JS_DATA_ID", $item["id"]); $this->tpl->setVariable("JS_DATA_TEXT", $desc); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("templates"); $this->tpl->setVariable("TXT_TEMPLATE", $this->lng->txt("svy_settings_template")); $this->tpl->parseCurrentBlock(); } } // display form to correct errors $form->setValuesByPost(); $tpl->setContent($form->getHtml()); }
/** * check whether goto script will succeed */ function _checkGoto($a_target) { global $ilAccess; $t_arr = explode("_", $a_target); if ($t_arr[0] != "svy" || (int) $t_arr[1] <= 0) { return false; } // 360° external raters if ($_GET["accesscode"]) { include_once "Modules/Survey/classes/class.ilObjSurvey.php"; if (ilObjSurvey::validateExternalRaterCode($t_arr[1], $_GET["accesscode"])) { return true; } } if ($ilAccess->checkAccess("read", "", $t_arr[1])) { return true; } return false; }
public function getSkippedValue() { include_once "Modules/Survey/classes/class.ilObjSurvey.php"; return ilObjSurvey::getSurveySkippedValue(); }
/** * Edit content (ajax, js) * * @return string */ public function editJS() { $node = $_POST["ajaxform_node"]; if ($node) { $node = explode("_", $node); if ($node[0] == "heading") { $id = (int) $node[1]; include_once "Modules/Survey/classes/class.ilObjSurvey.php"; echo ilObjSurvey::getTextblock($id); exit; } } }
/** * checks wether a single condition is fulfilled * every trigger object type must implement a static method * _checkCondition($a_operator, $a_value) */ function _checkCondition($a_id, $a_usr_id = 0) { global $ilUser; $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId(); $condition = ilConditionHandler::_getCondition($a_id); switch ($condition['trigger_type']) { case "tst": include_once './Modules/Test/classes/class.ilObjTestAccess.php'; return ilObjTestAccess::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); case "crs": include_once './Modules/Course/classes/class.ilObjCourse.php'; return ilObjCourse::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); case 'exc': include_once './Modules/Exercise/classes/class.ilObjExercise.php'; return ilObjExercise::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); case 'crsg': include_once './Modules/Course/classes/class.ilObjCourseGrouping.php'; return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); case 'sahs': include_once './Services/Tracking/classes/class.ilLPStatus.php'; return ilLPStatus::_lookupStatus($condition['trigger_obj_id'], $a_usr_id) == LP_STATUS_COMPLETED_NUM; case 'svy': include_once './Modules/Survey/classes/class.ilObjSurvey.php'; return ilObjSurvey::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); default: return false; } }