51 $this->title = $a_title;
57 $this->description = $a_description;
60 return($this->description);
63 $this->anonymous = $a_anonymous;
67 return($this->anonymous);
70 $this->required = $a_required;
74 return($this->required);
77 $this->show_on = $a_show_location;
81 return($this->show_on);
84 $this->votes = $a_votes;
91 $this->starttime = $a_starttime;
95 return($this->starttime);
98 $this->endtime = $a_endtime;
102 return($this->endtime);
105 $this->interval = $a_interval;
109 return($this->interval);
112 $this->interval_unit = $a_interval_unit;
116 return($this->interval_unit);
119 $this->first_vote_best = $a_first_vote_best;
123 return($this->first_vote_best);
126 $this->obj_id = $a_obj_id;
130 return($this->obj_id);
133 $this->ref_id = $a_ref_id;
136 return($this->ref_id);
139 $this->text_answer = $a_text_answer;
143 return($this->text_answer);
149 $this->user_id = $a_user_id;
152 $this->vote = $a_vote;
155 $this->note = $a_note;
162 $this->
setId($a_barometer[
'fb_id']);
163 $this->
setTitle($a_barometer[
'title']);
167 $this->
setShowOn($a_barometer[
'show_on']);
168 $this->
setVotes($a_barometer[
'votes']);
171 $this->
setInterval($a_barometer[
'repeat_interval']);
175 $this->
setObjId($a_barometer[
'obj_id']);
176 $this->
setRefId($a_barometer[
'ref_id']);
184 $q =
"INSERT INTO feedback_items (title, description, anonymous,".
185 "required, show_on, text_answer, votes, starttime, endtime, ".
186 "repeat_interval, interval_unit, first_vote_best, ref_id,obj_id) VALUES(".
187 $ilDB->quote($this->title).
", ".
188 $ilDB->quote($this->description).
", ".
189 $ilDB->quote($this->anonymous).
", ".
190 $ilDB->quote($this->required).
", ".
191 $ilDB->quote($this->show_on).
", ".
192 $ilDB->quote($this->text_answer).
", ".
193 $ilDB->quote($this->votes).
", ".
194 $ilDB->quote($this->starttime).
", ".
195 $ilDB->quote($this->endtime).
", ".
196 $ilDB->quote($this->interval).
", ".
197 $ilDB->quote($this->interval_unit).
", ".
198 $ilDB->quote($this->first_vote_best).
", ".
199 $ilDB->quote($this->ref_id).
", ".
200 $ilDB->quote($this->obj_id).
")";
202 $this->
id = $ilDB->getLastInsertId();
212 $q =
"UPDATE feedback_items set ".
213 "title=".$ilDB->quote($this->title).
", ".
214 "description=".$ilDB->quote($this->description).
", ".
215 "anonymous=".$ilDB->quote($this->anonymous).
", ".
216 "required=".$ilDB->quote($this->required).
", ".
217 "show_on=".$ilDB->quote($this->show_on).
", ".
218 "text_answer=".$ilDB->quote($this->text_answer).
", ".
219 "votes=".$ilDB->quote($this->votes).
", ".
220 "starttime=".$ilDB->quote($this->starttime).
", ".
221 "endtime=".$ilDB->quote($this->endtime).
", ".
222 "repeat_interval=".$ilDB->quote($this->interval).
", ".
223 "interval_unit=".$ilDB->quote($this->interval_unit).
", ".
224 "first_vote_best=".$ilDB->quote($this->first_vote_best).
" WHERE fb_id=".$ilDB->quote($this->
id);
227 $this->
id = $ilDB->getLastInsertId();
237 $q =
"SELECT * FROM feedback_items WHERE fb_id=".$ilDB->quote($this->
id);
238 $res = $ilDB->query($q);
249 $q =
"SELECT * FROM feedback_items WHERE obj_id=".$ilDB->quote($this->obj_id);
250 $res = $ilDB->query($q);
261 $q =
"SELECT * FROM feedback_items WHERE ref_id=".$ilDB->quote($this->ref_id);
262 $res = $ilDB->query($q);
273 $filter_req = ($required) ?
' required=1 AND ' :
'';
274 $q =
"SELECT * FROM feedback_items WHERE ".
276 " ((starttime<=UNIX_TIMESTAMP() AND".
277 " endtime>=UNIX_TIMESTAMP()) OR(starttime<=0 AND endtime<=0))";
278 $res = $ilDB->query($q);
292 $where.=
" ref_id=".$ilDB->quote($this->ref_id);
295 $where .=
' AND required=1 ';
297 $where =
' required = 1 ';
298 $q =
"SELECT * FROM feedback_items WHERE ".$where;
300 if($a_show_inactive==0){
302 $where =
' AND'.$where;
303 $q =
"SELECT * FROM feedback_items WHERE ".
304 " ((starttime<=UNIX_TIMESTAMP() AND".
305 " endtime>=UNIX_TIMESTAMP()) OR(starttime<=0 AND endtime<=0))".$where;
307 $res = $ilDB->query($q);
311 $barometers[$i]->setAllData($row);
315 return $barometers ? $barometers : array();
322 foreach ($this->ids as $k => $v)
323 $this->ids[$k] = $ilDB->quote($v);
324 $q =
"DELETE FROM feedback_items WHERE ".
325 "fb_id IN (".implode(
',',$this->ids).
")";
327 $q =
"DELETE FROM feedback_results WHERE ".
328 "fb_id IN (".implode(
',',$this->ids).
")";
339 if($this->
canVote($this->user_id,$this->
id)==1 || $this->user_id == 0){
340 $q =
"INSERT INTO feedback_results (".
341 "fb_id,user_id,vote,note,votetime) VALUES (".
342 $ilDB->quote($this->
id).
", ".
343 $ilDB->quote($this->user_id).
", ".
344 $ilDB->quote($this->vote).
", ".
345 $ilDB->quote($this->note).
", UNIX_TIMESTAMP())";
354 global $ilDB, $ilUser;
355 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
357 $q =
"SELECT * FROM feedback_results WHERE ".
358 "fb_id=".$ilDB->quote($a_fb_id).
" AND ".
359 "user_id=".$ilDB->quote($a_user_id).
" ORDER BY votetime DESC";;
360 $res = $ilDB->query($q);
363 $q =
"SELECT * FROM feedback_items WHERE ".
364 "fb_id = ".$ilDB->quote($a_fb_id);
365 $res1 = $ilDB->query($q);
369 if (!($row_items[
"starttime"]<=time() && $row_items[
"endtime"]>=time()))
377 if((
$res->numRows()==0) && $members_obj->isAssigned($ilUser->getId()))
380 if($members_obj->isAssigned($ilUser->getId()))
382 if($row_items[
'repeat_interval'] > 0){
383 $interval = $this->
interval2seconds($row_items[
'repeat_interval'], $row_items[
'interval_unit']);
384 if((time() - $row_results[
'votetime']) >= $interval){
399 if($this->user_id!=
'')
400 $user_filter =
' feedback_results.user_id='.$ilDB->quote($this->user_id).
' AND ';
401 $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'.
402 ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id WHERE '.
403 ' '.$user_filter.
' feedback_results.fb_id='.$ilDB->quote($this->
id).
404 ' ORDER BY feedback_results.votetime,usr_data.login';
406 $res = $ilDB->query($q);
412 $datapie[0][0] =
'Vote';
415 if(!isset($tmp[$row[
'user_id']]))
416 $tmp[$row[
'user_id']]=$j++;
417 if(!isset($tmpv[$row[
'vote']]))
418 $tmpv[$row[
'vote']] = $k++;
419 $data[$i][0] = $row[
'timelabel'];
420 $data[$i][$tmp[$row[
'user_id']]] = $row[
'vote'];
421 $legend[$row[
'login']] = $row[
'login'];
422 $legendpie[$row[
'vote']] = $row[
'vote'];
425 $datapie[0][$tmpv[$row[
'vote']]]++;
426 if($row[
'votetime']!=$pvt){
430 $pvt=$row[
'votetime'];
432 $table[
$n][
'votetime'] = $row[
'timelabel'];
433 $table[
$n][
'user'] = $row[
'login'];
434 $table[
$n][
'vote'] = $row[
'vote'];
438 foreach(
$data as $k => $v){
441 if(count($v)<=count($tmp)){
442 for($i=1;$i<=count($tmp);$i++)
449 return(array(
'data' =>
$data,
'legend' =>
$legend,
'legendpie' => $legendpie,
'datapie' => $datapie,
'table' => $table));
457 if($this->user_id!=
'')
458 $user_filter =
' AND feedback_results.user_id='.$ilDB->quote($this->user_id);
459 $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'.
460 ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id'.
461 ' WHERE feedback_results.note<>""'.
462 ' '.$user_filter.
' AND feedback_results.fb_id='.$ilDB->quote($this->
id).
463 ' ORDER BY feedback_results.votetime,usr_data.login';
465 $res = $ilDB->query($q);
468 $data[$i][
'user'] = $row[
'login'];
469 $data[$i][
'votetime'] = $row[
'timelabel'];
470 $data[$i][
'note'] = $row[
'note'];
481 $q=
'SELECT distinct(usr_data.login), feedback_results.user_id FROM'.
482 ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id'.
483 ' WHERE feedback_results.fb_id='.$ilDB->quote($this->
id).
484 ' ORDER BY feedback_results.votetime,usr_data.login';
486 $res = $ilDB->query($q);
489 $users[$row[
'user_id']] = $row[
'login'];
499 switch($a_interval_unit){
502 $multi_by = 24 * 60 * 60;
506 $mult_by = 7 * 24 * 60 * 60;
510 $mult_by = 30 * 24 * 60 *60;
518 $seconds = $a_interval * $mult_by;