5include_once(
"./Services/Block/classes/class.ilBlockGUI.php");
 
    6include_once(
"./Modules/Poll/classes/class.ilObjPoll.php");
 
   32        $this->lng = 
$DIC->language();
 
   33        $this->ctrl = 
$DIC->ctrl();
 
   34        $this->
user = $DIC->user();
 
   35        $this->access = 
$DIC->access();
 
   38        parent::__construct();
 
   40        $lng->loadLanguageModule(
"poll");
 
   67        return "ilobjpollgui";
 
   84        $this->poll_block = $a_block;
 
   94        $next_class = 
$ilCtrl->getNextClass();
 
   95        $cmd = 
$ilCtrl->getCmd(
"getHTML");
 
   97        switch ($next_class) {
 
  113        $mess = $this->poll_block->getMessage(
$ilUser->getId());
 
  115            $this->tpl->setVariable(
"TXT_QUESTION", $mess);
 
  124            if ($this->poll_block->mayVote(
$ilUser->getId())) {
 
  125                $this->tpl->setCurrentBlock(
"mode_info_bl");
 
  126                if ($this->poll_block->getPoll()->getNonAnonymous()) {
 
  127                    $mode_info = 
$lng->txt(
"poll_non_anonymous_warning");
 
  129                    $mode_info = 
$lng->txt(
"poll_anonymous_warning");
 
  131                $this->tpl->setVariable(
"MODE_INFO", $mode_info);
 
  132                $this->tpl->parseCurrentBlock();
 
  134                $is_multi_answer = ($this->poll_block->getPoll()->getMaxNumberOfAnswers() > 1);
 
  136                if (isset(
$_SESSION[
"last_poll_vote"][$this->poll_block->getPoll()->getId()])) {
 
  137                    $last_vote = 
$_SESSION[
"last_poll_vote"][$this->poll_block->getPoll()->getId()];
 
  138                    unset(
$_SESSION[
"last_poll_vote"][$this->poll_block->getPoll()->getId()]);
 
  140                    if ($is_multi_answer) {
 
  142                            $lng->txt(
"poll_vote_error_multi"),
 
  143                            $this->poll_block->getPoll()->getMaxNumberOfAnswers()
 
  146                        $error = 
$lng->txt(
"poll_vote_error_single");
 
  149                    $this->tpl->setCurrentBlock(
"error_bl");
 
  150                    $this->tpl->setVariable(
"FORM_ERROR", $error);
 
  151                    $this->tpl->parseCurrentBlock();
 
  154                $this->tpl->setCurrentBlock(
"answer");
 
  155                foreach ($a_poll->getAnswers() as $item) {
 
  156                    if (!$is_multi_answer) {
 
  157                        $this->tpl->setVariable(
"ANSWER_INPUT", 
"radio");
 
  158                        $this->tpl->setVariable(
"ANSWER_NAME", 
"aw");
 
  160                        $this->tpl->setVariable(
"ANSWER_INPUT", 
"checkbox");
 
  161                        $this->tpl->setVariable(
"ANSWER_NAME", 
"aw[]");
 
  163                        if (is_array($last_vote) && in_array($item[
"id"], $last_vote)) {
 
  164                            $this->tpl->setVariable(
"ANSWER_STATUS", 
'checked="checked"');
 
  167                    $this->tpl->setVariable(
"VALUE_ANSWER", $item[
"id"]);
 
  168                    $this->tpl->setVariable(
"TXT_ANSWER_VOTE", nl2br($item[
"answer"]));
 
  169                    $this->tpl->parseCurrentBlock();
 
  183                $url .= 
"#poll" . $a_poll->getID();
 
  185                $this->tpl->setVariable(
"URL_FORM", 
$url);
 
  186                $this->tpl->setVariable(
"CMD_FORM", 
"vote");
 
  187                $this->tpl->setVariable(
"TXT_SUBMIT", 
$lng->txt(
"poll_vote"));
 
  189                if ($this->poll_block->getPoll()->getVotingPeriod()) {
 
  190                    $this->tpl->setVariable(
 
  191                        "TXT_VOTING_END_PERIOD",
 
  193                            $lng->txt(
"poll_voting_period_info"),
 
  202            if ($this->poll_block->maySeeResults(
$ilUser->getId())) {
 
  203                if (!$this->poll_block->mayNotResultsYet(
$ilUser->getId())) {
 
  205                    foreach ($a_poll->getAnswers() as $item) {
 
  206                        $answers[$item[
"id"]] = $item[
"answer"];
 
  209                    $perc = $this->poll_block->getPoll()->getVotePercentages();
 
  211                    $perc = $perc[
"perc"];
 
  213                    $this->tpl->setVariable(
"TOTAL_ANSWERS", sprintf(
$lng->txt(
"poll_population"), 
$total));
 
  217                        if ($this->poll_block->getPoll()->getSortResultByVotes()) {
 
  220                            foreach (array_keys($answers) as $answer_id) {
 
  221                                if (!in_array($answer_id, $order)) {
 
  222                                    $order[] = $answer_id;
 
  226                            $order = array_keys($answers);
 
  231                            include_once(
"./Services/Chart/classes/class.ilChart.php");
 
  234                            $chart->setSize(
"100%", 200);
 
  235                            $chart->setAutoResize(
true);
 
  237                            $chart_data = $chart->getDataInstance();
 
  239                            foreach ($order as $answer_id) {
 
  240                                $chart_data->addPoint(
 
  241                                    round($perc[$answer_id][
"perc"]),
 
  242                                    nl2br($answers[$answer_id])
 
  249                            $chart->addData($chart_data);
 
  251                            $pie_legend_id = 
"poll_legend_" . $this->
getRefId();
 
  253                            $legend->setContainer($pie_legend_id);
 
  256                            $this->tpl->setVariable(
"PIE_LEGEND_ID", $pie_legend_id);
 
  257                            $this->tpl->setVariable(
"PIE_CHART", $chart->getHTML());
 
  261                            include_once 
"Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
 
  263                            $this->tpl->setCurrentBlock(
"answer_result");
 
  264                            foreach ($order as $answer_id) {
 
  266                                $pbar->setCurrent(round($perc[$answer_id][
"perc"]));
 
  267                                $this->tpl->setVariable(
"PERC_ANSWER_RESULT", $pbar->render());
 
  268                                $this->tpl->setVariable(
"TXT_ANSWER_RESULT", nl2br($answers[$answer_id]));
 
  269                                $this->tpl->parseCurrentBlock();
 
  276                    $end = $this->poll_block->getPoll()->getVotingPeriodEnd();
 
  282                    if ($this->poll_block->getPoll()->hasUserVoted(
$ilUser->getId())) {
 
  283                        $info .= 
$lng->txt(
"poll_block_message_already_voted") . 
" ";
 
  286                    $this->tpl->setVariable(
"TOTAL_ANSWERS", 
$info .
 
  287                        sprintf(
$lng->txt(
"poll_block_results_available_on"), 
$end));
 
  289            } elseif ($this->poll_block->getPoll()->hasUserVoted(
$ilUser->getId())) {
 
  290                $this->tpl->setVariable(
"TOTAL_ANSWERS", 
$lng->txt(
"poll_block_message_already_voted"));
 
  294        if (!$this->poll_block->mayVote(
$ilUser->getId()) && !$this->poll_block->getPoll()->hasUserVoted(
$ilUser->getId())) {
 
  295            if ($this->poll_block->getPoll()->getVotingPeriod()) {
 
  296                $this->tpl->setVariable(
 
  299                        $lng->txt(
"poll_voting_period_full_info"),
 
  306            $this->tpl->setVariable(
"TXT_QUESTION", nl2br(trim($a_poll->getQuestion())));
 
  308            $img = $a_poll->getImageFullPath();
 
  310                require_once(
'./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
 
  316        $this->tpl->setVariable(
"ANCHOR_ID", $a_poll->getID());
 
  319        $desc = trim($a_poll->getDescription());
 
  321            $this->tpl->setVariable(
"TXT_DESC", nl2br($desc));
 
  325        if ($this->poll_block->showComments()) {
 
  326            $this->tpl->setCurrentBlock(
"comment_link");
 
  327            $this->tpl->setVariable(
"LANG_COMMENTS", 
$lng->txt(
'poll_comments'));
 
  328            $this->tpl->setVariable(
"COMMENT_JSCALL", $this->
commentJSCall());
 
  329            $this->tpl->setVariable(
"COMMENTS_COUNT_ID", $this->
getRefId());
 
  333            if ($comments_count > 0) {
 
  334                $this->tpl->setVariable(
"COMMENTS_COUNT", 
"(" . $comments_count . 
")");
 
  337            if (!self::$js_init) {
 
  338                $redraw_url = 
$ilCtrl->getLinkTarget(
 
  340                    "getNumberOfCommentsForRedraw",
 
  345                $this->tpl->setVariable(
"COMMENTS_REDRAW_URL", $redraw_url);
 
  347                $tpl->addJavaScript(
"Modules/Poll/js/ilPoll.js");
 
  348                self::$js_init = 
true;
 
  363        $this->poll_block->setRefId($this->
getRefId());
 
  364        $this->may_write = $ilAccess->checkAccess(
"write", 
"", $this->
getRefId());
 
  365        $this->has_content = $this->poll_block->hasAnyContent(
$ilUser->getId(), $this->getRefId());
 
  367        #22078 and 22079 it always contains something. 
  373        $poll_obj = $this->poll_block->getPoll();
 
  374        $this->
setTitle($poll_obj->getTitle());
 
  375        $this->
setData(array($poll_obj));
 
  383        if (!$this->poll_block->getMessage(
$ilUser->getId())) {
 
  385            include_once 
"./Services/Notification/classes/class.ilNotification.php";
 
  392                    $lng->txt(
"poll_notification_unsubscribe")
 
  400                    $lng->txt(
"poll_notification_subscribe")
 
  405        if ($this->may_write) {
 
  412                $lng->txt(
"edit_content")
 
  419                $lng->txt(
"settings")
 
  440        return parent::getHTML();
 
  450        include_once(
"./Services/Notes/classes/class.ilNoteGUI.php");
 
  451        include_once(
"./Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
 
  465        $jsCall = 
$comment->getListCommentsJSCall($ajaxHash, 
"ilPoll.redrawComments(" . $refId . 
");");
 
  478            echo 
"(" . $number . 
")";
 
  494        include_once(
"./Services/Notes/classes/class.ilNote.php");
 
  499        if (count($number) == 0) {
 
An exception for terminatinating execution or to throw for unit testing.
This class represents a block method of a block.
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setData($a_data)
Set Data.
setTitle($a_title)
Set Title.
setBlockId($a_block_id=0)
Set Block Id.
addBlockCommand( $a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false, $a_html="")
Add Block Command.
getRefId()
Get Ref Id (only used if isRepositoryObject() is true).
static getInstanceByType($a_type, $a_id)
Get type instance.
static buildAjaxHash( $a_node_type, $a_node_id, $a_obj_type, $a_obj_id, $a_sub_type=null, $a_sub_id=null, $a_news_id=0)
Build ajax hash.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
static _countNotesAndComments( $a_rep_obj_id, $a_sub_obj_id=null, $a_obj_type="", $a_news_id=0)
Get all notes related to a specific object.
static hasNotification($type, $user_id, $id)
Check notification status for object and user.
const SHOW_RESULTS_AS_PIECHART
static _lookupObjectId($a_ref_id)
lookup object id
BlockGUI class for polls.
executeCommand()
execute command
__construct()
Constructor.
getNumberOfCommentsForRedraw()
Returns comment count for JS Redraw.
static getScreenMode()
Get Screen Mode for current command.
isRepositoryObject()
Returns whether block has a corresponding repository object.bool
getRepositoryObjectGUIName()
Get repository object GUI name.
getNumberOfComments($ref_id)
Get comment count.
setBlock($a_block)
Do most of the initialisation.
getHTML()
Get block HTML code.
commentJSCall()
Builds JavaScript Call to open CommentLayer via html link.
static getInstance()
Factory.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static signFile($path_to_file)