ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilPollStateInfo 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 ilPollStateInfo:

Public Member Functions

 isOfflineOrUnavailable (ilObjPoll $poll)
 
 hasQuestion (ilObjPoll $poll)
 
 hasVotingPeriodNotStarted (ilObjPoll $poll, bool $default)
 returns default if no voting period is set More...
 
 hasVotingPeriodEnded (ilObjPoll $poll, bool $default)
 returns default if no voting period is set More...
 
 hasUserAlreadyVoted (int $user_id, ilObjPoll $poll)
 
 mayUserVote (int $user_id)
 
 isUserAnonymous (int $user_id)
 
 areResultsVisible (int $user_id, ilObjPoll $poll)
 
 willResultsBeShown (ilObjPoll $poll)
 

Protected Attributes

array $cached_user_status = []
 

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 22 of file class.ilPollStateInfo.php.

Member Function Documentation

◆ areResultsVisible()

ilPollStateInfo::areResultsVisible ( int  $user_id,
ilObjPoll  $poll 
)

Definition at line 96 of file class.ilPollStateInfo.php.

References ilObjPoll\getViewResults(), hasUserAlreadyVoted(), hasVotingPeriodEnded(), ilObjPoll\VIEW_RESULTS_AFTER_PERIOD, ilObjPoll\VIEW_RESULTS_AFTER_VOTE, ilObjPoll\VIEW_RESULTS_ALWAYS, and ilObjPoll\VIEW_RESULTS_NEVER.

96  : bool
97  {
98  switch ($poll->getViewResults()) {
100  return false;
101 
103  return true;
104 
106  return $this->hasVotingPeriodEnded($poll, true);
107 
109  if ($this->hasUserAlreadyVoted($user_id, $poll)) {
110  return true;
111  }
112  return false;
113  }
114  return false;
115  }
const VIEW_RESULTS_AFTER_PERIOD
const VIEW_RESULTS_AFTER_VOTE
const VIEW_RESULTS_NEVER
const VIEW_RESULTS_ALWAYS
hasUserAlreadyVoted(int $user_id, ilObjPoll $poll)
hasVotingPeriodEnded(ilObjPoll $poll, bool $default)
returns default if no voting period is set
+ Here is the call graph for this function:

◆ hasQuestion()

ilPollStateInfo::hasQuestion ( ilObjPoll  $poll)

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

References ilObjPoll\getAnswers().

38  : bool
39  {
40  if (count($poll->getAnswers())) {
41  return true;
42  }
43  return false;
44  }
+ Here is the call graph for this function:

◆ hasUserAlreadyVoted()

ilPollStateInfo::hasUserAlreadyVoted ( int  $user_id,
ilObjPoll  $poll 
)

Definition at line 78 of file class.ilPollStateInfo.php.

References ilObjPoll\hasUserVoted().

Referenced by areResultsVisible().

78  : bool
79  {
80  if (!array_key_exists($user_id, $this->cached_user_status)) {
81  $this->cached_user_status[$user_id] = $poll->hasUserVoted($user_id);
82  }
83  return $this->cached_user_status[$user_id];
84  }
hasUserVoted(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasVotingPeriodEnded()

ilPollStateInfo::hasVotingPeriodEnded ( ilObjPoll  $poll,
bool  $default 
)

returns default if no voting period is set

Definition at line 65 of file class.ilPollStateInfo.php.

References ilObjPoll\getVotingPeriod(), and ilObjPoll\getVotingPeriodEnd().

Referenced by areResultsVisible(), and willResultsBeShown().

68  : bool {
69  if (!$poll->getVotingPeriod()) {
70  return $default;
71  }
72  if ($poll->getVotingPeriodEnd() < time()) {
73  return true;
74  }
75  return false;
76  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasVotingPeriodNotStarted()

ilPollStateInfo::hasVotingPeriodNotStarted ( ilObjPoll  $poll,
bool  $default 
)

returns default if no voting period is set

Definition at line 49 of file class.ilPollStateInfo.php.

References ilObjPoll\getVotingPeriod(), and ilObjPoll\getVotingPeriodBegin().

52  : bool {
53  if (!$poll->getVotingPeriod()) {
54  return $default;
55  }
56  if ($poll->getVotingPeriodBegin() > time()) {
57  return true;
58  }
59  return false;
60  }
+ Here is the call graph for this function:

◆ isOfflineOrUnavailable()

ilPollStateInfo::isOfflineOrUnavailable ( ilObjPoll  $poll)

Definition at line 26 of file class.ilPollStateInfo.php.

References ilObjPoll\getAccessBegin(), ilObjPoll\getAccessEnd(), ilObjPoll\getAccessType(), ilObject\getOfflineStatus(), and ilObjectActivation\TIMINGS_ACTIVATION.

26  : bool
27  {
28  $offline = $poll->getOfflineStatus();
29  $before_start = false;
30  $after_end = false;
32  $before_start = $poll->getAccessBegin() > time();
33  $after_end = $poll->getAccessEnd() < time();
34  }
35  return $offline || $before_start || $after_end;
36  }
+ Here is the call graph for this function:

◆ isUserAnonymous()

ilPollStateInfo::isUserAnonymous ( int  $user_id)

Definition at line 91 of file class.ilPollStateInfo.php.

References ANONYMOUS_USER_ID.

Referenced by mayUserVote().

91  : bool
92  {
93  return $user_id === ANONYMOUS_USER_ID;
94  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
+ Here is the caller graph for this function:

◆ mayUserVote()

ilPollStateInfo::mayUserVote ( int  $user_id)

Definition at line 86 of file class.ilPollStateInfo.php.

References isUserAnonymous().

86  : bool
87  {
88  return !$this->isUserAnonymous($user_id);
89  }
isUserAnonymous(int $user_id)
+ Here is the call graph for this function:

◆ willResultsBeShown()

ilPollStateInfo::willResultsBeShown ( ilObjPoll  $poll)

Definition at line 117 of file class.ilPollStateInfo.php.

References ilObjPoll\getViewResults(), hasVotingPeriodEnded(), and ilObjPoll\VIEW_RESULTS_AFTER_PERIOD.

117  : bool
118  {
119  if (
121  $this->hasVotingPeriodEnded($poll, false)
122  ) {
123  return false;
124  }
125  return true;
126  }
const VIEW_RESULTS_AFTER_PERIOD
hasVotingPeriodEnded(ilObjPoll $poll, bool $default)
returns default if no voting period is set
+ Here is the call graph for this function:

Field Documentation

◆ $cached_user_status

array ilPollStateInfo::$cached_user_status = []
protected

Definition at line 24 of file class.ilPollStateInfo.php.


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