ILIAS  trunk Revision v11.0_alpha-1862-g4e205cb56d4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPollStateInfo Class Reference
+ 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

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

Member Function Documentation

◆ areResultsVisible()

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

Definition at line 95 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.

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

◆ hasQuestion()

ilPollStateInfo::hasQuestion ( ilObjPoll  $poll)

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

References ilObjPoll\getAnswers().

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

◆ hasUserAlreadyVoted()

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

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

References $user_id, and ilObjPoll\hasUserVoted().

Referenced by areResultsVisible().

77  : bool
78  {
79  if (!array_key_exists($user_id, $this->cached_user_status)) {
80  $this->cached_user_status[$user_id] = $poll->hasUserVoted($user_id);
81  }
82  return $this->cached_user_status[$user_id];
83  }
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 64 of file class.ilPollStateInfo.php.

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

Referenced by areResultsVisible(), and willResultsBeShown().

67  : bool {
68  if (!$poll->getVotingPeriod()) {
69  return $default;
70  }
71  if ($poll->getVotingPeriodEnd() < time()) {
72  return true;
73  }
74  return false;
75  }
+ 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 48 of file class.ilPollStateInfo.php.

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

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

◆ isOfflineOrUnavailable()

ilPollStateInfo::isOfflineOrUnavailable ( ilObjPoll  $poll)

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

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

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

◆ isUserAnonymous()

ilPollStateInfo::isUserAnonymous ( int  $user_id)

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

References ANONYMOUS_USER_ID.

Referenced by mayUserVote().

90  : bool
91  {
92  return $user_id === ANONYMOUS_USER_ID;
93  }
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 85 of file class.ilPollStateInfo.php.

References isUserAnonymous().

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

◆ willResultsBeShown()

ilPollStateInfo::willResultsBeShown ( ilObjPoll  $poll)

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

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

116  : bool
117  {
118  if (
120  $this->hasVotingPeriodEnded($poll, false)
121  ) {
122  return false;
123  }
124  return true;
125  }
const int 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 23 of file class.ilPollStateInfo.php.


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