30 $this->obj_id = $a_obj_id;
31 $this->ref_id = $a_ref_id;
45 $this->obj_id = $a_obj_id;
49 return $this->members ? $this->members : array();
53 $this->members = $a_members;
66 $tmp_user->addDesktopItem($this->
getRefId(),
"exc");
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").
" ");
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));
89 if(is_array($a_members))
91 foreach($a_members as $member)
103 if($assigned == count($a_members))
123 $tmp_user->dropDesktopItem($this->
getRefId(),
"exc");
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").
" ";
129 $ilDB->manipulate(
$query);
134 $files_to_delete = array();
136 foreach ($delivered_files as
$key => $value)
138 array_push($files_to_delete, $value[
"returned_id"]);
139 $userfile = $value[
"filename"];
145 $pathinfo = pathinfo($userfile);
146 $dir = $pathinfo[
"dirname"];
157 if(is_array($a_members))
159 foreach($a_members as $member)
171 if(is_array($a_status))
173 $this->status = $a_status;
179 return $this->status ? $this->status : array();
183 if(isset($this->status[$a_member_id]))
185 return $this->status[$a_member_id];
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"),
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"),
234 if(is_array($a_status))
236 $this->status_sent = $a_status;
242 return $this->status_sent ? $this->status_sent : array(0 => 0);
246 if(isset($this->status_sent[$a_member_id]))
248 return $this->status_sent[$a_member_id];
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"),
270 return $this->status_returned ? $this->status_returned : array(0 => 0);
274 if(is_array($a_status))
276 $this->status_returned = $a_status;
284 if(isset($this->status_returned[$a_member_id]))
286 return $this->status_returned[$a_member_id];
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"),
315 if(is_array($a_status))
317 $this->status_feedback = $a_status;
323 return $this->status_feedback ? $this->status_feedback : array(0 => 0);
327 if(isset($this->status_feedback[$a_member_id]))
329 return $this->status_feedback[$a_member_id];
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"),
352 return $this->notice ? $this->notice : array(0 => 0);
357 if(is_array($a_notice))
359 $this->notice = $a_notice;
367 if(isset($this->notice[$a_member_id]))
369 return $this->notice[$a_member_id];
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);
394 $query =
"SELECT * FROM exc_returned WHERE obj_id = ".
395 $ilDB->quote($this->
getObjId(),
"integer");
398 while(
$row = $ilDB->fetchAssoc(
$res))
406 return $delivered ? $delivered : array();
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));
429 $delivered_files = array();
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);
445 return $delivered_files;
458 if (count($file_id_array))
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"));
468 $result_array = array();
472 array_push($result_array,
$row);
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"));
483 foreach ($result_array as
$key => $value)
498 global $ilUser,
$ilDB;
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))
511 if ($lu_rec[
"download_time"] > 0)
513 $and_str =
" AND ts > ".$ilDB->quote($lu_rec[
"download_time"],
"timestamp");
520 $query = sprintf(
"SELECT * FROM exc_returned WHERE obj_id = %s AND user_id = %s".
522 $ilDB->quote($this->getObjId(),
"integer"),
523 $ilDB->quote($a_member_id,
"integer"));
525 $count = $ilDB->numRows($result);
528 $row = $ilDB->fetchAssoc($result);
533 $array_files = array();
535 while (
$row = $ilDB->fetchAssoc($result))
539 $dir = $pathinfo[
"dirname"];
540 $file = $pathinfo[
"basename"];
541 array_push($array_files,
$file);
544 $dir = $pathinfo[
"dirname"];
563 global $ilUser,
$ilDB;
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()));
570 $ilDB->manipulateF(
"INSERT INTO exc_usr_tutor (obj_id, usr_id, tutor_id, download_time) VALUES ".
572 array(
"integer",
"integer",
"integer",
"timestamp"),
580 if (count($array_file_id))
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));
590 $array_found = array();
594 array_push($array_found,
$row);
596 if (count($array_found) == 1)
602 $filenames = array();
605 foreach ($array_found as
$key => $value)
608 $dir = $pathinfo[
"dirname"];
609 $file = $pathinfo[
"basename"];
610 array_push($filenames,
$file);
620 require_once
"./Services/Utilities/classes/class.ilUtil.php";
626 global
$lng, $ilObjDataCache;
627 require_once
"./Services/Utilities/classes/class.ilUtil.php";
633 $tmpzipfile = $tmpfile .
".zip";
642 $newFilename = trim(basename($array_filenames[
$key]));
643 $pos = strpos($newFilename ,
"_");
648 $newFilename= substr($newFilename, $pos + 1);
650 $newFilename = $tmpdir.DIRECTORY_SEPARATOR.$newFilename;
652 $oldFilename = $pathname.DIRECTORY_SEPARATOR.$array_filenames[
$key];
653 if (!copy ($oldFilename, $newFilename))
655 echo
'Could not copy '.$oldFilename.
' to '.$newFilename;
657 touch($newFilename, filectime($oldFilename));
663 $exerciseTitle = $ilObjDataCache->lookupTitle($this->
getObjId());
664 $deliverFilename = $exerciseTitle;
665 if ($a_member_id > 0)
668 $deliverFilename .=
"_".$userName[
"lastname"].
"_".$userName[
"firstname"];
671 $deliverFilename .=
"_files";
673 $deliverFilename .=
".zip";
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"),
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();
759 $query =
"SELECT * FROM exc_members ".
760 "WHERE obj_id = ".$ilDB->quote($this->
getObjId(),
"integer");
763 while(
$row = $ilDB->fetchObject(
$res))
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;
789 $query =
"SELECT * FROM exc_members ".
790 "WHERE obj_id = ".$ilDB->quote($this->
getObjId(),
"integer");
793 while(
$row = $ilDB->fetchObject(
$res))
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
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"])
829 $query =
"DELETE FROM exc_members WHERE obj_id = ".
830 $ilDB->quote($this->
getObjId(),
"integer");
831 $ilDB->manipulate(
$query);
840 $query =
"SELECT DISTINCT(usr_id) as ud FROM exc_members ".
841 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
844 while(
$row = $ilDB->fetchObject(
$res))
846 $usr_ids[] =
$row->ud;
849 return $usr_ids ? $usr_ids : array();
856 $query =
"SELECT DISTINCT(usr_id) as ud FROM exc_members ".
857 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" ".
861 while(
$row = $ilDB->fetchObject(
$res))
863 $usr_ids[] =
$row->ud;
866 return $usr_ids ? $usr_ids : array();
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");
881 while(
$row = $ilDB->fetchObject(
$res))
883 $usr_ids[] =
$row->usr_id;
885 return $usr_ids ? $usr_ids : array();
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");
896 while(
$row = $ilDB->fetchObject(
$res))
898 $usr_ids[] =
$row->usr_id;
900 return $usr_ids ? $usr_ids : array();
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");
920 return $row[
"status"];