FeedbackGUI Class. More...
Public Member Functions | |
ilFeedback ($a_id=0) | |
setId ($a_id) | |
getId () | |
setTitle ($a_title) | |
getTitle () | |
setDescription ($a_description) | |
getDescription () | |
setAnonymous ($a_anonymous) | |
getAnonymous () | |
setRequired ($a_required) | |
getRequired () | |
setShowOn ($a_show_location) | |
getShowOn () | |
setVotes ($a_votes) | |
getVotes () | |
setStarttime ($a_starttime) | |
getStarttime () | |
setEndtime ($a_endtime) | |
getEndtime () | |
setInterval ($a_interval) | |
getInterval () | |
setIntervalUnit ($a_interval_unit) | |
getIntervalUnit () | |
setFirstVoteBest ($a_first_vote_best) | |
getFirstVoteBest () | |
setObjId ($a_obj_id) | |
getObjId () | |
setRefId ($a_ref_id) | |
getRefId () | |
setTextAnswer ($a_text_answer) | |
getTextAnswer () | |
setIds ($a_ids) | |
setUserId ($a_user_id) | |
setVote ($a_vote) | |
setNote ($a_note) | |
setAllData ($a_barometer) | |
set all data of a baromter | |
create () | |
create an new barometer | |
update () | |
update a barometer | |
getBarometer () | |
get a baromter by id | |
getBarometerByObjId () | |
get a barometer by obj_id | |
getBarometerByRefId () | |
get a baromter by ref_id | |
getFeedback ($required=0) | |
get a required baromter for a certain ref_id | |
getAllBarometer ($a_show_inactive=1, $a_only_req=0) | |
get all barometers for a certain ref_id if no ref_id is set we get all barometers, this is needed for the personal desktop box. | |
delete () | |
delete a barometer and its results | |
saveResult () | |
save a feedback result | |
canVote ($a_user_id, $a_fb_id) | |
check if a certain user has already answerd a certain barometer | |
getChartData () | |
get the information to display on the charts | |
getNotes () | |
get the comments of an user or all users | |
getResultUsers () | |
get all users that have answerd a certain barometer | |
interval2seconds ($a_interval, $a_interval_unit) | |
convert a interval with unit to seconds ex. |
FeedbackGUI Class.
Definition at line 35 of file class.ilFeedback.php.
ilFeedback::canVote | ( | $ | a_user_id, | |
$ | a_fb_id | |||
) |
check if a certain user has already answerd a certain barometer
Definition at line 353 of file class.ilFeedback.php.
References $q, $res, ilCourseMembers::_isMember(), and interval2seconds().
Referenced by saveResult().
{ global $ilDB, $ilUser; include_once('course/classes/class.ilCourseMembers.php'); $q = "SELECT * FROM feedback_results WHERE ". "fb_id=".$ilDB->quote($a_fb_id)." AND ". "user_id=".$ilDB->quote($a_user_id)." ORDER BY votetime DESC";; $res = $ilDB->query($q); $row_results = $res->fetchRow(DB_FETCHMODE_ASSOC); $q = "SELECT * FROM feedback_items WHERE ". "fb_id = ".$ilDB->quote($a_fb_id); $res1 = $ilDB->query($q); $row_items = $res1->fetchRow(DB_FETCHMODE_ASSOC); // check end time if (!($row_items["starttime"]<=time() && $row_items["endtime"]>=time())) { return (0); } //Check if the user is Member of that course, otherwise its not necessary that he votes if(($res->numRows()==0)&&ilCourseMembers::_isMember($ilUser->getId(),$row_items['obj_id'])) return(1); if(ilCourseMembers::_isMember($ilUser->getId(),$row_items['obj_id'])){ if($row_items['repeat_interval'] > 0){ $interval = $this->interval2seconds($row_items['repeat_interval'], $row_items['interval_unit']); if((time() - $row_results['votetime']) >= $interval){ return(1); } } } return(0); }
ilFeedback::create | ( | ) |
create an new barometer
Definition at line 182 of file class.ilFeedback.php.
References $q.
{ global $ilDB; $q = "INSERT INTO feedback_items (title, description, anonymous,". "required, show_on, text_answer, votes, starttime, endtime, ". "repeat_interval, interval_unit, first_vote_best, ref_id,obj_id) VALUES(". $ilDB->quote($this->title).", ". $ilDB->quote($this->description).", ". $ilDB->quote($this->anonymous).", ". $ilDB->quote($this->required).", ". $ilDB->quote($this->show_on).", ". $ilDB->quote($this->text_answer).", ". $ilDB->quote($this->votes).", ". $ilDB->quote($this->starttime).", ". $ilDB->quote($this->endtime).", ". $ilDB->quote($this->interval).", ". $ilDB->quote($this->interval_unit).", ". $ilDB->quote($this->first_vote_best).", ". $ilDB->quote($this->ref_id).", ". $ilDB->quote($this->obj_id).")"; $ilDB->query($q); $this->id = $ilDB->getLastInsertId(); }
ilFeedback::delete | ( | ) |
delete a barometer and its results
Definition at line 320 of file class.ilFeedback.php.
References $q.
ilFeedback::getAllBarometer | ( | $ | a_show_inactive = 1 , |
|
$ | a_only_req = 0 | |||
) |
get all barometers for a certain ref_id if no ref_id is set we get all barometers, this is needed for the personal desktop box.
Definition at line 288 of file class.ilFeedback.php.
References $q, $res, $row, and ilFeedback().
{ global $ilDB; if($this->ref_id) $where.=" ref_id=".$ilDB->quote($this->ref_id); if($a_only_req==1) if($where!='') $where .= ' AND required=1 '; else $where = ' required = 1 '; $q = "SELECT * FROM feedback_items WHERE ".$where; if($a_show_inactive==0){ if($where!='') $where = ' AND'.$where; $q = "SELECT * FROM feedback_items WHERE ". " ((starttime<=UNIX_TIMESTAMP() AND". " endtime>=UNIX_TIMESTAMP()) OR(starttime<=0 AND endtime<=0))".$where; } $res = $ilDB->query($q); $i = 0; while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){ $barometers[$i] = new ilFeedback(); $barometers[$i]->setAllData($row); $i++; } return $barometers ? $barometers : array(); }
ilFeedback::getAnonymous | ( | ) |
Definition at line 66 of file class.ilFeedback.php.
{
return($this->anonymous);
}
ilFeedback::getBarometer | ( | ) |
get a baromter by id
Definition at line 235 of file class.ilFeedback.php.
References $q, $res, $row, and setAllData().
Referenced by ilFeedback().
{ global $ilDB; $q = "SELECT * FROM feedback_items WHERE fb_id=".$ilDB->quote($this->id); $res = $ilDB->query($q); if($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) $this->setAllData($row); }
ilFeedback::getBarometerByObjId | ( | ) |
get a barometer by obj_id
Definition at line 247 of file class.ilFeedback.php.
References $q, $res, $row, and setAllData().
{ global $ilDB; $q = "SELECT * FROM feedback_items WHERE obj_id=".$ilDB->quote($this->obj_id); $res = $ilDB->query($q); if($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) $this->setAllData($row); }
ilFeedback::getBarometerByRefId | ( | ) |
get a baromter by ref_id
Definition at line 259 of file class.ilFeedback.php.
References $q, $res, $row, and setAllData().
{ global $ilDB; $q = "SELECT * FROM feedback_items WHERE ref_id=".$ilDB->quote($this->ref_id); $res = $ilDB->query($q); if($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) $this->setAllData($row); }
ilFeedback::getChartData | ( | ) |
get the information to display on the charts
Definition at line 395 of file class.ilFeedback.php.
References $data, $legend, $q, $res, $row, and $table.
{ global $ilDB; if($this->user_id!='') $user_filter = ' feedback_results.user_id='.$ilDB->quote($this->user_id).' AND '; $q='SELECT usr_data.login, feedback_results.user_id,feedback_results.vote, feedback_results.votetime, FROM_UNIXTIME(feedback_results.votetime,"%d.%m.%Y %H:%i") as timelabel FROM'. ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id WHERE '. ' '.$user_filter.' feedback_results.fb_id='.$ilDB->quote($this->id). ' ORDER BY feedback_results.votetime,usr_data.login'; $res = $ilDB->query($q); $i=0; $j=1; $k=1; $n=0; $pvt=''; $datapie[0][0] = 'Vote'; while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){ if(!isset($tmp[$row['user_id']])) $tmp[$row['user_id']]=$j++; if(!isset($tmpv[$row['vote']])) $tmpv[$row['vote']] = $k++; $data[$i][0] = $row['timelabel']; $data[$i][$tmp[$row['user_id']]] = $row['vote']; $legend[$row['login']] = $row['login']; $legendpie[$row['vote']] = $row['vote']; $datapie[0][$tmpv[$row['vote']]]++; if($row['votetime']!=$pvt){ $i++; } $pvt=$row['votetime']; $table[$n]['votetime'] = $row['timelabel']; $table[$n]['user'] = $row['login']; $table[$n]['vote'] = $row['vote']; $n++; } if(is_array($data)){ foreach($data as $k => $v){ /* Look if there are set all Y-values. If a user has no Y value for a certain date, the Y value has to be set to something otherwise PHPlot will not work correctly. The array keys have also to be sorted for PHPlot */ if(count($v)<=count($tmp)){ for($i=1;$i<=count($tmp);$i++) if(!isset($v[$i])) $data[$k][$i]=''; } ksort($data[$k]); } } return(array('data' => $data,'legend' => $legend,'legendpie' => $legendpie, 'datapie' => $datapie, 'table' => $table)); }
ilFeedback::getDescription | ( | ) |
Definition at line 59 of file class.ilFeedback.php.
{
return($this->description);
}
ilFeedback::getEndtime | ( | ) |
Definition at line 101 of file class.ilFeedback.php.
{
return($this->endtime);
}
ilFeedback::getFeedback | ( | $ | required = 0 |
) |
get a required baromter for a certain ref_id
Definition at line 271 of file class.ilFeedback.php.
References $q, $res, $row, and setAllData().
{ global $ilDB; $filter_req = ($required) ? ' required=1 AND ' : ''; $q = "SELECT * FROM feedback_items WHERE ". $filter_req. " ((starttime<=UNIX_TIMESTAMP() AND". " endtime>=UNIX_TIMESTAMP()) OR(starttime<=0 AND endtime<=0))"; $res = $ilDB->query($q); if($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) $this->setAllData($row); }
ilFeedback::getFirstVoteBest | ( | ) |
Definition at line 122 of file class.ilFeedback.php.
{
return($this->first_vote_best);
}
ilFeedback::getId | ( | ) |
Definition at line 47 of file class.ilFeedback.php.
{ return($this->id); }
ilFeedback::getInterval | ( | ) |
Definition at line 108 of file class.ilFeedback.php.
{
return($this->interval);
}
ilFeedback::getIntervalUnit | ( | ) |
Definition at line 115 of file class.ilFeedback.php.
{
return($this->interval_unit);
}
ilFeedback::getNotes | ( | ) |
get the comments of an user or all users
Definition at line 453 of file class.ilFeedback.php.
References $data, $q, $res, and $row.
{ global $ilDB; if($this->user_id!='') $user_filter = ' AND feedback_results.user_id='.$ilDB->quote($this->user_id); $q='SELECT usr_data.login, feedback_results.user_id,feedback_results.note,feedback_results.vote, feedback_results.votetime, FROM_UNIXTIME(feedback_results.votetime,"%d.%m.%Y %H:%i") as timelabel FROM'. ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id'. ' WHERE feedback_results.note<>""'. ' '.$user_filter.' AND feedback_results.fb_id='.$ilDB->quote($this->id). ' ORDER BY feedback_results.votetime,usr_data.login'; $res = $ilDB->query($q); $i=0; while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){ $data[$i]['user'] = $row['login']; $data[$i]['votetime'] = $row['timelabel']; $data[$i]['note'] = $row['note']; $i++; } return($data); }
ilFeedback::getObjId | ( | ) |
Definition at line 129 of file class.ilFeedback.php.
{
return($this->obj_id);
}
ilFeedback::getRefId | ( | ) |
Definition at line 135 of file class.ilFeedback.php.
{
return($this->ref_id);
}
ilFeedback::getRequired | ( | ) |
Definition at line 73 of file class.ilFeedback.php.
{
return($this->required);
}
ilFeedback::getResultUsers | ( | ) |
get all users that have answerd a certain barometer
Definition at line 476 of file class.ilFeedback.php.
References $q, $res, $row, and $users.
{ global $ilDB; $q='SELECT distinct(usr_data.login), feedback_results.user_id FROM'. ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id'. ' WHERE feedback_results.fb_id='.$ilDB->quote($this->id). ' ORDER BY feedback_results.votetime,usr_data.login'; $res = $ilDB->query($q); while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){ $users[$row['user_id']] = $row['login']; } return($users); }
ilFeedback::getShowOn | ( | ) |
Definition at line 80 of file class.ilFeedback.php.
{
return($this->show_on);
}
ilFeedback::getStarttime | ( | ) |
Definition at line 94 of file class.ilFeedback.php.
{
return($this->starttime);
}
ilFeedback::getTextAnswer | ( | ) |
Definition at line 142 of file class.ilFeedback.php.
{
return($this->text_answer);
}
ilFeedback::getTitle | ( | ) |
Definition at line 53 of file class.ilFeedback.php.
{
return($this->title);
}
ilFeedback::getVotes | ( | ) |
Definition at line 87 of file class.ilFeedback.php.
{
return($this->votes);
}
ilFeedback::ilFeedback | ( | $ | a_id = 0 |
) |
Definition at line 36 of file class.ilFeedback.php.
References getBarometer().
Referenced by getAllBarometer().
{ if($a_id > 0){ $this->id = $a_id; $this->getBarometer(); } }
ilFeedback::interval2seconds | ( | $ | a_interval, | |
$ | a_interval_unit | |||
) |
convert a interval with unit to seconds ex.
4 days to seconds
Definition at line 496 of file class.ilFeedback.php.
Referenced by canVote().
{ switch($a_interval_unit){ case 1: //Days $multi_by = 24 * 60 * 60; break; case 2: //Weeks $mult_by = 7 * 24 * 60 * 60; break; case 3: // Months $mult_by = 30 * 24 * 60 *60; break; default: //Hours $mult_by = 60 * 60; break; } $seconds = $a_interval * $mult_by; return($seconds); }
ilFeedback::saveResult | ( | ) |
save a feedback result
Definition at line 335 of file class.ilFeedback.php.
{ global $ilDB; //Save Only if there is not already a result from this user for this barometer if($this->canVote($this->user_id,$this->id)==1){ $q = "INSERT INTO feedback_results (". "fb_id,user_id,vote,note,votetime) VALUES (". $ilDB->quote($this->id).", ". $ilDB->quote($this->user_id).", ". $ilDB->quote($this->vote).", ". $ilDB->quote($this->note).", UNIX_TIMESTAMP())"; $ilDB->query($q); } }
ilFeedback::setAllData | ( | $ | a_barometer | ) |
set all data of a baromter
Definition at line 161 of file class.ilFeedback.php.
References setAnonymous(), setDescription(), setEndtime(), setFirstVoteBest(), setId(), setInterval(), setIntervalUnit(), setObjId(), setRefId(), setRequired(), setShowOn(), setStarttime(), setTextAnswer(), setTitle(), and setVotes().
Referenced by getBarometer(), getBarometerByObjId(), getBarometerByRefId(), and getFeedback().
{ $this->setId($a_barometer['fb_id']); $this->setTitle($a_barometer['title']); $this->setDescription($a_barometer['description']); $this->setAnonymous($a_barometer['anonymous']); $this->setRequired($a_barometer['required']); $this->setShowOn($a_barometer['show_on']); $this->setVotes($a_barometer['votes']); $this->setStarttime($a_barometer['starttime']); $this->setEndtime($a_barometer['endtime']); $this->setInterval($a_barometer['repeat_interval']); $this->setIntervalUnit($a_barometer['interval_unit']); $this->setFirstVoteBest($a_barometer['first_vote_best']); $this->setTextAnswer($a_barometer['text_answer']); $this->setObjId($a_barometer['obj_id']); $this->setRefId($a_barometer['ref_id']); }
ilFeedback::setAnonymous | ( | $ | a_anonymous | ) |
Definition at line 62 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->anonymous = $a_anonymous; }
ilFeedback::setDescription | ( | $ | a_description | ) |
Definition at line 56 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->description = $a_description; }
ilFeedback::setEndtime | ( | $ | a_endtime | ) |
Definition at line 97 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->endtime = $a_endtime; }
ilFeedback::setFirstVoteBest | ( | $ | a_first_vote_best | ) |
Definition at line 118 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->first_vote_best = $a_first_vote_best; }
ilFeedback::setId | ( | $ | a_id | ) |
Definition at line 44 of file class.ilFeedback.php.
Referenced by setAllData().
{
$this->id = $a_id;
}
ilFeedback::setIds | ( | $ | a_ids | ) |
Definition at line 145 of file class.ilFeedback.php.
{ $this->ids = $a_ids; }
ilFeedback::setInterval | ( | $ | a_interval | ) |
Definition at line 104 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->interval = $a_interval; }
ilFeedback::setIntervalUnit | ( | $ | a_interval_unit | ) |
Definition at line 111 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->interval_unit = $a_interval_unit; }
ilFeedback::setNote | ( | $ | a_note | ) |
Definition at line 154 of file class.ilFeedback.php.
{ $this->note = $a_note; }
ilFeedback::setObjId | ( | $ | a_obj_id | ) |
Definition at line 125 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->obj_id = $a_obj_id; }
ilFeedback::setRefId | ( | $ | a_ref_id | ) |
Definition at line 132 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->ref_id = $a_ref_id; }
ilFeedback::setRequired | ( | $ | a_required | ) |
Definition at line 69 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->required = $a_required; }
ilFeedback::setShowOn | ( | $ | a_show_location | ) |
Definition at line 76 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->show_on = $a_show_location; }
ilFeedback::setStarttime | ( | $ | a_starttime | ) |
Definition at line 90 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->starttime = $a_starttime; }
ilFeedback::setTextAnswer | ( | $ | a_text_answer | ) |
Definition at line 138 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->text_answer = $a_text_answer; }
ilFeedback::setTitle | ( | $ | a_title | ) |
Definition at line 50 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->title = $a_title; }
ilFeedback::setUserId | ( | $ | a_user_id | ) |
Definition at line 148 of file class.ilFeedback.php.
{ $this->user_id = $a_user_id; }
ilFeedback::setVote | ( | $ | a_vote | ) |
Definition at line 151 of file class.ilFeedback.php.
{ $this->vote = $a_vote; }
ilFeedback::setVotes | ( | $ | a_votes | ) |
Definition at line 83 of file class.ilFeedback.php.
Referenced by setAllData().
{ $this->votes = $a_votes; }
ilFeedback::update | ( | ) |
update a barometer
Definition at line 210 of file class.ilFeedback.php.
References $q.
{ global $ilDB; $q = "UPDATE feedback_items set ". "title=".$ilDB->quote($this->title).", ". "description=".$ilDB->quote($this->description).", ". "anonymous=".$ilDB->quote($this->anonymous).", ". "required=".$ilDB->quote($this->required).", ". "show_on=".$ilDB->quote($this->show_on).", ". "text_answer=".$ilDB->quote($this->text_answer).", ". "votes=".$ilDB->quote($this->votes).", ". "starttime=".$ilDB->quote($this->starttime).", ". "endtime=".$ilDB->quote($this->endtime).", ". "repeat_interval=".$ilDB->quote($this->interval).", ". "interval_unit=".$ilDB->quote($this->interval_unit).", ". "first_vote_best=".$ilDB->quote($this->first_vote_best)." WHERE fb_id=".$ilDB->quote($this->id); $ilDB->query($q); $this->id = $ilDB->getLastInsertId(); }