ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilPollContentRenderer Class Reference
+ Collaboration diagram for ilPollContentRenderer:

Public Member Functions

 __construct (ilLanguage $lng, UIFactory $ui_factory, UIRenderer $ui_renderer, Refinery $refinery, ilPollStateInfo $availability, ilPollCommentsHandler $comments, ilPollAnswersHandler $answers, ilPollAnswersRenderer $answers_renderer, ilPollResultsHandler $results, ilPollResultsRenderer $results_renderer, ilPollImageFactoryInterface $poll_image_factory)
 
 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)
 

Protected Attributes

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

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

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

54  {
55  $this->lng = $lng;
56  $this->ui_factory = $ui_factory;
57  $this->ui_renderer = $ui_renderer;
58  $this->refinery = $refinery;
59  $this->state = $availability;
60  $this->comments = $comments;
61  $this->answers = $answers;
62  $this->answers_renderer = $answers_renderer;
63  $this->results = $results;
64  $this->results_renderer = $results_renderer;
65  $this->poll_image_factory = $poll_image_factory;
66  }
ilPollImageFactoryInterface $poll_image_factory
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 356 of file class.ilPollContentRenderer.php.

References ilDatePresentation\formatDate(), and IL_CAL_UNIX.

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

356  : string
357  {
359  new ilDateTime($date, IL_CAL_UNIX)
360  );
361  }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ilObjUser $user=null,)
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 349 of file class.ilPollContentRenderer.php.

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

349  : string
350  {
351  return $this->ui_renderer->render(
352  $this->ui_factory->messageBox()->info($message)
353  );
354  }
+ 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 68 of file class.ilPollContentRenderer.php.

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

74  : void {
75  $this->renderAnchor($tpl, $poll->getId());
76  $this->renderAvailability($tpl, $poll);
77  $this->renderDescription($tpl, $poll->getLongDescription());
78 
79  if (!$this->state->hasQuestion($poll)) {
80  $this->renderNoQuestionMessage($tpl);
81  } elseif ($this->state->hasVotingPeriodNotStarted($poll, false)) {
83  $tpl,
84  $poll->getVotingPeriodBegin(),
85  $poll->getVotingPeriodEnd()
86  );
87  } else {
88  $this->renderQuestion(
89  $tpl,
90  $poll->getQuestion(),
91  $this->poll_image_factory->handler()->getProcessedImageURL(new ObjectId($poll->getId()))
92  );
93  if (!$admin_view) {
94  $this->renderAnswersAndResults($tpl, $poll, $user_id);
95  }
96  }
97 
98  if ($poll->getShowComments()) {
99  $this->renderComments($tpl, $ref_id);
100  }
101 
102  if ($this->state->isUserAnonymous($user_id)) {
103  $this->renderAlertForAnonymousUser($tpl);
104  }
105  }
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:66
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)
+ Here is the call graph for this function:

◆ renderAlertForAnonymousUser()

ilPollContentRenderer::renderAlertForAnonymousUser ( ilTemplate  $tpl)
protected

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

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

Referenced by render().

329  : void
330  {
331  $tpl->setVariable("TXT_ANON", $this->lng->txt('no_access_item_public'));
332  }
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 304 of file class.ilPollContentRenderer.php.

References HTML_Template_IT\setVariable().

Referenced by render().

304  : void
305  {
306  $tpl->setVariable("ANCHOR_ID", $obj_id);
307  }
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 269 of file class.ilPollContentRenderer.php.

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

Referenced by renderAnswers().

272  : void {
273  if ($anonymous) {
274  $info = $this->lng->txt("poll_anonymous_warning");
275  } else {
276  $info = $this->lng->txt("poll_non_anonymous_warning");
277  }
278  $tpl->setVariable("ANONIMITY_INFO", $info);
279  }
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 148 of file class.ilPollContentRenderer.php.

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

Referenced by renderAnswersAndResults().

152  : void {
153  $this->renderMiscVoteInfo(
154  $tpl,
155  $this->answers->getAnswerLimitForInfo(),
156  $poll->getVotingPeriodEnd()
157  );
158  $this->answers_renderer->render(
159  $tpl,
160  $this->answers,
161  !$this->state->mayUserVote($user_id)
162  );
163  $this->renderAnonimityInfo($tpl, !$poll->getNonAnonymous());
164  }
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 107 of file class.ilPollContentRenderer.php.

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

Referenced by render().

111  : void {
112  $either_is_shown = false;
113  if (
114  !$this->state->hasUserAlreadyVoted($user_id, $poll) &&
115  !$this->state->hasVotingPeriodEnded($poll, false)
116  ) {
117  $this->renderAnswers($tpl, $poll, $user_id);
118  $either_is_shown = true;
119  }
120 
121  if (
122  $this->state->areResultsVisible($user_id, $poll) &&
123  $this->results->getTotalVotes()
124  ) {
125  $this->renderResults($tpl, $poll);
127  $tpl,
128  $this->results->getTotalVotes()
129  );
130  $either_is_shown = true;
131  } elseif ($this->state->areResultsVisible($user_id, $poll)) {
133  $tpl,
134  $this->results->getTotalVotes()
135  );
136  }
137 
138  if (!$either_is_shown) {
140  $tpl,
141  $this->state->hasUserAlreadyVoted($user_id, $poll),
142  $this->state->willResultsBeShown($poll),
143  $poll->getVotingPeriodEnd()
144  );
145  }
146  }
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 322 of file class.ilPollContentRenderer.php.

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

Referenced by render().

322  : void
323  {
324  if ($this->state->isOfflineOrUnavailable($poll)) {
325  $tpl->setVariable("TXT_OFFLINE", $this->lng->txt('offline'));
326  }
327  }
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 334 of file class.ilPollContentRenderer.php.

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

Referenced by render().

334  : void
335  {
336  $tpl->setVariable("LANG_COMMENTS", $this->lng->txt('poll_comments'));
337  $tpl->setVariable("COMMENT_JSCALL", $this->comments->commentJSCall($ref_id));
338  $tpl->setVariable("COMMENTS_COUNT_ID", $ref_id);
339 
340  $comments_count = $this->comments->getNumberOfComments($ref_id);
341 
342  if ($comments_count > 0) {
343  $tpl->setVariable("COMMENTS_COUNT", "(" . $comments_count . ")");
344  }
345 
346  $tpl->setVariable("COMMENTS_REDRAW_URL", $this->comments->getRedrawURL());
347  }
$ref_id
Definition: ltiauth.php:66
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 309 of file class.ilPollContentRenderer.php.

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

Referenced by render().

312  : void {
313  $description = trim($description);
314  if ($description) {
315  $tpl->setVariable(
316  "TXT_DESC",
317  nl2br($this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($description))
318  );
319  }
320  }
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 243 of file class.ilPollContentRenderer.php.

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

Referenced by renderAnswers().

247  : void {
248  $infos = [];
249 
250  if ($answer_limit) {
251  $infos[] = sprintf(
252  $this->lng->txt('poll_max_number_of_answers_info'),
253  $answer_limit
254  );
255  }
256 
257  if ($deadline) {
258  $infos[] = sprintf(
259  $this->lng->txt("poll_voting_period_info"),
260  $this->getFormattedDate($deadline)
261  );
262  }
263 
264  if ($infos) {
265  $tpl->setVariable('VOTE_INFO', implode(' ', $infos));
266  }
267  }
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 294 of file class.ilPollContentRenderer.php.

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

Referenced by render().

294  : void
295  {
296  $tpl->setVariable(
297  "MESSAGE_BOX",
298  $this->getMessageBox(
299  $this->lng->txt("poll_block_message_no_answers")
300  )
301  );
302  }
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 194 of file class.ilPollContentRenderer.php.

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

Referenced by renderAnswersAndResults().

199  : void {
200  $messages = [];
201 
202  if ($has_voted) {
203  $messages[] = $this->lng->txt("poll_block_message_already_voted");
204  } else {
205  $messages[] = sprintf(
206  $this->lng->txt("poll_voting_period_ended_info"),
207  $this->getFormattedDate($voting_end_date)
208  );
209  }
210 
211  if ($results_in_future && $has_voted) {
212  $messages[] = sprintf(
213  $this->lng->txt("poll_block_results_available_on"),
214  $this->getFormattedDate($voting_end_date)
215  );
216  }
217 
218  $tpl->setVariable(
219  "MESSAGE_BOX",
220  $this->getMessageBox(
221  implode(' ', $messages)
222  )
223  );
224  }
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 281 of file class.ilPollContentRenderer.php.

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

Referenced by render().

285  : void {
286  $message = sprintf(
287  $this->lng->txt("poll_voting_period_full_info"),
288  $this->getFormattedDate($vote_start),
289  $this->getFormattedDate($vote_end)
290  );
291  $tpl->setVariable("MESSAGE_BOX", $this->getMessageBox($message));
292  }
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:

◆ renderQuestion()

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

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

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

Referenced by render().

230  : void {
231  $tpl->setVariable(
232  "TXT_QUESTION",
233  $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform(nl2br(trim($text)))
234  );
235  if ($img_path) {
236  $tpl->setVariable(
237  "URL_IMAGE",
238  $img_path
239  );
240  }
241  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
$text
Definition: xapiexit.php:21
+ 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 166 of file class.ilPollContentRenderer.php.

References ilObjPoll\getShowResultsAs().

Referenced by renderAnswersAndResults().

169  : void {
170  $this->results_renderer->render(
171  $tpl,
172  $this->results,
173  $poll->getShowResultsAs()
174  );
175  }
+ 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 177 of file class.ilPollContentRenderer.php.

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

Referenced by renderAnswersAndResults().

180  : void {
181  if ($total === 1) {
182  $tpl->setVariable(
183  "TOTAL_ANSWERS",
184  $this->lng->txt("poll_population_singular")
185  );
186  return;
187  }
188  $tpl->setVariable(
189  "TOTAL_ANSWERS",
190  sprintf($this->lng->txt("poll_population"), $total)
191  );
192  }
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:

Field Documentation

◆ $answers

ilPollAnswersHandler ilPollContentRenderer::$answers
protected

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

Referenced by __construct().

◆ $answers_renderer

ilPollAnswersRenderer ilPollContentRenderer::$answers_renderer
protected

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

Referenced by __construct().

◆ $comments

ilPollCommentsHandler ilPollContentRenderer::$comments
protected

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

Referenced by __construct().

◆ $lng

ilLanguage ilPollContentRenderer::$lng
protected

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

Referenced by __construct().

◆ $poll_image_factory

ilPollImageFactoryInterface ilPollContentRenderer::$poll_image_factory
protected

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

Referenced by __construct().

◆ $refinery

Refinery ilPollContentRenderer::$refinery
protected

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

Referenced by __construct().

◆ $results

ilPollResultsHandler ilPollContentRenderer::$results
protected

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

Referenced by __construct().

◆ $results_renderer

ilPollResultsRenderer ilPollContentRenderer::$results_renderer
protected

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

Referenced by __construct().

◆ $state

ilPollStateInfo ilPollContentRenderer::$state
protected

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

◆ $ui_factory

UIFactory ilPollContentRenderer::$ui_factory
protected

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

Referenced by __construct().

◆ $ui_renderer

UIRenderer ilPollContentRenderer::$ui_renderer
protected

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

Referenced by __construct().


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