24 require_once
"classes/class.ilObject.php";
25 require_once
"./Modules/Exercise/classes/class.ilFileDataExercise.php";
26 require_once
"./Modules/Exercise/classes/class.ilExerciseMembers.php";
62 $this->
ilObject($a_id,$a_call_by_reference);
66 function setDate($a_hour,$a_minutes,$a_day,$a_month,$a_year)
68 $this->hour = (int) $a_hour;
69 $this->minutes = (int) $a_minutes;
70 $this->day = (int) $a_day;
71 $this->month = (int) $a_month;
72 $this->year = (int) $a_year;
73 $this->timestamp = mktime($this->hour,$this->minutes,0,$this->month,$this->day,$this->year);
82 $this->timestamp = $a_timestamp;
86 $this->instruction = $a_instruction;
99 return $this->hour == (int) date(
"H",$this->timestamp) and
100 $this->minutes == (int) date(
"i",$this->timestamp) and
101 $this->day == (int) date(
"d",$this->timestamp) and
102 $this->month == (int) date(
"m",$this->timestamp) and
103 $this->year == (int) date(
"Y",$this->timestamp);
107 function deliverFile($a_http_post_files, $user_id, $unzip =
false)
109 $deliver_result = $this->file_obj->deliverFile($a_http_post_files, $user_id, $unzip);
113 $query = sprintf(
"INSERT INTO exc_returned ".
114 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, TIMESTAMP) ".
115 "VALUES (NULL, %s, %s, %s, %s, %s, NULL)",
116 $this->ilias->db->quote($this->getId() .
""),
117 $this->ilias->db->quote($user_id .
""),
118 $this->ilias->db->quote($deliver_result[
"fullname"]),
119 $this->ilias->db->quote($a_http_post_files[
"name"]),
120 $this->ilias->db->quote($deliver_result[
"mimetype"])
122 $this->ilias->db->query($query);
123 if (!$this->members_obj->isAssigned($user_id))
125 $this->members_obj->assignMember($user_id);
127 $this->members_obj->setStatusReturnedForMember($user_id, 1);
135 if ($unzipUploadedFile && preg_match(
"/zip/", $a_http_post_files[
"type"]) == 1)
145 $this->file_obj->storeUploadedFile($a_http_post_files,
true);
151 $this->file_obj->unlinkFiles($a_files);
159 $query =
"INSERT INTO exc_data SET ".
160 "obj_id = ".$ilDB->quote($this->
getId()).
", ".
163 $this->ilias->db->query($query);
182 $new_obj->saveData();
186 $tmp_file_obj->ilClone($new_obj->getId());
187 unset($tmp_file_obj);
190 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
192 $obj_settings->cloneSettings($new_obj->getId());
193 unset($obj_settings);
207 $delivered_files =& $this->members_obj->getDeliveredFiles($user_id);
208 return $delivered_files;
219 $this->members_obj->deleteDeliveredFiles($file_id_array, $user_id);
222 if(!count($this->members_obj->getDeliveredFiles($user_id)))
224 $this->members_obj->setStatusReturnedForMember($user_id,0);
236 require_once
"./Services/Utilities/classes/class.ilUtil.php";
250 if (!parent::delete())
255 $query =
"DELETE FROM exc_data ".
256 "WHERE obj_id = ".$ilDB->quote($this->
getId());
258 $this->ilias->db->query($query);
260 $this->file_obj->delete();
261 $this->members_obj->delete();
276 function notify($a_event,$a_ref_id,$a_node_id,$a_params = 0)
289 $query =
"SELECT * FROM exc_data ".
290 "WHERE obj_id = ".$ilDB->quote($this->
getId());
292 $res = $this->ilias->db->query($query);
299 $this->members_obj->read();
303 $this->files = $this->file_obj->getFiles();
314 $query =
"UPDATE exc_data SET ".
316 "time_stamp = ".$ilDB->quote($this->
getTimestamp()).
" ".
317 "WHERE obj_id = ".$ilDB->quote($this->
getId());
319 $res = $this->ilias->db->query($query);
321 #$this->members_obj->update();
333 $q =
"SELECT * FROM exc_members ".
334 "WHERE obj_id = ".$ilDB->quote($this->
getId());
335 $set = $ilDB->query($q);
345 "name" => $name[
"lastname"].
", ".$name[
"firstname"],
347 "sent_time" => $rec[
"sent_time"],
349 "status_time" => $rec[
"status_time"],
350 "feedback_time" => $rec[
"feedback_time"],
351 "usr_id" => $rec[
"usr_id"],
352 "lastname" => $name[
"lastname"],
353 "firstname" => $name[
"firstname"],
354 "notice" => $rec[
"notice"],
355 "status" => $rec[
"status"]
372 $q=
"SELECT obj_id,user_id,timestamp FROM exc_returned ".
373 "WHERE obj_id =".$ilDB->quote($this->
getId()).
" AND user_id=".
374 $ilDB->quote($member_id).
375 " ORDER BY timestamp DESC";
377 $usr_set = $ilDB->query($q);
380 if ($array[
"timestamp"]==NULL)
395 $files = $this->file_obj->getFiles();
398 include_once
"./classes/class.ilFileDataMail.php";
403 $mfile_obj->copyAttachmentFile($this->file_obj->getAbsolutePath($file[
"name"]),$file[
"name"]);
404 $file_names[] = $file[
"name"];
408 include_once
"Services/Mail/classes/class.ilMail.php";
412 count($file_names) ? $file_names : array(),array(
"normal"));
414 unset($tmp_mail_obj);
416 if(count($file_names))
418 $mfile_obj->unlinkFiles($file_names);
424 foreach($a_members as $member_id => $value)
426 $this->members_obj->setStatusSentForMember($member_id,1);
441 $q=
"SELECT exc_members.status_time, exc_returned.timestamp ".
442 "FROM exc_members, exc_returned ".
443 "WHERE exc_members.status_time < exc_returned.timestamp ".
444 "AND exc_members.status_time <> '0000-00-00 00:00:00' ".
445 "AND exc_returned.obj_id = exc_members.obj_id ".
446 "AND exc_returned.user_id = exc_members.usr_id ".
447 "AND exc_returned.obj_id=".$ilDB->quote($exc_id).
" AND exc_returned.user_id=".
448 $ilDB->quote($member_id);
450 $usr_set = $ilDB->query($q);
454 if (count($array)==0)
473 $q =
"SELECT count(*) AS cnt FROM exc_members".
474 " WHERE sent_time <> '0000-00-00 00:00:00'".
475 " AND obj_id = ".$ilDB->quote($a_exc_id);
476 $set = $ilDB->query($q);
495 global $ilDB, $ilUser;
497 $q =
"SELECT exc_returned.returned_id AS id ".
498 "FROM exc_usr_tutor, exc_returned ".
499 "WHERE exc_returned.obj_id = exc_usr_tutor.obj_id ".
500 "AND exc_returned.user_id = exc_usr_tutor.usr_id ".
501 "AND exc_returned.obj_id = ".$ilDB->quote($exc_id).
502 "AND exc_returned.user_id = ".$ilDB->quote($member_id).
503 "AND exc_usr_tutor.tutor_id = ".$ilDB->quote($ilUser->getId()).
504 "AND exc_usr_tutor.download_time < exc_returned.timestamp ";
506 $new_up_set = $ilDB->query($q);
511 $new_up[] = $new_up_rec[
"id"];
527 "WHERE obj_id= ".$ilDB->quote($exc_id).
" AND usr_id= ".$ilDB->quote($member_id);
529 $set = $ilDB->query($q);
546 "WHERE obj_id= ".$ilDB->quote($exc_id).
" AND usr_id= ".$ilDB->quote($member_id);
548 $set = $ilDB->query($q);
565 "WHERE obj_id= ".$ilDB->quote($exc_id).
" AND usr_id= ".$ilDB->quote($member_id);
567 $set = $ilDB->query($q);
581 $body .= $lng->txt(
"exc_edit_until") .
": ".
584 $body .= ILIAS_HTTP_PATH.
587 "_".$this->getRefId().
"&client_id=".CLIENT_ID;
599 foreach($a_members as $member_id => $value)
602 $tmp_members[] = $tmp_obj->getLogin();
607 return implode(
',',$tmp_members ? $tmp_members : array());
614 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
643 global
$lng, $ilUser;
649 include_once (
"Services/Utilities/classes/class.ilFileUtils.php");
656 foreach ($filearray[
"file"] as $key =>
$filename)
659 $a_http_post_files[
"type"] =
"other";
660 $a_http_post_files[
"tmp_name"] = $filearray[
"path"][$key].
"/".
$filename;
661 $a_http_post_files[
"error"] = 0;
662 $a_http_post_files[
"size"] = filesize($filearray[
"path"][$key].
"/".
$filename);
664 if ($storageMethod ==
"deliverFile")
666 $this->$storageMethod($a_http_post_files, $ilUser->id,
true);
668 else if ($storageMethod ==
"storeUploadedFile")
670 $this->file_obj->$storageMethod($a_http_post_files,
true,
true);
699 $ex_pos = strrpos($a_filename,
"/exercise/");
702 $a_filename = CLIENT_DATA_DIR.substr($a_filename, $ex_pos);
713 if (is_array($a_array))
715 foreach ($a_array as $k => $v)
717 if ($v[
"filename"] !=
"")