35 $this->title = $a_title;
41 $this->description = $a_description;
44 return($this->description);
47 $this->anonymous = $a_anonymous;
51 return($this->anonymous);
54 $this->required = $a_required;
58 return($this->required);
61 $this->show_on = $a_show_location;
65 return($this->show_on);
68 $this->votes = $a_votes;
75 $this->starttime = $a_starttime;
79 return($this->starttime);
82 $this->endtime = $a_endtime;
86 return($this->endtime);
89 $this->interval = $a_interval;
93 return($this->interval);
96 $this->interval_unit = $a_interval_unit;
100 return($this->interval_unit);
103 $this->first_vote_best = $a_first_vote_best;
107 return($this->first_vote_best);
110 $this->obj_id = $a_obj_id;
114 return($this->obj_id);
117 $this->ref_id = $a_ref_id;
120 return($this->ref_id);
123 $this->text_answer = $a_text_answer;
127 return($this->text_answer);
133 $this->user_id = $a_user_id;
136 $this->vote = $a_vote;
139 $this->note = $a_note;
146 $this->
setId($a_barometer[
'fb_id']);
147 $this->
setTitle($a_barometer[
'title']);
151 $this->
setShowOn($a_barometer[
'show_on']);
152 $this->
setVotes($a_barometer[
'votes']);
155 $this->
setInterval($a_barometer[
'repeat_interval']);
159 $this->
setObjId($a_barometer[
'obj_id']);
160 $this->
setRefId($a_barometer[
'ref_id']);
170 $this->
id = $ilDB->nextId(
"feedback_items");
189 $ilDB->insert(
"feedback_items", array(
190 "fb_id" => array(
"integer", $this->
id),
191 "title" => array(
"text", $this->title),
192 "description" => array(
"clob", $this->description),
193 "anonymous" => array(
"integer", (
int) $this->anonymous),
194 "required" => array(
"integer", (
int) $this->required),
195 "show_on" => array(
"text", $this->show_on),
196 "text_answer" => array(
"integer", (
int) $this->text_answer),
197 "votes" => array(
"clob", $this->votes),
198 "starttime" => array(
"integer", (
int) $this->starttime),
199 "endtime" => array(
"integer", (
int) $this->endtime),
200 "repeat_interval" => array(
"integer", (
int) $this->interval),
201 "interval_unit" => array(
"integer", (
int) $this->interval_unit),
202 "first_vote_best" => array(
"integer", (
int) $this->first_vote_best),
203 "ref_id" => array(
"integer", (
int) $this->ref_id),
204 "obj_id" => array(
"integer", (
int) $this->obj_id)
234 $ilDB->update(
"feedback_items", array(
235 "title" => array(
"text", $this->title),
236 "description" => array(
"clob", $this->description),
237 "anonymous" => array(
"integer", (
int) $this->anonymous),
238 "required" => array(
"integer", (
int) $this->required),
239 "show_on" => array(
"text", $this->show_on),
240 "text_answer" => array(
"integer", (
int) $this->text_answer),
241 "votes" => array(
"clob", $this->votes),
242 "starttime" => array(
"integer", (
int) $this->starttime),
243 "endtime" => array(
"integer", (
int) $this->endtime),
244 "repeat_interval" => array(
"integer", (
int) $this->interval),
245 "interval_unit" => array(
"integer", (
int) $this->interval_unit),
246 "first_vote_best" => array(
"integer", (
int) $this->first_vote_best)
248 "fb_id" => array(
"integer", $this->
id)
260 $q =
"SELECT * FROM feedback_items WHERE fb_id = ".
261 $ilDB->quote($this->
id,
"integer");
276 $q =
"SELECT * FROM feedback_items WHERE obj_id = ".
277 $ilDB->quote($this->obj_id,
"integer");
291 $q =
"SELECT * FROM feedback_items WHERE ref_id = ".
292 $ilDB->quote($this->ref_id,
"integer");
307 $filter_req = ($required)
308 ?
' required = 1 AND '
310 $q =
"SELECT * FROM feedback_items WHERE ".
312 " ((starttime <= ".$ilDB->quote(time(),
"integer").
" AND".
313 " endtime >= ".$ilDB->quote(time(),
"integer").
314 ") OR (starttime <= 0 AND endtime <= 0))";
334 $where.=
" ref_id = ".$ilDB->quote($this->ref_id,
"integer");
336 if ($a_only_req == 1)
340 $where .=
' AND required = 1 ';
344 $where =
' required = 1 ';
347 $q =
"SELECT * FROM feedback_items WHERE ".$where;
349 if ($a_show_inactive == 0)
353 $where =
' AND '.$where;
355 $q =
"SELECT * FROM feedback_items WHERE ".
356 " ((starttime <= ".$ilDB->quote(time(),
"integer").
" AND".
357 " endtime >= ".$ilDB->quote(time(),
"integer").
358 ") OR (starttime <= 0 AND endtime <=0 ))".$where;
362 while(
$row = $ilDB->fetchAssoc(
$res))
365 $barometers[$i]->setAllData(
$row);
369 return $barometers ? $barometers : array();
386 $q =
"DELETE FROM feedback_items WHERE ".
387 $ilDB->in(
"fb_id", $this->ids,
false,
"integer");
390 $ilDB->manipulate(
$q);
391 $q =
"DELETE FROM feedback_results WHERE ".
392 $ilDB->in(
"fb_id", $this->ids,
false,
"integer");
394 $ilDB->manipulate(
$q);
404 if($this->
canVote($this->user_id,$this->
id)==1 || $this->user_id == 0)
414 $ilDB->insert(
"feedback_results", array(
415 "fb_id" => array(
"integer", $this->
id),
416 "user_id" => array(
"integer", $this->user_id),
417 "vote" => array(
"integer", $this->vote),
418 "note" => array(
"clob", $this->note),
419 "votetime" => array(
"integer", time())
428 global
$ilDB, $ilUser;
429 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
431 $q =
"SELECT * FROM feedback_results WHERE ".
432 "fb_id = ".$ilDB->quote($a_fb_id,
"integer").
" AND ".
433 "user_id = ".$ilDB->quote($a_user_id,
"integer").
434 " ORDER BY votetime DESC";;
437 $row_results = $ilDB->fetchAssoc(
$res);
438 $q =
"SELECT * FROM feedback_items WHERE ".
439 "fb_id = ".$ilDB->quote($a_fb_id,
"integer");
440 $res1 = $ilDB->query(
$q);
441 $row_items = $ilDB->fetchAssoc($res1);
444 if (!($row_items[
"starttime"]<=time() && $row_items[
"endtime"]>=time()))
452 if((
$res->numRows()==0) && $members_obj->isAssigned($ilUser->getId()))
455 if($members_obj->isAssigned($ilUser->getId()))
457 if($row_items[
'repeat_interval'] > 0){
458 $interval = $this->
interval2seconds($row_items[
'repeat_interval'], $row_items[
'interval_unit']);
459 if((time() - $row_results[
'votetime']) >= $interval){
476 if($this->user_id!=
'')
478 $user_filter =
' feedback_results.user_id = '.$ilDB->quote($this->user_id,
"integer").
' AND ';
480 $q=
'SELECT usr_data.login, feedback_results.user_id,feedback_results.vote, feedback_results.votetime FROM'.
481 ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id WHERE '.
482 ' '.$user_filter.
' feedback_results.fb_id='.$ilDB->quote($this->
id,
"integer").
483 ' ORDER BY feedback_results.votetime,usr_data.login';
491 $datapie[0][0] =
'Vote';
492 while(
$row = $ilDB->fetchAssoc(
$res))
494 $row[
"timelabel"] = date(
"d.m.Y H:i",
$row[
"votetime"]);
495 if(!isset($tmp[
$row[
'user_id']]))
497 $tmp[$row[
'user_id']]=$j++;
499 if(!isset($tmpv[$row[
'vote']]))
501 $tmpv[$row[
'vote']] = $k++;
503 $data[$i][0] = $row[
'timelabel'];
504 $data[$i][$tmp[$row[
'user_id']]] = $row[
'vote'];
505 $legend[$row[
'login']] = $row[
'login'];
506 $legendpie[$row[
'vote']] = $row[
'vote'];
509 $datapie[0][$tmpv[$row[
'vote']]]++;
510 if($row[
'votetime']!=$pvt){
514 $pvt=$row[
'votetime'];
516 $table[
$n][
'votetime'] = $row[
'timelabel'];
517 $table[
$n][
'user'] = $row[
'login'];
518 $table[
$n][
'vote'] = $row[
'vote'];
523 foreach(
$data as $k => $v)
527 if(count($v)<=count($tmp)){
528 for($i=1;$i<=count($tmp);$i++)
535 return(array(
'data' =>
$data,
'legend' =>
$legend,
'legendpie' => $legendpie,
'datapie' => $datapie,
'table' => $table));
545 if($this->user_id!=
'')
547 $user_filter =
' AND feedback_results.user_id='.$ilDB->quote($this->user_id,
"integer");
549 $q=
'SELECT usr_data.login, feedback_results.user_id,feedback_results.note,feedback_results.vote, feedback_results.votetime FROM'.
550 ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id'.
551 ' WHERE feedback_results.note IS NOT NULL '.
552 ' '.$user_filter.
' AND feedback_results.fb_id='.$ilDB->quote($this->
id,
"integer").
553 ' ORDER BY feedback_results.votetime,usr_data.login';
557 while(
$row = $ilDB->fetchAssoc(
$res))
559 $row[
"timelabel"] = date(
"d.m.Y H:i",
$row[
"votetime"]);
561 $data[$i][
'votetime'] =
$row[
'timelabel'];
574 $q=
'SELECT distinct(usr_data.login), feedback_results.user_id, feedback_results.votetime '.
576 ' feedback_results LEFT JOIN usr_data ON usr_data.usr_id = feedback_results.user_id'.
577 ' WHERE feedback_results.fb_id='.$ilDB->quote($this->
id,
"integer").
578 ' ORDER BY feedback_results.votetime,usr_data.login';
582 while(
$row = $ilDB->fetchAssoc(
$res))
584 $users[
$row[
'user_id']] = $row[
'login'];
595 switch($a_interval_unit)
599 $multi_by = 24 * 60 * 60;
603 $mult_by = 7 * 24 * 60 * 60;
607 $mult_by = 30 * 24 * 60 *60;
615 $seconds = $a_interval * $mult_by;