ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilPollBlock Class Reference

Custom block for polls. More...

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

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 setRefId ($a_id)
 Set ref id (needed for poll access) More...
 
 getPoll ()
 Get poll object. More...
 
 hasAnyContent ($a_user_id, $a_ref_id)
 Check if user will see any content (vote/result) More...
 
 mayVote ($a_user_id)
 
 mayNotResultsYet ()
 
 maySeeResults ($a_user_id)
 
 getMessage ($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 ($a_id=0)
 Constructor. More...
 
 setId ($a_id)
 Set Id. More...
 
 getId ()
 Get Id. More...
 
 setContextObjId ($a_context_obj_id)
 Set ContextObjId. More...
 
 getContextObjId ()
 Get ContextObjId. More...
 
 setContextObjType ($a_context_obj_type)
 Set ContextObjType. More...
 
 getContextObjType ()
 Get ContextObjType. More...
 
 setContextSubObjId ($a_context_sub_obj_id)
 Set ContextSubObjId. More...
 
 getContextSubObjId ()
 Get ContextSubObjId. More...
 
 setContextSubObjType ($a_context_sub_obj_type)
 Set ContextSubObjType. More...
 
 getContextSubObjType ()
 Get ContextSubObjType. More...
 
 setType ($a_type)
 Set Type. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 create ()
 Create new item. More...
 
 read ()
 Read item from database. More...
 
 update ()
 Update item in database. More...
 
 delete ()
 Delete item from database. More...
 
 querygetBlocksForContext ()
 Query getBlocksForContext. More...
 
 queryBlocksForContext ($a_include_sub_obj=true)
 Query BlocksForContext. More...
 
 queryTitleForId ()
 Query TitleForId. More...
 
 queryCntBlockForContext ()
 Query CntBlockForContext. More...
 

Protected Attributes

 $lng
 
 $poll
 
 $answers
 
 $visible
 
 $active
 
- Protected Attributes inherited from ilCustomBlock
 $db
 
 $id
 
 $context_obj_id
 
 $context_obj_type
 
 $context_sub_obj_id
 
 $context_sub_obj_type
 
 $type
 
 $title
 

Additional Inherited Members

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

Detailed Description

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilPollBlock::__construct (   $a_id = 0)

Constructor.

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

References $DIC.

24  {
25  global $DIC;
26 
27  parent::__construct($a_id);
28  $this->lng = $DIC->language();
29  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ getMessage()

ilPollBlock::getMessage (   $a_user_id)

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

References $lng, ilDatePresentation\formatDate(), and IL_CAL_UNIX.

143  {
144  $lng = $this->lng;
145 
146  if (!sizeof($this->answers)) {
147  return $lng->txt("poll_block_message_no_answers");
148  }
149 
150  if (!$this->active) {
151  if (!$this->poll->isOnline()) {
152  return $lng->txt("poll_block_message_offline");
153  }
154  if ($this->poll->getAccessBegin() > time()) {
155  $date = ilDatePresentation::formatDate(new ilDateTime($this->poll->getAccessBegin(), IL_CAL_UNIX));
156  return sprintf($lng->txt("poll_block_message_inactive"), $date);
157  }
158  }
159  }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
Date and time handling
+ Here is the call graph for this function:

◆ getPoll()

ilPollBlock::getPoll ( )

Get poll object.

Returns
ilObjPoll

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

References $poll.

54  {
55  return $this->poll;
56  }

◆ hasAnyContent()

ilPollBlock::hasAnyContent (   $a_user_id,
  $a_ref_id 
)

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

Parameters
int$a_user_id
Returns
boolean

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

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

65  {
66  if (!sizeof($this->answers)) {
67  return false;
68  }
69 
70  include_once "Modules/Poll/classes/class.ilObjPollAccess.php";
71  $this->active = ilObjPollAccess::_isActivated($a_ref_id);
72  if (!$this->active) {
73  return false;
74  }
75 
76  if (!$this->mayVote($a_user_id) &&
77  !$this->maySeeResults($a_user_id)) {
78  return false;
79  }
80 
81  return true;
82  }
static _isActivated($a_ref_id)
Is activated?
mayVote($a_user_id)
maySeeResults($a_user_id)
+ Here is the call graph for this function:

◆ mayNotResultsYet()

ilPollBlock::mayNotResultsYet ( )

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

References ilObjPoll\VIEW_RESULTS_AFTER_PERIOD.

108  {
109  if ($this->poll->getViewResults() == ilObjPoll::VIEW_RESULTS_AFTER_PERIOD &&
110  $this->poll->getVotingPeriod() &&
111  $this->poll->getVotingPeriodEnd() > time()) {
112  return true;
113  }
114  return false;
115  }
const VIEW_RESULTS_AFTER_PERIOD

◆ maySeeResults()

ilPollBlock::maySeeResults (   $a_user_id)

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

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

Referenced by hasAnyContent().

118  {
119  if (!$this->active) {
120  return false;
121  }
122 
123  switch ($this->poll->getViewResults()) {
125  return false;
126 
128  // fallthrough
129 
130  // #12023 - see mayNotResultsYet()
132  return true;
133 
135  if ($this->poll->hasUserVoted($a_user_id)) {
136  return true;
137  }
138  return false;
139  }
140  }
const VIEW_RESULTS_AFTER_PERIOD
const VIEW_RESULTS_AFTER_VOTE
const VIEW_RESULTS_NEVER
const VIEW_RESULTS_ALWAYS
+ Here is the caller graph for this function:

◆ mayVote()

ilPollBlock::mayVote (   $a_user_id)

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

Referenced by hasAnyContent().

85  {
86  if (!$this->active) {
87  return false;
88  }
89 
90  if ($a_user_id == ANONYMOUS_USER_ID) {
91  return false;
92  }
93 
94  if ($this->poll->hasUserVoted($a_user_id)) {
95  return false;
96  }
97 
98  if ($this->poll->getVotingPeriod() &&
99  ($this->poll->getVotingPeriodBegin() > time() ||
100  $this->poll->getVotingPeriodEnd() < time())) {
101  return false;
102  }
103 
104  return true;
105  }
+ Here is the caller graph for this function:

◆ setRefId()

ilPollBlock::setRefId (   $a_id)

Set ref id (needed for poll access)

Parameters
int$a_id

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

42  {
43  include_once "Modules/Poll/classes/class.ilObjPoll.php";
44  $this->poll = new ilObjPoll($a_id, true);
45  $this->answers = $this->poll->getAnswers();
46  }
Class ilObjPoll.

◆ showComments()

ilPollBlock::showComments ( )

Are Comments enabled or disabled.

Returns
bool

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

176  {
177  return $this->poll->getShowComments();
178  }

◆ showResultsAs()

ilPollBlock::showResultsAs ( )

Show Results as (Barchart or Piechart)

Returns
int

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

167  {
168  return $this->poll->getShowResultsAs();
169  }

Field Documentation

◆ $active

ilPollBlock::$active
protected

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

◆ $answers

ilPollBlock::$answers
protected

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

◆ $lng

ilPollBlock::$lng
protected

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

Referenced by getMessage().

◆ $poll

ilPollBlock::$poll
protected

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

Referenced by getPoll().

◆ $visible

ilPollBlock::$visible
protected

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


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