51 $this->obj_id = $a_obj_id;
52 $this->ref_id = $a_ref_id;
66 $this->obj_id = $a_obj_id;
70 return $this->members ? $this->members : array();
74 $this->members = $a_members;
87 $tmp_user->addDesktopItem($this->
getRefId(),
"exc");
90 $query =
"REPLACE INTO exc_members ".
91 "SET obj_id = ".$ilDB->quote($this->
getObjId()).
", ".
92 "usr_id = ".$ilDB->quote($a_usr_id).
", ".
93 "status = 'notgraded', sent = '0', feedback='0'";
95 $res = $this->ilias->db->query($query);
108 if(is_array($a_members))
110 foreach($a_members as $member)
122 if($assigned == count($a_members))
142 $tmp_user->dropDesktopItem($this->
getRefId(),
"exc");
144 $query =
"DELETE FROM exc_members ".
145 "WHERE obj_id = ".$ilDB->quote($this->
getObjId()).
" ".
146 "AND usr_id = ".$ilDB->quote($a_usr_id).
" ";
148 $this->ilias->db->query($query);
152 $files_to_delete = array();
154 foreach ($delivered_files as $key => $value)
156 array_push($files_to_delete, $value[
"returned_id"]);
157 $userfile = $value[
"filename"];
163 $pathinfo = pathinfo($userfile);
164 $dir = $pathinfo[
"dirname"];
175 if(is_array($a_members))
177 foreach($a_members as $member)
189 if(is_array($a_status))
191 $this->status = $a_status;
197 return $this->status ? $this->status : array();
201 if(isset($this->status[$a_member_id]))
203 return $this->status[$a_member_id];
218 $query =
"UPDATE exc_members ".
219 "SET status = ".$ilDB->quote($a_status).
", ".
220 "status_time= ".$ilDB->quote(date(
"Y-m-d H:i:s")).
" ".
221 " WHERE obj_id = ".$ilDB->quote($this->
getObjId()).
" ".
222 "AND usr_id = ".$ilDB->quote($a_member_id).
" ".
223 " AND status <> ".$ilDB->quote($a_status);
225 $this->ilias->db->query($query);
240 $query =
"UPDATE exc_members ".
241 "SET status_time= ".$ilDB->quote(date(
"Y-m-d H:i:s")).
" ".
242 " WHERE obj_id = ".$ilDB->quote($this->
getObjId()).
" ".
243 "AND usr_id = ".$ilDB->quote($a_member_id).
" ";
245 $this->ilias->db->query($query);
254 if(is_array($a_status))
256 $this->status_sent = $a_status;
262 return $this->status_sent ? $this->status_sent : array(0 => 0);
266 if(isset($this->status_sent[$a_member_id]))
268 return $this->status_sent[$a_member_id];
276 $query =
"UPDATE exc_members ".
277 "SET sent = ".$ilDB->quote(($a_status ? 1 : 0)).
" , ".
278 "sent_time=".$ilDB->quote(($a_status ? (date(
"Y-m-d H:i:s")) : (
"0000-00-00 00:00:00"))).
279 " WHERE obj_id = ".$ilDB->quote($this->
getObjId()).
" ".
280 "AND usr_id = ".$ilDB->quote($a_member_id).
" ";
282 $this->ilias->db->query($query);
290 return $this->status_returned ? $this->status_returned : array(0 => 0);
294 if(is_array($a_status))
296 $this->status_returned = $a_status;
304 if(isset($this->status_returned[$a_member_id]))
306 return $this->status_returned[$a_member_id];
314 $query =
"UPDATE exc_members ".
315 "SET returned = ".$ilDB->quote(($a_status ? 1 : 0)).
" ".
316 "WHERE obj_id = ".$ilDB->quote($this->
getObjId()).
" ".
317 "AND usr_id = ".$ilDB->quote($a_member_id).
" ";
319 $this->ilias->db->query($query);
328 if(is_array($a_status))
330 $this->status_feedback = $a_status;
336 return $this->status_feedback ? $this->status_feedback : array(0 => 0);
340 if(isset($this->status_feedback[$a_member_id]))
342 return $this->status_feedback[$a_member_id];
351 $query =
"UPDATE exc_members ".
352 "SET feedback = ".$ilDB->quote(($a_status ? 1 : 0)).
", ".
353 "feedback_time=".$ilDB->quote(($a_status ? (date(
"Y-m-d H:i:s")) : (
"0000-00-00 00:00:00"))).
354 " WHERE obj_id = ".$ilDB->quote($this->
getObjId()).
" ".
355 "AND usr_id = ".$ilDB->quote($a_member_id);
357 $this->ilias->db->query($query);
365 return $this->notice ? $this->notice : array(0 => 0);
370 if(is_array($a_notice))
372 $this->notice = $a_notice;
380 if(isset($this->notice[$a_member_id]))
382 return $this->notice[$a_member_id];
394 $query = sprintf(
"SELECT returned_id FROM exc_returned WHERE obj_id = %s AND user_id = %s",
395 $this->ilias->db->quote($this->getObjId() .
""),
396 $this->ilias->db->quote($a_member_id .
"")
398 $result = $this->ilias->db->query($query);
399 return $result->numRows();
409 $query =
"SELECT * FROM exc_returned WHERE obj_id = ".
412 $res = $this->ilias->db->query($query);
420 return $delivered ? $delivered : array();
432 $query = sprintf(
"SELECT *, TIMESTAMP + 0 AS timestamp14 FROM exc_returned WHERE obj_id = %s AND user_id = %s ORDER BY timestamp14",
433 $this->ilias->db->quote($this->getObjId() .
""),
434 $this->ilias->db->quote($a_member_id .
"")
436 $result = $this->ilias->db->query($query);
437 $delivered_files = array();
438 if ($result->numRows())
442 array_push($delivered_files, $row);
448 return $delivered_files;
461 if (count($file_id_array))
463 $query = sprintf(
"SELECT * FROM exc_returned WHERE user_id = %s AND returned_id IN (".
465 $this->ilias->db->quote($a_member_id .
"")
467 $result = $this->ilias->db->query($query);
468 if ($result->numRows())
470 $result_array = array();
473 array_push($result_array, $row);
476 $query = sprintf(
"DELETE FROM exc_returned WHERE user_id = %s AND returned_id IN ("
478 $this->ilias->db->quote($a_member_id .
"")
480 $result = $this->ilias->db->query($query);
482 foreach ($result_array as $key => $value)
497 global $ilUser, $ilDB;
503 $q =
"SELECT download_time FROM exc_usr_tutor WHERE ".
504 " obj_id = ".$ilDB->quote($this->
getObjId()).
" AND ".
505 " usr_id = ".$ilDB->quote($a_member_id).
" AND ".
506 " tutor_id = ".$ilDB->quote($ilUser->getId());
507 $lu_set = $ilDB->query($q);
510 if ($lu_rec[
"download_time"] > 0)
512 $and_str =
" AND timestamp > ".$ilDB->quote($lu_rec[
"download_time"]);
519 $query = sprintf(
"SELECT * FROM exc_returned WHERE obj_id = %s AND user_id = %s".
521 $this->ilias->db->quote($this->getObjId() .
""),
522 $this->ilias->db->quote($a_member_id .
"")
524 $result = $this->ilias->db->query($query);
525 $count = $result->numRows();
533 $array_files = array();
539 $dir = $pathinfo[
"dirname"];
540 $file = $pathinfo[
"basename"];
541 array_push($array_files,
$file);
544 $dir = $pathinfo[
"dirname"];
563 global $ilUser, $ilDB;
566 $q =
"REPLACE INTO exc_usr_tutor (obj_id, usr_id, tutor_id, download_time) VALUES ".
567 "(".$ilDB->quote($this->
getObjId()).
",".$ilDB->quote($a_member_id).
568 ",".$ilDB->quote($ilUser->getId()).
",now())";
576 if (count($array_file_id))
578 $query =
"SELECT * FROM exc_returned ".
579 "WHERE user_id = ".$ilDB->quote($a_user_id).
" ".
580 "AND returned_id IN (".
582 $result = $this->ilias->db->query($query);
585 $array_found = array();
588 array_push($array_found, $row);
590 if (count($array_found) == 1)
596 $filenames = array();
599 foreach ($array_found as $key => $value)
602 $dir = $pathinfo[
"dirname"];
603 $file = $pathinfo[
"basename"];
604 array_push($filenames,
$file);
614 require_once
"./Services/Utilities/classes/class.ilUtil.php";
620 global
$lng, $ilObjDataCache;
621 require_once
"./Services/Utilities/classes/class.ilUtil.php";
627 $tmpzipfile = $tmpfile .
".zip";
633 foreach ($array_filenames as $key =>
$filename)
636 $newFilename = trim(basename($array_filenames[$key]));
637 $pos = strpos($newFilename ,
"_");
642 $newFilename= substr($newFilename, $pos + 1);
644 $newFilename = $tmpdir.DIRECTORY_SEPARATOR.$newFilename;
646 $oldFilename = $pathname.DIRECTORY_SEPARATOR.$array_filenames[$key];
647 if (!copy ($oldFilename, $newFilename))
649 echo
'Could not copy '.$oldFilename.
' to '.$newFilename;
651 touch($newFilename, filectime($oldFilename));
657 $exerciseTitle = $ilObjDataCache->lookupTitle($this->
getObjId());
658 $deliverFilename = $exerciseTitle;
659 if ($a_member_id > 0)
662 $deliverFilename .=
"_".$userName[
"lastname"].
"_".$userName[
"firstname"];
665 $deliverFilename .=
"_files";
667 $deliverFilename .=
".zip";
677 $query =
"UPDATE exc_members ".
678 "SET notice = ".$ilDB->quote($a_notice).
" ".
679 "WHERE obj_id = ".$ilDB->quote($this->
getObjId()).
" ".
680 "AND usr_id = ".$ilDB->quote($a_member_id);
682 $this->ilias->db->query($query);
739 $tmp_arr_members = array();
740 $tmp_arr_status = array();
741 $tmp_arr_sent = array();
742 $tmp_arr_notice = array();
743 $tmp_arr_returned = array();
744 $tmp_arr_feedback = array();
746 $query =
"SELECT * FROM exc_members ".
747 "WHERE obj_id = ".$ilDB->quote($this->
getObjId());
749 $res = $this->ilias->db->query($query);
752 $tmp_arr_members[] = $row->usr_id;
753 $tmp_arr_notice[$row->usr_id] = $row->notice;
754 $tmp_arr_returned[$row->usr_id] = $row->returned;
755 $tmp_arr_status[$row->usr_id] = $row->status;
756 $tmp_arr_sent[$row->usr_id] = $row->sent;
757 $tmp_arr_feedback[$row->usr_id] = $row->feedback;
776 $query =
"SELECT * FROM exc_members ".
777 "WHERE obj_id = ".$ilDB->quote($this->
getObjId());
779 $res = $this->ilias->db->query($query);
782 $data[] = array(
"usr_id" => $row->usr_id,
783 "notice" => $row->notice,
784 "returned" => $row->returned,
785 "status" => $row->status,
786 "sent" => $row->sent,
787 "feedback" => $row->feedback
790 foreach(
$data as $row)
792 $query =
"INSERT INTO exc_members ".
793 "SET obj_id = ".$ilDB->quote($a_new_id).
", ".
794 "usr_id = ".$ilDB->quote($row[
"usr_id"]).
", ".
795 "notice = ".$ilDB->quote($row[
"notice"]).
", ".
796 "returned = ".$ilDB->quote($row[
"returned"]).
", ".
797 "status = ".$ilDB->quote($row[
"status"]).
", ".
798 "feedback = ".$ilDB->quote($row[
"feedback"]).
", ".
799 "sent = ".$ilDB->quote($row[
"sent"]);
801 $res = $this->ilias->db->query($query);
810 $query =
"DELETE FROM exc_members WHERE obj_id = ".$ilDB->quote($this->
getObjId());
811 $this->ilias->db->query($query);
820 $query =
"SELECT DISTINCT(usr_id) as ud FROM exc_members ".
821 "WHERE obj_id = ".$ilDB->quote($a_obj_id);
823 $res = $ilDB->query($query);
826 $usr_ids[] = $row->ud;
829 return $usr_ids ? $usr_ids : array();
836 $query =
"SELECT DISTINCT(usr_id) as ud FROM exc_members ".
837 "WHERE obj_id = ".$ilDB->quote($a_obj_id).
" ".
840 $res = $ilDB->query($query);
843 $usr_ids[] = $row->ud;
846 return $usr_ids ? $usr_ids : array();
857 $query =
"SELECT DISTINCT(usr_id) FROM exc_members ".
858 "WHERE obj_id = ".$ilDB->quote($a_obj_id).
" ".
859 "AND status = 'passed'";
860 $res = $ilDB->query($query);
863 $usr_ids[] = $row->usr_id;
865 return $usr_ids ? $usr_ids : array();
872 $query =
"SELECT DISTINCT(usr_id) FROM exc_members ".
873 "WHERE obj_id = ".$ilDB->quote($a_obj_id).
" ".
874 "AND status = 'failed'";
875 $res = $ilDB->query($query);
878 $usr_ids[] = $row->usr_id;
880 return $usr_ids ? $usr_ids : array();
893 $query =
"SELECT status FROM exc_members ".
894 "WHERE obj_id = ".$ilDB->quote($a_obj_id).
895 "AND usr_id = ".$ilDB->quote($a_user_id);
897 $res = $ilDB->query($query);
900 return $row[
"status"];