5include_once(
"./Services/Block/classes/class.ilBlockGUI.php");
 
    6include_once(
"./Modules/Poll/classes/class.ilObjPoll.php");
 
   32                parent::__construct();
 
   34                $lng->loadLanguageModule(
"poll");               
 
   65                return "ilobjpollgui";
 
   82                $this->poll_block = $a_block;                           
 
   92                $next_class = 
$ilCtrl->getNextClass();
 
  109                $mess = $this->poll_block->getMessage(
$ilUser->getId());
 
  112                        $this->tpl->setVariable(
"TXT_QUESTION", $mess);
 
  122                        if($this->poll_block->mayVote(
$ilUser->getId()))
 
  124                                $this->tpl->setCurrentBlock(
"mode_info_bl");                    
 
  125                                if($this->poll_block->getPoll()->getNonAnonymous())
 
  127                                        $mode_info = 
$lng->txt(
"poll_non_anonymous_warning");                                   
 
  131                                        $mode_info = 
$lng->txt(
"poll_anonymous_warning");       
 
  133                                $this->tpl->setVariable(
"MODE_INFO", $mode_info);
 
  134                                $this->tpl->parseCurrentBlock();
 
  136                                $is_multi_answer = ($this->poll_block->getPoll()->getMaxNumberOfAnswers() > 1);
 
  138                                if(isset(
$_SESSION[
"last_poll_vote"][$this->poll_block->getPoll()->getId()]))
 
  140                                        $last_vote = 
$_SESSION[
"last_poll_vote"][$this->poll_block->getPoll()->getId()];                                
 
  141                                        unset(
$_SESSION[
"last_poll_vote"][$this->poll_block->getPoll()->getId()]);
 
  145                                                $error = sprintf(
$lng->txt(
"poll_vote_error_multi"),
 
  146                                                        $this->poll_block->getPoll()->getMaxNumberOfAnswers());                                         
 
  150                                                $error = 
$lng->txt(
"poll_vote_error_single");
 
  153                                        $this->tpl->setCurrentBlock(
"error_bl");                                
 
  154                                        $this->tpl->setVariable(
"FORM_ERROR", $error);
 
  155                                        $this->tpl->parseCurrentBlock();
 
  158                                $this->tpl->setCurrentBlock(
"answer");
 
  159                                foreach($a_poll->getAnswers() as $item)
 
  161                                        if(!$is_multi_answer)
 
  163                                                $this->tpl->setVariable(
"ANSWER_INPUT", 
"radio");
 
  164                                                $this->tpl->setVariable(
"ANSWER_NAME", 
"aw"); 
 
  168                                                $this->tpl->setVariable(
"ANSWER_INPUT", 
"checkbox");
 
  169                                                $this->tpl->setVariable(
"ANSWER_NAME", 
"aw[]"); 
 
  171                                                if(is_array($last_vote) && in_array($item[
"id"], $last_vote))
 
  173                                                        $this->tpl->setVariable(
"ANSWER_STATUS", 
'checked="checked"'); 
 
  176                                        $this->tpl->setVariable(
"VALUE_ANSWER", $item[
"id"]);
 
  177                                        $this->tpl->setVariable(
"TXT_ANSWER_VOTE", nl2br($item[
"answer"]));
 
  178                                        $this->tpl->parseCurrentBlock();
 
  187                                $url .= 
"#poll".$a_poll->getID();
 
  189                                $this->tpl->setVariable(
"URL_FORM", $url);
 
  190                                $this->tpl->setVariable(
"CMD_FORM", 
"vote");
 
  191                                $this->tpl->setVariable(
"TXT_SUBMIT", 
$lng->txt(
"poll_vote"));          
 
  193                                if($this->poll_block->getPoll()->getVotingPeriod())
 
  195                                        $this->tpl->setVariable(
"TXT_VOTING_PERIOD",
 
  196                                                sprintf(
$lng->txt(
"poll_voting_period_info"),
 
  203                        if ($this->poll_block->maySeeResults(
$ilUser->getId()))
 
  205                                if (!$this->poll_block->mayNotResultsYet(
$ilUser->getId()))
 
  208                                        foreach ($a_poll->getAnswers() as $item)
 
  210                                                $answers[$item[
"id"]] = $item[
"answer"];
 
  213                                        $perc = $this->poll_block->getPoll()->getVotePercentages();
 
  215                                        $perc = $perc[
"perc"];
 
  217                                        $this->tpl->setVariable(
"TOTAL_ANSWERS", sprintf(
$lng->txt(
"poll_population"), 
$total));
 
  222                                                if ($this->poll_block->getPoll()->getSortResultByVotes())
 
  226                                                        foreach (array_keys($answers) as $answer_id)
 
  228                                                                if (!in_array($answer_id, $order))
 
  230                                                                        $order[] = $answer_id;
 
  236                                                        $order = array_keys($answers);
 
  243                                                        include_once(
"./Services/Chart/classes/class.ilChart.php");
 
  246                                                        $chart->setSize(
"100%", 200); 
 
  247                                                        $chart->setAutoResize(
true);
 
  249                                                        $chart_data = $chart->getDataInstance();
 
  251                                                        foreach ($order as $answer_id)
 
  253                                                                $chart_data->addPoint(
 
  254                                                                        round($perc[$answer_id][
"perc"]), 
 
  255                                                                        nl2br($answers[$answer_id])
 
  262                                                        $chart->addData($chart_data);
 
  264                                                        $pie_legend_id = 
"poll_legend_".$this->getRefId();
 
  266                                                        $legend->setContainer($pie_legend_id);
 
  267                                                        $chart->setLegend($legend);
 
  269                                                        $this->tpl->setVariable(
"PIE_LEGEND_ID", $pie_legend_id);
 
  270                                                        $this->tpl->setVariable(
"PIE_CHART", $chart->getHTML());
 
  275                                                        include_once 
"Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
 
  277                                                        $this->tpl->setCurrentBlock(
"answer_result");
 
  278                                                        foreach ($order as $answer_id)
 
  281                                                                $pbar->setCurrent(round($perc[$answer_id][
"perc"]));
 
  282                                                                $this->tpl->setVariable(
"PERC_ANSWER_RESULT", $pbar->render());
 
  283                                                                $this->tpl->setVariable(
"TXT_ANSWER_RESULT", nl2br($answers[$answer_id]));                                                              
 
  284                                                                $this->tpl->parseCurrentBlock();
 
  293                                        $end = $this->poll_block->getPoll()->getVotingPeriodEnd();
 
  299                                        if($this->poll_block->getPoll()->hasUserVoted(
$ilUser->getId()))
 
  301                                                $info .= 
$lng->txt(
"poll_block_message_already_voted").
" ";
 
  304                                        $this->tpl->setVariable(
"TOTAL_ANSWERS", $info.                                         
 
  305                                                sprintf(
$lng->txt(
"poll_block_results_available_on"), $end));                                   
 
  308                        else if($this->poll_block->getPoll()->hasUserVoted(
$ilUser->getId()))
 
  310                                $this->tpl->setVariable(
"TOTAL_ANSWERS", 
$lng->txt(
"poll_block_message_already_voted"));
 
  315                $this->tpl->setVariable(
"ANCHOR_ID", $a_poll->getID());
 
  316                $this->tpl->setVariable(
"TXT_QUESTION", nl2br(trim($a_poll->getQuestion())));
 
  318                $desc = trim($a_poll->getDescription());
 
  321                        $this->tpl->setVariable(
"TXT_DESC", nl2br($desc));
 
  324                $img = $a_poll->getImageFullPath();
 
  327                        $this->tpl->setVariable(
"URL_IMAGE", 
$img);
 
  330                if ($this->poll_block->showComments()) {
 
  331                        $this->tpl->setCurrentBlock(
"comment_link");
 
  332                        $this->tpl->setVariable(
"LANG_COMMENTS", 
$lng->txt(
'poll_comments'));
 
  333                        $this->tpl->setVariable(
"COMMENT_JSCALL", $this->
commentJSCall());
 
  334                        $this->tpl->setVariable(
"COMMENTS_COUNT_ID", $this->
getRefId());
 
  338                        if($comments_count > 0)
 
  340                                $this->tpl->setVariable(
"COMMENTS_COUNT", 
"(".$comments_count.
")");
 
  345                                $redraw_url = 
$ilCtrl->getLinkTarget($this, 
"getNumberOfCommentsForRedraw",
 
  347                                $this->tpl->setVariable(
"COMMENTS_REDRAW_URL", $redraw_url);    
 
  349                                $tpl->addJavaScript(
"Modules/Poll/js/ilPoll.js");
 
  350                                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                if(!$this->may_write && !$this->has_content)
 
  372                $poll_obj = $this->poll_block->getPoll();
 
  373                $this->
setTitle($poll_obj->getTitle());
 
  374                $this->
setData(array($poll_obj));       
 
  379                if(!$this->poll_block->getMessage(
$ilUser->getId()))
 
  382                        include_once 
"./Services/Notification/classes/class.ilNotification.php";
 
  388                                        $lng->txt(
"poll_notification_unsubscribe"));
 
  395                                        $lng->txt(
"poll_notification_subscribe"));
 
  399                if ($this->may_write)
 
  405                                $lng->txt(
"edit_content"));
 
  409                                $lng->txt(
"settings"));
 
  429                return parent::getHTML();
 
  439                include_once(
"./Services/Notes/classes/class.ilNoteGUI.php");
 
  440                include_once(
"./Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
 
  450                $jsCall = 
$comment->getListCommentsJSCall($ajaxHash, 
"ilPoll.redrawComments(".$refId.
");");
 
  464                        echo 
"(".$number.
")";
 
  482                include_once(
"./Services/Notes/classes/class.ilNote.php");
 
  487                if(count($number) == 0)
 
This class represents a block method of a block.
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setData($a_data)
Set Data.
addBlockCommand($a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false, $a_html="")
Add Block Command.
setTitle($a_title)
Set Title.
setBlockId($a_block_id=0)
Set Block Id.
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)
Build ajax hash.
static setUseRelativeDates($a_status)
set use relative dates
static formatDate(ilDateTime $date)
Format a date @access public.
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
static _countNotesAndComments($a_rep_obj_id, $a_sub_obj_id=null)
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.
__construct()
Constructor.
getNumberOfCommentsForRedraw()
Returns comment count for JS Redraw.
& executeCommand()
execute command
static getScreenMode()
Get Screen Mode for current command.
getRepositoryObjectGUIName()
Get repository object GUI name.
static getBlockType()
Get block type.
getNumberOfComments($ref_id)
Get comment count.
setBlock($a_block)
Do most of the initialisation.
getHTML()
Get block HTML code.
static isRepositoryObject()
Is block of repository object?
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