52 $this->exc_id = $a_val;
72 $this->start_time = $a_val;
82 return $this->start_time;
92 $this->deadline = $a_val;
102 return $this->deadline;
112 $this->instruction = $a_val;
122 return $this->instruction;
132 $this->title = $a_val;
152 $this->mandatory = $a_val;
162 return $this->mandatory;
172 $this->order_nr = $a_val;
182 return $this->order_nr;
192 $set = $ilDB->query(
"SELECT * FROM exc_assignment ".
193 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
195 while ($rec = $ilDB->fetchAssoc($set))
221 $next_id = $ilDB->nextId(
"exc_assignment");
222 $ilDB->insert(
"exc_assignment", array(
223 "id" => array(
"integer", $next_id),
225 "time_stamp" => array(
"integer", $this->
getDeadline()),
227 "title" => array(
"text", $this->
getTitle()),
228 "start_time" => array(
"integer", $this->
getStartTime()),
229 "order_nr" => array(
"integer", $this->
getOrderNr()),
232 $this->
setId($next_id);
234 $exc->updateAllUsersStatus();
245 $ilDB->update(
"exc_assignment",
248 "time_stamp" => array(
"integer", $this->
getDeadline()),
250 "title" => array(
"text", $this->
getTitle()),
251 "start_time" => array(
"integer", $this->
getStartTime()),
252 "order_nr" => array(
"integer", $this->
getOrderNr()),
256 "id" => array(
"integer", $this->
getId()),
259 $exc->updateAllUsersStatus();
269 $ilDB->manipulate(
"DELETE FROM exc_assignment WHERE ".
270 " id = ".$ilDB->quote($this->getId(),
"integer")
273 $exc->updateAllUsersStatus();
284 $set = $ilDB->query(
"SELECT * FROM exc_assignment ".
285 " WHERE exc_id = ".$ilDB->quote($a_exc_id,
"integer").
286 " ORDER BY order_nr ASC");
290 while ($rec = $ilDB->fetchAssoc($set))
295 "exc_id" => $rec[
"exc_id"],
296 "deadline" => $rec[
"time_stamp"],
297 "instruction" => $rec[
"instruction"],
298 "title" => $rec[
"title"],
299 "start_time" => $rec[
"start_time"],
300 "order_val" => $order_val,
301 "mandatory" => $rec[
"mandatory"]
317 foreach ($ass_data as
$d)
321 $new_ass->setExerciseId($a_new_exc_id);
322 $new_ass->setTitle($d[
"title"]);
323 $new_ass->setDeadline($d[
"deadline"]);
324 $new_ass->setInstruction($d[
"instruction"]);
325 $new_ass->setMandatory($d[
"mandatory"]);
326 $new_ass->setOrderNr($d[
"order_val"]);
327 $new_ass->setStartTime($d[
"start_time"]);
331 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
336 if (is_dir($old_storage->getPath()))
338 ilUtil::rCopy($old_storage->getPath(), $new_storage->getPath());
348 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
350 return $storage->getFiles();
360 $set = $ilDB->query(
"SELECT MAX(order_nr) mnr FROM exc_assignment ".
361 " WHERE exc_id = ".$ilDB->quote($a_exc_id,
"integer")
363 while ($rec = $ilDB->fetchAssoc($set))
365 return (
int) $rec[
"mnr"];
379 $query =
"SELECT id FROM exc_assignment ".
380 "WHERE start_time <= ".$ilDB->quote(time(),
'integer').
' '.
381 "AND time_stamp >= ".$ilDB->quote(time(),
'integer').
' '.
382 "AND id = ".$ilDB->quote($a_ass_id,
'integer');
385 return $res->numRows() ?
true :
false;
392 private static function lookup($a_id, $a_field)
396 $set = $ilDB->query(
"SELECT ".$a_field.
" FROM exc_assignment ".
397 " WHERE id = ".$ilDB->quote($a_id,
"integer")
400 $rec = $ilDB->fetchAssoc($set);
402 return $rec[$a_field];
420 $result_order = array();
423 foreach ($a_order as $k => $v)
426 $ilDB->manipulate(
$t =
"UPDATE exc_assignment SET ".
427 " order_nr = ".$ilDB->quote($nr,
"integer").
428 " WHERE id = ".$ilDB->quote((
int) $k,
"integer").
429 " AND exc_id = ".$ilDB->quote((
int) $a_ex_id,
"integer")
442 $set = $ilDB->query(
"SELECT id FROM exc_assignment ".
443 " WHERE exc_id = ".$ilDB->quote($a_ex_id,
"integer").
444 " ORDER BY time_stamp ASC"
447 while ($rec = $ilDB->fetchAssoc($set))
449 $ilDB->manipulate(
"UPDATE exc_assignment SET ".
450 " order_nr = ".$ilDB->quote($nr,
"integer").
451 " WHERE id = ".$ilDB->quote($rec[
"id"],
"integer")
464 $set = $ilDB->query(
"SELECT count(*) cntm FROM exc_assignment ".
465 " WHERE exc_id = ".$ilDB->quote($a_ex_id,
"integer").
466 " AND mandatory = ".$ilDB->quote(1,
"integer")
468 $rec = $ilDB->fetchAssoc($set);
483 $set = $ilDB->query(
"SELECT ".$a_field.
" FROM exc_mem_ass_status ".
484 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
485 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer")
487 $rec = $ilDB->fetchAssoc($set);
489 return $rec[$a_field];
499 $ilDB->manipulate(
"UPDATE exc_mem_ass_status SET ".
500 " ".$a_field.
" = ".$ilDB->quote($a_value, $a_type).
501 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
502 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer")
534 "u_comment", $a_value,
"text");
551 "mark", $a_value,
"text");
574 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
575 "SET status = %s, status_time= %s ".
576 " WHERE ass_id = %s AND usr_id = %s AND status <> %s ",
577 array(
"text",
"timestamp",
"integer",
"integer",
"text"),
578 array($a_status,
ilUtil::now(), $a_ass_id, $a_user_id, $a_status));
623 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
624 "SET sent = %s, status_time= %s, sent_time = %s ".
625 " WHERE ass_id = %s AND usr_id = %s ",
626 array(
"integer",
"timestamp",
"timestamp",
"integer",
"integer"),
628 $a_ass_id, $a_user_id));
660 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
661 "SET returned = %s, status_time= %s ".
662 " WHERE ass_id = %s AND usr_id = %s",
663 array(
"integer",
"timestamp",
"integer",
"integer"),
665 $a_ass_id, $a_user_id));
697 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
698 "SET feedback = %s, status_time= %s, feedback_time = %s ".
699 " WHERE ass_id = %s AND usr_id = %s",
700 array(
"integer",
"timestamp",
"timestamp",
"integer",
"integer"),
702 $a_ass_id, $a_user_id));
762 $result = $ilDB->queryF(
"SELECT returned_id FROM exc_returned WHERE ass_id = %s AND user_id = %s",
763 array(
"integer",
"integer"),
764 array($ass_id, $a_user_id));
765 return $ilDB->numRows(
$result);
776 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
779 $query =
"SELECT * FROM exc_returned WHERE ass_id = ".
780 $ilDB->quote($a_ass_id,
"integer");
783 while(
$row = $ilDB->fetchAssoc(
$res))
786 $row[
"filename"] = $fs->getAbsoluteSubmissionPath().
787 "/".$row[
"user_id"].
"/".basename(
$row[
"filename"]);
793 return $delivered ? $delivered : array();
803 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
806 $result = $ilDB->queryF(
"SELECT * FROM exc_returned WHERE ass_id = %s AND user_id = %s ORDER BY ts",
807 array(
"integer",
"integer"),
808 array($a_ass_id, $a_user_id));
810 $delivered_files = array();
816 $row[
"timestamp14"] = substr(
$row[
"ts"], 0, 4).
817 substr(
$row[
"ts"], 5, 2).substr(
$row[
"ts"], 8, 2).
818 substr(
$row[
"ts"], 11, 2).substr(
$row[
"ts"], 14, 2).
819 substr(
$row[
"ts"], 17, 2);
820 $row[
"filename"] = $fs->getAbsoluteSubmissionPath().
821 "/".$row[
"user_id"].
"/".basename(
$row[
"filename"]);
822 array_push($delivered_files,
$row);
828 return $delivered_files;
838 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
841 if (count($file_id_array))
843 $result = $ilDB->query(
"SELECT * FROM exc_returned WHERE user_id = ".
844 $ilDB->quote($a_user_id,
"integer").
" AND ".
845 $ilDB->in(
"returned_id", $file_id_array,
false,
"integer"));
849 $result_array = array();
853 array_push($result_array,
$row);
856 $ilDB->manipulate(
"DELETE FROM exc_returned WHERE user_id = ".
857 $ilDB->quote($a_user_id,
"integer").
" AND ".
858 $ilDB->in(
"returned_id", $file_id_array,
false,
"integer"));
864 foreach ($result_array as $key => $value)
866 $filename = $fs->getAbsoluteSubmissionPath().
867 "/".$value[
"user_id"].
"/".basename($value[
"filename"]);
879 global $ilUser,
$ilDB;
885 $q =
"SELECT download_time FROM exc_usr_tutor WHERE ".
886 " ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" AND ".
887 " usr_id = ".$ilDB->quote($a_user_id,
"integer").
" AND ".
888 " tutor_id = ".$ilDB->quote($ilUser->getId(),
"integer");
889 $lu_set = $ilDB->query($q);
890 if ($lu_rec = $ilDB->fetchAssoc($lu_set))
892 if ($lu_rec[
"download_time"] > 0)
894 $and_str =
" AND ts > ".$ilDB->quote($lu_rec[
"download_time"],
"timestamp");
901 $query = sprintf(
"SELECT * FROM exc_returned WHERE ass_id = %s AND user_id = %s".
903 $ilDB->quote($a_ass_id,
"integer"),
904 $ilDB->quote($a_user_id,
"integer"));
906 $count = $ilDB->numRows($result);
909 $row = $ilDB->fetchAssoc($result);
911 $row[
"filename"],
$row[
"filetitle"]);
915 $array_files = array();
917 while (
$row = $ilDB->fetchAssoc($result))
919 array_push($array_files, basename(
$row[
"filename"]));
927 $dir = $pathinfo[
"dirname"];
945 global $ilUser,
$ilDB;
947 $ilDB->manipulateF(
"DELETE FROM exc_usr_tutor ".
948 "WHERE ass_id = %s AND usr_id = %s AND tutor_id = %s",
949 array(
"integer",
"integer",
"integer"),
950 array($a_ass_id, $a_user_id, $ilUser->getId()));
952 $ilDB->manipulateF(
"INSERT INTO exc_usr_tutor (ass_id, obj_id, usr_id, tutor_id, download_time) VALUES ".
953 "(%s, %s, %s, %s, %s)",
954 array(
"integer",
"integer",
"integer",
"integer",
"timestamp"),
955 array($a_ass_id, $a_exc_id, $a_user_id, $ilUser->getId(),
ilUtil::now()));
965 if (count($array_file_id))
967 $result = $ilDB->query(
"SELECT * FROM exc_returned WHERE ".
968 $ilDB->in(
"returned_id", $array_file_id,
false,
"integer").
969 " AND user_id = ".$ilDB->quote($a_user_id));
972 $array_found = array();
976 array_push($array_found,
$row);
978 if (count($array_found) == 1)
981 $array_found[0][
"filename"], $array_found[0][
"filetitle"]);
985 $filenames = array();
988 foreach ($array_found as $key => $value)
994 array_push($filenames, basename($value[
"filename"]));
997 $filenames, $a_user_id);
1008 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1011 $filename = $fs->getAbsoluteSubmissionPath().
1014 require_once
"./Services/Utilities/classes/class.ilUtil.php";
1025 global
$lng, $ilObjDataCache;
1027 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1029 $pathname = $fs->getAbsoluteSubmissionPath().
1032 require_once
"./Services/Utilities/classes/class.ilUtil.php";
1038 $tmpzipfile = $tmpfile .
".zip";
1044 $deliverFilename = str_replace(
" ",
"_", $assTitle);
1048 $deliverFilename .=
"_".$userName[
"lastname"].
"_".$userName[
"firstname"];
1052 $deliverFilename .=
"_files";
1054 $orgDeliverFilename = trim($deliverFilename);
1057 chdir($tmpdir.
"/".$deliverFilename);
1060 foreach ($array_filenames as $key =>
$filename)
1064 $pos = strpos($newFilename ,
"_");
1069 $newFilename= substr($newFilename, $pos + 1);
1071 $newFilename = $tmpdir.DIRECTORY_SEPARATOR.$deliverFilename.DIRECTORY_SEPARATOR.$newFilename;
1073 $oldFilename = $pathname.DIRECTORY_SEPARATOR.$filename;
1074 if (!copy ($oldFilename, $newFilename))
1076 echo
'Could not copy '.$oldFilename.
' to '.$newFilename;
1078 touch($newFilename, filectime($oldFilename));
1079 $array_filenames[$key] =
ilUtil::escapeShellArg($deliverFilename.DIRECTORY_SEPARATOR.basename($newFilename));
1100 global
$lng, $ilObjDataCache, $ilias;
1102 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1103 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1110 $savepath = $storage->getAbsoluteSubmissionPath();
1118 if (!is_dir($savepath))
1124 chdir($storage->getTempPath());
1134 foreach ($members as $id => $object) {
1135 $directory = $savepath.DIRECTORY_SEPARATOR.$id;
1138 if ($dirsize > disk_free_space($tmpdir)) {
1147 foreach ($members as $id =>
$user)
1149 $sourcedir = $savepath.DIRECTORY_SEPARATOR.$id;
1150 if (!is_dir($sourcedir))
1154 if (array_key_exists($directory, $cache))
1158 if (array_key_exists($directory, $cache)) {
1160 $directory .=
"_".$id;
1164 $cache[$directory] = $directory;
1166 $sourcefiles = scandir($sourcedir);
1167 foreach ($sourcefiles as $sourcefile) {
1168 if ($sourcefile ==
"." || $sourcefile ==
"..")
1170 $targetfile = trim(basename($sourcefile));
1171 $pos = strpos($targetfile,
"_");
1176 $targetfile= substr($targetfile, $pos + 1);
1178 $targetfile = $directory.DIRECTORY_SEPARATOR.$targetfile;
1179 $sourcefile = $sourcedir.DIRECTORY_SEPARATOR.$sourcefile;
1181 if (!copy ($sourcefile, $targetfile))
1184 $ilias->raiseError(
'Could not copy '.basename($sourcefile).
" to '".$targetfile.
"'.",
1185 $ilias->error_obj->MESSAGE);
1190 touch($targetfile, filectime($sourcefile));
1197 $tmpzipfile = $tmpfile .
".zip";
1206 ? strtolower($lng->txt(
"exc_assignment"))
1207 : $assTitle).
".zip",
"",
false,
true);
1217 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
1218 "SET notice = %s, status_time= %s ".
1219 " WHERE ass_id = %s AND usr_id = %s AND ".
1220 $ilDB->equalsNot(
"notice", $a_notice,
"text",
true),
1221 array(
"text",
"timestamp",
"integer",
"integer"),
1222 array($a_notice,
ilUtil::now(), $a_ass_id, $a_user_id));
1233 $query =
"SELECT DISTINCT(usr_id) as ud FROM exc_mem_ass_status ".
1234 "WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" ".
1238 while(
$row = $ilDB->fetchObject(
$res))
1240 $usr_ids[] =
$row->ud;
1243 return $usr_ids ? $usr_ids : array();
1257 $q =
"SELECT obj_id,user_id,ts FROM exc_returned ".
1258 "WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" AND user_id = ".
1259 $ilDB->quote($a_user_id,
"integer").
1260 " ORDER BY ts DESC";
1262 $usr_set = $ilDB->query($q);
1264 $array = $ilDB->fetchAssoc($usr_set);
1265 if ($array[
"ts"]==NULL)
1282 $q =
"SELECT count(*) AS cnt FROM exc_mem_ass_status".
1283 " WHERE NOT sent_time IS NULL".
1284 " AND ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" ".
1286 $set = $ilDB->query($q);
1287 $rec = $ilDB->fetchAssoc($set);
1289 if ($rec[
"cnt"] > 0)
1308 $q=
"SELECT exc_mem_ass_status.status_time, exc_returned.ts ".
1309 "FROM exc_mem_ass_status, exc_returned ".
1310 "WHERE exc_mem_ass_status.status_time < exc_returned.ts ".
1311 "AND NOT exc_mem_ass_status.status_time IS NULL ".
1312 "AND exc_returned.ass_id = exc_mem_ass_status.ass_id ".
1313 "AND exc_returned.user_id = exc_mem_ass_status.usr_id ".
1314 "AND exc_returned.ass_id=".$ilDB->quote($ass_id,
"integer").
" AND exc_returned.user_id=".
1315 $ilDB->quote($member_id,
"integer");
1317 $usr_set = $ilDB->query($q);
1319 $array = $ilDB->fetchAssoc($usr_set);
1321 if (count($array)==0)
1338 global
$ilDB, $ilUser;
1340 $q =
"SELECT exc_returned.returned_id AS id ".
1341 "FROM exc_usr_tutor, exc_returned ".
1342 "WHERE exc_returned.ass_id = exc_usr_tutor.ass_id ".
1343 " AND exc_returned.user_id = exc_usr_tutor.usr_id ".
1344 " AND exc_returned.ass_id = ".$ilDB->quote($ass_id,
"integer").
1345 " AND exc_returned.user_id = ".$ilDB->quote($member_id,
"integer").
1346 " AND exc_usr_tutor.tutor_id = ".$ilDB->quote($ilUser->getId(),
"integer").
1347 " AND exc_usr_tutor.download_time < exc_returned.ts ";
1349 $new_up_set = $ilDB->query($q);
1352 while ($new_up_rec = $ilDB->fetchAssoc($new_up_set))
1354 $new_up[] = $new_up_rec[
"id"];
1370 $set = $ilDB->query(
"SELECT * FROM exc_members ".
1371 "WHERE obj_id = ".$ilDB->quote($a_exc_id,
"integer"));
1372 while($rec = $ilDB->fetchAssoc($set))
1379 $mem[$rec[
"usr_id"]] =
1381 "name" => $name[
"lastname"].
", ".$name[
"firstname"],
1383 "usr_id" => $rec[
"usr_id"],
1384 "lastname" => $name[
"lastname"],
1385 "firstname" => $name[
"firstname"]
1390 $q =
"SELECT * FROM exc_mem_ass_status ".
1391 "WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer");
1392 $set = $ilDB->query($q);
1393 while($rec = $ilDB->fetchAssoc($set))
1395 if (isset($mem[$rec[
"usr_id"]]))
1397 $mem[$rec[
"usr_id"]][
"sent_time"] = $rec[
"sent_time"];
1399 $mem[$rec[
"usr_id"]][
"status_time"] = $rec[
"status_time"];
1400 $mem[$rec[
"usr_id"]][
"feedback_time"] = $rec[
"feedback_time"];
1401 $mem[$rec[
"usr_id"]][
"notice"] = $rec[
"notice"];
1402 $mem[$rec[
"usr_id"]][
"status"] = $rec[
"status"];
1416 foreach ($ass_data as $ass)
1419 $ilDB->replace(
"exc_mem_ass_status", array(
1420 "ass_id" => array(
"integer", $ass[
"id"]),
1421 "usr_id" => array(
"integer", $a_user_id)
1423 "status" => array(
"text",
"notgraded")
1435 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
1437 $mems = $exmem->getMembers();
1439 foreach ($mems as $mem)
1441 $ilDB->replace(
"exc_mem_ass_status", array(
1442 "ass_id" => array(
"integer", $a_ass_id),
1443 "usr_id" => array(
"integer", $mem)
1445 "status" => array(
"text",
"notgraded")
1456 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1459 $storage->uploadAssignmentFiles($a_files);