ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilExerciseMembers.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 {
14  var $ilias;
15 
16  var $ref_id;
17  var $obj_id;
18  var $members;
19  var $status;
23  var $notice;
24 
25  function ilExerciseMembers($a_obj_id,$a_ref_id)
26  {
27  global $ilias;
28 
29  $this->ilias =& $ilias;
30  $this->obj_id = $a_obj_id;
31  $this->ref_id = $a_ref_id;
32  }
33 
34  // GET SET METHODS
35  function getRefId()
36  {
37  return $this->ref_id;
38  }
39  function getObjId()
40  {
41  return $this->obj_id;
42  }
43  function setObjId($a_obj_id)
44  {
45  $this->obj_id = $a_obj_id;
46  }
47  function getMembers()
48  {
49  return $this->members ? $this->members : array();
50  }
51  function setMembers($a_members)
52  {
53  $this->members = $a_members;
54  }
55 
61  function assignMember($a_usr_id)
62  {
63  global $ilDB;
64 
65  $tmp_user = ilObjectFactory::getInstanceByObjId($a_usr_id);
66  $tmp_user->addDesktopItem($this->getRefId(),"exc");
67 
68  $ilDB->manipulate("DELETE FROM exc_members ".
69  "WHERE obj_id = ".$ilDB->quote($this->getObjId(), "integer")." ".
70  "AND usr_id = ".$ilDB->quote($a_usr_id, "integer")." ");
71 
72  $ilDB->manipulateF("INSERT INTO exc_members (obj_id, usr_id, status, sent, feedback) ".
73  " VALUES (%s,%s,%s,%s,%s)",
74  array("integer", "integer", "text", "integer", "integer"),
75  array($this->getObjId(), $a_usr_id, 'notgraded', 0, 0));
76 
77  $this->read();
78 
79  return true;
80  }
81  function isAssigned($a_id)
82  {
83  return in_array($a_id,$this->getMembers());
84  }
85 
86  function assignMembers($a_members)
87  {
88  $assigned = 0;
89  if(is_array($a_members))
90  {
91  foreach($a_members as $member)
92  {
93  if(!$this->isAssigned($member))
94  {
95  $this->assignMember($member);
96  }
97  else
98  {
99  ++$assigned;
100  }
101  }
102  }
103  if($assigned == count($a_members))
104  {
105  return false;
106  }
107  else
108  {
109  return true;
110  }
111  }
112 
118  function deassignMember($a_usr_id)
119  {
120  global $ilDB;
121 
122  $tmp_user = ilObjectFactory::getInstanceByObjId($a_usr_id);
123  $tmp_user->dropDesktopItem($this->getRefId(),"exc");
124 
125  $query = "DELETE FROM exc_members ".
126  "WHERE obj_id = ".$ilDB->quote($this->getObjId(), "integer")." ".
127  "AND usr_id = ".$ilDB->quote($a_usr_id, "integer")." ";
128 
129  $ilDB->manipulate($query);
130 
131  $this->read();
132  // delete all delivered files of the member
133  $delivered_files =& $this->getDeliveredFiles($a_usr_id);
134  $files_to_delete = array();
135  $userfile = "";
136  foreach ($delivered_files as $key => $value)
137  {
138  array_push($files_to_delete, $value["returned_id"]);
139  $userfile = $value["filename"];
140  }
141  $this->deleteDeliveredFiles($files_to_delete, $a_usr_id);
142  // delete the user directory if existing
143  if ($userfile)
144  {
145  $pathinfo = pathinfo($userfile);
146  $dir = $pathinfo["dirname"];
147  }
148  if (is_dir($dir))
149  {
150  rmdir($dir);
151  }
152  return false;
153  }
154 
155  function deassignMembers($a_members)
156  {
157  if(is_array($a_members))
158  {
159  foreach($a_members as $member)
160  {
161  $this->deassignMember($member);
162  }
163  }
164  else
165  {
166  return false;
167  }
168  }
169  function setStatus($a_status)
170  {
171  if(is_array($a_status))
172  {
173  $this->status = $a_status;
174  return true;
175  }
176  }
177  function getStatus()
178  {
179  return $this->status ? $this->status : array();
180  }
181  function getStatusByMember($a_member_id)
182  {
183  if(isset($this->status[$a_member_id]))
184  {
185  return $this->status[$a_member_id];
186  }
187  return false;
188  }
189 
196  function setStatusForMember($a_member_id,$a_status)
197  {
198  global $ilDB;
199 
200  $ilDB->manipulateF("UPDATE exc_members ".
201  "SET status = %s, status_time= %s ".
202  " WHERE obj_id = %s AND usr_id = %s AND status <> %s ",
203  array("text", "timestamp", "integer", "integer", "text"),
204  array($a_status, ilUtil::now(), $this->getObjId(), $a_member_id, $a_status));
205 
206  $this->read();
207 
208  return true;
209  }
210 
216  function updateStatusTimeForMember($a_member_id)
217  {
218  global $ilDB;
219 
220  $ilDB->manipulateF("UPDATE exc_members ".
221  "SET status_time= %s ".
222  " WHERE obj_id = %s AND usr_id = %s ",
223  array("timestamp", "integer", "integer"),
224  array(ilUtil::now(), $this->getObjId(), $a_member_id));
225 
226  $this->read();
227 
228  return true;
229  }
230 
231 
232  function setStatusSent($a_status)
233  {
234  if(is_array($a_status))
235  {
236  $this->status_sent = $a_status;
237  return true;
238  }
239  }
240  function getStatusSent()
241  {
242  return $this->status_sent ? $this->status_sent : array(0 => 0);
243  }
244  function getStatusSentByMember($a_member_id)
245  {
246  if(isset($this->status_sent[$a_member_id]))
247  {
248  return $this->status_sent[$a_member_id];
249  }
250  return false;
251  }
252  function setStatusSentForMember($a_member_id,$a_status)
253  {
254  global $ilDB;
255 
256  $ilDB->manipulateF("UPDATE exc_members ".
257  "SET sent = %s, status_time= %s, sent_time = %s ".
258  " WHERE obj_id = %s AND usr_id = %s ",
259  array("integer", "timestamp", "timestamp", "integer", "integer"),
260  array((int) $a_status, ilUtil::now(), ($a_status ? ilUtil::now() : null),
261  $this->getObjId(), $a_member_id));
262 
263  $this->read();
264 
265  return true;
266  }
267 
268  function getStatusReturned()
269  {
270  return $this->status_returned ? $this->status_returned : array(0 => 0);
271  }
272  function setStatusReturned($a_status)
273  {
274  if(is_array($a_status))
275  {
276  $this->status_returned = $a_status;
277  return true;
278  }
279  return false;
280  }
281 
282  function getStatusReturnedByMember($a_member_id)
283  {
284  if(isset($this->status_returned[$a_member_id]))
285  {
286  return $this->status_returned[$a_member_id];
287  }
288  return false;
289  }
290  function setStatusReturnedForMember($a_member_id,$a_status)
291  {
292  global $ilDB;
293 
294  $ilDB->manipulateF("UPDATE exc_members ".
295  "SET returned = %s, status_time= %s ".
296  " WHERE obj_id = %s AND usr_id = %s",
297  array("integer", "timestamp", "integer", "integer"),
298  array((int) $a_status, ilUtil::now(),
299  $this->getObjId(), $a_member_id));
300 
301  /*$query = "UPDATE exc_members ".
302  "SET returned = ".$ilDB->quote(($a_status ? 1 : 0))." ".
303  "WHERE obj_id = ".$ilDB->quote($this->getObjId())." ".
304  "AND usr_id = ".$ilDB->quote($a_member_id)." ";
305 
306  $this->ilias->db->query($query);*/
307  $this->read();
308 
309  return true;
310  }
311 
312  // feedback functions
313  function setStatusFeedback($a_status)
314  {
315  if(is_array($a_status))
316  {
317  $this->status_feedback = $a_status;
318  return true;
319  }
320  }
321  function getStatusFeedback()
322  {
323  return $this->status_feedback ? $this->status_feedback : array(0 => 0);
324  }
325  function getStatusFeedbackByMember($a_member_id)
326  {
327  if(isset($this->status_feedback[$a_member_id]))
328  {
329  return $this->status_feedback[$a_member_id];
330  }
331  return false;
332  }
333 
334  function setStatusFeedbackForMember($a_member_id,$a_status)
335  {
336  global $ilDB;
337 
338  $ilDB->manipulateF("UPDATE exc_members ".
339  "SET feedback = %s, status_time= %s, feedback_time = %s ".
340  " WHERE obj_id = %s AND usr_id = %s",
341  array("integer", "timestamp", "timestamp", "integer", "integer"),
342  array((int) $a_status, ilUtil::now(), ($a_status ? ilUtil::now() : null),
343  $this->getObjId(), $a_member_id));
344 
345  $this->read();
346 
347  return true;
348  }
349 
350  function getNotice()
351  {
352  return $this->notice ? $this->notice : array(0 => 0);
353  }
354 
355  function setNotice($a_notice)
356  {
357  if(is_array($a_notice))
358  {
359  $this->notice = $a_notice;
360  return true;
361  }
362  return false;
363  }
364 
365  function getNoticeByMember($a_member_id)
366  {
367  if(isset($this->notice[$a_member_id]))
368  {
369  return $this->notice[$a_member_id];
370  }
371  else
372  {
373  return "";
374  }
375  }
376 
377  function hasReturned($a_member_id)
378  {
379  global $ilDB;
380 
381  $result = $ilDB->queryF("SELECT returned_id FROM exc_returned WHERE obj_id = %s AND user_id = %s",
382  array("integer", "integer"),
383  array($this->getObjId(), $a_member_id));
384  return $ilDB->numRows($result);
385  }
386 
391  {
392  global $ilDB;
393 
394  $query = "SELECT * FROM exc_returned WHERE obj_id = ".
395  $ilDB->quote($this->getObjId(), "integer");
396 
397  $res = $ilDB->query($query);
398  while($row = $ilDB->fetchAssoc($res))
399  {
400  $row["timestamp"] = $row["ts"];
401  $delivered[] = $row;
402  }
403 
404  $delivered = ilObjExercise::_fixFilenameArray($delivered);
405 
406  return $delivered ? $delivered : array();
407  }
408 
416  function getDeliveredFiles($a_member_id)
417  {
418  global $ilDB;
419 
420  /*$query = sprintf("SELECT *, ts + 0 AS timestamp14 FROM exc_returned WHERE obj_id = %s AND user_id = %s ORDER BY timestamp14",
421  $this->ilias->db->quote($this->getObjId() . ""),
422  $this->ilias->db->quote($a_member_id . "")
423  );
424  $result = $this->ilias->db->query($query);*/
425  $result = $ilDB->queryF("SELECT * FROM exc_returned WHERE obj_id = %s AND user_id = %s ORDER BY ts",
426  array("integer", "integer"),
427  array($this->getObjId(),$a_member_id));
428 
429  $delivered_files = array();
430  if ($ilDB->numRows($result))
431  {
432  while ($row = $ilDB->fetchAssoc($result))
433  {
434  $row["timestamp"] = $row["ts"];
435  $row["timestamp14"] = substr($row["ts"], 0, 4).
436  substr($row["ts"], 5, 2).substr($row["ts"], 8, 2).
437  substr($row["ts"], 11, 2).substr($row["ts"], 14, 2).
438  substr($row["ts"], 17, 2);
439  array_push($delivered_files, $row);
440  }
441  }
442 
443  $delivered_files = ilObjExercise::_fixFilenameArray($delivered_files);
444 
445  return $delivered_files;
446  }
447 
454  function deleteDeliveredFiles($file_id_array, $a_member_id)
455  {
456  global $ilDB;
457 
458  if (count($file_id_array))
459  {
460  $result = $ilDB->query("SELECT * FROM exc_returned WHERE user_id = ".
461  $ilDB->quote($a_member_id, "integer")." AND ".
462  $ilDB->in("returned_id", $file_id_array, false, "integer"));
463  //returned_id IN (".
464  //implode(ilUtil::quoteArray($file_id_array) ,",").")",
465  //$this->ilias->db->quote($a_member_id . "")
466  if ($ilDB->numRows($result))
467  {
468  $result_array = array();
469  while ($row = $ilDB->fetchAssoc($result))
470  {
471  $row["timestamp"] = $row["ts"];
472  array_push($result_array, $row);
473  }
474  // delete the entries in the database
475  $ilDB->manipulate("DELETE FROM exc_returned WHERE user_id = ".
476  $ilDB->quote($a_member_id, "integer")." AND ".
477  $ilDB->in("returned_id", $file_id_array, false, "integer"));
478  //returned_id IN ("
479  //.implode(ilUtil::quoteArray($file_id_array) ,",").")",
480  //$this->ilias->db->quote($a_member_id . "")
481 
482  // delete the files
483  foreach ($result_array as $key => $value)
484  {
485  unlink(ilObjExercise::_fixFilename($value["filename"]));
486  }
487  }
488  }
489  }
490 
496  function deliverReturnedFiles($a_member_id, $a_only_new = false)
497  {
498  global $ilUser, $ilDB;
499 
500  // get last download time
501  $and_str = "";
502  if ($a_only_new)
503  {
504  $q = "SELECT download_time FROM exc_usr_tutor WHERE ".
505  " obj_id = ".$ilDB->quote($this->getObjId(), "integer")." AND ".
506  " usr_id = ".$ilDB->quote($a_member_id, "integer")." AND ".
507  " tutor_id = ".$ilDB->quote($ilUser->getId(), "integer");
508  $lu_set = $ilDB->query($q);
509  if ($lu_rec = $ilDB->fetchAssoc($lu_set))
510  {
511  if ($lu_rec["download_time"] > 0)
512  {
513  $and_str = " AND ts > ".$ilDB->quote($lu_rec["download_time"], "timestamp");
514  }
515  }
516  }
517 
518  $this->updateTutorDownloadTime($a_member_id);
519 
520  $query = sprintf("SELECT * FROM exc_returned WHERE obj_id = %s AND user_id = %s".
521  $and_str,
522  $ilDB->quote($this->getObjId(), "integer"),
523  $ilDB->quote($a_member_id, "integer"));
524  $result = $ilDB->query($query);
525  $count = $ilDB->numRows($result);
526  if ($count == 1)
527  {
528  $row = $ilDB->fetchAssoc($result);
529  $this->downloadSingleFile(ilObjExercise::_fixFilename($row["filename"]), $row["filetitle"]);
530  }
531  else if ($count > 0)
532  {
533  $array_files = array();
534  $filename = "";
535  while ($row = $ilDB->fetchAssoc($result))
536  {
538  $pathinfo = pathinfo($filename);
539  $dir = $pathinfo["dirname"];
540  $file = $pathinfo["basename"];
541  array_push($array_files, $file);
542  }
543  $pathinfo = pathinfo($filename);
544  $dir = $pathinfo["dirname"];
545  $this->downloadMultipleFiles($array_files, $dir, $a_member_id);
546  }
547  else
548  {
549  return false;
550  }
551 
552  return true;
553  }
554 
561  function updateTutorDownloadTime($a_member_id)
562  {
563  global $ilUser, $ilDB;
564 
565  $ilDB->manipulateF("DELETE FROM exc_usr_tutor ".
566  "WHERE obj_id = %s AND usr_id = %s AND tutor_id = %s",
567  array("integer", "integer", "integer"),
568  array($this->getObjId(), $a_member_id, $ilUser->getId()));
569 
570  $ilDB->manipulateF("INSERT INTO exc_usr_tutor (obj_id, usr_id, tutor_id, download_time) VALUES ".
571  "(%s, %s, %s, %s)",
572  array("integer", "integer", "integer", "timestamp"),
573  array($this->getObjId(), $a_member_id, $ilUser->getId(), ilUtil::now()));
574  }
575 
576  function downloadSelectedFiles($array_file_id,$a_user_id)
577  {
578  global $ilDB;
579 
580  if (count($array_file_id))
581  {
582  //$query = "SELECT * FROM exc_returned WHERE returned_id IN (".
583  // implode(ilUtil::quoteArray($array_file_id) ,",").")";
584  //$result = $this->ilias->db->query($query);
585  $result = $ilDB->query("SELECT * FROM exc_returned WHERE ".
586  $ilDB->in("returned_id", $array_file_id, false, "integer").
587  " AND user_id = ".$ilDB->quote($a_user_id));
588  if ($ilDB->numRows($result))
589  {
590  $array_found = array();
591  while ($row = $ilDB->fetchAssoc($result))
592  {
593  $row["timestamp"] = $row["ts"];
594  array_push($array_found, $row);
595  }
596  if (count($array_found) == 1)
597  {
598  $this->downloadSingleFile(ilObjExercise::_fixFilename($array_found[0]["filename"]), $array_found[0]["filetitle"]);
599  }
600  else
601  {
602  $filenames = array();
603  $dir = "";
604  $file = "";
605  foreach ($array_found as $key => $value)
606  {
607  $pathinfo = pathinfo(ilObjExercise::_fixFilename($value["filename"]));
608  $dir = $pathinfo["dirname"];
609  $file = $pathinfo["basename"];
610  array_push($filenames, $file);
611  }
612  $this->downloadMultipleFiles($filenames, $dir);
613  }
614  }
615  }
616  }
617 
618  function downloadSingleFile($filename, $filetitle)
619  {
620  require_once "./Services/Utilities/classes/class.ilUtil.php";
621  ilUtil::deliverFile($filename, $filetitle);
622  }
623 
624  function downloadMultipleFiles($array_filenames, $pathname, $a_member_id = 0)
625  {
626  global $lng, $ilObjDataCache;
627  require_once "./Services/Utilities/classes/class.ilUtil.php";
628  $cdir = getcwd();
629 
630  $zip = PATH_TO_ZIP;
631  $tmpdir = ilUtil::ilTempnam();
632  $tmpfile = ilUtil::ilTempnam();
633  $tmpzipfile = $tmpfile . ".zip";
634 
635  ilUtil::makeDir($tmpdir);
636  chdir($tmpdir);
637 
638  //copy all files to a temporary directory and remove them afterwards
639  foreach ($array_filenames as $key => $filename)
640  {
641  // remove timestamp
642  $newFilename = trim(basename($array_filenames[$key]));
643  $pos = strpos($newFilename , "_");
644  if ($pos === false)
645  {
646  } else
647  {
648  $newFilename= substr($newFilename, $pos + 1);
649  }
650  $newFilename = $tmpdir.DIRECTORY_SEPARATOR.$newFilename;
651  // copy to temporal directory
652  $oldFilename = $pathname.DIRECTORY_SEPARATOR.$array_filenames[$key];
653  if (!copy ($oldFilename, $newFilename))
654  {
655  echo 'Could not copy '.$oldFilename.' to '.$newFilename;
656  }
657  touch($newFilename, filectime($oldFilename));
658  $array_filenames[$key] = ilUtil::escapeShellArg(basename($newFilename)); //$array_filenames[$key]);
659  }
660  $zipcmd = $zip." ".ilUtil::escapeShellArg($tmpzipfile)." ".join($array_filenames, " ");
661  exec($zipcmd);
662  ilUtil::delDir($tmpdir);
663  $exerciseTitle = $ilObjDataCache->lookupTitle($this->getObjId());
664  $deliverFilename = $exerciseTitle;
665  if ($a_member_id > 0)
666  {
667  $userName = ilObjUser::_lookupName($a_member_id);
668  $deliverFilename .= "_".$userName["lastname"]."_".$userName["firstname"];
669  } else
670  {
671  $deliverFilename .= "_files";
672  }
673  $deliverFilename .= ".zip";
674  ilUtil::deliverFile($tmpzipfile, $deliverFilename);
675  chdir($cdir);
676  unlink($tmpzipfile);
677  }
678 
679  function setNoticeForMember($a_member_id,$a_notice)
680  {
681  global $ilDB;
682 
683  $ilDB->manipulateF("UPDATE exc_members ".
684  "SET notice = %s, status_time= %s ".
685  " WHERE obj_id = %s AND usr_id = %s AND ".
686  $ilDB->equalsNot("notice", $a_notice, "text", true),
687  array("text", "timestamp", "integer", "integer"),
688  array($a_notice, ilUtil::now(), $this->getObjId(), $a_member_id));
689 //echo "-".$ilDB->equalsNot("notice", $a_notice, "text", true)."-"; exit;
690  /*$query = "UPDATE exc_members ".
691  "SET notice = ".$ilDB->quote($a_notice)." ".
692  "WHERE obj_id = ".$ilDB->quote($this->getObjId())." ".
693  "AND usr_id = ".$ilDB->quote($a_member_id);
694 
695  $this->ilias->db->query($query);*/
696  $this->read();
697 
698  return true;
699  }
700 /*
701  function update()
702  {
703  $save_members = $this->getMembers();
704  $save_notice = $this->getNotice();
705  $saved_st_solved = $this->getStatusSolved();
706  $saved_st_sent = $this->getStatusSent();
707  $saved_st_return = $this->getStatusReturned();
708 
709  $this->read();
710 
711  // UPDATE MEMBERS
712  foreach(array_diff($this->getMembers(),$save_members) as $member)
713  {
714  $query = "DELETE FROM exc_members ".
715  "WHERE obj_id = '".$this->getObjId()."' ".
716  "AND usr_id = '".$member."'";
717  $this->ilias->db->query($query);
718  }
719  foreach(array_diff($save_members,$this->getMembers()) as $member)
720  {
721  $query = "INSERT INTO exc_members ".
722  "SET obj_id = '".$this->getObjId()."', ".
723  "usr_id = '".$member."', ".
724  "sent = '0', ".
725  "solved = '0'";
726  $this->ilias->db->query($query);
727  }
728  $this->setMembers($save_members);
729  $this->setNotice($save_notice);
730  $this->setStatusSent($saved_st_sent);
731  $this->setStatusSolved($saved_st_solved);
732  $this->setStatusReturned($saved_st_return);
733 
734 
735  // UPDATE SOLVED AND SENT
736  foreach($this->getMembers() as $member)
737  {
738  $query = "UPDATE exc_members ".
739  "SET solved = '".$this->getStatusSolvedByMember($member)."', ".
740  "notice = '".addslashes($this->getNoticeByMember($member))."', ".
741  "returned = '".$this->getStatusReturnedByMember($member)."', ".
742  "sent = '".$this->getStatusSentByMember($member)."'";
743  $this->ilias->db->query($query);
744  }
745  return true;
746  }
747 */
748  function read()
749  {
750  global $ilDB;
751 
752  $tmp_arr_members = array();
753  $tmp_arr_status = array();
754  $tmp_arr_sent = array();
755  $tmp_arr_notice = array();
756  $tmp_arr_returned = array();
757  $tmp_arr_feedback = array();
758 
759  $query = "SELECT * FROM exc_members ".
760  "WHERE obj_id = ".$ilDB->quote($this->getObjId(), "integer");
761 
762  $res = $ilDB->query($query);
763  while($row = $ilDB->fetchObject($res))
764  {
765  $tmp_arr_members[] = $row->usr_id;
766  $tmp_arr_notice[$row->usr_id] = $row->notice;
767  $tmp_arr_returned[$row->usr_id] = $row->returned;
768  $tmp_arr_status[$row->usr_id] = $row->status;
769  $tmp_arr_sent[$row->usr_id] = $row->sent;
770  $tmp_arr_feedback[$row->usr_id] = $row->feedback;
771  }
772  $this->setMembers($tmp_arr_members);
773  $this->setNotice($tmp_arr_notice);
774  $this->setStatus($tmp_arr_status);
775  $this->setStatusSent($tmp_arr_sent);
776  $this->setStatusReturned($tmp_arr_returned);
777  $this->setStatusFeedback($tmp_arr_feedback);
778 
779  return true;
780  }
781 
782 
783  function ilClone($a_new_id)
784  {
785  global $ilDB;
786 
787  $data = array();
788 
789  $query = "SELECT * FROM exc_members ".
790  "WHERE obj_id = ".$ilDB->quote($this->getObjId(), "integer");
791 
792  $res = $ilDB->query($query);
793  while($row = $ilDB->fetchObject($res))
794  {
795  $data[] = array("usr_id" => $row->usr_id,
796  "notice" => $row->notice,
797  "returned" => $row->returned,
798  "status" => $row->status,
799  "sent" => $row->sent,
800  "feedback" => $row->feedback
801  );
802  }
803  foreach($data as $row)
804  {
805  $ilDB->manipulateF("INSERT INTO exc_members ".
806  " (obj_id, usr_id, notice, returned, status, feedback, sent) VALUES ".
807  " (%s,%s,%s,%s,%s,%s,%s)",
808  array ("integer", "integer", "text", "integer", "text", "integer", "integer"),
809  array ($a_new_id, $row["usr_id"], $row["notice"], (int) $row["returned"],
810  $row["status"], (int) $row["feedback"], (int) $row["sent"])
811  );
812  /*"SET obj_id = ".$ilDB->quote($a_new_id).", ".
813  "usr_id = ".$ilDB->quote($row["usr_id"]).", ".
814  "notice = ".$ilDB->quote($row["notice"]).", ".
815  "returned = ".$ilDB->quote($row["returned"]).", ".
816  "status = ".$ilDB->quote($row["status"]).", ".
817  "feedback = ".$ilDB->quote($row["feedback"]).", ".
818  "sent = ".$ilDB->quote($row["sent"]);
819 
820  $res = $this->ilias->db->query($query);*/
821  }
822  return true;
823  }
824 
825  function delete()
826  {
827  global $ilDB;
828 
829  $query = "DELETE FROM exc_members WHERE obj_id = ".
830  $ilDB->quote($this->getObjId(), "integer");
831  $ilDB->manipulate($query);
832 
833  return true;
834  }
835 
836  function _getMembers($a_obj_id)
837  {
838  global $ilDB;
839 
840  $query = "SELECT DISTINCT(usr_id) as ud FROM exc_members ".
841  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer");
842 
843  $res = $ilDB->query($query);
844  while($row = $ilDB->fetchObject($res))
845  {
846  $usr_ids[] = $row->ud;
847  }
848 
849  return $usr_ids ? $usr_ids : array();
850  }
851 
852  function _getReturned($a_obj_id)
853  {
854  global $ilDB;
855 
856  $query = "SELECT DISTINCT(usr_id) as ud FROM exc_members ".
857  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer")." ".
858  "AND returned = 1";
859 
860  $res = $ilDB->query($query);
861  while($row = $ilDB->fetchObject($res))
862  {
863  $usr_ids[] = $row->ud;
864  }
865 
866  return $usr_ids ? $usr_ids : array();
867  }
868 
869  /* deprecated use _lookupStatus instead
870  modified and added this function again.
871  Learning progress needs this function and _getFailedUsers
872  */
873  function _getPassedUsers($a_obj_id)
874  {
875  global $ilDB;
876 
877  $query = "SELECT DISTINCT(usr_id) FROM exc_members ".
878  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer")." ".
879  "AND status = ".$ilDB->quote("passed", "text");
880  $res = $ilDB->query($query);
881  while($row = $ilDB->fetchObject($res))
882  {
883  $usr_ids[] = $row->usr_id;
884  }
885  return $usr_ids ? $usr_ids : array();
886  }
887 
888  function _getFailedUsers($a_obj_id)
889  {
890  global $ilDB;
891 
892  $query = "SELECT DISTINCT(usr_id) FROM exc_members ".
893  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer")." ".
894  "AND status = ".$ilDB->quote("failed", "text");
895  $res = $ilDB->query($query);
896  while($row = $ilDB->fetchObject($res))
897  {
898  $usr_ids[] = $row->usr_id;
899  }
900  return $usr_ids ? $usr_ids : array();
901  }
902 
909  function _lookupStatus($a_obj_id, $a_user_id)
910  {
911  global $ilDB;
912 
913  $query = "SELECT status FROM exc_members ".
914  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer").
915  " AND usr_id = ".$ilDB->quote($a_user_id, "integer");
916 
917  $res = $ilDB->query($query);
918  if($row = $ilDB->fetchAssoc($res))
919  {
920  return $row["status"];
921  }
922 
923  return false;
924  }
925 
926 } //END class.ilObjExercise
927 ?>