5require_once
"Services/Object/classes/class.ilObject2.php";
6require_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;
123 $this->image = (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"));
241 include_once(
"./Services/Notes/classes/class.ilNote.php");
258 "image" => array(
"text", $this->
getImage()),
259 "online_status" => array(
"integer", $this->
isOnline()),
280 $fields[
"id"] = array(
"integer", $this->
getId());
282 $ilDB->insert(
"il_poll", $fields);
289 include_once
"Modules/Poll/classes/class.ilPollBlock.php";
291 $block->setType(
"poll");
292 $block->setContextObjId($this->
getId());
293 $block->setContextObjType(
"poll");
306 $ilDB->update(
"il_poll", $fields,
307 array(
"id"=>array(
"integer", $this->
getId())));
310 include_once(
"./Services/Notes/classes/class.ilNote.php");
320 $activation->update($this->ref_id);
340 $ilDB->manipulate(
"DELETE FROM il_poll".
341 " WHERE id = ".
$ilDB->quote($this->id,
"integer"));
368 if(!$cp_options->isRootNode($this->getRefId()))
382 foreach($answers as $item)
425 include_once
"Modules/Poll/classes/class.ilFSStoragePoll.php";
442 include_once
"Modules/Poll/classes/class.ilFSStoragePoll.php";
446 $path = $storage->getAbsolutePath().
"/";
450 $path .= $a_subdir.
"/";
477 $clean_name = preg_replace(
"/[^a-zA-Z0-9\_\.\-]/",
"", $a_upload[
"name"]);
480 $original =
"org_".$this->id.
"_".$clean_name;
481 $thumb =
"thb_".$this->id.
"_".$clean_name;
482 $processed = $this->
id.
"_".$clean_name;
496 chmod(
$path.$original, 0770);
503 ilUtil::execConvert($original_file.
"[0] -geometry \"100x100>\" -quality 100 PNG:".$thumb_file);
504 ilUtil::execConvert($original_file.
"[0] -geometry \"".self::getImageSize().
">\" -quality 100 PNG:".$processed_file);
529 $sql =
"SELECT * FROM il_poll_answer".
530 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer").
532 $set =
$ilDB->query($sql);
544 $sql =
"SELECT * FROM il_poll_answer".
545 " WHERE id = ".$ilDB->quote($a_id,
"integer");
546 $set =
$ilDB->query($sql);
547 return (array)
$ilDB->fetchAssoc($set);
559 $id =
$ilDB->nextId(
"il_poll_answer");
564 $sql =
"SELECT max(pos) pos".
565 " FROM il_poll_answer".
566 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer");
567 $set =
$ilDB->query($sql);
568 $a_pos =
$ilDB->fetchAssoc($set);
569 $a_pos = (int)$a_pos[
"pos"]+10;
573 "id" => array(
"integer",
$id),
574 "poll_id" => array(
"integer", $this->
getId()),
575 "answer" => array(
"text", trim($a_text)),
576 "pos" => array(
"integer", $a_pos)
578 $ilDB->insert(
"il_poll_answer", $fields);
587 $ilDB->update(
"il_poll_answer",
588 array(
"answer" => array(
"text", $a_text)),
589 array(
"id" => array(
"integer", $a_id)));
597 foreach($answers as $item)
599 $pos[$item[
"id"]] = $item[
"pos"];
612 foreach(array_keys($a_pos) as
$id)
616 $ilDB->update(
"il_poll_answer",
617 array(
"pos" => array(
"integer", $pos)),
618 array(
"id" => array(
"integer",
$id)));
628 $ilDB->manipulate(
"DELETE FROM il_poll_vote".
629 " WHERE answer_id = ".
$ilDB->quote($this->getId(),
"integer"));
631 $ilDB->manipulate(
"DELETE FROM il_poll_answer".
632 " WHERE id = ".
$ilDB->quote($a_id,
"integer"));
644 $ilDB->manipulate(
"DELETE FROM il_poll_answer".
645 " WHERE poll_id = ".
$ilDB->quote($this->getId(),
"integer"));
655 $ilDB->manipulate(
"DELETE FROM il_poll_vote".
656 " WHERE poll_id = ".
$ilDB->quote($this->getId(),
"integer"));
666 foreach($a_answers as $answer)
672 foreach($existing as $idx => $item)
674 if(trim($answer) == $item[
"answer"])
677 unset($existing[$idx]);
698 if(
sizeof($existing))
700 foreach($existing as $item)
729 if(!is_array($a_answers))
731 $a_answers = array($a_answers);
734 foreach($a_answers as $answer_id)
736 $fields = array(
"user_id" => array(
"integer", $a_user_id),
737 "poll_id" => array(
"integer", $this->
getId()),
738 "answer_id" => array(
"integer", $answer_id));
739 $ilDB->insert(
"il_poll_vote", $fields);
747 $sql =
"SELECT user_id".
748 " FROM il_poll_vote".
749 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer").
750 " AND user_id = ".$ilDB->quote($a_user_id,
"integer");
752 $set =
$ilDB->query($sql);
753 return (
bool)
$ilDB->numRows($set);
760 $sql =
"SELECT COUNT(DISTINCT(user_id)) cnt".
761 " FROM il_poll_vote".
762 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer");
763 $set =
$ilDB->query($sql);
765 return (
int)
$row[
"cnt"];
775 $sql =
"SELECT answer_id, count(*) cnt".
776 " FROM il_poll_vote".
777 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer").
778 " GROUP BY answer_id";
779 $set =
$ilDB->query($sql);
783 $res[
$row[
"answer_id"]] = array(
"abs"=>
$row[
"cnt"],
"perc"=>0);
788 $res[
$id][
"perc"] = $item[
"abs"]/$cnt*100;
800 $sql =
"SELECT answer_id, user_id, firstname, lastname, login".
801 " FROM il_poll_vote".
802 " JOIN usr_data ON (usr_data.usr_id = il_poll_vote.user_id)".
803 " WHERE poll_id = ".$ilDB->quote($this->
getId(),
"integer");
804 $set =
$ilDB->query($sql);
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
static activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
Activate notes feature.
setShowResultsAs($a_value)
const VIEW_RESULTS_ALWAYS
uploadImage(array $a_upload, $a_clone=false)
Upload new image file.
__construct($a_id=0, $a_reference=true)
Constructor @access public.
doCloneObject(ilObjPoll $new_obj, $a_target_id, $a_copy_id=0)
Clone poll.
setNonAnonymous($a_value)
static initStorage($a_id, $a_subdir=null)
Init file system storage.
setVotingPeriodBegin($a_value)
const SHOW_RESULTS_AS_PIECHART
saveAnswer($a_text, $a_pos=null)
const VIEW_RESULTS_AFTER_VOTE
setMaxNumberOfAnswers($a_value)
setVotingPeriod($a_value)
updateAnswerPositions(array $a_pos)
const SHOW_RESULTS_AS_BARCHART
saveAnswers(array $a_answers)
setSortResultByVotes($a_value)
const VIEW_RESULTS_AFTER_PERIOD
updateAnswer($a_id, $a_text)
saveVote($a_user_id, $a_answers)
deleteImage()
remove existing file
setVotingPeriodEnd($a_value)
setAccessVisibility($a_value)
setShowComments($a_value)
getImageFullPath($a_as_thumb=false)
Get image incl.
Class ilObject2 This is an intermediate progress of ilObject class.
getType()
get object type @access public
update()
update object in db
getId()
get object id @access public
Class ilObjectActivation.
const TIMINGS_DEACTIVATED
static deleteAllEntries($a_ref_id)
Delete all db entries for ref id.
static getItem($a_ref_id)
Get item data.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static escapeShellArg($a_arg)
static execConvert($args)
execute convert command