ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjPoll Class Reference

Class ilObjPoll. More...

+ Inheritance diagram for ilObjPoll:
+ Collaboration diagram for ilObjPoll:

Public Member Functions

 __construct (int $a_id=0, bool $a_reference=true)
 Constructor. More...
 
 setAccessType (int $a_value)
 
 getAccessType ()
 
 setAccessBegin (int $a_value)
 
 getAccessBegin ()
 
 setAccessEnd (int $a_value)
 
 getAccessEnd ()
 
 setAccessVisibility (bool $a_value)
 
 getAccessVisibility ()
 
 setQuestion (string $a_value)
 
 getQuestion ()
 
 setViewResults (int $a_value)
 
 getViewResults ()
 
 setVotingPeriod (bool $a_value)
 
 getVotingPeriod ()
 
 setVotingPeriodBegin (int $a_value)
 
 getVotingPeriodBegin ()
 
 setVotingPeriodEnd (int $a_value)
 
 getVotingPeriodEnd ()
 
 setMaxNumberOfAnswers (int $a_value)
 
 getMaxNumberOfAnswers ()
 
 setSortResultByVotes (bool $a_value)
 
 getSortResultByVotes ()
 
 setNonAnonymous (bool $a_value)
 
 getNonAnonymous ()
 
 setShowComments (bool $a_value)
 
 getShowComments ()
 
 setShowResultsAs (int $a_value)
 
 getShowResultsAs ()
 
 uploadImage (string $file_path, string $file_name)
 
 getAnswers ()
 
 getAnswer (int $a_id)
 
 saveAnswer (string $a_text, ?int $a_pos=null)
 
 updateAnswer (int $a_id, string $a_text)
 
 rebuildAnswerPositions ()
 
 updateAnswerPositions (array $a_pos)
 
 deleteAnswer (int $a_id)
 
 deleteAllVotes ()
 
 saveAnswers (array $a_answers)
 
 saveVote (int $a_user_id, array $a_answers)
 
 hasUserVoted (int $a_user_id)
 
 countVotes ()
 
 getVotePercentages ()
 
 getVotesByUsers ()
 
- Public Member Functions inherited from ilObject2
 __construct (int $a_id=0, bool $a_reference=true)
 Constructor. More...
 
 read ()
 
 create (bool $a_clone_mode=false)
 
 update ()
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 cloneObject (int $target_id, int $copy_id=0, bool $omit_tree=false)
 
- Public Member Functions inherited from ilObject
 getObjectProperties ()
 
 flushObjectProperties ()
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 processAutoRating ()
 
 read ()
 
 getId ()
 
 setId (int $id)
 
 setRefId (int $ref_id)
 
 getRefId ()
 
 getType ()
 
 setType (string $type)
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 
 getUntranslatedTitle ()
 Get untranslated object title WebDAV needs to access the untranslated title of an object. More...
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $description)
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 
 setImportId (string $import_id)
 
 setOfflineStatus (bool $status)
 
 getOfflineStatus ()
 
 supportsOfflineHandling ()
 
 getOwner ()
 
 getOwnerName ()
 get full name of object owner More...
 
 setOwner (int $usr_id)
 
 getCreateDate ()
 Get create date in YYYY-MM-DD HH-MM-SS format. More...
 
 getLastUpdateDate ()
 Get last update date in YYYY-MM-DD HH-MM-SS format. More...
 
 create ()
 note: title, description and type should be set when this function is called More...
 
 update ()
 
 MDUpdateListener (string $element)
 Metadata update listener. More...
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree (int $parent_ref_id)
 maybe this method should be in tree object!? More...
 
 setPermissions (int $parent_ref_id)
 
 setParentRolePermissions (int $parent_ref_id)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type. More...
 
 applyDidacticTemplate (int $tpl_id)
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo (int $target_id, int $copy_id, int $new_obj_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies (int $target_id, int $copy_id)
 Clone object dependencies. More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 selfOrParentWithRatingEnabled ()
 
 getPossibleSubObjects (bool $filter=true)
 get all possible sub objects of this type the object can decide which types of sub objects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static getImageSize ()
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId (string $import_id)
 Get (latest) object id for an import id. More...
 
static _lookupImportId (int $obj_id)
 
static _lookupOwnerName (int $owner_id)
 Lookup owner name for owner id. More...
 
static _getIdForImportId (string $import_id)
 
static _getAllReferences (int $id)
 get all reference ids for object ID More...
 
static _lookupTitle (int $obj_id)
 
static lookupOfflineStatus (int $obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner (int $obj_id)
 Lookup owner user ID for object ID. More...
 
static _getIdsForTitle (string $title, string $type='', bool $partial_match=false)
 
static _lookupDescription (int $obj_id)
 
static _lookupLastUpdate (int $obj_id, bool $formatted=false)
 
static _getLastUpdateOfObjects (array $obj_ids)
 
static _lookupObjId (int $ref_id)
 
static _setDeletedDate (int $ref_id, int $deleted_by)
 
static setDeletedDates (array $ref_ids, int $user_id)
 
static _resetDeletedDate (int $ref_id)
 
static _lookupDeletedDate (int $ref_id)
 
static _writeTitle (int $obj_id, string $title)
 write title to db (static) More...
 
static _writeDescription (int $obj_id, string $desc)
 write description to db (static) More...
 
static _writeImportId (int $obj_id, string $import_id)
 write import id to db (static) More...
 
static _lookupType (int $id, bool $reference=false)
 
static _isInTrash (int $ref_id)
 
static _hasUntrashedReference (int $obj_id)
 checks whether an object has at least one reference that is not in trash More...
 
static _lookupObjectId (int $ref_id)
 
static _getObjectsDataForType (string $type, bool $omit_trash=false)
 get all objects of a certain type More...
 
static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType (string $obj_type="", ?int $owner=null)
 
static _prepareCloneSelection (array $ref_ids, string $new_type, bool $show_path=true)
 Prepare copy wizard object selection. More...
 
static getIconForType (string $type)
 
static _getIcon (int $obj_id=0, string $size="big", string $type="", bool $offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies (int $obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $obj_ids)
 
static getAllOwnedRepositoryObjects (int $user_id)
 
static fixMissingTitles ($type, array &$obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate (int $obj_id)
 
static _getObjectTypeIdByTitle (string $type, ?\ilDBInterface $ilDB=null)
 

Data Fields

const int VIEW_RESULTS_ALWAYS = 1
 
const int VIEW_RESULTS_NEVER = 2
 
const int VIEW_RESULTS_AFTER_VOTE = 3
 
const int VIEW_RESULTS_AFTER_PERIOD = 4
 
const int SHOW_RESULTS_AS_BARCHART = 1
 
const int SHOW_RESULTS_AS_STACKED_CHART = 2
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 
const DESC_LENGTH = 128
 
const LONG_DESC_LENGTH = 4000
 
const TABLE_OBJECT_DATA = "object_data"
 
array $objectList
 
string $untranslatedTitle
 

Protected Member Functions

 initType ()
 
 doRead ()
 
 propertiesToDB ()
 
 doCreate (bool $clone_mode=false)
 
 doUpdate ()
 
 doDelete ()
 
 doCloneObject (ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id=0)
 
 deleteAllAnswers ()
 
- Protected Member Functions inherited from ilObject2
 initType ()
 
 doRead ()
 
 doCreate (bool $clone_mode=false)
 
 beforeCreate ()
 If overwritten this method should return true, there is currently no "abort" handling for cases where "false" is returned. More...
 
 doUpdate ()
 
 beforeUpdate ()
 
 doDelete ()
 
 beforeDelete ()
 
 doCloneObject (ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id=null)
 
 beforeCloneObject ()
 
- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 

Protected Attributes

PollImageFactory $poll_image_factory
 
NotesService $notes
 
DataFactory $data_factory
 
int $access_type = 0
 
int $access_begin = 0
 
int $access_end = 0
 
bool $access_visibility = false
 
string $question = ""
 
string $image = ""
 
int $view_results = 0
 
bool $period = false
 
int $period_begin = 0
 
int $period_end = 0
 
int $max_number_answers = 0
 
bool $result_sort_by_votes = false
 
bool $mode_non_anonymous = false
 
bool $show_comments = false
 
int $show_results_as = 1
 
- Protected Attributes inherited from ilObject
ilLogger $obj_log
 
ILIAS $ilias
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLogger $log
 
ilErrorHandling $error
 
ilTree $tree
 
ilAppEventHandler $app_event_handler
 
ilRbacAdmin $rbac_admin
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilLanguage $lng
 
LOMServices $lom_services
 
bool $call_by_reference
 
int $max_title = self::TITLE_LENGTH
 
int $max_desc = self::DESC_LENGTH
 
bool $add_dots = true
 
int $ref_id = null
 
string $type = ""
 
string $title = ""
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Detailed Description

Class ilObjPoll.

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 33 of file class.ilObjPoll.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjPoll::__construct ( int  $a_id = 0,
bool  $a_reference = true 
)

Constructor.

Parameters
int$a_idreference_id or object_id
bool$a_referencetreat the id as reference_id (true) or object_id (false)

Reimplemented from ilObject2.

Definition at line 63 of file class.ilObjPoll.php.

64 {
65 global $DIC;
66
67 $this->db = $DIC->database();
68 // default
69 $this->setViewResults(self::VIEW_RESULTS_AFTER_VOTE);
71 $this->setVotingPeriod(false);
72 $this->notes = $DIC->notes();
73 $this->poll_image_factory = new PollImageFactory();
74 $this->data_factory = new DataFactory();
75 parent::__construct($a_id, $a_reference);
76 }
setViewResults(int $a_value)
setAccessType(int $a_value)
setVotingPeriod(bool $a_value)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), setAccessType(), setViewResults(), setVotingPeriod(), and ilObjectActivation\TIMINGS_DEACTIVATED.

+ Here is the call graph for this function:

Member Function Documentation

◆ countVotes()

ilObjPoll::countVotes ( )

Definition at line 621 of file class.ilObjPoll.php.

621 : int
622 {
623 $sql = "SELECT COUNT(DISTINCT(user_id)) cnt" .
624 " FROM il_poll_vote" .
625 " WHERE poll_id = " . $this->db->quote($this->getId(), "integer");
626 $set = $this->db->query($sql);
627 $row = $this->db->fetchAssoc($set);
628 return (int) $row["cnt"];
629 }

References ilObject\getId().

Referenced by getVotePercentages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAllAnswers()

ilObjPoll::deleteAllAnswers ( )
protected

Definition at line 520 of file class.ilObjPoll.php.

520 : void
521 {
523
524 if ($this->getId()) {
525 $this->deleteAllVotes();
526
527 $ilDB->manipulate("DELETE FROM il_poll_answer" .
528 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer"));
529 }
530 }
ilDBInterface $db

References ilObject\$db, $ilDB, deleteAllVotes(), and ilObject\getId().

Referenced by doDelete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAllVotes()

ilObjPoll::deleteAllVotes ( )

Definition at line 532 of file class.ilObjPoll.php.

532 : void
533 {
535
536 if ($this->getId()) {
537 $ilDB->manipulate("DELETE FROM il_poll_vote" .
538 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer"));
539 }
540 }

References ilObject\$db, $ilDB, and ilObject\getId().

Referenced by deleteAllAnswers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAnswer()

ilObjPoll::deleteAnswer ( int  $a_id)

Definition at line 507 of file class.ilObjPoll.php.

507 : void
508 {
510
511 if ($a_id) {
512 $ilDB->manipulate("DELETE FROM il_poll_vote" .
513 " WHERE answer_id = " . $ilDB->quote($this->getId(), "integer"));
514
515 $ilDB->manipulate("DELETE FROM il_poll_answer" .
516 " WHERE id = " . $ilDB->quote($a_id, "integer"));
517 }
518 }

References ilObject\$db, and $ilDB.

Referenced by saveAnswers().

+ Here is the caller graph for this function:

◆ doCloneObject()

ilObjPoll::doCloneObject ( ilObject2  $new_obj,
int  $a_target_id,
?int  $a_copy_id = 0 
)
protected

Reimplemented from ilObject2.

Definition at line 341 of file class.ilObjPoll.php.

341 : void
342 {
343 assert($new_obj instanceof ilObjPoll);
344
345 // question/image
346 $new_obj->setQuestion($this->getQuestion());
347
348 $this->poll_image_factory->handler()->cloneImage(
349 $this->data_factory->objId($this->id),
350 $this->data_factory->objId($new_obj->getId()),
351 $this->user->getId()
352 );
353
354 //copy online status if object is not the root copy object
355 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
356
357 if ($cp_options->isRootNode($this->getRefId())) {
358 $new_obj->setOfflineStatus(true);
359 }
360
361 $view_results = $this->getViewResults();
363 // default view results setting to always, since
364 // voting period is not copied.
366 }
367 $new_obj->setViewResults($view_results);
368 $new_obj->setShowComments($this->getShowComments());
369 $new_obj->setShowResultsAs($this->getShowResultsAs());
370 $new_obj->setMaxNumberOfAnswers($this->getMaxNumberOfAnswers());
371 $new_obj->setSortResultByVotes($this->getSortResultByVotes());
372 $new_obj->setNonAnonymous($this->getNonAnonymous());
373 $new_obj->update();
374
375 // answers
376 $answers = $this->getAnswers();
377 if ($answers) {
378 foreach ($answers as $item) {
379 $new_obj->saveAnswer($item["answer"]);
380 }
381 }
382 }
static _getInstance(int $a_copy_id)
Class ilObjPoll.
const int VIEW_RESULTS_ALWAYS
const int VIEW_RESULTS_AFTER_PERIOD
setOfflineStatus(bool $status)

References $view_results, ilCopyWizardOptions\_getInstance(), getAnswers(), ilObject\getId(), getMaxNumberOfAnswers(), getNonAnonymous(), getQuestion(), getShowComments(), getShowResultsAs(), getSortResultByVotes(), getViewResults(), ilObject\setOfflineStatus(), ilObject2\update(), VIEW_RESULTS_AFTER_PERIOD, and VIEW_RESULTS_ALWAYS.

+ Here is the call graph for this function:

◆ doCreate()

ilObjPoll::doCreate ( bool  $clone_mode = false)
protected

Reimplemented from ilObject2.

Definition at line 270 of file class.ilObjPoll.php.

270 : void
271 {
273
274 if ($this->getId()) {
275 $fields = $this->propertiesToDB();
276 $fields["id"] = array("integer", $this->getId());
277 $fields["migrated"] = array("integer", "1");
278
279 $ilDB->insert("il_poll", $fields);
280
281
282 // object activation default entry will be created on demand
283
284
285 // block handling
286 $block = new ilPollBlock();
287 $block->setType("poll");
288 $block->setContextObjId($this->getId());
289 $block->setContextObjType("poll");
290 $block->create();
291 }
292 }
Custom block for polls.

References ilObject\$db, $ilDB, ilObject\getId(), and propertiesToDB().

+ Here is the call graph for this function:

◆ doDelete()

ilObjPoll::doDelete ( )
protected

Reimplemented from ilObject2.

Definition at line 321 of file class.ilObjPoll.php.

321 : void
322 {
324
325 if ($this->getId()) {
326 $this->poll_image_factory->handler()->deleteImage(
327 $this->data_factory->objId($this->getId()),
328 $this->user->getId()
329 );
330 $this->deleteAllAnswers();
331
332 if ($this->ref_id) {
334 }
335
336 $ilDB->manipulate("DELETE FROM il_poll" .
337 " WHERE id = " . $ilDB->quote($this->id, "integer"));
338 }
339 }
static deleteAllEntries(int $ref_id)
Delete all db entries for ref id.

References ilObject\$db, $ilDB, deleteAllAnswers(), ilObjectActivation\deleteAllEntries(), and ilObject\getId().

+ Here is the call graph for this function:

◆ doRead()

ilObjPoll::doRead ( )
protected

Reimplemented from ilObject2.

Definition at line 223 of file class.ilObjPoll.php.

223 : void
224 {
226
227 $set = $ilDB->query("SELECT * FROM il_poll" .
228 " WHERE id = " . $ilDB->quote($this->getId(), "integer"));
229 $row = $ilDB->fetchAssoc($set);
230 $this->setQuestion((string) ($row["question"] ?? ''));
231 $this->setViewResults((int) ($row["view_results"] ?? self::VIEW_RESULTS_AFTER_VOTE));
232 $this->setVotingPeriod((bool) ($row["period"] ?? 0));
233 $this->setVotingPeriodBegin((int) ($row["period_begin"] ?? 0));
234 $this->setVotingPeriodEnd((int) ($row["period_end"] ?? 0));
235 $this->setMaxNumberOfAnswers((int) ($row["max_answers"] ?? 0));
236 $this->setSortResultByVotes((bool) ($row["result_sort"] ?? 0));
237 $this->setNonAnonymous((bool) ($row["non_anon"] ?? 0));
238 $this->setShowResultsAs((int) ($row["show_results_as"] ?? self::SHOW_RESULTS_AS_BARCHART));
239
240 // #14661
241 $this->setShowComments($this->notes->domain()->commentsActive($this->getId()));
242
243 if ($this->ref_id) {
244 $activation = ilObjectActivation::getItem($this->ref_id);
245 $this->setAccessType((int) ($activation["timing_type"] ?? ilObjectActivation::TIMINGS_DEACTIVATED));
247 // default entry values should not be loaded if not activated
248 $this->setAccessBegin((int) ($activation["timing_start"] ?? time()));
249 $this->setAccessEnd((int) ($activation["timing_end"] ?? time()));
250 $this->setAccessVisibility((bool) ($activation["visible"] ?? false));
251 }
252 }
253 }
setVotingPeriodBegin(int $a_value)
setVotingPeriodEnd(int $a_value)
setAccessBegin(int $a_value)
setShowComments(bool $a_value)
setNonAnonymous(bool $a_value)
setShowResultsAs(int $a_value)
setMaxNumberOfAnswers(int $a_value)
setAccessEnd(int $a_value)
setQuestion(string $a_value)
setSortResultByVotes(bool $a_value)
setAccessVisibility(bool $a_value)
static getItem(int $ref_id)

References ilObject\$db, $ilDB, getAccessType(), ilObjectActivation\getItem(), setAccessBegin(), setAccessEnd(), setAccessType(), setAccessVisibility(), setMaxNumberOfAnswers(), setNonAnonymous(), setQuestion(), setShowComments(), setShowResultsAs(), setSortResultByVotes(), setViewResults(), setVotingPeriod(), setVotingPeriodBegin(), setVotingPeriodEnd(), ilObjectActivation\TIMINGS_ACTIVATION, and ilObjectActivation\TIMINGS_DEACTIVATED.

+ Here is the call graph for this function:

◆ doUpdate()

ilObjPoll::doUpdate ( )
protected

Reimplemented from ilObject2.

Definition at line 294 of file class.ilObjPoll.php.

294 : void
295 {
297
298 if ($this->getId()) {
299 $fields = $this->propertiesToDB();
300
301 $ilDB->update(
302 "il_poll",
303 $fields,
304 array("id" => array("integer", $this->getId()))
305 );
306
307 // #14661
308 $this->notes->domain()->activateComments($this->getId(), $this->getShowComments());
309
310 if ($this->getRefId()) {
311 $activation = new ilObjectActivation();
312 $activation->setTimingType($this->getAccessType());
313 $activation->setTimingStart($this->getAccessBegin());
314 $activation->setTimingEnd($this->getAccessEnd());
315 $activation->toggleVisible($this->getAccessVisibility());
316 $activation->update($this->ref_id);
317 }
318 }
319 }
Class ilObjectActivation.

References ilObject\$db, $ilDB, getAccessBegin(), getAccessEnd(), getAccessType(), getAccessVisibility(), ilObject\getId(), ilObject\getRefId(), getShowComments(), and propertiesToDB().

+ Here is the call graph for this function:

◆ getAccessBegin()

ilObjPoll::getAccessBegin ( )

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

98 : int
99 {
100 return $this->access_begin;
101 }

References $access_begin.

Referenced by doUpdate(), and ilPollStateInfo\isOfflineOrUnavailable().

+ Here is the caller graph for this function:

◆ getAccessEnd()

ilObjPoll::getAccessEnd ( )

Definition at line 108 of file class.ilObjPoll.php.

108 : int
109 {
110 return $this->access_end;
111 }

References $access_end.

Referenced by doUpdate(), and ilPollStateInfo\isOfflineOrUnavailable().

+ Here is the caller graph for this function:

◆ getAccessType()

ilObjPoll::getAccessType ( )

Definition at line 88 of file class.ilObjPoll.php.

88 : int
89 {
90 return $this->access_type;
91 }

References $access_type.

Referenced by doRead(), doUpdate(), and ilPollStateInfo\isOfflineOrUnavailable().

+ Here is the caller graph for this function:

◆ getAccessVisibility()

ilObjPoll::getAccessVisibility ( )

Definition at line 118 of file class.ilObjPoll.php.

118 : bool
119 {
121 }
bool $access_visibility

References $access_visibility.

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getAnswer()

ilObjPoll::getAnswer ( int  $a_id)

Definition at line 424 of file class.ilObjPoll.php.

424 : array
425 {
427
428 $sql = "SELECT * FROM il_poll_answer" .
429 " WHERE id = " . $ilDB->quote($a_id, "integer");
430 $set = $ilDB->query($sql);
431 return (array) $ilDB->fetchAssoc($set);
432 }

References ilObject\$db, and $ilDB.

◆ getAnswers()

ilObjPoll::getAnswers ( )

Definition at line 408 of file class.ilObjPoll.php.

408 : array
409 {
411
412 $res = [];
413
414 $sql = "SELECT * FROM il_poll_answer" .
415 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer") .
416 " ORDER BY pos ASC";
417 $set = $ilDB->query($sql);
418 while ($row = $ilDB->fetchAssoc($set)) {
419 $res[] = $row;
420 }
421 return $res;
422 }
$res
Definition: ltiservices.php:69

References ilObject\$db, $ilDB, $res, and ilObject\getId().

Referenced by ilPollAnswersHandler\__construct(), doCloneObject(), ilPollStateInfo\hasQuestion(), rebuildAnswerPositions(), and saveAnswers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImageSize()

static ilObjPoll::getImageSize ( )
static

Definition at line 397 of file class.ilObjPoll.php.

397 : string
398 {
399 // :TODO:
400 return "600x600";
401 }

Referenced by ilObjPollGUI\initQuestionForm().

+ Here is the caller graph for this function:

◆ getMaxNumberOfAnswers()

ilObjPoll::getMaxNumberOfAnswers ( )

Definition at line 178 of file class.ilObjPoll.php.

178 : int
179 {
181 }
int $max_number_answers

References $max_number_answers.

Referenced by ilPollAnswersHandler\__construct(), doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getNonAnonymous()

ilObjPoll::getNonAnonymous ( )

Definition at line 198 of file class.ilObjPoll.php.

198 : bool
199 {
201 }
bool $mode_non_anonymous

References $mode_non_anonymous.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getQuestion()

ilObjPoll::getQuestion ( )

Definition at line 128 of file class.ilObjPoll.php.

128 : string
129 {
130 return $this->question;
131 }
string $question

References $question.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getShowComments()

ilObjPoll::getShowComments ( )

Definition at line 208 of file class.ilObjPoll.php.

208 : bool
209 {
211 }
bool $show_comments

References $show_comments.

Referenced by doCloneObject(), and doUpdate().

+ Here is the caller graph for this function:

◆ getShowResultsAs()

ilObjPoll::getShowResultsAs ( )

Definition at line 218 of file class.ilObjPoll.php.

218 : int
219 {
221 }
int $show_results_as

References $show_results_as.

Referenced by doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getSortResultByVotes()

ilObjPoll::getSortResultByVotes ( )

Definition at line 188 of file class.ilObjPoll.php.

188 : bool
189 {
191 }
bool $result_sort_by_votes

References $result_sort_by_votes.

Referenced by ilPollResultsHandler\__construct(), doCloneObject(), and propertiesToDB().

+ Here is the caller graph for this function:

◆ getViewResults()

ilObjPoll::getViewResults ( )

Definition at line 138 of file class.ilObjPoll.php.

138 : int
139 {
140 return $this->view_results;
141 }

References $view_results.

Referenced by ilPollStateInfo\areResultsVisible(), doCloneObject(), propertiesToDB(), and ilPollStateInfo\willResultsBeShown().

+ Here is the caller graph for this function:

◆ getVotePercentages()

ilObjPoll::getVotePercentages ( )

Definition at line 631 of file class.ilObjPoll.php.

631 : array
632 {
633 $res = [];
634 $cnt = 0;
635
636 $sql = "SELECT answer_id, count(*) cnt" .
637 " FROM il_poll_vote" .
638 " WHERE poll_id = " . $this->db->quote($this->getId(), "integer") .
639 " GROUP BY answer_id";
640 $set = $this->db->query($sql);
641 while ($row = $this->db->fetchAssoc($set)) {
642 $cnt += (int) $row["cnt"];
643 $res[(int) $row["answer_id"]] = array("abs" => (int) $row["cnt"], "perc" => 0);
644 }
645
646 foreach ($res as $id => $item) {
647 $abs = (int) ($item['abs'] ?? 0);
648 $id = (int) ($id ?? 0);
649 if ($cnt === 0) {
650 $res[$id]["perc"] = 0;
651 } else {
652 $res[$id]["perc"] = $abs / $cnt * 100;
653 }
654 }
655
656 return array("perc" => $res, "total" => $this->countVotes());
657 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, $res, countVotes(), ilObject\getId(), and ILIAS\Repository\int().

Referenced by ilPollResultsHandler\__construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVotesByUsers()

ilObjPoll::getVotesByUsers ( )

Definition at line 659 of file class.ilObjPoll.php.

659 : array
660 {
662
663 $res = [];
664
665 $sql = "SELECT answer_id, user_id, firstname, lastname, login" .
666 " FROM il_poll_vote" .
667 " JOIN usr_data ON (usr_data.usr_id = il_poll_vote.user_id)" .
668 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer");
669 $set = $ilDB->query($sql);
670 while ($row = $ilDB->fetchAssoc($set)) {
671 $user_id = (int) ($row["user_id"] ?? 0);
672 if (!isset($res[$user_id])) {
673 $res[$user_id] = $row;
674 }
675 $res[$user_id]["answers"][] = (int) ($row["answer_id"] ?? 0);
676 }
677
678 return $res;
679 }

References ilObject\$db, $ilDB, $res, $user_id, ilObject\getId(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getVotingPeriod()

ilObjPoll::getVotingPeriod ( )

Definition at line 148 of file class.ilObjPoll.php.

148 : bool
149 {
150 return $this->period;
151 }

References $period.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getVotingPeriodBegin()

ilObjPoll::getVotingPeriodBegin ( )

Definition at line 158 of file class.ilObjPoll.php.

158 : int
159 {
160 return $this->period_begin;
161 }

References $period_begin.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ getVotingPeriodEnd()

ilObjPoll::getVotingPeriodEnd ( )

Definition at line 168 of file class.ilObjPoll.php.

168 : int
169 {
170 return $this->period_end;
171 }

References $period_end.

Referenced by propertiesToDB().

+ Here is the caller graph for this function:

◆ hasUserVoted()

ilObjPoll::hasUserVoted ( int  $a_user_id)

Definition at line 610 of file class.ilObjPoll.php.

610 : bool
611 {
612 $sql = "SELECT user_id" .
613 " FROM il_poll_vote" .
614 " WHERE poll_id = " . $this->db->quote($this->getId(), "integer") .
615 " AND user_id = " . $this->db->quote($a_user_id, "integer");
616 $this->db->setLimit(1, 0);
617 $set = $this->db->query($sql);
618 return (bool) $this->db->numRows($set);
619 }

References ilObject\getId().

Referenced by ilPollStateInfo\hasUserAlreadyVoted(), and saveVote().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initType()

ilObjPoll::initType ( )
protected

Reimplemented from ilObject2.

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

78 : void
79 {
80 $this->type = "poll";
81 }

◆ propertiesToDB()

ilObjPoll::propertiesToDB ( )
protected

Definition at line 255 of file class.ilObjPoll.php.

255 : array
256 {
257 return array(
258 "question" => array("text", $this->getQuestion()),
259 "view_results" => array("integer", $this->getViewResults()),
260 "period" => array("integer", $this->getVotingPeriod()),
261 "period_begin" => array("integer", $this->getVotingPeriodBegin()),
262 "period_end" => array("integer", $this->getVotingPeriodEnd()),
263 "max_answers" => array("integer", $this->getMaxNumberOfAnswers()),
264 "result_sort" => array("integer", $this->getSortResultByVotes()),
265 "non_anon" => array("integer", $this->getNonAnonymous()),
266 "show_results_as" => array("integer", $this->getShowResultsAs()),
267 );
268 }

References getMaxNumberOfAnswers(), getNonAnonymous(), getQuestion(), getShowResultsAs(), getSortResultByVotes(), getViewResults(), getVotingPeriod(), getVotingPeriodBegin(), and getVotingPeriodEnd().

Referenced by doCreate(), and doUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rebuildAnswerPositions()

ilObjPoll::rebuildAnswerPositions ( )

Definition at line 476 of file class.ilObjPoll.php.

476 : void
477 {
478 $answers = $this->getAnswers();
479
480 $pos = [];
481 foreach ($answers as $item) {
482 $id = (int) ($item['id'] ?? 0);
483 $pos[$id] = (int) ($item["pos"] ?? 10);
484 }
485
486 $this->updateAnswerPositions($pos);
487 }
updateAnswerPositions(array $a_pos)

References $id, getAnswers(), ILIAS\Repository\int(), and updateAnswerPositions().

+ Here is the call graph for this function:

◆ saveAnswer()

ilObjPoll::saveAnswer ( string  $a_text,
?int  $a_pos = null 
)

Definition at line 434 of file class.ilObjPoll.php.

434 : ?int
435 {
437
438 if (!trim($a_text)) {
439 return null;
440 }
441
442 $id = $ilDB->nextId("il_poll_answer");
443
444 if (!$a_pos) {
445 // append
446 $sql = "SELECT max(pos) pos" .
447 " FROM il_poll_answer" .
448 " WHERE poll_id = " . $ilDB->quote($this->getId(), "integer");
449 $set = $ilDB->query($sql);
450 $a_pos = $ilDB->fetchAssoc($set);
451 $a_pos = (int) ($a_pos["pos"] ?? 0) + 10;
452 }
453
454 $fields = array(
455 "id" => array("integer", $id),
456 "poll_id" => array("integer", $this->getId()),
457 "answer" => array("text", trim($a_text)),
458 "pos" => array("integer", $a_pos)
459 );
460 $ilDB->insert("il_poll_answer", $fields);
461
462 return $id;
463 }

References ilObject\$db, $id, $ilDB, ilObject\getId(), and ILIAS\Repository\int().

Referenced by saveAnswers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAnswers()

ilObjPoll::saveAnswers ( array  $a_answers)

Definition at line 542 of file class.ilObjPoll.php.

542 : int
543 {
544 $existing = $this->getAnswers();
545
546 $ids = [];
547 $pos = 0;
548 $id = null;
549 foreach ($a_answers as $answer) {
550 if (trim($answer)) {
551 // existing answer?
552 $found = false;
553 foreach ($existing as $idx => $item) {
554 if (trim($answer) === (string) ($item["answer"] ?? '')) {
555 $found = true;
556 unset($existing[$idx]);
557
558 $id = (int) ($item["id"] ?? 0);
559 }
560 }
561
562 // create new answer
563 if (!$found) {
564 $id = $this->saveAnswer($answer);
565 }
566
567 // add existing answer id to order
568 if (isset($id) && is_int($id)) {
569 $ids[$id] = ++$pos;
570 }
571 }
572 }
573
574 // remove obsolete answers
575 if (count($existing)) {
576 foreach ($existing as $item) {
577 if (isset($item["id"])) {
578 $this->deleteAnswer((int) $item["id"]);
579 }
580 }
581 }
582
583 // save current order
584 if (count($ids)) {
585 $this->updateAnswerPositions($ids);
586 }
587
588 return count($ids);
589 }
deleteAnswer(int $a_id)
saveAnswer(string $a_text, ?int $a_pos=null)

References $id, deleteAnswer(), getAnswers(), ILIAS\Repository\int(), saveAnswer(), and updateAnswerPositions().

+ Here is the call graph for this function:

◆ saveVote()

ilObjPoll::saveVote ( int  $a_user_id,
array  $a_answers 
)

Definition at line 596 of file class.ilObjPoll.php.

596 : void
597 {
598 if ($this->hasUserVoted($a_user_id)) {
599 return;
600 }
601
602 foreach ($a_answers as $answer_id) {
603 $fields = array("user_id" => array("integer", $a_user_id),
604 "poll_id" => array("integer", $this->getId()),
605 "answer_id" => array("integer", $answer_id));
606 $this->db->insert("il_poll_vote", $fields);
607 }
608 }
hasUserVoted(int $a_user_id)

References ilObject\getId(), and hasUserVoted().

+ Here is the call graph for this function:

◆ setAccessBegin()

ilObjPoll::setAccessBegin ( int  $a_value)

Definition at line 93 of file class.ilObjPoll.php.

93 : void
94 {
95 $this->access_begin = $a_value;
96 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setAccessEnd()

ilObjPoll::setAccessEnd ( int  $a_value)

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

103 : void
104 {
105 $this->access_end = $a_value;
106 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setAccessType()

ilObjPoll::setAccessType ( int  $a_value)

Definition at line 83 of file class.ilObjPoll.php.

83 : void
84 {
85 $this->access_type = $a_value;
86 }

Referenced by __construct(), and doRead().

+ Here is the caller graph for this function:

◆ setAccessVisibility()

ilObjPoll::setAccessVisibility ( bool  $a_value)

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

113 : void
114 {
115 $this->access_visibility = $a_value;
116 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setMaxNumberOfAnswers()

ilObjPoll::setMaxNumberOfAnswers ( int  $a_value)

Definition at line 173 of file class.ilObjPoll.php.

173 : void
174 {
175 $this->max_number_answers = $a_value;
176 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setNonAnonymous()

ilObjPoll::setNonAnonymous ( bool  $a_value)

Definition at line 193 of file class.ilObjPoll.php.

193 : void
194 {
195 $this->mode_non_anonymous = $a_value;
196 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setQuestion()

ilObjPoll::setQuestion ( string  $a_value)

Definition at line 123 of file class.ilObjPoll.php.

123 : void
124 {
125 $this->question = $a_value;
126 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setShowComments()

ilObjPoll::setShowComments ( bool  $a_value)

Definition at line 203 of file class.ilObjPoll.php.

203 : void
204 {
205 $this->show_comments = $a_value;
206 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setShowResultsAs()

ilObjPoll::setShowResultsAs ( int  $a_value)

Definition at line 213 of file class.ilObjPoll.php.

213 : void
214 {
215 $this->show_results_as = $a_value;
216 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setSortResultByVotes()

ilObjPoll::setSortResultByVotes ( bool  $a_value)

Definition at line 183 of file class.ilObjPoll.php.

183 : void
184 {
185 $this->result_sort_by_votes = $a_value;
186 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setViewResults()

ilObjPoll::setViewResults ( int  $a_value)

Definition at line 133 of file class.ilObjPoll.php.

133 : void
134 {
135 $this->view_results = $a_value;
136 }

Referenced by __construct(), and doRead().

+ Here is the caller graph for this function:

◆ setVotingPeriod()

ilObjPoll::setVotingPeriod ( bool  $a_value)

Definition at line 143 of file class.ilObjPoll.php.

143 : void
144 {
145 $this->period = $a_value;
146 }

Referenced by __construct(), and doRead().

+ Here is the caller graph for this function:

◆ setVotingPeriodBegin()

ilObjPoll::setVotingPeriodBegin ( int  $a_value)

Definition at line 153 of file class.ilObjPoll.php.

153 : void
154 {
155 $this->period_begin = $a_value;
156 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setVotingPeriodEnd()

ilObjPoll::setVotingPeriodEnd ( int  $a_value)

Definition at line 163 of file class.ilObjPoll.php.

163 : void
164 {
165 $this->period_end = $a_value;
166 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ updateAnswer()

ilObjPoll::updateAnswer ( int  $a_id,
string  $a_text 
)

Definition at line 465 of file class.ilObjPoll.php.

465 : void
466 {
468
469 $ilDB->update(
470 "il_poll_answer",
471 array("answer" => array("text", $a_text)),
472 array("id" => array("integer", $a_id))
473 );
474 }

References ilObject\$db, and $ilDB.

◆ updateAnswerPositions()

ilObjPoll::updateAnswerPositions ( array  $a_pos)

Definition at line 489 of file class.ilObjPoll.php.

489 : void
490 {
492
493 asort($a_pos);
494
495 $pos = 0;
496 foreach (array_keys($a_pos) as $id) {
497 $pos += 10;
498
499 $ilDB->update(
500 "il_poll_answer",
501 array("pos" => array("integer", $pos)),
502 array("id" => array("integer", $id))
503 );
504 }
505 }

References ilObject\$db, $id, and $ilDB.

Referenced by rebuildAnswerPositions(), and saveAnswers().

+ Here is the caller graph for this function:

◆ uploadImage()

ilObjPoll::uploadImage ( string  $file_path,
string  $file_name 
)

Definition at line 384 of file class.ilObjPoll.php.

384 : void
385 {
386 if (!$this->getId() or $file_path === "") {
387 return;
388 }
389 $this->poll_image_factory->handler()->uploadImage(
390 $this->data_factory->objId($this->getId()),
391 $file_path,
392 $file_name,
393 $this->user->getId()
394 );
395 }

References ilObject\getId().

+ Here is the call graph for this function:

Field Documentation

◆ $access_begin

int ilObjPoll::$access_begin = 0
protected

Definition at line 39 of file class.ilObjPoll.php.

Referenced by getAccessBegin().

◆ $access_end

int ilObjPoll::$access_end = 0
protected

Definition at line 40 of file class.ilObjPoll.php.

Referenced by getAccessEnd().

◆ $access_type

int ilObjPoll::$access_type = 0
protected

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

Referenced by getAccessType().

◆ $access_visibility

bool ilObjPoll::$access_visibility = false
protected

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

Referenced by getAccessVisibility().

◆ $data_factory

DataFactory ilObjPoll::$data_factory
protected

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

◆ $image

string ilObjPoll::$image = ""
protected

Definition at line 43 of file class.ilObjPoll.php.

◆ $max_number_answers

int ilObjPoll::$max_number_answers = 0
protected

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

Referenced by getMaxNumberOfAnswers().

◆ $mode_non_anonymous

bool ilObjPoll::$mode_non_anonymous = false
protected

Definition at line 51 of file class.ilObjPoll.php.

Referenced by getNonAnonymous().

◆ $notes

NotesService ilObjPoll::$notes
protected

Definition at line 36 of file class.ilObjPoll.php.

◆ $period

bool ilObjPoll::$period = false
protected

Definition at line 45 of file class.ilObjPoll.php.

Referenced by getVotingPeriod().

◆ $period_begin

int ilObjPoll::$period_begin = 0
protected

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

Referenced by getVotingPeriodBegin().

◆ $period_end

int ilObjPoll::$period_end = 0
protected

Definition at line 47 of file class.ilObjPoll.php.

Referenced by getVotingPeriodEnd().

◆ $poll_image_factory

PollImageFactory ilObjPoll::$poll_image_factory
protected

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

◆ $question

string ilObjPoll::$question = ""
protected

Definition at line 42 of file class.ilObjPoll.php.

Referenced by getQuestion().

◆ $result_sort_by_votes

bool ilObjPoll::$result_sort_by_votes = false
protected

Definition at line 50 of file class.ilObjPoll.php.

Referenced by getSortResultByVotes().

◆ $show_comments

bool ilObjPoll::$show_comments = false
protected

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

Referenced by getShowComments().

◆ $show_results_as

int ilObjPoll::$show_results_as = 1
protected

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

Referenced by getShowResultsAs().

◆ $view_results

int ilObjPoll::$view_results = 0
protected

Definition at line 44 of file class.ilObjPoll.php.

Referenced by doCloneObject(), and getViewResults().

◆ SHOW_RESULTS_AS_BARCHART

const int ilObjPoll::SHOW_RESULTS_AS_BARCHART = 1

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

Referenced by ilObjPollGUI\initEditCustomForm().

◆ SHOW_RESULTS_AS_STACKED_CHART

const int ilObjPoll::SHOW_RESULTS_AS_STACKED_CHART = 2

Definition at line 61 of file class.ilObjPoll.php.

Referenced by ilObjPollGUI\initEditCustomForm().

◆ VIEW_RESULTS_AFTER_PERIOD

◆ VIEW_RESULTS_AFTER_VOTE

const int ilObjPoll::VIEW_RESULTS_AFTER_VOTE = 3

◆ VIEW_RESULTS_ALWAYS

const int ilObjPoll::VIEW_RESULTS_ALWAYS = 1

◆ VIEW_RESULTS_NEVER

const int ilObjPoll::VIEW_RESULTS_NEVER = 2

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