5 include_once(
"./Services/Block/classes/class.ilBlockGUI.php");
6 include_once(
"./Modules/Poll/classes/class.ilObjPoll.php");
32 $lng->loadLanguageModule(
"poll");
70 $this->poll_block = $a_block;
80 $next_class = $ilCtrl->getNextClass();
81 $cmd = $ilCtrl->getCmd(
"getHTML");
97 $mess = $this->poll_block->getMessage($ilUser->getId());
100 $this->tpl->setVariable(
"TXT_QUESTION", $mess);
110 if($this->poll_block->mayVote($ilUser->getId()))
112 $this->tpl->setCurrentBlock(
"answer");
113 foreach($a_poll->getAnswers() as $item)
115 $this->tpl->setVariable(
"VALUE_ANSWER", $item[
"id"]);
116 $this->tpl->setVariable(
"TXT_ANSWER_VOTE", nl2br($item[
"answer"]));
117 $this->tpl->parseCurrentBlock();
120 $ilCtrl->setParameterByClass(
"ilobjpollgui",
122 $url = $ilCtrl->getLinkTargetByClass(array(
"ilrepositorygui",
"ilobjpollgui"),
124 $ilCtrl->clearParametersByClass(
"ilobjpollgui");
126 $url .=
"#poll".$a_poll->getID();
128 $this->tpl->setVariable(
"URL_FORM", $url);
129 $this->tpl->setVariable(
"CMD_FORM",
"vote");
130 $this->tpl->setVariable(
"TXT_SUBMIT", $lng->txt(
"poll_vote"));
132 if($this->poll_block->getPoll()->getVotingPeriod())
134 $this->tpl->setVariable(
"TXT_VOTING_PERIOD",
135 sprintf($lng->txt(
"poll_voting_period_info"),
142 if($this->poll_block->maySeeResults($ilUser->getId()))
144 if(!$this->poll_block->mayNotResultsYet($ilUser->getId()))
146 $perc = $this->poll_block->getPoll()->getVotePercentages();
148 $perc = $perc[
"perc"];
150 $this->tpl->setVariable(
"TOTAL_ANSWERS", sprintf($lng->txt(
"poll_population"),
$total));
152 $this->tpl->setCurrentBlock(
"answer_result");
153 foreach($a_poll->getAnswers() as $item)
155 $this->tpl->setVariable(
"TXT_ANSWER_RESULT", nl2br($item[
"answer"]));
156 $this->tpl->setVariable(
"PERC_ANSWER_RESULT", round($perc[$item[
"id"]][
"perc"]));
157 $this->tpl->parseCurrentBlock();
164 $end = $this->poll_block->getPoll()->getVotingPeriodEnd();
170 if($this->poll_block->getPoll()->hasUserVoted($ilUser->getId()))
172 $info .= $lng->txt(
"poll_block_message_already_voted").
" ";
175 $this->tpl->setVariable(
"TOTAL_ANSWERS", $info.
176 sprintf($lng->txt(
"poll_block_results_available_on"), $end));
179 else if($this->poll_block->getPoll()->hasUserVoted($ilUser->getId()))
181 $this->tpl->setVariable(
"TOTAL_ANSWERS", $lng->txt(
"poll_block_message_already_voted"));
186 $this->tpl->setVariable(
"ANCHOR_ID", $a_poll->getID());
187 $this->tpl->setVariable(
"TXT_QUESTION", nl2br(trim($a_poll->getQuestion())));
189 $desc = trim($a_poll->getDescription());
192 $this->tpl->setVariable(
"TXT_DESC", nl2br($desc));
195 $img = $a_poll->getImageFullPath();
198 $this->tpl->setVariable(
"URL_IMAGE",
$img);
209 $this->poll_block->setRefId($this->
getRefId());
210 $this->may_write = $ilAccess->checkAccess(
"write",
"", $this->
getRefId());
211 $this->has_content = $this->poll_block->hasAnyContent($ilUser->getId(), $this->
getRefId());
213 if(!$this->may_write && !$this->has_content)
218 $poll_obj = $this->poll_block->getPoll();
219 $this->
setTitle($poll_obj->getTitle());
220 $this->
setData(array($poll_obj));
222 if ($this->may_write)
225 $ilCtrl->setParameterByClass(
"ilobjpollgui",
228 $ilCtrl->getLinkTargetByClass(array(
"ilrepositorygui",
"ilobjpollgui"),
230 $lng->txt(
"edit_content"));
232 $ilCtrl->getLinkTargetByClass(array(
"ilrepositorygui",
"ilobjpollgui"),
234 $lng->txt(
"settings"));
251 $ilCtrl->clearParametersByClass(
"ilobjpollgui");