4 require_once
"classes/class.ilObject.php";
5 require_once
"./Modules/Exercise/classes/class.ilFileDataExercise.php";
6 require_once
"./Modules/Exercise/classes/class.ilExerciseMembers.php";
42 $this->
ilObject($a_id,$a_call_by_reference);
46 function setDate($a_hour,$a_minutes,$a_day,$a_month,$a_year)
48 $this->hour = (int) $a_hour;
49 $this->minutes = (int) $a_minutes;
50 $this->day = (int) $a_day;
51 $this->month = (int) $a_month;
52 $this->year = (int) $a_year;
53 $this->timestamp = mktime($this->hour,$this->minutes,0,$this->month,$this->day,$this->year);
62 $this->timestamp = $a_timestamp;
66 $this->instruction = $a_instruction;
79 return $this->hour == (int) date(
"H",$this->timestamp) and
80 $this->minutes == (int) date(
"i",$this->timestamp) and
81 $this->day == (int) date(
"d",$this->timestamp) and
82 $this->month == (int) date(
"m",$this->timestamp) and
83 $this->year == (int) date(
"Y",$this->timestamp);
87 function deliverFile($a_http_post_files, $user_id, $unzip =
false)
91 $deliver_result = $this->file_obj->deliverFile($a_http_post_files, $user_id, $unzip);
95 $next_id = $ilDB->nextId(
"exc_returned");
96 $query = sprintf(
"INSERT INTO exc_returned ".
97 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts) ".
98 "VALUES (%s, %s, %s, %s, %s, %s, %s)",
99 $ilDB->quote($next_id,
"integer"),
100 $ilDB->quote($this->
getId(),
"integer"),
101 $ilDB->quote($user_id,
"integer"),
102 $ilDB->quote($deliver_result[
"fullname"],
"text"),
103 $ilDB->quote($a_http_post_files[
"name"],
"text"),
104 $ilDB->quote($deliver_result[
"mimetype"],
"text"),
107 $ilDB->manipulate(
$query);
108 if (!$this->members_obj->isAssigned($user_id))
110 $this->members_obj->assignMember($user_id);
112 $this->members_obj->setStatusReturnedForMember($user_id, 1);
120 if ($unzipUploadedFile && preg_match(
"/zip/", $a_http_post_files[
"type"]) == 1)
130 $this->file_obj->storeUploadedFile($a_http_post_files,
true);
136 $this->file_obj->unlinkFiles($a_files);
150 $ilDB->insert(
"exc_data", array(
151 "obj_id" => array(
"integer", $this->
getId()),
173 $new_obj->saveData();
177 $tmp_file_obj->ilClone($new_obj->getId());
178 unset($tmp_file_obj);
181 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
183 $obj_settings->cloneSettings($new_obj->getId());
184 unset($obj_settings);
198 $delivered_files =& $this->members_obj->getDeliveredFiles($user_id);
199 return $delivered_files;
210 $this->members_obj->deleteDeliveredFiles($file_id_array, $user_id);
213 if(!count($this->members_obj->getDeliveredFiles($user_id)))
215 $this->members_obj->setStatusReturnedForMember($user_id,0);
226 require_once
"./Services/Utilities/classes/class.ilUtil.php";
240 if (!parent::delete())
245 $ilDB->manipulate(
"DELETE FROM exc_data ".
246 "WHERE obj_id = ".$ilDB->quote($this->getId(),
"integer"));
250 $this->file_obj->delete();
251 $this->members_obj->delete();
266 function notify($a_event,$a_ref_id,$a_node_id,$a_params = 0)
279 $query =
"SELECT * FROM exc_data ".
280 "WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
283 while(
$row = $ilDB->fetchObject(
$res))
289 $this->members_obj->read();
293 $this->files = $this->file_obj->getFiles();
310 $ilDB->update(
"exc_data", array(
314 "obj_id" => array(
"integer", $this->
getId())
319 #$this->members_obj->update();
331 $q =
"SELECT * FROM exc_members ".
332 "WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
333 $set = $ilDB->query(
$q);
334 while($rec = $ilDB->fetchAssoc($set))
343 "name" =>
$name[
"lastname"].
", ".
$name[
"firstname"],
345 "sent_time" => $rec[
"sent_time"],
347 "status_time" => $rec[
"status_time"],
348 "feedback_time" => $rec[
"feedback_time"],
349 "usr_id" => $rec[
"usr_id"],
350 "lastname" => $name[
"lastname"],
351 "firstname" => $name[
"firstname"],
352 "notice" => $rec[
"notice"],
353 "status" => $rec[
"status"]
370 $q=
"SELECT obj_id,user_id,ts FROM exc_returned ".
371 "WHERE obj_id =".$ilDB->quote($this->
getId(),
"integer").
" AND user_id=".
372 $ilDB->quote($member_id,
"integer").
375 $usr_set = $ilDB->query(
$q);
377 $array = $ilDB->fetchAssoc($usr_set);
378 if ($array[
"ts"]==NULL)
393 $files = $this->file_obj->getFiles();
396 include_once
"./classes/class.ilFileDataMail.php";
401 $mfile_obj->copyAttachmentFile($this->file_obj->getAbsolutePath($file[
"name"]),$file[
"name"]);
402 $file_names[] = $file[
"name"];
406 include_once
"Services/Mail/classes/class.ilMail.php";
410 count($file_names) ? $file_names : array(),array(
"normal"));
412 unset($tmp_mail_obj);
414 if(count($file_names))
416 $mfile_obj->unlinkFiles($file_names);
422 foreach($a_members as $member_id => $value)
424 $this->members_obj->setStatusSentForMember($member_id,1);
439 $q=
"SELECT exc_members.status_time, exc_returned.ts ".
440 "FROM exc_members, exc_returned ".
441 "WHERE exc_members.status_time < exc_returned.ts ".
442 "AND NOT exc_members.status_time IS NULL ".
443 "AND exc_returned.obj_id = exc_members.obj_id ".
444 "AND exc_returned.user_id = exc_members.usr_id ".
445 "AND exc_returned.obj_id=".$ilDB->quote($exc_id,
"integer").
" AND exc_returned.user_id=".
446 $ilDB->quote($member_id,
"integer");
448 $usr_set = $ilDB->query(
$q);
450 $array = $ilDB->fetchAssoc($usr_set);
452 if (count($array)==0)
471 $q =
"SELECT count(*) AS cnt FROM exc_members".
472 " WHERE NOT sent_time IS NULL".
473 " AND obj_id = ".$ilDB->quote($a_exc_id,
"integer").
" ".
475 $set = $ilDB->query(
$q);
476 $rec = $ilDB->fetchAssoc($set);
494 global
$ilDB, $ilUser;
496 $q =
"SELECT exc_returned.returned_id AS id ".
497 "FROM exc_usr_tutor, exc_returned ".
498 "WHERE exc_returned.obj_id = exc_usr_tutor.obj_id ".
499 " AND exc_returned.user_id = exc_usr_tutor.usr_id ".
500 " AND exc_returned.obj_id = ".$ilDB->quote($exc_id,
"integer").
501 " AND exc_returned.user_id = ".$ilDB->quote($member_id,
"integer").
502 " AND exc_usr_tutor.tutor_id = ".$ilDB->quote($ilUser->getId(),
"integer").
503 " AND exc_usr_tutor.download_time < exc_returned.ts ";
505 $new_up_set = $ilDB->query(
$q);
508 while ($new_up_rec = $ilDB->fetchAssoc($new_up_set))
510 $new_up[] = $new_up_rec[
"id"];
526 "WHERE obj_id= ".$ilDB->quote($exc_id,
"integer").
527 " AND usr_id= ".$ilDB->quote($member_id,
"integer");
529 $set = $ilDB->query(
$q);
530 if ($rec = $ilDB->fetchAssoc($set))
546 "WHERE obj_id= ".$ilDB->quote($exc_id,
"integer").
547 " AND usr_id= ".$ilDB->quote($member_id,
"integer");
549 $set = $ilDB->query(
$q);
550 if ($rec = $ilDB->fetchAssoc($set))
566 "WHERE obj_id= ".$ilDB->quote($exc_id,
"integer").
567 " AND usr_id= ".$ilDB->quote($member_id,
"integer");
569 $set = $ilDB->query(
$q);
570 if ($rec = $ilDB->fetchAssoc($set))
583 $body .= $lng->txt(
"exc_edit_until") .
": ".
586 $body .= ILIAS_HTTP_PATH.
589 "_".$this->getRefId().
"&client_id=".CLIENT_ID;
601 foreach($a_members as $member_id => $value)
604 $tmp_members[] = $tmp_obj->getLogin();
609 return implode(
',',$tmp_members ? $tmp_members : array());
616 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
645 global
$lng, $ilUser;
651 include_once (
"Services/Utilities/classes/class.ilFileUtils.php");
661 $a_http_post_files[
"type"] =
"other";
662 $a_http_post_files[
"tmp_name"] = $filearray[
"path"][
$key].
"/".
$filename;
663 $a_http_post_files[
"error"] = 0;
664 $a_http_post_files[
"size"] = filesize($filearray[
"path"][
$key].
"/".
$filename);
666 if ($storageMethod ==
"deliverFile")
668 $this->$storageMethod($a_http_post_files, $ilUser->id,
true);
670 else if ($storageMethod ==
"storeUploadedFile")
672 $this->file_obj->$storageMethod($a_http_post_files,
true,
true);
701 $ex_pos = strrpos($a_filename,
"/exercise/");
704 $a_filename = CLIENT_DATA_DIR.substr($a_filename, $ex_pos);
715 if (is_array($a_array))
717 foreach ($a_array as $k => $v)
719 if ($v[
"filename"] !=
"")