ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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_AFTER_VOTE
const int VIEW_RESULTS_ALWAYS
const int VIEW_RESULTS_NEVER
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

References $user_id, ilObjPoll\getViewResults(), ilObjPoll\VIEW_RESULTS_AFTER_PERIOD, ilObjPoll\VIEW_RESULTS_AFTER_VOTE, ilObjPoll\VIEW_RESULTS_ALWAYS, and ilObjPoll\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.

37 : bool
38 {
39 if (count($poll->getAnswers())) {
40 return true;
41 }
42 return false;
43 }

References ilObjPoll\getAnswers().

+ 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.

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)

References $user_id, and ilObjPoll\hasUserVoted().

+ Here is the call 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.

67 : bool {
68 if (!$poll->getVotingPeriod()) {
69 return $default;
70 }
71 if ($poll->getVotingPeriodEnd() < time()) {
72 return true;
73 }
74 return false;
75 }

◆ hasVotingPeriodNotStarted()

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

returns default if no voting period is set

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

51 : bool {
52 if (!$poll->getVotingPeriod()) {
53 return $default;
54 }
55 if ($poll->getVotingPeriodBegin() > time()) {
56 return true;
57 }
58 return false;
59 }

◆ isOfflineOrUnavailable()

ilPollStateInfo::isOfflineOrUnavailable ( ilObjPoll  $poll)

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

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 }

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

+ Here is the call graph for this function:

◆ isUserAnonymous()

ilPollStateInfo::isUserAnonymous ( int  $user_id)

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

90 : bool
91 {
92 return $user_id === ANONYMOUS_USER_ID;
93 }
const ANONYMOUS_USER_ID
Definition: constants.php:27

References $user_id, and ANONYMOUS_USER_ID.

◆ mayUserVote()

ilPollStateInfo::mayUserVote ( int  $user_id)

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

85 : bool
86 {
87 return !$this->isUserAnonymous($user_id);
88 }
isUserAnonymous(int $user_id)

References $user_id.

◆ willResultsBeShown()

ilPollStateInfo::willResultsBeShown ( ilObjPoll  $poll)

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

116 : bool
117 {
118 if (
120 $this->hasVotingPeriodEnded($poll, false)
121 ) {
122 return false;
123 }
124 return true;
125 }

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

+ 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: