37 $this->title = $a_title;
43 $this->description = $a_description;
46 return($this->description);
49 $this->anonymous = $a_anonymous;
53 return($this->anonymous);
56 $this->required = $a_required;
60 return($this->required);
63 $this->show_on = $a_show_location;
67 return($this->show_on);
70 $this->votes = $a_votes;
77 $this->starttime = $a_starttime;
81 return($this->starttime);
84 $this->endtime = $a_endtime;
88 return($this->endtime);
91 $this->interval = $a_interval;
95 return($this->interval);
98 $this->interval_unit = $a_interval_unit;
102 return($this->interval_unit);
105 $this->first_vote_best = $a_first_vote_best;
109 return($this->first_vote_best);
112 $this->obj_id = $a_obj_id;
116 return($this->obj_id);
119 $this->ref_id = $a_ref_id;
122 return($this->ref_id);
125 $this->text_answer = $a_text_answer;
129 return($this->text_answer);
135 $this->user_id = $a_user_id;
138 $this->vote = $a_vote;
141 $this->note = $a_note;
148 $this->
setId($a_barometer[
'fb_id']);
149 $this->
setTitle($a_barometer[
'title']);
153 $this->
setShowOn($a_barometer[
'show_on']);
154 $this->
setVotes($a_barometer[
'votes']);
157 $this->
setInterval($a_barometer[
'repeat_interval']);
161 $this->
setObjId($a_barometer[
'obj_id']);
162 $this->
setRefId($a_barometer[
'ref_id']);
172 $this->
id = $ilDB->nextId(
"feedback_items");
191 $ilDB->insert(
"feedback_items", array(
192 "fb_id" => array(
"integer", $this->
id),
193 "title" => array(
"text", $this->title),
194 "description" => array(
"clob", $this->description),
195 "anonymous" => array(
"integer", (
int) $this->anonymous),
196 "required" => array(
"integer", (
int) $this->required),
197 "show_on" => array(
"text", $this->show_on),
198 "text_answer" => array(
"integer", (
int) $this->text_answer),
199 "votes" => array(
"clob", $this->votes),
200 "starttime" => array(
"integer", (
int) $this->starttime),
201 "endtime" => array(
"integer", (
int) $this->endtime),
202 "repeat_interval" => array(
"integer", (
int) $this->interval),
203 "interval_unit" => array(
"integer", (
int) $this->interval_unit),
204 "first_vote_best" => array(
"integer", (
int) $this->first_vote_best),
205 "ref_id" => array(
"integer", (
int) $this->ref_id),
206 "obj_id" => array(
"integer", (
int) $this->obj_id)
236 $ilDB->update(
"feedback_items", array(
237 "title" => array(
"text", $this->title),
238 "description" => array(
"clob", $this->description),
239 "anonymous" => array(
"integer", (
int) $this->anonymous),
240 "required" => array(
"integer", (
int) $this->required),
241 "show_on" => array(
"text", $this->show_on),
242 "text_answer" => array(
"integer", (
int) $this->text_answer),
243 "votes" => array(
"clob", $this->votes),
244 "starttime" => array(
"integer", (
int) $this->starttime),
245 "endtime" => array(
"integer", (
int) $this->endtime),
246 "repeat_interval" => array(
"integer", (
int) $this->interval),
247 "interval_unit" => array(
"integer", (
int) $this->interval_unit),
248 "first_vote_best" => array(
"integer", (
int) $this->first_vote_best)
250 "fb_id" => array(
"integer", $this->
id)
262 $q =
"SELECT * FROM feedback_items WHERE fb_id = ".
263 $ilDB->quote($this->
id,
"integer");
264 $res = $ilDB->query($q);
278 $q =
"SELECT * FROM feedback_items WHERE obj_id = ".
279 $ilDB->quote($this->obj_id,
"integer");
280 $res = $ilDB->query($q);
293 $q =
"SELECT * FROM feedback_items WHERE ref_id = ".
294 $ilDB->quote($this->ref_id,
"integer");
295 $res = $ilDB->query($q);
309 $filter_req = ($required)
310 ?
' required = 1 AND '
312 $q =
"SELECT * FROM feedback_items WHERE ".
314 " ((starttime <= ".$ilDB->quote(time(),
"integer").
" AND".
315 " endtime >= ".$ilDB->quote(time(),
"integer").
316 ") OR (starttime <= 0 AND endtime <= 0))";
318 $res = $ilDB->query($q);
338 $where.=
" ref_id = ".$ilDB->quote($this->ref_id,
"integer");
340 if ($a_only_req == 1)
344 $where .=
' AND required = 1 ';
348 $where =
' required = 1 ';
351 $q =
"SELECT * FROM feedback_items WHERE ".$where;
353 if ($a_show_inactive == 0)
357 $where =
' AND '.$where;
359 $q =
"SELECT * FROM feedback_items WHERE ".
360 " ((starttime <= ".$ilDB->quote(time(),
"integer").
" AND".
361 " endtime >= ".$ilDB->quote(time(),
"integer").
362 ") OR (starttime <= 0 AND endtime <=0 ))".$where;
364 $res = $ilDB->query($q);
367 $barometers = array();
368 while(
$row = $ilDB->fetchAssoc(
$res))
371 $barometers[$i]->setAllData(
$row);
392 $q =
"DELETE FROM feedback_items WHERE ".
393 $ilDB->in(
"fb_id", $this->ids,
false,
"integer");
396 $ilDB->manipulate($q);
397 $q =
"DELETE FROM feedback_results WHERE ".
398 $ilDB->in(
"fb_id", $this->ids,
false,
"integer");
400 $ilDB->manipulate($q);
410 if($this->
canVote($this->user_id,$this->
id)==1 || $this->user_id == 0)
420 $ilDB->insert(
"feedback_results", array(
421 "fb_id" => array(
"integer", $this->
id),
422 "user_id" => array(
"integer", $this->user_id),
423 "vote" => array(
"integer", $this->vote),
424 "note" => array(
"clob", $this->note),
425 "votetime" => array(
"integer", time())
434 global
$ilDB, $ilUser;
435 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
437 $q =
"SELECT * FROM feedback_results WHERE ".
438 "fb_id = ".$ilDB->quote($a_fb_id,
"integer").
" AND ".
439 "user_id = ".$ilDB->quote($a_user_id,
"integer").
440 " ORDER BY votetime DESC";;
441 $res = $ilDB->query($q);
443 $row_results = $ilDB->fetchAssoc(
$res);
444 $q =
"SELECT * FROM feedback_items WHERE ".
445 "fb_id = ".$ilDB->quote($a_fb_id,
"integer");
446 $res1 = $ilDB->query($q);
447 $row_items = $ilDB->fetchAssoc($res1);
450 if (!($row_items[
"starttime"]<=time() && $row_items[
"endtime"]>=time()))
458 if((
$res->numRows()==0) && $members_obj->isAssigned($ilUser->getId()))
461 if($members_obj->isAssigned($ilUser->getId()))
463 if($row_items[
'repeat_interval'] > 0){
464 $interval = $this->
interval2seconds($row_items[
'repeat_interval'], $row_items[
'interval_unit']);
465 if((time() - $row_results[
'votetime']) >= $interval){
482 if($this->user_id!=
'')
484 $user_filter =
' feedback_results.user_id = '.$ilDB->quote($this->user_id,
"integer").
' AND ';
486 $q=
'SELECT usr_data.login, feedback_results.user_id,feedback_results.vote, feedback_results.votetime FROM'.
487 ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id WHERE '.
488 ' '.$user_filter.
' feedback_results.fb_id='.$ilDB->quote($this->
id,
"integer").
489 ' ORDER BY feedback_results.votetime,usr_data.login';
491 $res = $ilDB->query($q);
497 $datapie[0][0] =
'Vote';
498 while(
$row = $ilDB->fetchAssoc(
$res))
500 $row[
"timelabel"] = date(
"d.m.Y H:i",
$row[
"votetime"]);
501 if(!isset($tmp[
$row[
'user_id']]))
503 $tmp[$row[
'user_id']]=$j++;
505 if(!isset($tmpv[$row[
'vote']]))
507 $tmpv[$row[
'vote']] = $k++;
509 $data[$i][0] = $row[
'timelabel'];
510 $data[$i][$tmp[$row[
'user_id']]] = $row[
'vote'];
511 $legend[$row[
'login']] = $row[
'login'];
512 $legendpie[$row[
'vote']] = $row[
'vote'];
515 $datapie[0][$tmpv[$row[
'vote']]]++;
516 if($row[
'votetime']!=$pvt){
520 $pvt=$row[
'votetime'];
522 $table[
$n][
'votetime'] = $row[
'timelabel'];
523 $table[
$n][
'user'] = $row[
'login'];
524 $table[
$n][
'vote'] = $row[
'vote'];
529 foreach(
$data as $k => $v)
533 if(count($v)<=count($tmp)){
534 for($i=1;$i<=count($tmp);$i++)
541 return(array(
'data' =>
$data,
'legend' =>
$legend,
'legendpie' => $legendpie,
'datapie' => $datapie,
'table' => $table));
551 if($this->user_id!=
'')
553 $user_filter =
' AND feedback_results.user_id='.$ilDB->quote($this->user_id,
"integer");
555 $q=
'SELECT usr_data.login, feedback_results.user_id,feedback_results.note,feedback_results.vote, feedback_results.votetime FROM'.
556 ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id'.
557 ' WHERE feedback_results.note IS NOT NULL '.
558 ' '.$user_filter.
' AND feedback_results.fb_id='.$ilDB->quote($this->
id,
"integer").
559 ' ORDER BY feedback_results.votetime,usr_data.login';
561 $res = $ilDB->query($q);
563 while(
$row = $ilDB->fetchAssoc(
$res))
565 $row[
"timelabel"] = date(
"d.m.Y H:i",
$row[
"votetime"]);
567 $data[$i][
'votetime'] =
$row[
'timelabel'];
580 $q=
'SELECT distinct(usr_data.login), feedback_results.user_id, feedback_results.votetime '.
582 ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id'.
583 ' WHERE feedback_results.fb_id='.$ilDB->quote($this->
id,
"integer").
584 ' ORDER BY feedback_results.votetime,usr_data.login';
586 $res = $ilDB->query($q);
588 while(
$row = $ilDB->fetchAssoc(
$res))
590 $users[
$row[
'user_id']] = $row[
'login'];
601 switch($a_interval_unit)
605 $multi_by = 24 * 60 * 60;
609 $mult_by = 7 * 24 * 60 * 60;
613 $mult_by = 30 * 24 * 60 *60;
621 $seconds = $a_interval * $mult_by;