22 $this->
setType(self::TYPE_UPLOAD);
58 $this->exc_id = $a_val;
78 $this->start_time = $a_val;
88 return $this->start_time;
98 $this->deadline = $a_val;
108 return $this->deadline;
118 $this->instruction = $a_val;
128 return $this->instruction;
138 $this->title = $a_val;
158 $this->mandatory = $a_val;
168 return $this->mandatory;
178 $this->order_nr = $a_val;
188 return $this->order_nr;
200 $this->type = (int)$a_value;
222 if(in_array((
int)$a_value, array(self::TYPE_UPLOAD, self::TYPE_BLOG, self::TYPE_PORTFOLIO)))
236 $set = $ilDB->query(
"SELECT * FROM exc_assignment ".
237 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
239 while ($rec = $ilDB->fetchAssoc($set))
266 $next_id = $ilDB->nextId(
"exc_assignment");
267 $ilDB->insert(
"exc_assignment", array(
268 "id" => array(
"integer", $next_id),
270 "time_stamp" => array(
"integer", $this->
getDeadline()),
272 "title" => array(
"text", $this->
getTitle()),
273 "start_time" => array(
"integer", $this->
getStartTime()),
274 "order_nr" => array(
"integer", $this->
getOrderNr()),
276 "type" => array(
"integer", $this->
getType())
278 $this->
setId($next_id);
280 $exc->updateAllUsersStatus();
291 $ilDB->update(
"exc_assignment",
294 "time_stamp" => array(
"integer", $this->
getDeadline()),
296 "title" => array(
"text", $this->
getTitle()),
297 "start_time" => array(
"integer", $this->
getStartTime()),
298 "order_nr" => array(
"integer", $this->
getOrderNr()),
300 "type" => array(
"integer", $this->
getType())
303 "id" => array(
"integer", $this->
getId()),
306 $exc->updateAllUsersStatus();
316 $ilDB->manipulate(
"DELETE FROM exc_assignment WHERE ".
317 " id = ".$ilDB->quote($this->getId(),
"integer")
320 $exc->updateAllUsersStatus();
331 $set = $ilDB->query(
"SELECT * FROM exc_assignment ".
332 " WHERE exc_id = ".$ilDB->quote($a_exc_id,
"integer").
333 " ORDER BY order_nr ASC");
337 while ($rec = $ilDB->fetchAssoc($set))
342 "exc_id" => $rec[
"exc_id"],
343 "deadline" => $rec[
"time_stamp"],
344 "instruction" => $rec[
"instruction"],
345 "title" => $rec[
"title"],
346 "start_time" => $rec[
"start_time"],
347 "order_val" => $order_val,
348 "mandatory" => $rec[
"mandatory"],
349 "type" => $rec[
"type"]
365 foreach ($ass_data as
$d)
369 $new_ass->setExerciseId($a_new_exc_id);
370 $new_ass->setTitle($d[
"title"]);
371 $new_ass->setDeadline($d[
"deadline"]);
372 $new_ass->setInstruction($d[
"instruction"]);
373 $new_ass->setMandatory($d[
"mandatory"]);
374 $new_ass->setOrderNr($d[
"order_val"]);
375 $new_ass->setStartTime($d[
"start_time"]);
376 $new_ass->setType($d[
"type"]);
380 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
385 if (is_dir($old_storage->getPath()))
387 ilUtil::rCopy($old_storage->getPath(), $new_storage->getPath());
397 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
399 return $storage->getFiles();
409 $set = $ilDB->query(
"SELECT MAX(order_nr) mnr FROM exc_assignment ".
410 " WHERE exc_id = ".$ilDB->quote($a_exc_id,
"integer")
412 while ($rec = $ilDB->fetchAssoc($set))
414 return (
int) $rec[
"mnr"];
428 $query =
"SELECT id FROM exc_assignment ".
429 "WHERE start_time <= ".$ilDB->quote(time(),
'integer').
' '.
430 "AND time_stamp >= ".$ilDB->quote(time(),
'integer').
' '.
431 "AND id = ".$ilDB->quote($a_ass_id,
'integer');
434 return $res->numRows() ?
true :
false;
441 private static function lookup($a_id, $a_field)
445 $set = $ilDB->query(
"SELECT ".$a_field.
" FROM exc_assignment ".
446 " WHERE id = ".$ilDB->quote($a_id,
"integer")
449 $rec = $ilDB->fetchAssoc($set);
451 return $rec[$a_field];
477 $result_order = array();
480 foreach ($a_order as $k => $v)
483 $ilDB->manipulate(
$t =
"UPDATE exc_assignment SET ".
484 " order_nr = ".$ilDB->quote($nr,
"integer").
485 " WHERE id = ".$ilDB->quote((
int) $k,
"integer").
486 " AND exc_id = ".$ilDB->quote((
int) $a_ex_id,
"integer")
499 $set = $ilDB->query(
"SELECT id FROM exc_assignment ".
500 " WHERE exc_id = ".$ilDB->quote($a_ex_id,
"integer").
501 " ORDER BY time_stamp ASC"
504 while ($rec = $ilDB->fetchAssoc($set))
506 $ilDB->manipulate(
"UPDATE exc_assignment SET ".
507 " order_nr = ".$ilDB->quote($nr,
"integer").
508 " WHERE id = ".$ilDB->quote($rec[
"id"],
"integer")
521 $set = $ilDB->query(
"SELECT count(*) cntm FROM exc_assignment ".
522 " WHERE exc_id = ".$ilDB->quote($a_ex_id,
"integer").
523 " AND mandatory = ".$ilDB->quote(1,
"integer")
525 $rec = $ilDB->fetchAssoc($set);
540 $set = $ilDB->query(
"SELECT ".$a_field.
" FROM exc_mem_ass_status ".
541 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
542 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer")
544 $rec = $ilDB->fetchAssoc($set);
546 return $rec[$a_field];
556 $ilDB->manipulate(
"UPDATE exc_mem_ass_status SET ".
557 " ".$a_field.
" = ".$ilDB->quote($a_value, $a_type).
558 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
559 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer")
591 "u_comment", $a_value,
"text");
608 "mark", $a_value,
"text");
631 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
632 "SET status = %s, status_time= %s ".
633 " WHERE ass_id = %s AND usr_id = %s AND status <> %s ",
634 array(
"text",
"timestamp",
"integer",
"integer",
"text"),
635 array($a_status,
ilUtil::now(), $a_ass_id, $a_user_id, $a_status));
680 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
681 "SET sent = %s, status_time= %s, sent_time = %s ".
682 " WHERE ass_id = %s AND usr_id = %s ",
683 array(
"integer",
"timestamp",
"timestamp",
"integer",
"integer"),
685 $a_ass_id, $a_user_id));
717 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
718 "SET returned = %s, status_time= %s ".
719 " WHERE ass_id = %s AND usr_id = %s",
720 array(
"integer",
"timestamp",
"integer",
"integer"),
722 $a_ass_id, $a_user_id));
754 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
755 "SET feedback = %s, status_time= %s, feedback_time = %s ".
756 " WHERE ass_id = %s AND usr_id = %s",
757 array(
"integer",
"timestamp",
"timestamp",
"integer",
"integer"),
759 $a_ass_id, $a_user_id));
819 $result = $ilDB->queryF(
"SELECT returned_id FROM exc_returned WHERE ass_id = %s AND user_id = %s",
820 array(
"integer",
"integer"),
821 array($ass_id, $a_user_id));
822 return $ilDB->numRows(
$result);
833 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
836 $query =
"SELECT * FROM exc_returned WHERE ass_id = ".
837 $ilDB->quote($a_ass_id,
"integer");
840 while(
$row = $ilDB->fetchAssoc(
$res))
843 $row[
"filename"] = $fs->getAbsoluteSubmissionPath().
844 "/".$row[
"user_id"].
"/".basename(
$row[
"filename"]);
850 return $delivered ? $delivered : array();
860 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
863 $result = $ilDB->queryF(
"SELECT * FROM exc_returned WHERE ass_id = %s AND user_id = %s ORDER BY ts",
864 array(
"integer",
"integer"),
865 array($a_ass_id, $a_user_id));
867 $delivered_files = array();
872 if($a_filter_empty_filename && !
$row[
"filename"])
877 $row[
"timestamp14"] = substr(
$row[
"ts"], 0, 4).
878 substr(
$row[
"ts"], 5, 2).substr(
$row[
"ts"], 8, 2).
879 substr(
$row[
"ts"], 11, 2).substr(
$row[
"ts"], 14, 2).
880 substr(
$row[
"ts"], 17, 2);
881 $row[
"filename"] = $fs->getAbsoluteSubmissionPath().
882 "/".$row[
"user_id"].
"/".basename(
$row[
"filename"]);
883 array_push($delivered_files,
$row);
888 return $delivered_files;
898 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
901 if (count($file_id_array))
903 $result = $ilDB->query(
"SELECT * FROM exc_returned WHERE user_id = ".
904 $ilDB->quote($a_user_id,
"integer").
" AND ".
905 $ilDB->in(
"returned_id", $file_id_array,
false,
"integer"));
909 $result_array = array();
913 array_push($result_array,
$row);
916 $ilDB->manipulate(
"DELETE FROM exc_returned WHERE user_id = ".
917 $ilDB->quote($a_user_id,
"integer").
" AND ".
918 $ilDB->in(
"returned_id", $file_id_array,
false,
"integer"));
924 foreach ($result_array as $key => $value)
926 if($value[
"filename"])
928 $filename = $fs->getAbsoluteSubmissionPath().
929 "/".$value[
"user_id"].
"/".basename($value[
"filename"]);
947 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
950 $set = $ilDB->query(
"SELECT * FROM exc_returned ".
951 " WHERE obj_id = ".$ilDB->quote($a_exc_id,
"integer").
952 " AND user_id = ".$ilDB->quote($a_user_id,
"integer")
954 while ($rec = $ilDB->fetchAssoc($set))
959 $filename = $fs->getAbsoluteSubmissionPath().
960 "/".$a_user_id.
"/".basename($rec[
"filename"]);
967 $ilDB->manipulate(
$d =
"DELETE FROM exc_returned WHERE ".
968 " obj_id = ".$ilDB->quote($a_exc_id,
"integer").
969 " AND user_id = ".$ilDB->quote($a_user_id,
"integer")
979 global $ilUser,
$ilDB;
985 $q =
"SELECT download_time FROM exc_usr_tutor WHERE ".
986 " ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" AND ".
987 " usr_id = ".$ilDB->quote($a_user_id,
"integer").
" AND ".
988 " tutor_id = ".$ilDB->quote($ilUser->getId(),
"integer");
989 $lu_set = $ilDB->query($q);
990 if ($lu_rec = $ilDB->fetchAssoc($lu_set))
992 if ($lu_rec[
"download_time"] > 0)
994 $and_str =
" AND ts > ".$ilDB->quote($lu_rec[
"download_time"],
"timestamp");
1001 $query = sprintf(
"SELECT * FROM exc_returned WHERE ass_id = %s AND user_id = %s".
1003 $ilDB->quote($a_ass_id,
"integer"),
1004 $ilDB->quote($a_user_id,
"integer"));
1006 $count = $ilDB->numRows($result);
1009 $row = $ilDB->fetchAssoc($result);
1011 switch(self::lookupType($a_ass_id))
1013 case self::TYPE_BLOG:
1014 case self::TYPE_PORTFOLIO:
1018 $row[
"filetitle"][
"firstname"].
" ".
1019 $row[
"filetitle"][
"lastname"].
" (".
1020 $row[
"filetitle"][
"login"].
").zip";
1028 $row[
"filename"],
$row[
"filetitle"]);
1030 else if ($count > 0)
1032 $array_files = array();
1034 while (
$row = $ilDB->fetchAssoc($result))
1036 array_push($array_files, basename(
$row[
"filename"]));
1044 $dir = $pathinfo[
"dirname"];
1062 global $ilUser,
$ilDB;
1064 $ilDB->manipulateF(
"DELETE FROM exc_usr_tutor ".
1065 "WHERE ass_id = %s AND usr_id = %s AND tutor_id = %s",
1066 array(
"integer",
"integer",
"integer"),
1067 array($a_ass_id, $a_user_id, $ilUser->getId()));
1069 $ilDB->manipulateF(
"INSERT INTO exc_usr_tutor (ass_id, obj_id, usr_id, tutor_id, download_time) VALUES ".
1070 "(%s, %s, %s, %s, %s)",
1071 array(
"integer",
"integer",
"integer",
"integer",
"timestamp"),
1072 array($a_ass_id, $a_exc_id, $a_user_id, $ilUser->getId(),
ilUtil::now()));
1082 if (count($array_file_id))
1084 $result = $ilDB->query(
"SELECT * FROM exc_returned WHERE ".
1085 $ilDB->in(
"returned_id", $array_file_id,
false,
"integer").
1086 " AND user_id = ".$ilDB->quote($a_user_id));
1089 $array_found = array();
1093 array_push($array_found,
$row);
1095 if (count($array_found) == 1)
1098 if(is_numeric($array_found[0][
"filetitle"]))
1106 $ass->getTitle().
" - ".
1107 $user_data[
"firstname"].
" ".
1108 $user_data[
"lastname"].
" (".
1109 $user_data[
"login"].
").zip";
1114 $array_found[0][
"filename"], $array_found[0][
"filetitle"]);
1118 $filenames = array();
1121 foreach ($array_found as $key => $value)
1127 array_push($filenames, basename($value[
"filename"]));
1130 $filenames, $a_user_id);
1141 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1144 $filename = $fs->getAbsoluteSubmissionPath().
1147 require_once
"./Services/Utilities/classes/class.ilUtil.php";
1158 global
$lng, $ilObjDataCache;
1160 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1162 $pathname = $fs->getAbsoluteSubmissionPath().
1165 require_once
"./Services/Utilities/classes/class.ilUtil.php";
1171 $tmpzipfile = $tmpfile .
".zip";
1177 $deliverFilename = str_replace(
" ",
"_", $assTitle);
1181 $deliverFilename .=
"_".$userName[
"lastname"].
"_".$userName[
"firstname"];
1185 $deliverFilename .=
"_files";
1187 $orgDeliverFilename = trim($deliverFilename);
1190 chdir($tmpdir.
"/".$deliverFilename);
1193 foreach ($array_filenames as $key =>
$filename)
1197 $pos = strpos($newFilename ,
"_");
1202 $newFilename= substr($newFilename, $pos + 1);
1204 $newFilename = $tmpdir.DIRECTORY_SEPARATOR.$deliverFilename.DIRECTORY_SEPARATOR.$newFilename;
1206 $oldFilename = $pathname.DIRECTORY_SEPARATOR.$filename;
1207 if (!copy ($oldFilename, $newFilename))
1209 echo
'Could not copy '.$oldFilename.
' to '.$newFilename;
1211 touch($newFilename, filectime($oldFilename));
1212 $array_filenames[$key] =
ilUtil::escapeShellArg($deliverFilename.DIRECTORY_SEPARATOR.basename($newFilename));
1233 global
$lng, $ilObjDataCache, $ilias;
1235 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1236 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1243 $savepath = $storage->getAbsoluteSubmissionPath();
1251 if (!is_dir($savepath))
1257 chdir($storage->getTempPath());
1267 foreach ($members as $id => $object) {
1268 $directory = $savepath.DIRECTORY_SEPARATOR.$id;
1271 if ($dirsize > disk_free_space($tmpdir)) {
1282 foreach ($members as $id => $user)
1284 $sourcedir = $savepath.DIRECTORY_SEPARATOR.$id;
1285 if (!is_dir($sourcedir))
1289 if (array_key_exists($directory, $cache))
1293 if (array_key_exists($directory, $cache)) {
1295 $directory .=
"_".$id;
1299 $cache[$directory] = $directory;
1301 $sourcefiles = scandir($sourcedir);
1302 foreach ($sourcefiles as $sourcefile) {
1303 if ($sourcefile ==
"." || $sourcefile ==
"..")
1308 $targetfile = trim(basename($sourcefile));
1309 $pos = strpos($targetfile,
"_");
1312 $targetfile= substr($targetfile, $pos + 1);
1315 $targetfile = $directory.DIRECTORY_SEPARATOR.$targetfile;
1316 $sourcefile = $sourcedir.DIRECTORY_SEPARATOR.$sourcefile;
1318 if (!copy ($sourcefile, $targetfile))
1321 $ilias->raiseError(
'Could not copy '.basename($sourcefile).
" to '".$targetfile.
"'.",
1322 $ilias->error_obj->MESSAGE);
1327 touch($targetfile, filectime($sourcefile));
1334 unlink($targetfile);
1342 $tmpzipfile = $tmpfile .
".zip";
1351 ? strtolower($lng->txt(
"exc_assignment"))
1352 : $assTitle).
".zip",
"",
false,
true);
1362 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
1363 "SET notice = %s, status_time= %s ".
1364 " WHERE ass_id = %s AND usr_id = %s AND ".
1365 $ilDB->equalsNot(
"notice", $a_notice,
"text",
true),
1366 array(
"text",
"timestamp",
"integer",
"integer"),
1367 array($a_notice,
ilUtil::now(), $a_ass_id, $a_user_id));
1378 $query =
"SELECT DISTINCT(usr_id) as ud FROM exc_mem_ass_status ".
1379 "WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" ".
1383 while(
$row = $ilDB->fetchObject(
$res))
1385 $usr_ids[] =
$row->ud;
1388 return $usr_ids ? $usr_ids : array();
1402 $q =
"SELECT obj_id,user_id,ts FROM exc_returned ".
1403 "WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" AND user_id = ".
1404 $ilDB->quote($a_user_id,
"integer").
1405 " ORDER BY ts DESC";
1407 $usr_set = $ilDB->query($q);
1409 $array = $ilDB->fetchAssoc($usr_set);
1410 if ($array[
"ts"]==NULL)
1427 $q =
"SELECT count(*) AS cnt FROM exc_mem_ass_status".
1428 " WHERE NOT sent_time IS NULL".
1429 " AND ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" ".
1431 $set = $ilDB->query($q);
1432 $rec = $ilDB->fetchAssoc($set);
1434 if ($rec[
"cnt"] > 0)
1453 $q=
"SELECT exc_mem_ass_status.status_time, exc_returned.ts ".
1454 "FROM exc_mem_ass_status, exc_returned ".
1455 "WHERE exc_mem_ass_status.status_time < exc_returned.ts ".
1456 "AND NOT exc_mem_ass_status.status_time IS NULL ".
1457 "AND exc_returned.ass_id = exc_mem_ass_status.ass_id ".
1458 "AND exc_returned.user_id = exc_mem_ass_status.usr_id ".
1459 "AND exc_returned.ass_id=".$ilDB->quote($ass_id,
"integer").
" AND exc_returned.user_id=".
1460 $ilDB->quote($member_id,
"integer");
1462 $usr_set = $ilDB->query($q);
1464 $array = $ilDB->fetchAssoc($usr_set);
1466 if (count($array)==0)
1483 global
$ilDB, $ilUser;
1485 $q =
"SELECT exc_returned.returned_id AS id ".
1486 "FROM exc_usr_tutor, exc_returned ".
1487 "WHERE exc_returned.ass_id = exc_usr_tutor.ass_id ".
1488 " AND exc_returned.user_id = exc_usr_tutor.usr_id ".
1489 " AND exc_returned.ass_id = ".$ilDB->quote($ass_id,
"integer").
1490 " AND exc_returned.user_id = ".$ilDB->quote($member_id,
"integer").
1491 " AND exc_usr_tutor.tutor_id = ".$ilDB->quote($ilUser->getId(),
"integer").
1492 " AND exc_usr_tutor.download_time < exc_returned.ts ";
1494 $new_up_set = $ilDB->query($q);
1497 while ($new_up_rec = $ilDB->fetchAssoc($new_up_set))
1499 $new_up[] = $new_up_rec[
"id"];
1515 $set = $ilDB->query(
"SELECT * FROM exc_members ".
1516 "WHERE obj_id = ".$ilDB->quote($a_exc_id,
"integer"));
1517 while($rec = $ilDB->fetchAssoc($set))
1524 $mem[$rec[
"usr_id"]] =
1526 "name" => $name[
"lastname"].
", ".$name[
"firstname"],
1528 "usr_id" => $rec[
"usr_id"],
1529 "lastname" => $name[
"lastname"],
1530 "firstname" => $name[
"firstname"]
1535 $q =
"SELECT * FROM exc_mem_ass_status ".
1536 "WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer");
1537 $set = $ilDB->query($q);
1538 while($rec = $ilDB->fetchAssoc($set))
1540 if (isset($mem[$rec[
"usr_id"]]))
1542 $mem[$rec[
"usr_id"]][
"sent_time"] = $rec[
"sent_time"];
1544 $mem[$rec[
"usr_id"]][
"status_time"] = $rec[
"status_time"];
1545 $mem[$rec[
"usr_id"]][
"feedback_time"] = $rec[
"feedback_time"];
1546 $mem[$rec[
"usr_id"]][
"notice"] = $rec[
"notice"];
1547 $mem[$rec[
"usr_id"]][
"status"] = $rec[
"status"];
1561 foreach ($ass_data as $ass)
1564 $ilDB->replace(
"exc_mem_ass_status", array(
1565 "ass_id" => array(
"integer", $ass[
"id"]),
1566 "usr_id" => array(
"integer", $a_user_id)
1568 "status" => array(
"text",
"notgraded")
1580 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
1582 $mems = $exmem->getMembers();
1584 foreach ($mems as $mem)
1586 $ilDB->replace(
"exc_mem_ass_status", array(
1587 "ass_id" => array(
"integer", $a_ass_id),
1588 "usr_id" => array(
"integer", $mem)
1590 "status" => array(
"text",
"notgraded")
1601 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1604 $storage->uploadAssignmentFiles($a_files);