ILIAS  release_8 Revision v8.24
ilPollBlock Class Reference

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

+ Inheritance diagram for ilPollBlock:
+ Collaboration diagram for ilPollBlock:

Public Member Functions

 __construct (int $a_id=0)
 
 setRefId (int $a_id)
 Set ref id (needed for poll access) More...
 
 getPoll ()
 
 hasAnyContent (int $a_user_id, int $a_ref_id)
 Check if user will see any content (vote/result) More...
 
 maySeeQuestion ($a_user_id)
 
 mayVote ($a_user_id)
 
 mayNotResultsYet ()
 
 maySeeResults (int $a_user_id)
 
 getMessage (int $a_user_id)
 
 showResultsAs ()
 Show Results as (Barchart or Piechart) More...
 
 showComments ()
 Are comments enabled or disabled. More...
 
- Public Member Functions inherited from ilCustomBlock
 __construct (int $a_id=0)
 
 setId (int $a_id)
 
 getId ()
 
 setContextObjId (int $a_context_obj_id)
 
 getContextObjId ()
 
 setContextObjType (string $a_context_obj_type)
 
 getContextObjType ()
 
 setContextSubObjId (int $a_context_sub_obj_id)
 
 getContextSubObjId ()
 
 setContextSubObjType (string $a_context_sub_obj_type)
 
 getContextSubObjType ()
 
 setType (string $a_type)
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 create ()
 
 read ()
 
 update ()
 
 delete ()
 
 queryBlocksForContext (bool $a_include_sub_obj=true)
 Query BlocksForContext. More...
 
 queryCntBlockForContext ()
 

Protected Attributes

ilLanguage $lng
 
ilObjPoll $poll
 
array $answers = []
 
bool $visible = false
 
bool $active = false
 
- Protected Attributes inherited from ilCustomBlock
ilDBInterface $db
 
int $id = 0
 
int $context_obj_id = 0
 
string $context_obj_type = ""
 
int $context_sub_obj_id = 0
 
string $context_sub_obj_type = ""
 
string $type = ""
 
string $title = ""
 

Additional Inherited Members

- Static Public Member Functions inherited from ilCustomBlock
static multiBlockQuery (string $a_context_obj_type, array $a_context_obj_ids)
 

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 Custom block for polls

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilPollBlock::__construct ( int  $a_id = 0)

Reimplemented from ilCustomBlock.

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

36 {
37 global $DIC;
38
40 $this->lng = $DIC->language();
41 }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ getMessage()

ilPollBlock::getMessage ( int  $a_user_id)

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

139 : ?string
140 {
141 if (!count($this->answers)) {
142 return $this->lng->txt("poll_block_message_no_answers");
143 }
144
145 if (!$this->active) {
146 if ($this->poll->getOfflineStatus()) {
147 return $this->lng->txt("poll_block_message_offline");
148 }
149 if ($this->poll->getAccessBegin() > time()) {
150 $date = ilDatePresentation::formatDate(new ilDateTime($this->poll->getAccessBegin(), IL_CAL_UNIX));
151 return sprintf($this->lng->txt("poll_block_message_inactive"), $date);
152 }
153 }
154
155 return null;
156 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling

References ilDatePresentation\formatDate(), IL_CAL_UNIX, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getPoll()

ilPollBlock::getPoll ( )

Definition at line 52 of file class.ilPollBlock.php.

52 : ilObjPoll
53 {
54 return $this->poll;
55 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $poll.

◆ hasAnyContent()

ilPollBlock::hasAnyContent ( int  $a_user_id,
int  $a_ref_id 
)

Check if user will see any content (vote/result)

Definition at line 60 of file class.ilPollBlock.php.

60 : bool
61 {
62 if (!count($this->answers)) {
63 return false;
64 }
65
66 $this->active = ilObjPollAccess::_isActivated($a_ref_id);
67 if (!$this->active) {
68 return false;
69 }
70
71 if (!$this->maySeeQuestion($a_user_id) &&
72 !$this->maySeeResults($a_user_id)) {
73 return false;
74 }
75
76 return true;
77 }
static _isActivated(int $a_ref_id)
maySeeResults(int $a_user_id)
maySeeQuestion($a_user_id)

References ilObjPollAccess\_isActivated(), maySeeQuestion(), and maySeeResults().

+ Here is the call graph for this function:

◆ mayNotResultsYet()

ilPollBlock::mayNotResultsYet ( )

Definition at line 103 of file class.ilPollBlock.php.

103 : bool
104 {
105 if ($this->poll->getViewResults() === ilObjPoll::VIEW_RESULTS_AFTER_PERIOD &&
106 $this->poll->getVotingPeriod() &&
107 $this->poll->getVotingPeriodEnd() > time()) {
108 return true;
109 }
110 return false;
111 }
const VIEW_RESULTS_AFTER_PERIOD

References ilObjPoll\VIEW_RESULTS_AFTER_PERIOD.

◆ maySeeQuestion()

ilPollBlock::maySeeQuestion (   $a_user_id)

Definition at line 79 of file class.ilPollBlock.php.

79 : bool
80 {
81 if (!$this->active) {
82 return false;
83 }
84
85 if ($this->poll->hasUserVoted($a_user_id)) {
86 return false;
87 }
88
89 if ($this->poll->getVotingPeriod() &&
90 ($this->poll->getVotingPeriodBegin() > time() ||
91 $this->poll->getVotingPeriodEnd() < time())) {
92 return false;
93 }
94
95 return true;
96 }

Referenced by hasAnyContent(), and mayVote().

+ Here is the caller graph for this function:

◆ maySeeResults()

ilPollBlock::maySeeResults ( int  $a_user_id)

Definition at line 113 of file class.ilPollBlock.php.

113 : bool
114 {
115 if (!$this->active) {
116 return false;
117 }
118
119 switch ($this->poll->getViewResults()) {
121 return false;
122
124 // fallthrough
125
126 // #12023 - see mayNotResultsYet()
128 return true;
129
131 if ($this->poll->hasUserVoted($a_user_id)) {
132 return true;
133 }
134 return false;
135 }
136 return false;
137 }
const VIEW_RESULTS_ALWAYS
const VIEW_RESULTS_AFTER_VOTE
const VIEW_RESULTS_NEVER

References ilObjPoll\VIEW_RESULTS_AFTER_PERIOD, ilObjPoll\VIEW_RESULTS_AFTER_VOTE, ilObjPoll\VIEW_RESULTS_ALWAYS, and ilObjPoll\VIEW_RESULTS_NEVER.

Referenced by hasAnyContent().

+ Here is the caller graph for this function:

◆ mayVote()

ilPollBlock::mayVote (   $a_user_id)

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

98 : bool
99 {
100 return $this->maySeeQuestion($a_user_id) && $a_user_id != ANONYMOUS_USER_ID;
101 }
const ANONYMOUS_USER_ID
Definition: constants.php:27

References ANONYMOUS_USER_ID, and maySeeQuestion().

+ Here is the call graph for this function:

◆ setRefId()

ilPollBlock::setRefId ( int  $a_id)

Set ref id (needed for poll access)

Definition at line 46 of file class.ilPollBlock.php.

46 : void
47 {
48 $this->poll = new ilObjPoll($a_id, true);
49 $this->answers = $this->poll->getAnswers();
50 }

◆ showComments()

ilPollBlock::showComments ( )

Are comments enabled or disabled.

Definition at line 169 of file class.ilPollBlock.php.

169 : bool
170 {
171 return $this->poll->getShowComments();
172 }

◆ showResultsAs()

ilPollBlock::showResultsAs ( )

Show Results as (Barchart or Piechart)

Definition at line 161 of file class.ilPollBlock.php.

161 : int
162 {
163 return $this->poll->getShowResultsAs();
164 }

Field Documentation

◆ $active

bool ilPollBlock::$active = false
protected

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

◆ $answers

array ilPollBlock::$answers = []
protected

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

◆ $lng

ilLanguage ilPollBlock::$lng
protected

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

◆ $poll

ilObjPoll ilPollBlock::$poll
protected

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

Referenced by getPoll().

◆ $visible

bool ilPollBlock::$visible = false
protected

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


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