public function parseGlobalOptions(stdClass $a_options) { // if no inner labels set, use legend if (!isset($a_options->series->pie->label) && !$this->legend) { $legend = new ilChartLegend(); $legend->setPosition("nw"); $this->setLegend($legend); } }
function fillRow($a_poll) { global $ilCtrl, $lng, $ilUser, $tpl; // handle messages $mess = $this->poll_block->getMessage($ilUser->getId()); if ($mess) { $this->tpl->setVariable("TXT_QUESTION", $mess); return; } // nested form problem if (!$_SESSION["il_cont_admin_panel"]) { // vote if ($this->poll_block->mayVote($ilUser->getId())) { $this->tpl->setCurrentBlock("mode_info_bl"); if ($this->poll_block->getPoll()->getNonAnonymous()) { $mode_info = $lng->txt("poll_non_anonymous_warning"); } else { $mode_info = $lng->txt("poll_anonymous_warning"); } $this->tpl->setVariable("MODE_INFO", $mode_info); $this->tpl->parseCurrentBlock(); $is_multi_answer = $this->poll_block->getPoll()->getMaxNumberOfAnswers() > 1; if (isset($_SESSION["last_poll_vote"][$this->poll_block->getPoll()->getId()])) { $last_vote = $_SESSION["last_poll_vote"][$this->poll_block->getPoll()->getId()]; unset($_SESSION["last_poll_vote"][$this->poll_block->getPoll()->getId()]); if ($is_multi_answer) { $error = sprintf($lng->txt("poll_vote_error_multi"), $this->poll_block->getPoll()->getMaxNumberOfAnswers()); } else { $error = $lng->txt("poll_vote_error_single"); } $this->tpl->setCurrentBlock("error_bl"); $this->tpl->setVariable("FORM_ERROR", $error); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("answer"); foreach ($a_poll->getAnswers() as $item) { if (!$is_multi_answer) { $this->tpl->setVariable("ANSWER_INPUT", "radio"); $this->tpl->setVariable("ANSWER_NAME", "aw"); } else { $this->tpl->setVariable("ANSWER_INPUT", "checkbox"); $this->tpl->setVariable("ANSWER_NAME", "aw[]"); if (is_array($last_vote) && in_array($item["id"], $last_vote)) { $this->tpl->setVariable("ANSWER_STATUS", 'checked="checked"'); } } $this->tpl->setVariable("VALUE_ANSWER", $item["id"]); $this->tpl->setVariable("TXT_ANSWER_VOTE", nl2br($item["answer"])); $this->tpl->parseCurrentBlock(); } $ilCtrl->setParameterByClass($this->getRepositoryObjectGUIName(), "ref_id", $this->getRefId()); $url = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", $this->getRepositoryObjectGUIName()), "vote"); $ilCtrl->clearParametersByClass($this->getRepositoryObjectGUIName()); $url .= "#poll" . $a_poll->getID(); $this->tpl->setVariable("URL_FORM", $url); $this->tpl->setVariable("CMD_FORM", "vote"); $this->tpl->setVariable("TXT_SUBMIT", $lng->txt("poll_vote")); if ($this->poll_block->getPoll()->getVotingPeriod()) { $this->tpl->setVariable("TXT_VOTING_PERIOD", sprintf($lng->txt("poll_voting_period_info"), ilDatePresentation::formatDate(new ilDateTime($this->poll_block->getPoll()->getVotingPeriodEnd(), IL_CAL_UNIX)))); } } // result if ($this->poll_block->maySeeResults($ilUser->getId())) { if (!$this->poll_block->mayNotResultsYet($ilUser->getId())) { $answers = array(); foreach ($a_poll->getAnswers() as $item) { $answers[$item["id"]] = $item["answer"]; } $perc = $this->poll_block->getPoll()->getVotePercentages(); $total = $perc["total"]; $perc = $perc["perc"]; $this->tpl->setVariable("TOTAL_ANSWERS", sprintf($lng->txt("poll_population"), $total)); if ($total) { // sort results by votes / original position if ($this->poll_block->getPoll()->getSortResultByVotes()) { $order = array_keys(ilUtil::sortArray($perc, "abs", "desc", true, true)); foreach (array_keys($answers) as $answer_id) { if (!in_array($answer_id, $order)) { $order[] = $answer_id; } } } else { $order = array_keys($answers); } // pie chart if ($this->poll_block->showResultsAs() == ilObjPoll::SHOW_RESULTS_AS_PIECHART) { include_once "./Services/Chart/classes/class.ilChart.php"; $chart = ilChart::getInstanceByType(ilCHart::TYPE_PIE, "poll_results_pie_" . $this->getRefId()); $chart->setSize("100%", 200); $chart->setAutoResize(true); $chart_data = $chart->getDataInstance(); foreach ($order as $answer_id) { $chart_data->addPoint(round($perc[$answer_id]["perc"]), nl2br($answers[$answer_id])); } // disable legend, use inner labels - currently not preferred // $chart_data->setLabelRadius(0.8); $chart->addData($chart_data); $pie_legend_id = "poll_legend_" . $this->getRefId(); $legend = new ilChartLegend(); $legend->setContainer($pie_legend_id); $chart->setLegend($legend); $this->tpl->setVariable("PIE_LEGEND_ID", $pie_legend_id); $this->tpl->setVariable("PIE_CHART", $chart->getHTML()); } else { include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php"; $this->tpl->setCurrentBlock("answer_result"); foreach ($order as $answer_id) { $pbar = ilProgressBar::getInstance(); $pbar->setCurrent(round($perc[$answer_id]["perc"])); $this->tpl->setVariable("PERC_ANSWER_RESULT", $pbar->render()); $this->tpl->setVariable("TXT_ANSWER_RESULT", nl2br($answers[$answer_id])); $this->tpl->parseCurrentBlock(); } } } } else { $rel = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $end = $this->poll_block->getPoll()->getVotingPeriodEnd(); $end = ilDatePresentation::formatDate(new ilDateTime($end, IL_CAL_UNIX)); ilDatePresentation::setUseRelativeDates($rel); // #14607 $info = ""; if ($this->poll_block->getPoll()->hasUserVoted($ilUser->getId())) { $info .= $lng->txt("poll_block_message_already_voted") . " "; } $this->tpl->setVariable("TOTAL_ANSWERS", $info . sprintf($lng->txt("poll_block_results_available_on"), $end)); } } else { if ($this->poll_block->getPoll()->hasUserVoted($ilUser->getId())) { $this->tpl->setVariable("TOTAL_ANSWERS", $lng->txt("poll_block_message_already_voted")); } } } $this->tpl->setVariable("ANCHOR_ID", $a_poll->getID()); $this->tpl->setVariable("TXT_QUESTION", nl2br(trim($a_poll->getQuestion()))); $desc = trim($a_poll->getDescription()); if ($desc) { $this->tpl->setVariable("TXT_DESC", nl2br($desc)); } $img = $a_poll->getImageFullPath(); if ($img) { $this->tpl->setVariable("URL_IMAGE", $img); } if ($this->poll_block->showComments()) { $this->tpl->setCurrentBlock("comment_link"); $this->tpl->setVariable("LANG_COMMENTS", $lng->txt('poll_comments')); $this->tpl->setVariable("COMMENT_JSCALL", $this->commentJSCall()); $this->tpl->setVariable("COMMENTS_COUNT_ID", $this->getRefId()); $comments_count = $this->getNumberOfComments($this->getRefId()); if ($comments_count > 0) { $this->tpl->setVariable("COMMENTS_COUNT", "(" . $comments_count . ")"); } if (!self::$js_init) { $redraw_url = $ilCtrl->getLinkTarget($this, "getNumberOfCommentsForRedraw", "", true, false); $this->tpl->setVariable("COMMENTS_REDRAW_URL", $redraw_url); $tpl->addJavaScript("Modules/Poll/js/ilPoll.js"); self::$js_init = true; } } }