/** * 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(); }
/** * 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(); }
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; }
/** * 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(); }