19 declare(strict_types=1);
34 protected \ilDBInterface
$db;
42 $this->log = $DIC->logger()->exc();
43 $this->db = (is_null($db))
51 $set = $this->db->queryF(
52 "SELECT * FROM exc_returned " .
53 " WHERE ass_id = %s ",
57 while ($rec = $this->db->fetchAssoc($set)) {
68 bool $type_uses_uploads,
69 bool $type_uses_print_versions,
71 ?array $submit_ids =
null,
72 bool $only_valid =
false,
73 ?
string $min_timestamp =
null,
74 bool $print_versions =
false 76 $where =
" team_id = " . $this->db->quote($team_id,
"integer") .
" ";
81 $type_uses_print_versions,
94 bool $type_uses_uploads,
95 bool $type_uses_print_versions,
97 ?array $submit_ids =
null,
98 bool $only_valid =
false,
99 ?
string $min_timestamp =
null,
100 bool $print_versions =
false 102 $where =
" " . $this->db->in(
"user_id", $user_ids,
false,
"integer") .
" ";
107 $type_uses_print_versions,
121 bool $type_uses_uploads,
122 bool $type_uses_print_versions,
123 ?array $submit_ids =
null,
124 bool $only_valid =
false,
125 ?
string $min_timestamp =
null,
126 bool $print_versions =
false 128 $sql =
"SELECT * FROM exc_returned" .
129 " WHERE ass_id = " . $this->db->quote($ass_id,
"integer");
130 $sql .=
" AND " . $where;
133 $sql .=
" AND " . $this->db->in(
"returned_id", $submit_ids,
false,
"integer");
136 if ($min_timestamp) {
137 $sql .=
" AND ts > " . $this->db->quote($min_timestamp,
"timestamp");
140 $result = $this->db->query($sql);
141 $delivered_files = array();
142 while ($row = $this->db->fetchAssoc($result)) {
146 !(trim((
string) $row[
"atext"]))) {
151 $row[
"timestamp"] = $row[
"ts"];
158 $row[
"rid"] = (string) $row[
"rid"];
161 if ($row[
"rid"] !==
"" || (!$type_uses_uploads)) {
164 if ($type_uses_print_versions) {
165 $is_print_version =
false;
166 if (str_ends_with($row[
"filetitle"],
"print")) {
167 $is_print_version =
true;
169 if (str_ends_with($row[
"filetitle"],
"print.zip")) {
170 $is_print_version =
true;
172 if ($is_print_version != $print_versions) {
186 $sql =
"SELECT * FROM exc_returned" .
187 " WHERE returned_id = " . $this->db->quote($id,
"integer");
188 $result = $this->db->query($sql);
189 if ($row = $this->db->fetchAssoc($result)) {
198 $q =
"SELECT user_id FROM exc_returned " .
199 " WHERE returned_id = " . $this->db->quote($submission_id,
"integer");
200 $usr_set = $this->db->query(
$q);
202 $rec = $this->db->fetchAssoc($usr_set);
203 return (
int) ($rec[
"user_id"] ?? 0);
208 $set = $this->db->queryF(
209 "SELECT returned_id FROM exc_returned " .
210 " WHERE ass_id = %s AND user_id = %s",
211 [
"integer",
"integer"],
215 while ($rec = $this->db->fetchAssoc($set)) {
216 $user_ids[] = (
int) $rec[
"returned_id"];
224 $query =
"SELECT * FROM exc_returned " .
225 " WHERE ass_id = " . $this->db->quote($assignment_id,
"integer") .
226 " AND (filename IS NOT NULL OR atext IS NOT NULL)" .
227 " AND ts IS NOT NULL";
228 $res = $this->db->query($query);
229 return $res->numRows();
235 $this->db->manipulate(
"UPDATE exc_returned " .
236 " SET web_dir_access_time = " . $this->db->quote(\
ilUtil::now(),
"timestamp") .
237 " WHERE ass_id = " . $this->db->quote($assignment_id,
"integer") .
238 " AND user_id = " . $this->db->quote($member_id,
"integer"));
252 foreach ($assignment_ids as
$id) {
253 $submitted[(
int) $id] =
false;
257 "SELECT ass_id FROM exc_returned " .
258 " WHERE " . $db->in(
"ass_id", $assignment_ids,
false,
"integer") .
259 " AND user_id = %s " .
260 " AND (filename IS NOT NULL OR atext IS NOT NULL)" .
261 " AND ts IS NOT NULL",
265 while ($rec = $db->fetchAssoc($set)) {
266 $submitted[(
int) $rec[
"ass_id"]] =
true;
270 "SELECT ret.ass_id FROM exc_returned ret JOIN il_exc_team team " .
271 " ON (ret.team_id = team.id AND ret.ass_id = team.ass_id) " .
272 " WHERE " . $db->in(
"ret.ass_id", $assignment_ids,
false,
"integer") .
273 " AND team.user_id = %s " .
274 " AND (ret.filename IS NOT NULL OR ret.atext IS NOT NULL)" .
275 " AND ret.ts IS NOT NULL",
279 while ($rec = $db->fetchAssoc($set)) {
280 $submitted[(
int) $rec[
"ass_id"]] =
true;
290 $this->db->manipulate(
"UPDATE exc_returned" .
291 " SET late = " . $this->db->quote((
int) $late,
"integer") .
292 " WHERE returned_id = " . $this->db->quote($return_id,
"integer"));
312 "SELECT MAX(max_num) AS max" .
313 " FROM (SELECT COUNT(user_id) AS max_num FROM exc_returned" .
314 " WHERE obj_id= %s AND ass_id= %s " . $and .
" AND mimetype IS NOT NULL" .
315 " GROUP BY user_id) AS COUNTS",
316 [
"integer",
"integer"],
319 $row = $db->fetchAssoc($set);
320 return (
int) $row[
'max'];
331 $set = $db->
query(
"SELECT DISTINCT(user_id)" .
332 " FROM exc_returned" .
333 " WHERE ass_id = " . $db->quote($ass_id,
"integer") .
334 " AND (filename IS NOT NULL OR atext IS NOT NULL)");
335 while ($row = $db->fetchAssoc($set)) {
336 $user_ids[] = (
int) $row[
"user_id"];
352 $rid = $this->irss->importLocalFile(
360 $info = $this->irss->getResourceInfo(
$rid);
361 $next_id = $db->nextId(
"exc_returned");
363 "INSERT INTO exc_returned " .
364 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id, late, team_id, rid) " .
365 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
366 $db->quote($next_id,
"integer"),
367 $db->quote($obj_id,
"integer"),
368 $db->quote($user_id,
"integer"),
369 $db->quote($filename,
"text"),
370 $db->quote($filename,
"text"),
371 $db->quote($info->getMimeType(),
"text"),
373 $db->quote($ass_id,
"integer"),
374 $db->quote($is_late,
"integer"),
375 $db->quote($team_id,
"integer"),
376 $db->quote(
$rid,
"text")
378 $db->manipulate($query);
386 return $this->data->submission(
387 (
int) $rec[
"returned_id"],
388 (
int) $rec[
"ass_id"],
389 (
int) $rec[
"user_id"],
390 (
int) $rec[
"team_id"],
391 (
string) $rec[
"filetitle"],
392 (
string) $rec[
"atext"],
393 (
string) $rec[
"rid"],
394 (
string) $rec[
"mimetype"],
411 $rid = $this->irss->importFileFromUploadResult(
418 $info = $this->irss->getResourceInfo(
$rid);
419 $next_id = $db->nextId(
"exc_returned");
421 "INSERT INTO exc_returned " .
422 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id, late, team_id, rid) " .
423 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
424 $db->quote($next_id,
"integer"),
425 $db->quote($obj_id,
"integer"),
426 $db->quote($user_id,
"integer"),
427 $db->quote($filename,
"text"),
428 $db->quote($filename,
"text"),
429 $db->quote($info->getMimeType(),
"text"),
431 $db->quote($ass_id,
"integer"),
432 $db->quote($is_late,
"integer"),
433 $db->quote($team_id,
"integer"),
434 $db->quote(
$rid,
"text")
436 $db->manipulate($query);
453 int $remaining_allowed
459 $this->log->debug(
"5");
460 $rid = $this->irss->importFileFromUploadResult(
464 $this->log->debug(
"6");
465 $stream = $this->irss->stream(
$rid);
467 if ($remaining_allowed !== -1 &&
468 $remaining_allowed < $DIC->archives()->unzip($stream)->getAmountOfFiles()) {
472 foreach ($DIC->archives()->unzip($stream)->getFileStreams() as $stream) {
473 $this->log->debug(
"7");
474 $rid = $this->irss->importStream(
478 $info = $this->irss->getResourceInfo(
$rid);
480 $this->log->debug(
"8");
482 $this->log->debug(
"9");
483 $info = $this->irss->getResourceInfo(
$rid);
484 $next_id = $db->nextId(
"exc_returned");
486 "INSERT INTO exc_returned " .
487 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id, late, team_id, rid) " .
488 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
489 $db->quote($next_id,
"integer"),
490 $db->quote($obj_id,
"integer"),
491 $db->quote($user_id,
"integer"),
494 $db->quote($info->getMimeType(),
"text"),
496 $db->quote($ass_id,
"integer"),
497 $db->quote($is_late,
"integer"),
498 $db->quote($team_id,
"integer"),
499 $db->quote(
$rid,
"text")
501 $db->manipulate($query);
508 public function delete(
512 $set = $this->db->queryF(
513 "SELECT rid FROM exc_returned " .
514 " WHERE returned_id = %s ",
518 if ($rec = $this->db->fetchAssoc($set)) {
519 $rid = (string) ($rec[
"rid"] ??
"");
521 $this->irss->deleteResource(
526 $this->db->manipulateF(
527 "DELETE FROM exc_returned WHERE " .
539 string $filetitle =
"" 541 if ($filetitle !==
"") {
542 $this->irss->renameCurrentRevision($rid, $filetitle);
544 $this->irss->deliverFile($rid);
551 return $this->irss->stream($rid);
updateLate(int $return_id, bool $late)
addLocalFile(int $obj_id, int $ass_id, int $user_id, int $team_id, string $file, string $filename, bool $is_late, ResourceStakeholder $stakeholder)
addZipUpload(int $obj_id, int $ass_id, int $user_id, int $team_id, UploadResult $result, bool $is_late, ResourceStakeholder $stakeholder, int $remaining_allowed)
getUserId(int $submission_id)
updateWebDirAccessTime(int $assignment_id, int $member_id)
static getValidFilename(string $a_filename)
quote($value, string $type)
deliverFile(int $ass_id, int $user_id, string $rid, string $filetitle="")
getUserSubmissionState(int $user_id, array $assignment_ids)
Checks if a user has submitted anything for a number of assignments.
getSubmissionsOfUsers(int $ass_id, bool $type_uses_uploads, bool $type_uses_print_versions, array $user_ids, ?array $submit_ids=null, bool $only_valid=false, ?string $min_timestamp=null, bool $print_versions=false)
static now()
Return current timestamp in Y-m-d H:i:s format.
Submission repository Interface.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
addUpload(int $obj_id, int $ass_id, int $user_id, int $team_id, UploadResult $result, string $filename, bool $is_late, ResourceStakeholder $stakeholder)
getMaxAmountOfSubmittedFiles(int $obj_id, int $ass_id, int $user_id=0)
Get the number of max amount of files submitted by a single user in the assignment.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAllEntriesOfAssignment(int $ass_id)
query(string $query)
Run a (read-only) Query on the database.
getUsersWithSubmission(int $ass_id)
Get all user ids, that have submitted something.
Internal factory for data objects.
getSubmissionsOfTeam(int $ass_id, bool $type_uses_uploads, bool $type_uses_print_versions, int $team_id, ?array $submit_ids=null, bool $only_valid=false, ?string $min_timestamp=null, bool $print_versions=false)
__construct(protected IRSSWrapper $irss, protected InternalDataService $data, ?\ilDBInterface $db=null)
queryF(string $query, array $types, array $values)
getStream(int $ass_id, string $rid)
getSubmissions(string $where, int $ass_id, bool $type_uses_uploads, bool $type_uses_print_versions, ?array $submit_ids=null, bool $only_valid=false, ?string $min_timestamp=null, bool $print_versions=false)
hasSubmissions(int $assignment_id)
getAllSubmissionIdsOfOwner(int $ass_id, int $user_id)
Interface ResourceStakeholder.
The base interface for all filesystem streams.
getSubmissionFromRecord(array $rec)