32 protected \ILIAS\Exercise\InternalDomainService
$domain;
53 bool $a_is_tutor =
false,
54 bool $a_public_submissions =
false 57 $this->main_tpl = $DIC->ui()->mainTemplate();
59 $this->
user = $DIC->user();
60 $this->db = $DIC->database();
61 $this->
lng = $DIC->language();
62 $this->
ctrl = $DIC->ctrl();
64 $this->assignment = $a_ass;
68 $this->user_id = $a_user_id;
69 $this->is_tutor = $a_is_tutor;
70 $this->public_submissions = $a_public_submissions;
78 $this->team = $a_team;
82 if ($this->assignment->getPeerReview()) {
85 $this->domain = $DIC->exercise()->internal()->domain();
90 return $this->assignment->getAssignmentType()->getSubmissionType();
115 if ($this->peer_review) {
116 $valid = $this->peer_review->isFeedbackValidForPassed($user_id);
133 return $this->team->getMembers();
137 return array($this->user_id);
146 return "t" . $this->team->getId();
154 return (
bool) count($this->
getFiles(null,
true));
171 if (count($submitted) > 0) {
172 $submitted = array_pop($submitted);
174 if (is_file($submitted[
'filename'])) {
175 return $submitted[
'filename'];
186 return array_pop($files);
194 $this->state->isSubmissionAllowed());
204 $this->public_submissions) {
209 if ($this->peer_review) {
211 foreach ($this->peer_review->getPeerReviewsByPeerId($this->getUserId()) as $giver) {
212 if ($giver[
"giver_id"] == $ilUser->getId()) {
228 if ($this->assignment->hasTeam() &&
229 !$this->team->getId()) {
235 public function isInTeam(
int $a_user_id = null): bool
240 $a_user_id = $ilUser->
getId();
242 return in_array($a_user_id, $this->
getUserIds());
249 return ($ilUser->getId() == $this->
getUserId());
254 return ($this->peer_review &&
255 $this->peer_review->hasPeerReviewAccess($this->user_id));
266 $max <=
sizeof($this->
getFiles())) {
280 $dl = $this->state->getOfficialDeadline();
282 return ($dl && $dl < time());
287 return new ilFSStorageExercise($this->assignment->getExerciseId(), $this->assignment->getId());
292 if ($this->ass_type->isSubmissionAssignedToTeam()) {
293 $storage_id = $this->
getTeam()->getId();
307 array $a_http_post_files,
315 if ($this->ass_type->isSubmissionAssignedToTeam()) {
316 $team_id = $this->
getTeam()->getId();
327 $deliver_result = $this->
initStorage()->uploadFile($a_http_post_files, $storage_id, $unzip);
329 if ($deliver_result) {
330 $next_id =
$ilDB->nextId(
"exc_returned");
332 "INSERT INTO exc_returned " .
333 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id, late, team_id) " .
334 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
335 $ilDB->quote($next_id,
"integer"),
336 $ilDB->quote($this->assignment->getExerciseId(),
"integer"),
337 $ilDB->quote($user_id,
"integer"),
338 $ilDB->quote($deliver_result[
"fullname"],
"text"),
340 $ilDB->quote($deliver_result[
"mimetype"],
"text"),
342 $ilDB->quote($this->assignment->getId(),
"integer"),
343 $ilDB->quote($this->isLate(),
"integer"),
344 $ilDB->quote($team_id,
"integer")
346 $ilDB->manipulate($query);
349 $this->team->writeLog(
351 $a_http_post_files[
"name"]
361 \
ILIAS\FileUpload\DTO\UploadResult $result
368 if ($this->ass_type->isSubmissionAssignedToTeam()) {
369 $team_id = $this->
getTeam()->getId();
380 $deliver_result = $this->
initStorage()->addFileUpload($result, $storage_id);
382 if ($deliver_result) {
383 $next_id =
$ilDB->nextId(
"exc_returned");
385 "INSERT INTO exc_returned " .
386 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id, late, team_id) " .
387 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
388 $ilDB->quote($next_id,
"integer"),
389 $ilDB->quote($this->assignment->getExerciseId(),
"integer"),
390 $ilDB->quote($user_id,
"integer"),
391 $ilDB->quote($deliver_result[
"fullname"],
"text"),
393 $ilDB->quote($deliver_result[
"mimetype"],
"text"),
395 $ilDB->quote($this->assignment->getId(),
"integer"),
396 $ilDB->quote($this->isLate(),
"integer"),
397 $ilDB->quote($team_id,
"integer")
399 $ilDB->manipulate($query);
402 $this->team->writeLog(
430 self::processZipFile($newDir, $fileTmp,
false);
434 $max_num = $this->assignment->getMaxFile();
436 $current_num = count($this->
getFiles());
437 $zip_num = count($filearray[
"file"]);
438 if ($current_num + $zip_num > $max_num) {
440 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
"exc_upload_error") .
" [Zip1]",
true);
447 $a_http_post_files[
"type"] =
"other";
448 $a_http_post_files[
"tmp_name"] = $filearray[
"path"][
$key] .
"/" .
$filename;
449 $a_http_post_files[
"error"] = 0;
450 $a_http_post_files[
"size"] = filesize($filearray[
"path"][
$key] .
"/" .
$filename);
452 if (!$this->
uploadFile($a_http_post_files,
true)) {
454 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
"exc_upload_error") .
" [Zip2]",
true);
476 $ilDB = $DIC->database();
479 $path = $storage->getAbsoluteSubmissionPath();
483 $query =
"SELECT * FROM exc_returned WHERE ass_id = " .
484 $ilDB->quote($a_ass_id,
"integer");
490 $storage_id = $row[
"team_id"];
492 $storage_id = $row[
"user_id"];
495 $row[
"timestamp"] = $row[
"ts"];
496 $row[
"filename"] =
$path .
"/" . $storage_id .
"/" . basename($row[
"filename"] ??
"");
513 $ilDB = $DIC->database();
516 $path = $storage->getAbsoluteSubmissionPath();
520 $query =
"SELECT * FROM exc_returned WHERE ass_id = " .
521 $ilDB->quote($a_ass_id,
"integer") .
522 " AND user_id IN (" . implode(
',', $a_users) .
")";
528 $storage_id = $row[
"team_id"];
530 $storage_id = $row[
"user_id"];
533 $row[
"timestamp"] = $row[
"ts"];
534 $row[
"filename"] =
$path .
"/" . $storage_id .
"/" . basename($row[
"filename"] ??
"");
546 array $a_file_ids = null,
547 bool $a_only_valid =
false,
548 string $a_min_timestamp = null,
549 bool $print_versions =
false 553 $sql =
"SELECT * FROM exc_returned" .
560 $sql .=
" AND " .
$ilDB->in(
"returned_id", $a_file_ids,
false,
"integer");
563 if ($a_min_timestamp) {
564 $sql .=
" AND ts > " .
$ilDB->quote($a_min_timestamp,
"timestamp");
567 $result =
$ilDB->query($sql);
569 $delivered_files = array();
570 if (
$ilDB->numRows($result)) {
573 while ($row =
$ilDB->fetchAssoc($result)) {
577 !(trim((
string) $row[
"atext"]))) {
581 $row[
"owner_id"] = $row[
"user_id"];
582 $row[
"timestamp"] = $row[
"ts"];
583 $row[
"timestamp14"] = substr($row[
"ts"], 0, 4) .
584 substr($row[
"ts"], 5, 2) . substr($row[
"ts"], 8, 2) .
585 substr($row[
"ts"], 11, 2) . substr($row[
"ts"], 14, 2) .
586 substr($row[
"ts"], 17, 2);
588 if ($this->
getAssignment()->getAssignmentType()->isSubmissionAssignedToTeam()) {
589 $storage_id = $row[
"team_id"];
591 $storage_id = $row[
"user_id"];
595 $row[
"filename"] =
$path .
596 "/" . $storage_id .
"/" . (($row[
"filename"]) ? basename($row[
"filename"]) :
'');
599 if (is_file($row[
"filename"]) || (!$this->assignment->getAssignmentType()->usesFileUpload())) {
600 $delivered_files[] = $row;
606 if (in_array($this->assignment->getType(), [
611 $delivered_files = array_filter($delivered_files,
function ($i) use ($print_versions) {
612 $is_print_version =
false;
613 if (substr($i[
"filetitle"], strlen($i[
"filetitle"]) - 5) ==
"print") {
614 $is_print_version =
true;
616 if (substr($i[
"filetitle"], strlen($i[
"filetitle"]) - 9) ==
"print.zip") {
617 $is_print_version =
true;
619 return ($is_print_version == $print_versions);
623 return $delivered_files;
641 $q =
"SELECT exc_returned.returned_id AS id " .
642 "FROM exc_usr_tutor, exc_returned " .
643 "WHERE exc_returned.ass_id = exc_usr_tutor.ass_id " .
644 " AND exc_returned.user_id = exc_usr_tutor.usr_id " .
647 " AND exc_usr_tutor.tutor_id = " .
$ilDB->quote($tutor,
"integer") .
648 " AND exc_usr_tutor.download_time < exc_returned.ts ";
650 $new_up_set =
$ilDB->query(
$q);
653 while ($new_up_rec =
$ilDB->fetchAssoc($new_up_set)) {
654 $new_up[] = $new_up_rec[
"id"];
668 $ilDB = $DIC->database();
670 $set =
$ilDB->query(
"SELECT obj_id" .
671 " FROM exc_returned" .
672 " WHERE returned_id = " .
$ilDB->quote($a_returned_id,
"integer"));
673 $row =
$ilDB->fetchAssoc($set);
674 return (
int) $row[
"obj_id"];
687 $ilDB = $DIC->database();
689 $set =
$ilDB->query(
"SELECT obj_id, ass_id" .
690 " FROM exc_returned" .
691 " WHERE user_id = " .
$ilDB->quote($a_user_id,
"integer") .
692 " AND filetitle = " .
$ilDB->quote($a_filetitle,
"text"));
694 while ($row =
$ilDB->fetchAssoc($set)) {
695 $res[$row[
"ass_id"]] = $row;
704 foreach ($this->
getFiles() as $item) {
705 $files[] = $item[
"returned_id"];
708 foreach ($this->
getFiles(null,
false, null,
true) as $item) {
709 $files[] = $item[
"returned_id"];
729 if ($file_id_array === []) {
733 if ($file_id_array !== []) {
734 $result =
$ilDB->query(
"SELECT * FROM exc_returned" .
735 " WHERE " .
$ilDB->in(
"returned_id", $file_id_array,
false,
"integer") .
738 if (
$ilDB->numRows($result)) {
739 $result_array = array();
740 while ($row =
$ilDB->fetchAssoc($result)) {
741 $row[
"timestamp"] = $row[
"ts"];
742 $result_array[] = $row;
746 $ilDB->manipulate(
"DELETE FROM exc_returned" .
747 " WHERE " .
$ilDB->in(
"returned_id", $file_id_array,
false,
"integer") .
752 foreach ($result_array as $value) {
753 if ($value[
"filename"]) {
755 $this->team->writeLog(
761 if ($this->
getAssignment()->getAssignmentType()->isSubmissionAssignedToTeam()) {
762 $storage_id = $value[
"team_id"];
764 $storage_id = $value[
"user_id"];
767 $filename =
$path .
"/" . $storage_id .
"/" . basename($value[
"filename"]);
787 $db = $DIC->database();
790 $submission =
new self($ass, $a_user_id);
791 $submission->deleteAllFiles();
794 $team = $submission->getTeam();
800 $member_status = $ass->getMemberStatus($a_user_id);
801 $member_status->setStatus(
"notgraded");
802 $member_status->update();
805 "DELETE FROM exc_usr_tutor " .
806 "WHERE ass_id = %s AND usr_id = %s",
807 array(
"integer",
"integer"),
808 array($ass->getId(), $a_user_id)
823 $q =
"SELECT download_time FROM exc_usr_tutor WHERE " .
825 $ilDB->in(
"usr_id", $a_user_ids,
"",
"integer") .
" AND " .
826 " tutor_id = " .
$ilDB->quote($ilUser->getId(),
"integer") .
827 " ORDER BY download_time DESC";
829 $lu_rec =
$ilDB->fetchAssoc($lu_set);
830 return $lu_rec[
"download_time"] ??
"";
834 array $a_file_ids = null,
835 bool $a_only_new =
false,
836 bool $a_peer_review_mask_filename =
false 842 $is_team = $this->assignment->hasTeam();
844 $download_time = null;
849 if ($this->is_tutor) {
853 if ($a_peer_review_mask_filename) {
856 foreach ($this->peer_review->getPeerReviewsByGiver($ilUser->getId()) as $idx => $item) {
857 if ($item[
"peer_id"] == $this->
getUserId()) {
866 $files = $this->
getFiles($a_file_ids,
false, $download_time);
869 if (count($files) == 1) {
870 $file = array_pop($files);
872 switch ($this->assignment->getType()) {
877 $this->assignment->getTitle() .
" - " .
878 $file[
"filetitle"][
"firstname"] .
" " .
879 $file[
"filetitle"][
"lastname"] .
" (" .
880 $file[
"filetitle"][
"login"] .
").zip";
886 $this->assignment->getTitle() .
" (Team " . $this->
getTeam()->getId() .
").zip";
893 if ($a_peer_review_mask_filename) {
894 $title_a = explode(
".", $file[
"filetitle"]);
895 $suffix = array_pop($title_a);
896 $file[
"filetitle"] = $this->assignment->getTitle() .
"_peer" . $peer_id .
"." . $suffix;
897 } elseif ($file[
"late"]) {
898 $file[
"filetitle"] = $lng->
txt(
"exc_late_submission") .
" - " .
902 $this->
downloadSingleFile($file[
"user_id"], $file[
"filename"], $file[
"filetitle"], $file[
"team_id"]);
904 $array_files = array();
905 foreach ($files as $seq => $file) {
906 if ($this->assignment->getAssignmentType()->isSubmissionAssignedToTeam()) {
907 $storage_id = $file[
"team_id"];
909 $storage_id = $file[
"user_id"];
912 $src = basename($file[
"filename"]);
913 if ($a_peer_review_mask_filename) {
914 $src_a = explode(
".", $src);
915 $suffix = array_pop($src_a);
916 $tgt = $this->assignment->getTitle() .
"_peer" . $peer_id .
917 "_" . (++$seq) .
"." . $suffix;
919 $array_files[$storage_id][] = array(
924 $array_files[$storage_id][] = array(
926 "late" => $file[
"late"]
949 $exc_id = $this->assignment->getExerciseId();
950 $ass_id = $this->assignment->getId();
954 "DELETE FROM exc_usr_tutor " .
955 "WHERE ass_id = %s AND usr_id = %s AND tutor_id = %s",
956 array(
"integer",
"integer",
"integer"),
957 array($ass_id, $user_id, $ilUser->getId())
961 "INSERT INTO exc_usr_tutor (ass_id, obj_id, usr_id, tutor_id, download_time) VALUES " .
962 "(%s, %s, %s, %s, %s)",
963 array(
"integer",
"integer",
"integer",
"integer",
"timestamp"),
964 array($ass_id, $exc_id, $user_id, $ilUser->getId(),
ilUtil::now())
975 if ($this->ass_type->isSubmissionAssignedToTeam()) {
976 $storage_id = $a_team_id;
978 $storage_id = $a_user_id;
981 $filename = $this->
initStorage()->getAbsoluteSubmissionPath() .
982 "/" . $storage_id .
"/" . basename($filename);
990 bool $a_multi_user =
false 993 $a_user_id = (
int) $a_user_id;
1002 $tmpzipfile = $tmpfile .
".zip";
1008 $deliverFilename = str_replace(
" ",
"_", $assTitle);
1009 if ($a_user_id > 0 && !$a_multi_user) {
1011 $deliverFilename .=
"_" . $userName[
"lastname"] .
"_" . $userName[
"firstname"];
1013 $deliverFilename .=
"_files";
1015 $orgDeliverFilename = trim($deliverFilename);
1018 chdir($tmpdir .
"/" . $deliverFilename);
1021 $parsed_files = $duplicates = array();
1022 foreach ($a_filenames as $storage_id => $files) {
1023 $pathname =
$path .
"/" . $storage_id;
1027 if (isset($filename[
"tgt"])) {
1028 $newFilename = $filename[
"tgt"];
1029 $filename = $filename[
"src"];
1031 $late = $filename[
"late"];
1032 $filename = $filename[
"src"];
1035 $newFilename = trim($filename);
1036 $pos = strpos($newFilename,
"_");
1037 if ($pos !==
false) {
1038 $newFilename = substr($newFilename, $pos + 1);
1041 $chkName = strtolower($newFilename);
1042 if (array_key_exists($chkName, $duplicates)) {
1043 $suffix = strrpos($newFilename,
".");
1044 $newFilename = substr($newFilename, 0, $suffix) .
1045 " (" . (++$duplicates[$chkName]) .
")" .
1046 substr($newFilename, $suffix);
1048 $duplicates[$chkName] = 1;
1052 $newFilename = $lng->
txt(
"exc_late_submission") .
" - " .
1058 $newFilename = $tmpdir . DIRECTORY_SEPARATOR . $deliverFilename . DIRECTORY_SEPARATOR . $newFilename;
1060 $oldFilename = $pathname . DIRECTORY_SEPARATOR .
$filename;
1061 if (!copy($oldFilename, $newFilename)) {
1062 echo
'Could not copy ' . $oldFilename .
' to ' . $newFilename;
1064 touch($newFilename, filectime($oldFilename));
1066 $deliverFilename . DIRECTORY_SEPARATOR . basename($newFilename)
1093 $lng = $DIC->language();
1095 $domain = $DIC->exercise()->internal()->domain();
1102 $savepath = $storage->getAbsoluteSubmissionPath();
1110 if (!is_dir($savepath)) {
1116 $tmpdir = $storage->getTempPath();
1122 foreach (array_keys($members) as
$id) {
1123 $directory = $savepath . DIRECTORY_SEPARATOR .
$id;
1126 if ($dirsize > disk_free_space($tmpdir)) {
1130 $ass_type = $a_ass->
getType();
1139 $team_dirs = array();
1142 foreach ($members as $id => $item) {
1143 $user_files = $item[
"files"] ?? null;
1144 $sourcedir = $savepath . DIRECTORY_SEPARATOR .
$id;
1145 if (!is_dir($sourcedir)) {
1151 if (is_array($team_map) &&
1152 array_key_exists($id, $team_map)) {
1153 $team_id = $team_map[
$id];
1154 if (!array_key_exists($team_id, $team_dirs)) {
1155 $team_dir = $lng->
txt(
"exc_team") .
" " . $team_id;
1157 $team_dirs[$team_id] = $team_dir;
1159 $team_dir = $team_dirs[$team_id] . DIRECTORY_SEPARATOR;
1166 if ($targetdir ==
"") {
1170 $targetdir = self::getDirectoryNameFromUserData($id);
1172 $targetdir = $team_dir . $targetdir;
1176 $log->debug(
"Creation target directory: " . $targetdir);
1179 $log->debug(
"Scanning source directory: " . $sourcedir);
1180 $sourcefiles = scandir($sourcedir);
1181 $duplicates = array();
1182 foreach ($sourcefiles as $sourcefile) {
1183 if ($sourcefile ==
"." || $sourcefile ==
"..") {
1187 $targetfile = trim(basename($sourcefile));
1188 $pos = strpos($targetfile,
"_");
1189 if ($pos !==
false) {
1190 $targetfile = substr($targetfile, $pos + 1);
1193 if ($a_ass->
getAssignmentType()->getSubmissionType() == self::TYPE_REPO_OBJECT) {
1196 $targetfile = $obj_type .
"_" . $obj_id .
".zip";
1201 if (array_key_exists($targetfile, $duplicates)) {
1202 $suffix = strrpos($targetfile,
".");
1203 $targetfile = substr($targetfile, 0, $suffix) .
1204 " (" . (++$duplicates[$targetfile]) .
")" .
1205 substr($targetfile, $suffix);
1207 $duplicates[$targetfile] = 1;
1211 if (isset($user_files)) {
1212 foreach ($user_files as $file) {
1213 if (basename($file[
"filename"]) == $sourcefile) {
1214 if ($file[
"late"]) {
1215 $targetfile = $lng->
txt(
"exc_late_submission") .
" - " .
1224 $targetfile = $targetdir . DIRECTORY_SEPARATOR . $targetfile;
1225 $sourcefile = $sourcedir . DIRECTORY_SEPARATOR . $sourcefile;
1227 $log->debug(
"Copying: " . $sourcefile .
" -> " . $targetfile);
1229 if (!copy($sourcefile, $targetfile)) {
1230 throw new ilExerciseException(
"Could not copy " . basename($sourcefile) .
" to '" . $targetfile .
"'.");
1233 touch($targetfile, filectime($sourcefile));
1238 $log->debug(
"Unzipping: " . $targetfile);
1239 $log->debug(
"Current directory is: " . getcwd());
1241 $domain->resources()->zip()->unzipFile($targetfile);
1242 unlink($targetfile);
1252 $path_final_zip_file = $to_path . DIRECTORY_SEPARATOR . $tmpzipfile;
1254 if (file_exists($tmpdir . DIRECTORY_SEPARATOR . $tmpzipfile)) {
1255 copy($tmpzipfile, $path_final_zip_file);
1260 $domain->resources()->zip()->unzipFile($path_final_zip_file);
1261 unlink($path_final_zip_file);
1270 bool $a_team_mode =
false 1274 if ($this->
getAssignment()->getAssignmentType()->isSubmissionAssignedToTeam()) {
1275 $team_id = $this->
getTeam()->getId();
1276 $where =
" team_id = " .
$ilDB->quote($team_id,
"integer") .
" ";
1279 $where =
" " .
$ilDB->in(
"user_id", $this->
getUserIds(),
"",
"integer") .
" ";
1281 $where =
" user_id = " .
$ilDB->quote($this->
getUserId(),
"integer");
1296 $ilDB->setLimit(1, 0);
1298 $q =
"SELECT obj_id,user_id,ts FROM exc_returned" .
1299 " WHERE ass_id = " .
$ilDB->quote($this->assignment->getId(),
"integer") .
1301 " AND (filename IS NOT NULL OR atext IS NOT NULL)" .
1302 " AND ts IS NOT NULL" .
1303 " ORDER BY ts DESC";
1305 $array =
$ilDB->fetchAssoc($usr_set);
1306 return ($array[
"ts"] ?? null);
1315 $this->db->setLimit(1, 0);
1317 $q =
"SELECT web_dir_access_time FROM exc_returned" .
1318 " WHERE ass_id = " . $this->db->quote($this->assignment->getId(),
"integer") .
1319 " AND (filename IS NOT NULL OR atext IS NOT NULL)" .
1320 " AND web_dir_access_time IS NOT NULL" .
1322 " ORDER BY web_dir_access_time DESC";
1324 $res = $this->db->query(
$q);
1328 return $data[
"web_dir_access_time"] ?? null;
1343 string $a_text = null
1347 if ($this->
getAssignment()->getAssignmentType()->isSubmissionAssignedToTeam()) {
1349 $team_id = $this->
getTeam()->getId();
1363 throw new ilExerciseException(
"Repository object $a_wsp_id is already assigned to another assignment.");
1367 $next_id =
$ilDB->nextId(
"exc_returned");
1369 "INSERT INTO exc_returned " .
1370 "(returned_id, obj_id, user_id, filetitle, ass_id, ts, atext, late, team_id) " .
1371 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
1372 $ilDB->quote($next_id,
"integer"),
1373 $ilDB->quote($this->assignment->getExerciseId(),
"integer"),
1374 $ilDB->quote($user_id,
"integer"),
1375 $ilDB->quote($a_wsp_id,
"text"),
1376 $ilDB->quote($this->assignment->getId(),
"integer"),
1378 $ilDB->quote($a_text,
"text"),
1380 $ilDB->quote($team_id,
"integer")
1382 $ilDB->manipulate($query);
1408 if (!trim($a_text)) {
1416 $files = array_shift($files);
1417 $id = $files[
"returned_id"];
1419 $ilDB->manipulate(
"UPDATE exc_returned" .
1420 " SET atext = " .
$ilDB->quote($a_text,
"text") .
1422 ", late = " .
$ilDB->quote($this->
isLate(),
"integer") .
1423 " WHERE returned_id = " .
$ilDB->quote(
$id,
"integer"));
1443 $result[
"files"][
"count"] =
"---";
1453 $result[
"last_submission"][
"txt"] = $lng->
txt(
"exc_last_submission");
1454 $result[
"last_submission"][
"value"] = $last_sub;
1457 $ilCtrl->setParameterByClass(
"ilexsubmissionfilegui",
"member_id", $this->
getUserId());
1460 switch ($this->assignment->getType()) {
1468 foreach ($all_files as $file) {
1469 if ($file[
"late"]) {
1475 $result[
"files"][
"txt"] = $lng->
txt(
"exc_files_returned");
1476 if ($late_files !== 0) {
1477 $result[
"files"][
"txt"] .=
' - <span class="warning">' . $lng->
txt(
"exc_late_submission") .
" (" . $late_files .
")</span>";
1479 $sub_cnt = count($all_files);
1482 $sub_cnt .=
" " . sprintf($lng->
txt(
"cnt_new"), count($new));
1485 $result[
"files"][
"count"] = $sub_cnt;
1489 $result[
"files"][
"download_url"] =
1490 $ilCtrl->getLinkTargetByClass(
"ilexsubmissionfilegui",
"downloadReturned");
1492 if (count($new) <= 0) {
1493 $result[
"files"][
"download_txt"] = $lng->
txt(
"exc_tbl_action_download_files");
1495 $result[
"files"][
"download_txt"] = $lng->
txt(
"exc_tbl_action_download_all_files");
1500 $result[
"files"][
"download_new_url"] =
1501 $ilCtrl->getLinkTargetByClass(
"ilexsubmissionfilegui",
"downloadNewReturned");
1503 $result[
"files"][
"download_new_txt"] = $lng->
txt(
"exc_tbl_action_download_new_files");
1509 $result[
"files"][
"txt"] = $lng->
txt(
"exc_blog_returned");
1511 if ($blogs !== []) {
1512 $blogs = array_pop($blogs);
1513 if ($blogs && substr($blogs[
"filename"], -1) !=
"/") {
1514 if ($blogs[
"late"]) {
1515 $result[
"files"][
"txt"] .=
' - <span class="warning">' . $lng->
txt(
"exc_late_submission") .
"</span>";
1518 $result[
"files"][
"count"] = 1;
1520 $result[
"files"][
"download_url"] =
1521 $ilCtrl->getLinkTargetByClass(
"ilexsubmissionfilegui",
"downloadReturned");
1523 $result[
"files"][
"download_txt"] = $lng->
txt(
"exc_tbl_action_download_files");
1529 $result[
"files"][
"txt"] = $lng->
txt(
"exc_portfolio_returned");
1531 if ($portfolios !== []) {
1532 $portfolios = array_pop($portfolios);
1533 if ($portfolios && substr($portfolios[
"filename"], -1) !=
"/") {
1534 if ($portfolios[
"late"]) {
1535 $result[
"files"][
"txt"] .=
' - <span class="warning">' . $lng->
txt(
"exc_late_submission") .
"</span>";
1538 $result[
"files"][
"count"] = 1;
1540 $result[
"files"][
"download_url"] =
1541 $ilCtrl->getLinkTargetByClass(
"ilexsubmissionfilegui",
"downloadReturned");
1543 $result[
"files"][
"download_txt"] = $lng->
txt(
"exc_tbl_action_download_files");
1549 $result[
"files"][
"txt"] = $lng->
txt(
"exc_files_returned_text");
1551 if ($files !== []) {
1552 $result[
"files"][
"count"] = 1;
1554 $files = array_shift($files);
1555 if (trim($files[
"atext"]) !==
'' && trim($files[
"atext"]) !==
'0') {
1556 if ($files[
"late"]) {
1557 $result[
"files"][
"txt"] .=
' - <span class="warning">' . $lng->
txt(
"exc_late_submission") .
"</span>";
1560 $result[
"files"][
"download_url"] =
1561 $ilCtrl->getLinkTargetByClass(
"ilexsubmissiontextgui",
"showAssignmentText");
1563 $result[
"files"][
"download_txt"] = $lng->
txt(
"exc_tbl_action_text_assignment_show");
1569 $result[
"files"][
"txt"] = $lng->
txt(
"exc_wiki_returned");
1572 $objs = array_pop($objs);
1573 if ($objs && substr($objs[
"filename"], -1) !=
"/") {
1574 if ($objs[
"late"]) {
1575 $result[
"files"][
"txt"] .=
' - <span class="warning">' . $lng->
txt(
"exc_late_submission") .
"</span>";
1578 $result[
"files"][
"count"] = 1;
1580 $result[
"files"][
"download_url"] =
1581 $ilCtrl->getLinkTargetByClass(
"ilexsubmissionfilegui",
"downloadReturned");
1583 $result[
"files"][
"download_txt"] = $lng->
txt(
"exc_tbl_action_download_files");
1589 $ilCtrl->setParameterByClass(
"ilexsubmissionfilegui",
"member_id",
"");
1599 array $a_assignment_types = array()
1603 $db = $DIC->database();
1605 $query =
"SELECT * FROM exc_returned r LEFT JOIN exc_assignment a" .
1606 " ON (r.ass_id = a.id) " .
1607 " WHERE r.filetitle = " . $db->
quote($a_filename,
"string");
1609 if (is_array($a_assignment_types) && $a_assignment_types !== []) {
1610 $query .=
" AND " . $db->
in(
"a.type", $a_assignment_types,
false,
"integer");
1613 $set = $db->
query($query);
1627 trim($userName[
"lastname"]) .
"_" .
1628 trim($userName[
"firstname"]) .
"_" .
1629 trim($userName[
"login"]) .
"_" .
1630 $userName[
"user_id"]
1640 $ilDB = $DIC->database();
1642 $participants = array();
1643 $query =
"SELECT user_id FROM exc_returned WHERE ass_id = " .
1644 $ilDB->quote($a_ass_id,
"integer") .
1646 $ilDB->quote($a_exercise_id,
"integer");
1650 while ($row =
$ilDB->fetchAssoc(
$res)) {
1651 $participants[] = $row[
'user_id'];
1654 return $participants;
1658 string $a_directory,
1664 $lng = $DIC->language();
1666 $pathinfo = pathinfo($a_file);
1667 $file = $pathinfo[
"basename"];
1670 if (($pathinfo[
"extension"] ??
'') ===
'') {
1678 $DIC->legacyArchives()->unzip(
1679 $a_directory .
"/" . $file,
1685 unlink($a_directory .
"/" . $file);
1693 if (empty($filearray)) {
1695 $lng->
txt(
"archive_broken"),
1701 foreach ($filearray[
"file"] as
$key => $value) {
1703 if (substr($value, 0, 1) ==
"." || stristr(
1704 $filearray[
"path"][
$key],
1707 unlink($filearray[
"path"][$key] . $value);
1708 unset($filearray[
"path"][$key]);
1709 unset($filearray[
"file"][$key]);
1716 unlink($filearray[
'path'][$key]);
1718 $lng->
txt(
"file_is_infected") .
"<br />" . $vir[1],
1721 } elseif ($vir[1] !=
"") {
1732 foreach (array_count_values($filearray[
"file"]) as
$key => $value) {
1734 if ($value !=
"1") {
1738 if (strlen($doublettes) > 0) {
1740 $lng->
txt(
"exc_upload_error") .
"<br />" . $lng->
txt(
1741 "zip_structure_error" 1747 $mac_dir = $a_directory .
"/__MACOSX";
1748 if (file_exists($mac_dir)) {
downloadFiles(array $a_file_ids=null, bool $a_only_new=false, bool $a_peer_review_mask_filename=false)
updateTextSubmission(string $a_text)
Handle text assignment submissions.
getFiles(array $a_file_ids=null, bool $a_only_valid=false, string $a_min_timestamp=null, bool $print_versions=false)
Get submission items (not only files)
removeTeamMember(int $a_user_id, ?int $a_exc_ref_id=null)
getType()
Get type this will most probably become an non public function in the future (or become obsolete) ...
getFeedbackId()
used for the legacy storage path of feedbacks only
manipulateF(string $query, array $types, array $values)
static getLogger(string $a_component_id)
Get component logger.
static downloadAllAssignmentFiles(ilExAssignment $a_ass, array $members, string $to_path)
Download all submitted files of an assignment (all user)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
fetchAssoc(ilDBStatement $statement)
hasSubmittedPrintVersion()
static utf8_encode(string $string)
Class ChatMainBarProvider .
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
static lookupTitle(int $a_id)
ilGlobalTemplateInterface $main_tpl
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
ilExcAssMemberState $state
static lookupType(int $a_id)
static _lookupName(int $a_user_id)
lookup user name
ilExPeerReview $peer_review
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getValidFilename(string $a_filename)
quote($value, string $type)
static escapeShellArg(string $a_arg)
static getInstanceByUserId(int $a_assignment_id, int $a_user_id, bool $a_create_on_demand=false)
static processZipFile(string $a_directory, string $a_file, bool $structure)
processUploadedZipFile(string $fileTmp)
processes error handling etc for uploaded archive
const TYPE_UPLOAD
direct checks against const should be avoided, use type objects instead
static now()
Return current timestamp in Y-m-d H:i:s format.
getLastDownloadTime(array $a_user_ids)
static getAssignmentParticipants(int $a_exercise_id, int $a_ass_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static getASCIIFilename(string $a_filename)
downloadMultipleFiles(array $a_filenames, ?int $a_user_id, bool $a_multi_user=false)
ILIAS Exercise InternalDomainService $domain
__construct(ilExAssignment $a_ass, int $a_user_id, ilExAssignmentTeam $a_team=null, bool $a_is_tutor=false, bool $a_public_submissions=false)
const TEAM_LOG_REMOVE_FILE
getTableUserWhere(bool $a_team_mode=false)
addResourceObject(string $a_wsp_id, string $a_text=null)
Add personal resource or repository object (ref_id) to assigment.
static _lookupTitle(int $obj_id)
static recursive_dirscan(string $dir, array &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
static dirsize(string $directory)
get size of a directory or a file.
getDownloadedFilesInfoForTableGUIS()
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
ilExAssignment $assignment
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
getLastSubmission()
TODO -> get rid of getTableUserWhere and move to repository class Get the date of the last submission...
$structure
TOTAL STRUCTURE.
static lookupExerciseIdForReturnedId(int $a_returned_id)
Get exercise from submission id (used in ilObjMediaObject)
query(string $query)
Run a (read-only) Query on the database.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static getAssignmentFilesByUsers(int $a_exc_id, int $a_ass_id, array $a_users)
static getAssignmentTeamMap(int $a_ass_id)
getLastOpeningHTMLView()
TODO -> get rid of getTableUserWhere and move to repository class Get a mysql timestamp from the last...
static getDirectoryNameFromUserData(int $a_user_id)
in(string $field, array $values, bool $negate=false, string $type="")
static getInstancesByExercise(int $a_exc_id)
static int $INFECTED_FILE
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
uploadFile(array $a_http_post_files, bool $unzip=false)
Save submitted file of user.
create()
Create directory.
isSubmissionAssignedToTeam()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
ilExAssignmentTypes $ass_types
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilExAssignmentTypeInterface $ass_type
static deleteUser(int $a_exc_id, int $a_user_id)
Delete all delivered files of user.
lookupNewFiles(int $a_tutor=null)
Check how much files have been uploaded by the learner after the last download of the tutor...
static _lookupType(int $id, bool $reference=false)
addFileUpload(\ILIAS\FileUpload\DTO\UploadResult $result)
static int $DOUBLETTES_FOUND
isInTeam(int $a_user_id=null)
static findUserFiles(int $a_user_id, string $a_filetitle)
Check if given file was assigned Used in Blog/Portfolio.
downloadSingleFile(int $a_user_id, string $filename, string $filetitle, int $a_team_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAllAssignmentFiles(int $a_exc_id, int $a_ass_id)
updateTutorDownloadTime()
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
deleteSelectedFiles(array $file_id_array)
Deletes already delivered files.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getSubmissionsForFilename(string $a_filename, array $a_assignment_types=array())
Get assignment return entries for a filename.