5 require_once
"Services/Object/classes/class.ilObject2.php";
6 require_once
"Services/Object/classes/class.ilObjectActivation.php";
53 parent::__construct($a_id, $a_reference);
63 $this->online = (bool)$a_value;
73 $this->access_type = (int)$a_value;
83 $this->access_begin = (int)$a_value;
93 $this->access_end = (int)$a_value;
103 $this->access_visibility = (bool)$a_value;
113 $this->question = (
string)$a_value;
133 $this->view_results = (int)$a_value;
143 $this->period = (bool)$a_value;
153 $this->period_begin = (int)$a_value;
163 $this->period_end = (int)$a_value;
173 $this->max_number_answers = (int)$a_value;
183 $this->result_sort_by_votes = (bool)$a_value;
193 $this->mode_non_anonymous = (bool)$a_value;
203 $this->show_comments = (bool)$a_value;
213 $this->show_results_as = (int)$a_value;
225 $set = $ilDB->query(
"SELECT * FROM il_poll".
226 " WHERE id = ".$ilDB->quote($this->getId(),
"integer"));
227 $row = $ilDB->fetchAssoc($set);
241 include_once(
"./Services/Notes/classes/class.ilNote.php");
284 $fields[
"id"] =
array(
"integer", $this->
getId());
286 $ilDB->insert(
"il_poll", $fields);
293 include_once
"Modules/Poll/classes/class.ilPollBlock.php";
295 $block->setType(
"poll");
296 $block->setContextObjId($this->
getId());
297 $block->setContextObjType(
"poll");
310 $ilDB->update(
"il_poll", $fields,
314 include_once(
"./Services/Notes/classes/class.ilNote.php");
324 $activation->update($this->ref_id);
344 $ilDB->manipulate(
"DELETE FROM il_poll".
345 " WHERE id = ".$ilDB->quote($this->id,
"integer"));
368 $new_obj->uploadImage(
$image,
true);
374 if(!$cp_options->isRootNode($this->getRefId()))
376 $new_obj->setOnline($this->
isOnline());
388 foreach($answers as $item)
390 $new_obj->saveAnswer($item[
"answer"]);
431 include_once
"Modules/Poll/classes/class.ilFSStoragePoll.php";
448 include_once
"Modules/Poll/classes/class.ilFSStoragePoll.php";
452 $path = $storage->getAbsolutePath().
"/";
456 $path .= $a_subdir.
"/";
483 $clean_name = preg_replace(
"/[^a-zA-Z0-9\_\.\-]/",
"", $a_upload[
"name"]);
486 $original =
"org_".$this->id.
"_".$clean_name;
487 $thumb =
"thb_".$this->id.
"_".$clean_name;
488 $processed = $this->
id.
"_".$clean_name;
502 chmod(
$path.$original, 0770);
509 ilUtil::execConvert($original_file.
"[0] -geometry \"100x100>\" -quality 100 PNG:".$thumb_file);
510 ilUtil::execConvert($original_file.
"[0] -geometry \"".self::getImageSize().
">\" -quality 100 PNG:".$processed_file);
535 $sql =
"SELECT * FROM il_poll_answer".
536 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer").
538 $set = $ilDB->query($sql);
539 while(
$row = $ilDB->fetchAssoc($set))
550 $sql =
"SELECT * FROM il_poll_answer".
551 " WHERE id = ".$ilDB->quote($a_id,
"integer");
552 $set = $ilDB->query($sql);
553 return (
array)$ilDB->fetchAssoc($set);
565 $id = $ilDB->nextId(
"il_poll_answer");
570 $sql =
"SELECT max(pos) pos".
571 " FROM il_poll_answer".
572 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer");
573 $set = $ilDB->query($sql);
574 $a_pos = $ilDB->fetchAssoc($set);
575 $a_pos = (int)$a_pos[
"pos"]+10;
580 "poll_id" =>
array(
"integer", $this->
getId()),
581 "answer" =>
array(
"text", trim($a_text)),
582 "pos" =>
array(
"integer", $a_pos)
584 $ilDB->insert(
"il_poll_answer", $fields);
593 $ilDB->update(
"il_poll_answer",
603 foreach($answers as $item)
605 $pos[$item[
"id"]] = $item[
"pos"];
618 foreach(array_keys($a_pos) as
$id)
622 $ilDB->update(
"il_poll_answer",
634 $ilDB->manipulate(
"DELETE FROM il_poll_vote".
635 " WHERE answer_id = ".$ilDB->quote($this->getId(),
"integer"));
637 $ilDB->manipulate(
"DELETE FROM il_poll_answer".
638 " WHERE id = ".$ilDB->quote($a_id,
"integer"));
650 $ilDB->manipulate(
"DELETE FROM il_poll_answer".
651 " WHERE poll_id = ".$ilDB->quote($this->getId(),
"integer"));
661 $ilDB->manipulate(
"DELETE FROM il_poll_vote".
662 " WHERE poll_id = ".$ilDB->quote($this->getId(),
"integer"));
672 foreach($a_answers as $answer)
678 foreach($existing as $idx => $item)
680 if(trim($answer) == $item[
"answer"])
683 unset($existing[$idx]);
704 if(
sizeof($existing))
706 foreach($existing as $item)
735 if(!is_array($a_answers))
737 $a_answers =
array($a_answers);
740 foreach($a_answers as $answer_id)
742 $fields =
array(
"user_id" =>
array(
"integer", $a_user_id),
743 "poll_id" =>
array(
"integer", $this->
getId()),
744 "answer_id" =>
array(
"integer", $answer_id));
745 $ilDB->insert(
"il_poll_vote", $fields);
753 $sql =
"SELECT user_id".
754 " FROM il_poll_vote".
755 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer").
756 " AND user_id = ".$ilDB->quote($a_user_id,
"integer");
758 $set = $ilDB->query($sql);
759 return (
bool)$ilDB->numRows($set);
766 $sql =
"SELECT COUNT(DISTINCT(user_id)) cnt".
767 " FROM il_poll_vote".
768 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer");
769 $set = $ilDB->query($sql);
770 $row = $ilDB->fetchAssoc($set);
771 return (
int)
$row[
"cnt"];
781 $sql =
"SELECT answer_id, count(*) cnt".
782 " FROM il_poll_vote".
783 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer").
784 " GROUP BY answer_id";
785 $set = $ilDB->query($sql);
786 while(
$row = $ilDB->fetchAssoc($set))
789 $res[
$row[
"answer_id"]] =
array(
"abs"=>$row[
"cnt"],
"perc"=>0);
794 $res[
$id][
"perc"] = $item[
"abs"]/$cnt*100;
806 $sql =
"SELECT answer_id, user_id, firstname, lastname, login".
807 " FROM il_poll_vote".
808 " JOIN usr_data ON (usr_data.usr_id = il_poll_vote.user_id)".
809 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer");
810 $set = $ilDB->query($sql);
811 while(
$row = $ilDB->fetchAssoc($set))
817 $res[$row[
"user_id"]][
"answers"][] = $row[
"answer_id"];
deleteImage()
remove existing file
const VIEW_RESULTS_AFTER_PERIOD
const VIEW_RESULTS_AFTER_VOTE
getImageFullPath($a_as_thumb=false)
Get image incl.
updateAnswer($a_id, $a_text)
setVotingPeriod($a_value)
const VIEW_RESULTS_ALWAYS
setAccessVisibility($a_value)
static getItem($a_ref_id)
Get item data.
const SHOW_RESULTS_AS_PIECHART
setSortResultByVotes($a_value)
const TIMINGS_DEACTIVATED
setShowResultsAs($a_value)
Add rich text string
The name of the decorator.
setShowComments($a_value)
saveAnswer($a_text, $a_pos=null)
setMaxNumberOfAnswers($a_value)
const SHOW_RESULTS_AS_BARCHART
saveVote($a_user_id, $a_answers)
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static execConvert($args)
execute convert command
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
updateAnswerPositions(array $a_pos)
uploadImage(array $a_upload, $a_clone=false)
Upload new image file.
Create styles array
The data for the language used.
static initStorage($a_id, $a_subdir=null)
Init file system storage.
static deleteAllEntries($a_ref_id)
Delete all db entries for ref id.
saveAnswers(array $a_answers)
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
doCloneObject($new_obj, $a_target_id, $a_copy_id=0)
Clone poll.
static activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
Activate notes feature.
static escapeShellArg($a_arg)
__construct($a_id=0, $a_reference=true)
Class ilObject2 This is an intermediate progress of ilObject class.
setNonAnonymous($a_value)
setVotingPeriodBegin($a_value)
Class ilObjectActivation.
setVotingPeriodEnd($a_value)