ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilPollContentRenderer Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilPollContentRenderer:

Public Member Functions

 __construct (ilLanguage $lng, UIFactory $ui_factory, UIRenderer $ui_renderer, ilPollStateInfo $availability, ilPollCommentsHandler $comments, ilPollAnswersHandler $answers, ilPollAnswersRenderer $answers_renderer, ilPollResultsHandler $results, ilPollResultsRenderer $results_renderer)
 
 render (ilTemplate $tpl, int $ref_id, int $user_id, ilObjPoll $poll, bool $admin_view=false)
 

Protected Member Functions

 renderAnswersAndResults (ilTemplate $tpl, ilObjPoll $poll, int $user_id)
 
 renderAnswers (ilTemplate $tpl, ilObjPoll $poll, int $user_id)
 
 renderResults (ilTemplate $tpl, ilObjPoll $poll)
 
 renderTotalParticipantsInfo (ilTemplate $tpl, int $total)
 
 renderNotAbleToVoteMessage (ilTemplate $tpl, bool $has_voted, bool $results_in_future, int $voting_end_date)
 
 renderQuestion (ilTemplate $tpl, string $text, ?string $img_path)
 
 renderMiscVoteInfo (ilTemplate $tpl, ?int $answer_limit, int $deadline)
 
 renderAnonimityInfo (ilTemplate $tpl, bool $anonymous)
 
 renderNotWithinVotingPeriodMessage (ilTemplate $tpl, int $vote_start, int $vote_end)
 
 renderNoQuestionMessage (ilTemplate $tpl)
 
 renderAnchor (ilTemplate $tpl, int $obj_id)
 
 renderDescription (ilTemplate $tpl, string $description)
 
 renderAvailability (ilTemplate $tpl, ilObjPoll $poll)
 
 renderAlertForAnonymousUser (ilTemplate $tpl)
 
 renderComments (ilTemplate $tpl, int $ref_id)
 
 getMessageBox (string $message)
 
 getFormattedDate (int $date)
 
 specialCharsAsEntities (string $string)
 

Protected Attributes

ilPollStateInfo $state
 
ilPollCommentsHandler $comments
 
ilPollAnswersHandler $answers
 
ilPollAnswersRenderer $answers_renderer
 
ilPollResultsHandler $results
 
ilPollResultsRenderer $results_renderer
 
ilLanguage $lng
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 25 of file class.ilPollContentRenderer.php.

Constructor & Destructor Documentation

◆ __construct()

ilPollContentRenderer::__construct ( ilLanguage  $lng,
UIFactory  $ui_factory,
UIRenderer  $ui_renderer,
ilPollStateInfo  $availability,
ilPollCommentsHandler  $comments,
ilPollAnswersHandler  $answers,
ilPollAnswersRenderer  $answers_renderer,
ilPollResultsHandler  $results,
ilPollResultsRenderer  $results_renderer 
)

Definition at line 37 of file class.ilPollContentRenderer.php.

References $answers, $answers_renderer, $comments, $lng, $results, $results_renderer, $ui_factory, $ui_renderer, and ILIAS\Repository\lng().

47  {
48  $this->lng = $lng;
49  $this->ui_factory = $ui_factory;
50  $this->ui_renderer = $ui_renderer;
51  $this->state = $availability;
52  $this->comments = $comments;
53  $this->answers = $answers;
54  $this->answers_renderer = $answers_renderer;
55  $this->results = $results;
56  $this->results_renderer = $results_renderer;
57  }
ilPollResultsRenderer $results_renderer
ilPollAnswersRenderer $answers_renderer
+ Here is the call graph for this function:

Member Function Documentation

◆ getFormattedDate()

ilPollContentRenderer::getFormattedDate ( int  $date)
protected

Definition at line 347 of file class.ilPollContentRenderer.php.

References ilDatePresentation\formatDate(), and IL_CAL_UNIX.

Referenced by renderMiscVoteInfo(), renderNotAbleToVoteMessage(), and renderNotWithinVotingPeriodMessage().

347  : string
348  {
350  new ilDateTime($date, IL_CAL_UNIX)
351  );
352  }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMessageBox()

ilPollContentRenderer::getMessageBox ( string  $message)
protected

Definition at line 340 of file class.ilPollContentRenderer.php.

Referenced by renderNoQuestionMessage(), renderNotAbleToVoteMessage(), and renderNotWithinVotingPeriodMessage().

340  : string
341  {
342  return $this->ui_renderer->render(
343  $this->ui_factory->messageBox()->info($message)
344  );
345  }
$message
Definition: xapiexit.php:32
+ Here is the caller graph for this function:

◆ render()

ilPollContentRenderer::render ( ilTemplate  $tpl,
int  $ref_id,
int  $user_id,
ilObjPoll  $poll,
bool  $admin_view = false 
)

Definition at line 59 of file class.ilPollContentRenderer.php.

References ilObject\getId(), ilObjPoll\getImageFullPath(), ilObject\getLongDescription(), ilObjPoll\getQuestion(), ilObjPoll\getShowComments(), ilObjPoll\getVotingPeriodBegin(), ilObjPoll\getVotingPeriodEnd(), renderAlertForAnonymousUser(), renderAnchor(), renderAnswersAndResults(), renderAvailability(), renderComments(), renderDescription(), renderNoQuestionMessage(), renderNotWithinVotingPeriodMessage(), and renderQuestion().

65  : void {
66  $this->renderAnchor($tpl, $poll->getId());
67  $this->renderAvailability($tpl, $poll);
68  $this->renderDescription($tpl, $poll->getLongDescription());
69 
70  if (!$this->state->hasQuestion($poll)) {
71  $this->renderNoQuestionMessage($tpl);
72  } elseif ($this->state->hasVotingPeriodNotStarted($poll, false)) {
74  $tpl,
75  $poll->getVotingPeriodBegin(),
76  $poll->getVotingPeriodEnd()
77  );
78  } else {
79  $this->renderQuestion(
80  $tpl,
81  $poll->getQuestion(),
82  $poll->getImageFullPath()
83  );
84  if (!$admin_view) {
85  $this->renderAnswersAndResults($tpl, $poll, $user_id);
86  }
87  }
88 
89  if ($poll->getShowComments()) {
90  $this->renderComments($tpl, $ref_id);
91  }
92 
93  if ($this->state->isUserAnonymous($user_id)) {
94  $this->renderAlertForAnonymousUser($tpl);
95  }
96  }
renderNotWithinVotingPeriodMessage(ilTemplate $tpl, int $vote_start, int $vote_end)
renderDescription(ilTemplate $tpl, string $description)
renderAnchor(ilTemplate $tpl, int $obj_id)
$ref_id
Definition: ltiauth.php:67
renderQuestion(ilTemplate $tpl, string $text, ?string $img_path)
renderComments(ilTemplate $tpl, int $ref_id)
getLongDescription()
get object long description (stored in object_description)
renderAvailability(ilTemplate $tpl, ilObjPoll $poll)
renderAnswersAndResults(ilTemplate $tpl, ilObjPoll $poll, int $user_id)
renderAlertForAnonymousUser(ilTemplate $tpl)
getImageFullPath(bool $a_as_thumb=false)
+ Here is the call graph for this function:

◆ renderAlertForAnonymousUser()

ilPollContentRenderer::renderAlertForAnonymousUser ( ilTemplate  $tpl)
protected

Definition at line 320 of file class.ilPollContentRenderer.php.

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by render().

320  : void
321  {
322  $tpl->setVariable("TXT_ANON", $this->lng->txt('no_access_item_public'));
323  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderAnchor()

ilPollContentRenderer::renderAnchor ( ilTemplate  $tpl,
int  $obj_id 
)
protected

Definition at line 295 of file class.ilPollContentRenderer.php.

References HTML_Template_IT\setVariable().

Referenced by render().

295  : void
296  {
297  $tpl->setVariable("ANCHOR_ID", $obj_id);
298  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderAnonimityInfo()

ilPollContentRenderer::renderAnonimityInfo ( ilTemplate  $tpl,
bool  $anonymous 
)
protected

Definition at line 260 of file class.ilPollContentRenderer.php.

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by renderAnswers().

263  : void {
264  if ($anonymous) {
265  $info = $this->lng->txt("poll_anonymous_warning");
266  } else {
267  $info = $this->lng->txt("poll_non_anonymous_warning");
268  }
269  $tpl->setVariable("ANONIMITY_INFO", $info);
270  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderAnswers()

ilPollContentRenderer::renderAnswers ( ilTemplate  $tpl,
ilObjPoll  $poll,
int  $user_id 
)
protected

Definition at line 139 of file class.ilPollContentRenderer.php.

References ilObjPoll\getNonAnonymous(), ilObjPoll\getVotingPeriodEnd(), renderAnonimityInfo(), and renderMiscVoteInfo().

Referenced by renderAnswersAndResults().

143  : void {
144  $this->renderMiscVoteInfo(
145  $tpl,
146  $this->answers->getAnswerLimitForInfo(),
147  $poll->getVotingPeriodEnd()
148  );
149  $this->answers_renderer->render(
150  $tpl,
151  $this->answers,
152  !$this->state->mayUserVote($user_id)
153  );
154  $this->renderAnonimityInfo($tpl, !$poll->getNonAnonymous());
155  }
renderMiscVoteInfo(ilTemplate $tpl, ?int $answer_limit, int $deadline)
renderAnonimityInfo(ilTemplate $tpl, bool $anonymous)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderAnswersAndResults()

ilPollContentRenderer::renderAnswersAndResults ( ilTemplate  $tpl,
ilObjPoll  $poll,
int  $user_id 
)
protected

Definition at line 98 of file class.ilPollContentRenderer.php.

References ilObjPoll\getVotingPeriodEnd(), renderAnswers(), renderNotAbleToVoteMessage(), renderResults(), and renderTotalParticipantsInfo().

Referenced by render().

102  : void {
103  $either_is_shown = false;
104  if (
105  !$this->state->hasUserAlreadyVoted($user_id, $poll) &&
106  !$this->state->hasVotingPeriodEnded($poll, false)
107  ) {
108  $this->renderAnswers($tpl, $poll, $user_id);
109  $either_is_shown = true;
110  }
111 
112  if (
113  $this->state->areResultsVisible($user_id, $poll) &&
114  $this->results->getTotalVotes()
115  ) {
116  $this->renderResults($tpl, $poll);
118  $tpl,
119  $this->results->getTotalVotes()
120  );
121  $either_is_shown = true;
122  } elseif ($this->state->areResultsVisible($user_id, $poll)) {
124  $tpl,
125  $this->results->getTotalVotes()
126  );
127  }
128 
129  if (!$either_is_shown) {
131  $tpl,
132  $this->state->hasUserAlreadyVoted($user_id, $poll),
133  $this->state->willResultsBeShown($poll),
134  $poll->getVotingPeriodEnd()
135  );
136  }
137  }
renderNotAbleToVoteMessage(ilTemplate $tpl, bool $has_voted, bool $results_in_future, int $voting_end_date)
renderResults(ilTemplate $tpl, ilObjPoll $poll)
renderTotalParticipantsInfo(ilTemplate $tpl, int $total)
renderAnswers(ilTemplate $tpl, ilObjPoll $poll, int $user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderAvailability()

ilPollContentRenderer::renderAvailability ( ilTemplate  $tpl,
ilObjPoll  $poll 
)
protected

Definition at line 313 of file class.ilPollContentRenderer.php.

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by render().

313  : void
314  {
315  if ($this->state->isOfflineOrUnavailable($poll)) {
316  $tpl->setVariable("TXT_OFFLINE", $this->lng->txt('offline'));
317  }
318  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderComments()

ilPollContentRenderer::renderComments ( ilTemplate  $tpl,
int  $ref_id 
)
protected

Definition at line 325 of file class.ilPollContentRenderer.php.

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by render().

325  : void
326  {
327  $tpl->setVariable("LANG_COMMENTS", $this->lng->txt('poll_comments'));
328  $tpl->setVariable("COMMENT_JSCALL", $this->comments->commentJSCall($ref_id));
329  $tpl->setVariable("COMMENTS_COUNT_ID", $ref_id);
330 
331  $comments_count = $this->comments->getNumberOfComments($ref_id);
332 
333  if ($comments_count > 0) {
334  $tpl->setVariable("COMMENTS_COUNT", "(" . $comments_count . ")");
335  }
336 
337  $tpl->setVariable("COMMENTS_REDRAW_URL", $this->comments->getRedrawURL());
338  }
$ref_id
Definition: ltiauth.php:67
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderDescription()

ilPollContentRenderer::renderDescription ( ilTemplate  $tpl,
string  $description 
)
protected

Definition at line 300 of file class.ilPollContentRenderer.php.

References HTML_Template_IT\setVariable(), and specialCharsAsEntities().

Referenced by render().

303  : void {
304  $description = trim($description);
305  if ($description) {
306  $tpl->setVariable(
307  "TXT_DESC",
308  nl2br($this->specialCharsAsEntities($description))
309  );
310  }
311  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderMiscVoteInfo()

ilPollContentRenderer::renderMiscVoteInfo ( ilTemplate  $tpl,
?int  $answer_limit,
int  $deadline 
)
protected

Definition at line 234 of file class.ilPollContentRenderer.php.

References getFormattedDate(), ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by renderAnswers().

238  : void {
239  $infos = [];
240 
241  if ($answer_limit) {
242  $infos[] = sprintf(
243  $this->lng->txt('poll_max_number_of_answers_info'),
244  $answer_limit
245  );
246  }
247 
248  if ($deadline) {
249  $infos[] = sprintf(
250  $this->lng->txt("poll_voting_period_info"),
251  $this->getFormattedDate($deadline)
252  );
253  }
254 
255  if ($infos) {
256  $tpl->setVariable('VOTE_INFO', implode(' ', $infos));
257  }
258  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderNoQuestionMessage()

ilPollContentRenderer::renderNoQuestionMessage ( ilTemplate  $tpl)
protected

Definition at line 285 of file class.ilPollContentRenderer.php.

References getMessageBox(), ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by render().

285  : void
286  {
287  $tpl->setVariable(
288  "MESSAGE_BOX",
289  $this->getMessageBox(
290  $this->lng->txt("poll_block_message_no_answers")
291  )
292  );
293  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderNotAbleToVoteMessage()

ilPollContentRenderer::renderNotAbleToVoteMessage ( ilTemplate  $tpl,
bool  $has_voted,
bool  $results_in_future,
int  $voting_end_date 
)
protected

Definition at line 185 of file class.ilPollContentRenderer.php.

References $messages, getFormattedDate(), getMessageBox(), ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by renderAnswersAndResults().

190  : void {
191  $messages = [];
192 
193  if ($has_voted) {
194  $messages[] = $this->lng->txt("poll_block_message_already_voted");
195  } else {
196  $messages[] = sprintf(
197  $this->lng->txt("poll_voting_period_ended_info"),
198  $this->getFormattedDate($voting_end_date)
199  );
200  }
201 
202  if ($results_in_future && $has_voted) {
203  $messages[] = sprintf(
204  $this->lng->txt("poll_block_results_available_on"),
205  $this->getFormattedDate($voting_end_date)
206  );
207  }
208 
209  $tpl->setVariable(
210  "MESSAGE_BOX",
211  $this->getMessageBox(
212  implode(' ', $messages)
213  )
214  );
215  }
$messages
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: xapiexit.php:22
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderNotWithinVotingPeriodMessage()

ilPollContentRenderer::renderNotWithinVotingPeriodMessage ( ilTemplate  $tpl,
int  $vote_start,
int  $vote_end 
)
protected

Definition at line 272 of file class.ilPollContentRenderer.php.

References $message, getFormattedDate(), getMessageBox(), ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by render().

276  : void {
277  $message = sprintf(
278  $this->lng->txt("poll_voting_period_full_info"),
279  $this->getFormattedDate($vote_start),
280  $this->getFormattedDate($vote_end)
281  );
282  $tpl->setVariable("MESSAGE_BOX", $this->getMessageBox($message));
283  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderQuestion()

ilPollContentRenderer::renderQuestion ( ilTemplate  $tpl,
string  $text,
?string  $img_path 
)
protected

Definition at line 217 of file class.ilPollContentRenderer.php.

References HTML_Template_IT\setVariable(), ilWACSignedPath\signFile(), and specialCharsAsEntities().

Referenced by render().

221  : void {
222  $tpl->setVariable(
223  "TXT_QUESTION",
224  $this->specialCharsAsEntities(nl2br(trim($text)))
225  );
226  if ($img_path) {
227  $tpl->setVariable(
228  "URL_IMAGE",
229  ilWACSignedPath::signFile($img_path)
230  );
231  }
232  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
static signFile(string $path_to_file)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderResults()

ilPollContentRenderer::renderResults ( ilTemplate  $tpl,
ilObjPoll  $poll 
)
protected

Definition at line 157 of file class.ilPollContentRenderer.php.

References ilObjPoll\getShowResultsAs().

Referenced by renderAnswersAndResults().

160  : void {
161  $this->results_renderer->render(
162  $tpl,
163  $this->results,
164  $poll->getShowResultsAs()
165  );
166  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderTotalParticipantsInfo()

ilPollContentRenderer::renderTotalParticipantsInfo ( ilTemplate  $tpl,
int  $total 
)
protected

Definition at line 168 of file class.ilPollContentRenderer.php.

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by renderAnswersAndResults().

171  : void {
172  if ($total === 1) {
173  $tpl->setVariable(
174  "TOTAL_ANSWERS",
175  $this->lng->txt("poll_population_singular")
176  );
177  return;
178  }
179  $tpl->setVariable(
180  "TOTAL_ANSWERS",
181  sprintf($this->lng->txt("poll_population"), $total)
182  );
183  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ specialCharsAsEntities()

ilPollContentRenderer::specialCharsAsEntities ( string  $string)
protected

Definition at line 354 of file class.ilPollContentRenderer.php.

Referenced by renderDescription(), and renderQuestion().

354  : string
355  {
356  // Should be replaced by a proper refinery transformation once https://github.com/ILIAS-eLearning/ILIAS/pull/6314 is merged
357  return htmlspecialchars(
358  $string,
359  ENT_QUOTES | ENT_SUBSTITUTE,
360  'utf-8'
361  );
362  }
+ Here is the caller graph for this function:

Field Documentation

◆ $answers

ilPollAnswersHandler ilPollContentRenderer::$answers
protected

Definition at line 29 of file class.ilPollContentRenderer.php.

Referenced by __construct().

◆ $answers_renderer

ilPollAnswersRenderer ilPollContentRenderer::$answers_renderer
protected

Definition at line 30 of file class.ilPollContentRenderer.php.

Referenced by __construct().

◆ $comments

ilPollCommentsHandler ilPollContentRenderer::$comments
protected

Definition at line 28 of file class.ilPollContentRenderer.php.

Referenced by __construct().

◆ $lng

ilLanguage ilPollContentRenderer::$lng
protected

Definition at line 33 of file class.ilPollContentRenderer.php.

Referenced by __construct().

◆ $results

ilPollResultsHandler ilPollContentRenderer::$results
protected

Definition at line 31 of file class.ilPollContentRenderer.php.

Referenced by __construct().

◆ $results_renderer

ilPollResultsRenderer ilPollContentRenderer::$results_renderer
protected

Definition at line 32 of file class.ilPollContentRenderer.php.

Referenced by __construct().

◆ $state

ilPollStateInfo ilPollContentRenderer::$state
protected

Definition at line 27 of file class.ilPollContentRenderer.php.

◆ $ui_factory

UIFactory ilPollContentRenderer::$ui_factory
protected

Definition at line 34 of file class.ilPollContentRenderer.php.

Referenced by __construct().

◆ $ui_renderer

UIRenderer ilPollContentRenderer::$ui_renderer
protected

Definition at line 35 of file class.ilPollContentRenderer.php.

Referenced by __construct().


The documentation for this class was generated from the following file: