ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilExSubmission Class Reference

Exercise submission //TODO: This class has many static methods related to delivered "files". More...

+ Collaboration diagram for ilExSubmission:

Public Member Functions

 __construct (ilExAssignment $a_ass, int $a_user_id, ?ilExAssignmentTeam $a_team=null, bool $a_is_tutor=false, bool $a_public_submissions=false)
 
 getSubmissionType ()
 
 getAssignment ()
 
 getTeam ()
 
 getPeerReview ()
 
 validatePeerReviews ()
 
 getUserId ()
 
 getUserIds ()
 
 getFeedbackId ()
 used for the legacy storage path of feedbacks only More...
 
 hasSubmitted ()
 
 hasSubmittedPrintVersion ()
 
 getSubmittedEntry (bool $print=false)
 
 getSelectedObject ()
 
 canSubmit ()
 
 canView ()
 
 isTutor ()
 
 hasNoTeamYet ()
 
 isInTeam (?int $a_user_id=null)
 
 isOwner ()
 
 hasPeerReviewAccess ()
 
 canAddFile ()
 
 isLate ()
 
 lookupNewFiles (?int $a_tutor=null)
 Check how much files have been uploaded by the learner after the last download of the tutor. More...
 
 deleteAllFiles ()
 
 updateTutorDownloadTime ()
 
 getTableUserWhere ()
 
 getLastSubmission ()
 TODO -> get rid of getTableUserWhere and move to repository class Get the date of the last submission of a user for the assignment. More...
 
 getLastOpeningHTMLView ()
 TODO -> get rid of getTableUserWhere and move to repository class Get a mysql timestamp from the last HTML view opening. More...
 
 addResourceObject (string $a_wsp_id, ?string $a_text=null)
 Add personal resource or repository object (ref_id) to assigment. More...
 
 deleteResourceObject ()
 
 updateTextSubmission (string $a_text)
 Handle text assignment submissions. More...
 

Static Public Member Functions

static lookupExerciseIdForReturnedId (int $a_returned_id)
 Get exercise from submission id (used in ilObjMediaObject) More...
 
static findUserFiles (int $a_user_id, string $a_filetitle)
 Check if given file was assigned Used in Blog/Portfolio. More...
 
static deleteUser (int $a_exc_id, int $a_user_id)
 Deletes already delivered files. More...
 
static getSubmissionsForFilename (string $a_filename, array $a_assignment_types=array())
 Get assignment return entries for a filename. More...
 
static getDirectoryNameFromUserData (int $a_user_id)
 
static getAssignmentParticipants (int $a_exercise_id, int $a_ass_id)
 
static processZipFile (string $a_directory, string $a_file, bool $structure)
 

Data Fields

const TYPE_FILE = "File"
 
const TYPE_OBJECT = "Object"
 
const TYPE_TEXT = "Text"
 
const TYPE_REPO_OBJECT = "RepoObject"
 

Protected Member Functions

 getStorageId ()
 
 getLastDownloadTime (array $a_user_ids)
 
 downloadSingleFile (Submission $sub, string $title)
 

Protected Attributes

ILIAS Exercise Submission SubmissionManager $sub_manager
 
ILIAS Exercise InternalDomainService $domain
 
ilObjUser $user
 
ilDBInterface $db
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilExAssignment $assignment
 
int $user_id
 
ilExAssignmentTeam $team = null
 
ilExPeerReview $peer_review = null
 
bool $is_tutor
 
bool $public_submissions
 
ilExAssignmentTypeInterface $ass_type
 
ilExAssignmentTypes $ass_types
 
ilExcAssMemberState $state
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

Exercise submission //TODO: This class has many static methods related to delivered "files".

Extract them to classes.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 28 of file class.ilExSubmission.php.

Constructor & Destructor Documentation

◆ __construct()

ilExSubmission::__construct ( ilExAssignment  $a_ass,
int  $a_user_id,
?ilExAssignmentTeam  $a_team = null,
bool  $a_is_tutor = false,
bool  $a_public_submissions = false 
)

Definition at line 52 of file class.ilExSubmission.php.

58 {
59 global $DIC;
60 $this->main_tpl = $DIC->ui()->mainTemplate();
61
62 $this->user = $DIC->user();
63 $this->db = $DIC->database();
64 $this->lng = $DIC->language();
65 $this->ctrl = $DIC->ctrl();
66
67 $this->assignment = $a_ass;
68 $this->ass_type = $this->assignment->getAssignmentType();
69 $this->ass_types = ilExAssignmentTypes::getInstance();
70
71 $this->user_id = $a_user_id;
72 $this->is_tutor = $a_is_tutor;
73 $this->public_submissions = $a_public_submissions;
74
75 $this->state = ilExcAssMemberState::getInstanceByIds($a_ass->getId(), $a_user_id);
76
77 if ($a_ass->hasTeam()) { // ass type uses teams...
78 if (!$a_team) {
79 // this might be a team with no id (since the create on demand parameter is not set)
80 $this->team = ilExAssignmentTeam::getInstanceByUserId($this->assignment->getId(), $this->user_id);
81 } else {
82 $this->team = $a_team;
83 }
84 }
85
86 if ($this->assignment->getPeerReview()) {
87 $this->peer_review = new ilExPeerReview($this->assignment);
88 }
89 $this->domain = $DIC->exercise()->internal()->domain();
90 $this->sub_manager = $DIC->exercise()->internal()->domain()->submission(
91 $a_ass->getId()
92 );
93 }
static getInstanceByUserId(int $a_assignment_id, int $a_user_id, bool $a_create_on_demand=false)
Exercise peer review.
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), ilExAssignment\getAssignmentType(), ilExAssignment\getId(), ilExAssignmentTypes\getInstance(), ilExcAssMemberState\getInstanceByIds(), ilExAssignmentTeam\getInstanceByUserId(), ilExAssignment\hasTeam(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addResourceObject()

ilExSubmission::addResourceObject ( string  $a_wsp_id,
?string  $a_text = null 
)

Add personal resource or repository object (ref_id) to assigment.

Exceptions
ilExcUnknownAssignmentTypeException
ilExerciseException

Definition at line 693 of file class.ilExSubmission.php.

696 : int {
698
699 if ($this->getAssignment()->getAssignmentType()->isSubmissionAssignedToTeam()) {
700 $user_id = 0;
701 $team_id = $this->getTeam()->getId();
702 } else {
703 $user_id = $this->getUserId();
704 $team_id = 0;
705 }
706
707 // repository objects must be unique in submissions
708 // the same repo object cannot be used in different submissions or even different assignment/exercises
709 // why? -> the access handling would fail, since the access depends e.g. on teams or even phase of the
710 // assignment
711 if ($this->getAssignment()->getAssignmentType()->getSubmissionType() == ilExSubmission::TYPE_REPO_OBJECT) {
712 $repos_ass_type_ids = $this->ass_types->getIdsForSubmissionType(ilExSubmission::TYPE_REPO_OBJECT);
713 $subs = $this->getSubmissionsForFilename($a_wsp_id, $repos_ass_type_ids);
714 if ($subs !== []) {
715 throw new ilExerciseException("Repository object $a_wsp_id is already assigned to another assignment.");
716 }
717 }
718
719 $next_id = $ilDB->nextId("exc_returned");
720 $query = sprintf(
721 "INSERT INTO exc_returned " .
722 "(returned_id, obj_id, user_id, filetitle, ass_id, ts, atext, late, team_id) " .
723 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
724 $ilDB->quote($next_id, "integer"),
725 $ilDB->quote($this->assignment->getExerciseId(), "integer"),
726 $ilDB->quote($user_id, "integer"),
727 $ilDB->quote($a_wsp_id, "text"),
728 $ilDB->quote($this->assignment->getId(), "integer"),
729 $ilDB->quote(ilUtil::now(), "timestamp"),
730 $ilDB->quote($a_text, "text"),
731 $ilDB->quote($this->isLate(), "integer"),
732 $ilDB->quote($team_id, "integer")
733 );
734 $ilDB->manipulate($query);
735
736 return $next_id;
737 }
static getSubmissionsForFilename(string $a_filename, array $a_assignment_types=array())
Get assignment return entries for a filename.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static now()
Return current timestamp in Y-m-d H:i:s format.

References $user_id.

◆ canAddFile()

ilExSubmission::canAddFile ( )

Definition at line 256 of file class.ilExSubmission.php.

256 : bool
257 {
258 if (!$this->canSubmit()) {
259 return false;
260 }
261
262 $max = $this->getAssignment()->getMaxFile();
263 $cnt_sub = $this->sub_manager->countSubmissionsOfUser(
264 $this->getUserId()
265 );
266 if ($max &&
267 $max <= $cnt_sub) {
268 return false;
269 }
270
271 return true;
272 }

References canSubmit(), getAssignment(), and getUserId().

+ Here is the call graph for this function:

◆ canSubmit()

ilExSubmission::canSubmit ( )

Definition at line 189 of file class.ilExSubmission.php.

189 : bool
190 {
191 return ($this->isOwner() &&
192 $this->state->isSubmissionAllowed());
193 }

References isOwner().

Referenced by canAddFile(), canView(), ilExSubmissionObjectGUI\getOverviewContentPortfolio(), and ilExAssTypeWikiTeamGUI\renderOverviewContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ canView()

ilExSubmission::canView ( )

Definition at line 195 of file class.ilExSubmission.php.

195 : bool
196 {
197 $ilUser = $this->user;
198
199 if ($this->canSubmit() ||
200 $this->isTutor() ||
201 $this->isInTeam() ||
202 $this->public_submissions) {
203 return true;
204 }
205
206 // #16115
207 if ($this->peer_review) {
208 // peer review givers may view peer submissions
209 foreach ($this->peer_review->getPeerReviewsByPeerId($this->getUserId()) as $giver) {
210 if ($giver["giver_id"] == $ilUser->getId()) {
211 return true;
212 }
213 }
214 }
215
216 return false;
217 }
isInTeam(?int $a_user_id=null)

References $user, canSubmit(), isInTeam(), and isTutor().

+ Here is the call graph for this function:

◆ deleteAllFiles()

ilExSubmission::deleteAllFiles ( )

Definition at line 370 of file class.ilExSubmission.php.

370 : void
371 {
372 $this->sub_manager->deleteAllSubmissionsOfUser($this->getUserId());
373 }

◆ deleteResourceObject()

ilExSubmission::deleteResourceObject ( )

Definition at line 743 of file class.ilExSubmission.php.

743 : void
744 {
745 $this->deleteAllFiles();
746 }

Referenced by ilExSubmissionObjectGUI\getOverviewContentPortfolio(), and ilExAssTypeWikiTeamGUI\renderOverviewContent().

+ Here is the caller graph for this function:

◆ deleteUser()

static ilExSubmission::deleteUser ( int  $a_exc_id,
int  $a_user_id 
)
static

Deletes already delivered files.

Parameters
array$file_id_arrayAn array containing database ids of the delivered files Delete all delivered files of user
Exceptions
ilExcUnknownAssignmentTypeException

Definition at line 441 of file class.ilExSubmission.php.

444 : void {
445 global $DIC;
446
447 $db = $DIC->database();
448
449 foreach (ilExAssignment::getInstancesByExercise($a_exc_id) as $ass) {
450 $submission = new self($ass, $a_user_id);
451 $submission->deleteAllFiles();
452
453 // remove from any team
454 $team = $submission->getTeam();
455 if ($team) {
456 $team->removeTeamMember($a_user_id);
457 }
458
459 // #14900
460 if (\ilObject::_lookupType($ass->getExerciseId()) === "exc") { // see #45183
461 $member_status = $ass->getMemberStatus($a_user_id);
462 $member_status->setStatus("notgraded");
463 $member_status->update();
464 }
465
467 "DELETE FROM exc_usr_tutor " .
468 "WHERE ass_id = %s AND usr_id = %s",
469 array("integer", "integer"),
470 array($ass->getId(), $a_user_id)
471 );
472 }
473 }
removeTeamMember(int $a_user_id, ?int $a_exc_ref_id=null)
static getInstancesByExercise(int $a_exc_id)
ilExAssignmentTeam $team
static _lookupType(int $id, bool $reference=false)
manipulateF(string $query, array $types, array $values)

References ilObject\_lookupType(), ilDBInterface\manipulateF(), and ilExAssignmentTeam\removeTeamMember().

Referenced by ilExerciseMembers\deassignMember(), and ILIAS\Exercise\User\UserEvent\handleDeletion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ downloadSingleFile()

ilExSubmission::downloadSingleFile ( Submission  $sub,
string  $title 
)
protected

Definition at line 614 of file class.ilExSubmission.php.

617 : void {
618 $this->domain->submission($this->assignment->getId())->deliverFile(
619 $sub->getUserId(),
620 $sub->getRid(),
621 $title
622 );
623 }

◆ findUserFiles()

static ilExSubmission::findUserFiles ( int  $a_user_id,
string  $a_filetitle 
)
static

Check if given file was assigned Used in Blog/Portfolio.

Definition at line 351 of file class.ilExSubmission.php.

354 : array {
355 global $DIC;
356
357 $ilDB = $DIC->database();
358
359 $set = $ilDB->query("SELECT obj_id, ass_id" .
360 " FROM exc_returned" .
361 " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") .
362 " AND filetitle = " . $ilDB->quote($a_filetitle, "text"));
363 $res = array();
364 while ($row = $ilDB->fetchAssoc($set)) {
365 $res[$row["ass_id"]] = $row;
366 }
367 return $res;
368 }
$res
Definition: ltiservices.php:69

Referenced by ILIAS\Blog\Exercise\BlogExercise\getAssignmentsOfBlog(), and ilPortfolioExercise\getAssignmentsOfPortfolio().

+ Here is the caller graph for this function:

◆ getAssignment()

◆ getAssignmentParticipants()

static ilExSubmission::getAssignmentParticipants ( int  $a_exercise_id,
int  $a_ass_id 
)
static

Definition at line 988 of file class.ilExSubmission.php.

991 : array {
992 global $DIC;
993
994 $ilDB = $DIC->database();
995
996 $participants = array();
997 $query = "SELECT user_id FROM exc_returned WHERE ass_id = " .
998 $ilDB->quote($a_ass_id, "integer") .
999 " AND obj_id = " .
1000 $ilDB->quote($a_exercise_id, "integer");
1001
1002 $res = $ilDB->query($query);
1003
1004 while ($row = $ilDB->fetchAssoc($res)) {
1005 $participants[] = $row['user_id'];
1006 }
1007
1008 return $participants;
1009 }

◆ getDirectoryNameFromUserData()

static ilExSubmission::getDirectoryNameFromUserData ( int  $a_user_id)
static
Deprecated:
see getDirectoryNameFromUserData in SubmissionManager

Definition at line 977 of file class.ilExSubmission.php.

977 : string
978 {
979 $userName = ilObjUser::_lookupName($a_user_id);
981 trim($userName["lastname"]) . "_" .
982 trim($userName["firstname"]) . "_" .
983 trim($userName["login"]) . "_" .
984 $userName["user_id"]
985 );
986 }
static getASCIIFilename(string $a_filename)
static _lookupName(int $a_user_id)

References ilObjUser\_lookupName(), and ilFileUtils\getASCIIFilename().

Referenced by ilExerciseManagementCollectFilesJob\createTargetDirectory(), ilExerciseManagementCollectFilesJob\getFeedbackDirectory(), and ilDownloadSubmissionsBackgroundTask\run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFeedbackId()

ilExSubmission::getFeedbackId ( )

used for the legacy storage path of feedbacks only

Definition at line 150 of file class.ilExSubmission.php.

150 : string
151 {
152 if ($this->team) {
153 return "t" . $this->team->getId();
154 } else {
155 return (string) $this->getUserId();
156 }
157 }

References getUserId().

+ Here is the call graph for this function:

◆ getLastDownloadTime()

ilExSubmission::getLastDownloadTime ( array  $a_user_ids)
protected
Parameters
array$a_user_ids
Returns
string "Y-m-d H:i:s"

Definition at line 479 of file class.ilExSubmission.php.

481 : string {
483 $ilUser = $this->user;
484
485 $q = "SELECT download_time FROM exc_usr_tutor WHERE " .
486 " ass_id = " . $ilDB->quote($this->getAssignment()->getId(), "integer") . " AND " .
487 $ilDB->in("usr_id", $a_user_ids, "", "integer") . " AND " .
488 " tutor_id = " . $ilDB->quote($ilUser->getId(), "integer") .
489 " ORDER BY download_time DESC";
490 $lu_set = $ilDB->query($q);
491 $lu_rec = $ilDB->fetchAssoc($lu_set);
492 return $lu_rec["download_time"] ?? "";
493 }
$q
Definition: shib_logout.php:23

◆ getLastOpeningHTMLView()

ilExSubmission::getLastOpeningHTMLView ( )

TODO -> get rid of getTableUserWhere and move to repository class Get a mysql timestamp from the last HTML view opening.

Definition at line 665 of file class.ilExSubmission.php.

665 : ?string
666 {
667 $this->db->setLimit(1, 0);
668
669 $q = "SELECT web_dir_access_time FROM exc_returned" .
670 " WHERE ass_id = " . $this->db->quote($this->assignment->getId(), "integer") .
671 " AND (filename IS NOT NULL OR atext IS NOT NULL)" .
672 " AND web_dir_access_time IS NOT NULL" .
673 " AND " . $this->getTableUserWhere() .
674 " ORDER BY web_dir_access_time DESC";
675
676 $res = $this->db->query($q);
677
678 $data = $this->db->fetchAssoc($res);
679
680 return $data["web_dir_access_time"] ?? null;
681 }

References $data, $q, and $res.

◆ getLastSubmission()

ilExSubmission::getLastSubmission ( )

TODO -> get rid of getTableUserWhere and move to repository class Get the date of the last submission of a user for the assignment.

Definition at line 644 of file class.ilExSubmission.php.

644 : ?string
645 {
647
648 $ilDB->setLimit(1, 0);
649
650 $q = "SELECT obj_id,user_id,ts FROM exc_returned" .
651 " WHERE ass_id = " . $ilDB->quote($this->assignment->getId(), "integer") .
652 " AND " . $this->getTableUserWhere() .
653 " AND (filename IS NOT NULL OR atext IS NOT NULL)" .
654 " AND ts IS NOT NULL" .
655 " ORDER BY ts DESC";
656 $usr_set = $ilDB->query($q);
657 $array = $ilDB->fetchAssoc($usr_set);
658 return ($array["ts"] ?? null);
659 }

References $ilDB, and $q.

Referenced by ilExSubmissionTeamGUI\buildSubmissionPropertiesAndActions().

+ Here is the caller graph for this function:

◆ getPeerReview()

ilExSubmission::getPeerReview ( )

Definition at line 110 of file class.ilExSubmission.php.

111 {
112 return $this->peer_review;
113 }
ilExPeerReview $peer_review

References $peer_review.

Referenced by ilExPeerReviewGUI\buildSubmissionPropertiesAndActions(), and ilExPeerReviewGUI\getPeerReviewReceiverPanel().

+ Here is the caller graph for this function:

◆ getSelectedObject()

ilExSubmission::getSelectedObject ( )

Definition at line 184 of file class.ilExSubmission.php.

184 : ?Submission
185 {
186 return $this->sub_manager->getSubmissionsOfUser($this->getUserId())->current();
187 }

References getUserId().

Referenced by ilExSubmissionObjectGUI\getOverviewContentPortfolio(), and ilExAssTypeWikiTeamGUI\renderOverviewContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStorageId()

ilExSubmission::getStorageId ( )
protected

Definition at line 286 of file class.ilExSubmission.php.

286 : int
287 {
288 if ($this->ass_type->isSubmissionAssignedToTeam()) {
289 $storage_id = $this->getTeam()->getId();
290 } else {
291 $storage_id = $this->getUserId();
292 }
293 return $storage_id;
294 }

References getTeam(), and getUserId().

+ Here is the call graph for this function:

◆ getSubmissionsForFilename()

static ilExSubmission::getSubmissionsForFilename ( string  $a_filename,
array  $a_assignment_types = array() 
)
static

Get assignment return entries for a filename.

Definition at line 948 of file class.ilExSubmission.php.

951 : array {
952 global $DIC;
953
954 $db = $DIC->database();
955
956 $query = "SELECT * FROM exc_returned r LEFT JOIN exc_assignment a" .
957 " ON (r.ass_id = a.id) " .
958 " WHERE r.filetitle = " . $db->quote($a_filename, "string");
959
960 if (is_array($a_assignment_types) && $a_assignment_types !== []) {
961 $query .= " AND " . $db->in("a.type", $a_assignment_types, false, "integer");
962 }
963
964 $set = $db->query($query);
965 $rets = array();
966 while ($rec = $db->fetchAssoc($set)) {
967 $rets[] = $rec;
968 }
969
970
971 return $rets;
972 }
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
in(string $field, array $values, bool $negate=false, string $type="")

References ilDBInterface\in().

Referenced by ilExcRepoObjAssignmentInfo\getInfo(), and ilObjWikiListGUI\getProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubmissionType()

ilExSubmission::getSubmissionType ( )

Definition at line 95 of file class.ilExSubmission.php.

95 : string
96 {
97 return $this->assignment->getAssignmentType()->getSubmissionType();
98 }

◆ getSubmittedEntry()

ilExSubmission::getSubmittedEntry ( bool  $print = false)

Definition at line 173 of file class.ilExSubmission.php.

173 : ?Submission
174 {
175 return $this->sub_manager->getSubmissionsOfUser(
176 $this->getUserId(),
177 null,
178 false,
179 null,
180 $print
181 )->current();
182 }

References getUserId().

Referenced by hasSubmittedPrintVersion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableUserWhere()

ilExSubmission::getTableUserWhere ( )

Definition at line 626 of file class.ilExSubmission.php.

626 : string
627 {
629
630 if ($this->getAssignment()->getAssignmentType()->isSubmissionAssignedToTeam()) {
631 $team_id = $this->getTeam()->getId();
632 $where = " team_id = " . $ilDB->quote($team_id, "integer") . " ";
633 } else {
634 $where = " " . $ilDB->in("user_id", $this->getUserIds(), "", "integer") . " ";
635 }
636 return $where;
637 }

References $ilDB.

◆ getTeam()

ilExSubmission::getTeam ( )

Definition at line 105 of file class.ilExSubmission.php.

106 {
107 return $this->team;
108 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $team.

Referenced by ilExSubmissionTeamGUI\buildSubmissionPropertiesAndActions(), getStorageId(), and ilExAssTypeWikiTeamGUI\renderOverviewContent().

+ Here is the caller graph for this function:

◆ getUserId()

◆ getUserIds()

ilExSubmission::getUserIds ( )

Definition at line 136 of file class.ilExSubmission.php.

136 : array
137 {
138 if ($this->team &&
139 !$this->hasNoTeamYet()) {
140 return $this->team->getMembers();
141 }
142
143 // if has no team currently there still might be uploads attached
144 return array($this->user_id);
145 }

References hasNoTeamYet().

Referenced by isInTeam(), and validatePeerReviews().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasNoTeamYet()

ilExSubmission::hasNoTeamYet ( )

Definition at line 224 of file class.ilExSubmission.php.

224 : bool
225 {
226 if ($this->assignment->hasTeam() &&
227 !$this->team->getId()) {
228 return true;
229 }
230 return false;
231 }

Referenced by getUserIds().

+ Here is the caller graph for this function:

◆ hasPeerReviewAccess()

ilExSubmission::hasPeerReviewAccess ( )

Definition at line 250 of file class.ilExSubmission.php.

250 : bool
251 {
252 return ($this->peer_review &&
253 $this->peer_review->hasPeerReviewAccess($this->user_id));
254 }

◆ hasSubmitted()

ilExSubmission::hasSubmitted ( )

Definition at line 159 of file class.ilExSubmission.php.

159 : bool
160 {
161 return (bool) $this->sub_manager->getSubmissionsOfUser(
162 $this->getUserId(),
163 null,
164 true
165 )->current();
166 }

References getUserId().

Referenced by ilExSubmissionTeamGUI\buildSubmissionPropertiesAndActions(), ilExSubmissionObjectGUI\getOverviewContentPortfolio(), ilExcAssMemberState\isGlobalFeedbackFileAccessible(), and ilExAssTypeWikiTeamGUI\renderOverviewContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasSubmittedPrintVersion()

ilExSubmission::hasSubmittedPrintVersion ( )

Definition at line 168 of file class.ilExSubmission.php.

168 : bool
169 {
170 return ($this->getSubmittedEntry(true)?->getRid() != "");
171 }
getSubmittedEntry(bool $print=false)

References getSubmittedEntry().

+ Here is the call graph for this function:

◆ isInTeam()

ilExSubmission::isInTeam ( ?int  $a_user_id = null)

Definition at line 233 of file class.ilExSubmission.php.

233 : bool
234 {
235 $ilUser = $this->user;
236
237 if (!$a_user_id) {
238 $a_user_id = $ilUser->getId();
239 }
240 return in_array($a_user_id, $this->getUserIds());
241 }

References $user, ilObject\getId(), and getUserIds().

Referenced by canView().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLate()

ilExSubmission::isLate ( )

Definition at line 279 of file class.ilExSubmission.php.

279 : bool
280 {
281 $dl = $this->state->getOfficialDeadline();
282 //$dl = $this->assignment->getPersonalDeadline($this->getUserId());
283 return ($dl && $dl < time());
284 }

◆ isOwner()

ilExSubmission::isOwner ( )

Definition at line 243 of file class.ilExSubmission.php.

243 : bool
244 {
245 $ilUser = $this->user;
246
247 return ($ilUser->getId() == $this->getUserId());
248 }

References $user.

Referenced by canSubmit().

+ Here is the caller graph for this function:

◆ isTutor()

ilExSubmission::isTutor ( )

Definition at line 219 of file class.ilExSubmission.php.

219 : bool
220 {
221 return $this->is_tutor;
222 }

References $is_tutor.

Referenced by canView().

+ Here is the caller graph for this function:

◆ lookupExerciseIdForReturnedId()

static ilExSubmission::lookupExerciseIdForReturnedId ( int  $a_returned_id)
static

Get exercise from submission id (used in ilObjMediaObject)

Definition at line 333 of file class.ilExSubmission.php.

335 : int {
336 global $DIC;
337
338 $ilDB = $DIC->database();
339
340 $set = $ilDB->query("SELECT obj_id" .
341 " FROM exc_returned" .
342 " WHERE returned_id = " . $ilDB->quote($a_returned_id, "integer"));
343 $row = $ilDB->fetchAssoc($set);
344 return (int) $row["obj_id"];
345 }

◆ lookupNewFiles()

ilExSubmission::lookupNewFiles ( ?int  $a_tutor = null)

Check how much files have been uploaded by the learner after the last download of the tutor.

Definition at line 300 of file class.ilExSubmission.php.

302 : array {
304 $ilUser = $this->user;
305
306 $tutor = ($a_tutor)
307 ?: $ilUser->getId();
308
309 $where = " AND " . $this->getTableUserWhere();
310
311 $q = "SELECT exc_returned.returned_id AS id " .
312 "FROM exc_usr_tutor, exc_returned " .
313 "WHERE exc_returned.ass_id = exc_usr_tutor.ass_id " .
314 " AND exc_returned.user_id = exc_usr_tutor.usr_id " .
315 " AND exc_returned.ass_id = " . $ilDB->quote($this->getAssignment()->getId(), "integer") .
316 $where .
317 " AND exc_usr_tutor.tutor_id = " . $ilDB->quote($tutor, "integer") .
318 " AND exc_usr_tutor.download_time < exc_returned.ts ";
319
320 $new_up_set = $ilDB->query($q);
321
322 $new_up = array();
323 while ($new_up_rec = $ilDB->fetchAssoc($new_up_set)) {
324 $new_up[] = $new_up_rec["id"];
325 }
326
327 return $new_up;
328 }

◆ processZipFile()

static ilExSubmission::processZipFile ( string  $a_directory,
string  $a_file,
bool  $structure 
)
static

Definition at line 1011 of file class.ilExSubmission.php.

1015 : void {
1016 global $DIC;
1017
1018 $lng = $DIC->language();
1019
1020 $pathinfo = pathinfo($a_file);
1021 $file = $pathinfo["basename"];
1022
1023 // see 22727
1024 if (($pathinfo["extension"] ?? '') === '') {
1025 $file .= ".zip";
1026 }
1027
1028 // Copy zip-file to new directory, unzip and remove it
1029 // TODO: check archive for broken file
1030 //copy ($a_file, $a_directory . "/" . $file);
1031 ilFileUtils::moveUploadedFile($a_file, $file, $a_directory . "/" . $file);
1032 $DIC->legacyArchives()->unzip(
1033 $a_directory . "/" . $file,
1034 null,
1035 false,
1036 true,
1037 false
1038 );
1039 unlink($a_directory . "/" . $file);
1040 //echo "-".$a_directory . "/" . $file."-";
1041 // Stores filename and paths into $filearray to check for viruses
1042 // Checks if filenames can be read, else -> throw exception and leave
1043 $filearray = [];
1044 ilFileUtils::recursive_dirscan($a_directory, $filearray);
1045
1046 // if there are no files unziped (->broken file!)
1047 if (empty($filearray)) {
1048 throw new ilFileUtilsException(
1049 $lng->txt("archive_broken"),
1051 );
1052 }
1053
1054 // virus handling
1055 foreach ($filearray["file"] as $key => $value) {
1056 // remove "invisible" files
1057 if (substr($value, 0, 1) == "." || stristr(
1058 $filearray["path"][$key],
1059 "/__MACOSX/"
1060 )) {
1061 unlink($filearray["path"][$key] . $value);
1062 unset($filearray["path"][$key]);
1063 unset($filearray["file"][$key]);
1064 continue;
1065 }
1066
1067 $vir = ilVirusScanner::virusHandling($filearray["path"][$key], $value);
1068 if (!$vir[0]) {
1069 // Unlink file and throw exception
1070 unlink($filearray['path'][$key]);
1071 throw new ilFileUtilsException(
1072 $lng->txt("file_is_infected") . "<br />" . $vir[1],
1074 );
1075 } elseif ($vir[1] != "") {
1076 throw new ilFileUtilsException(
1077 $vir[1],
1079 );
1080 }
1081 }
1082
1083 // If archive is to be used "flat"
1084 $doublettes = '';
1085 if (!$structure) {
1086 foreach (array_count_values($filearray["file"]) as $key => $value) {
1087 // Archive contains same filenames in different directories
1088 if ($value != "1") {
1089 $doublettes .= " '" . ilFileUtils::utf8_encode($key) . "'";
1090 }
1091 }
1092 if (strlen($doublettes) > 0) {
1093 throw new ilFileUtilsException(
1094 $lng->txt("exc_upload_error") . "<br />" . $lng->txt(
1095 "zip_structure_error"
1096 ) . $doublettes,
1098 );
1099 }
1100 } else {
1101 $mac_dir = $a_directory . "/__MACOSX";
1102 if (file_exists($mac_dir)) {
1103 ilFileUtils::delDir($mac_dir);
1104 }
1105 }
1106 }
$structure
TOTAL STRUCTURE.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static utf8_encode(string $string)
static recursive_dirscan(string $dir, array &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
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...
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)

◆ updateTextSubmission()

ilExSubmission::updateTextSubmission ( string  $a_text)

Handle text assignment submissions.

Exceptions
ilExcUnknownAssignmentTypeException
ilExerciseException

Definition at line 753 of file class.ilExSubmission.php.

753 : ?int
754 {
756
757 // no text = remove submission
758 if (!trim($a_text)) {
759 $this->sub_manager->deleteAllSubmissionsOfUser($this->getUserId());
760 return null;
761 }
762
763 $sub = $this->sub_manager->getSubmissionsOfUser($this->getUserId())->current();
764
765 if (!$sub) {
766 return $this->addResourceObject("TEXT", $a_text);
767 } else {
768 $id = $sub->getId();
769 if ($id) {
770 $ilDB->manipulate("UPDATE exc_returned" .
771 " SET atext = " . $ilDB->quote($a_text, "text") .
772 ", ts = " . $ilDB->quote(ilUtil::now(), "timestamp") .
773 ", late = " . $ilDB->quote($this->isLate(), "integer") .
774 " WHERE returned_id = " . $ilDB->quote($id, "integer"));
775 return $id;
776 }
777 }
778 return null;
779 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
addResourceObject(string $a_wsp_id, ?string $a_text=null)
Add personal resource or repository object (ref_id) to assigment.

References $id, $ilDB, and ilUtil\now().

+ Here is the call graph for this function:

◆ updateTutorDownloadTime()

ilExSubmission::updateTutorDownloadTime ( )

Definition at line 589 of file class.ilExSubmission.php.

589 : void
590 {
591 $ilUser = $this->user;
593
594 $exc_id = $this->assignment->getExerciseId();
595 $ass_id = $this->assignment->getId();
596
597 foreach ($this->getUserIds() as $user_id) {
598 $ilDB->manipulateF(
599 "DELETE FROM exc_usr_tutor " .
600 "WHERE ass_id = %s AND usr_id = %s AND tutor_id = %s",
601 array("integer", "integer", "integer"),
602 array($ass_id, $user_id, $ilUser->getId())
603 );
604
605 $ilDB->manipulateF(
606 "INSERT INTO exc_usr_tutor (ass_id, obj_id, usr_id, tutor_id, download_time) VALUES " .
607 "(%s, %s, %s, %s, %s)",
608 array("integer", "integer", "integer", "integer", "timestamp"),
609 array($ass_id, $exc_id, $user_id, $ilUser->getId(), ilUtil::now())
610 );
611 }
612 }

References $ass_id, $ilDB, $user_id, and ilUtil\now().

+ Here is the call graph for this function:

◆ validatePeerReviews()

ilExSubmission::validatePeerReviews ( )

Definition at line 115 of file class.ilExSubmission.php.

115 : array
116 {
117 $res = array();
118 foreach ($this->getUserIds() as $user_id) {
119 $valid = true;
120
121 // no peer review == valid
122 if ($this->peer_review) {
123 $valid = $this->peer_review->isFeedbackValidForPassed($user_id);
124 }
125
127 }
128 return $res;
129 }
$valid

References $res, $user_id, $valid, and getUserIds().

+ Here is the call graph for this function:

Field Documentation

◆ $ass_type

ilExAssignmentTypeInterface ilExSubmission::$ass_type
protected

Definition at line 47 of file class.ilExSubmission.php.

◆ $ass_types

ilExAssignmentTypes ilExSubmission::$ass_types
protected

Definition at line 48 of file class.ilExSubmission.php.

◆ $assignment

ilExAssignment ilExSubmission::$assignment
protected

Definition at line 41 of file class.ilExSubmission.php.

Referenced by getAssignment().

◆ $ctrl

ilCtrl ilExSubmission::$ctrl
protected

Definition at line 40 of file class.ilExSubmission.php.

◆ $db

ilDBInterface ilExSubmission::$db
protected

Definition at line 38 of file class.ilExSubmission.php.

◆ $domain

ILIAS Exercise InternalDomainService ilExSubmission::$domain
protected

Definition at line 35 of file class.ilExSubmission.php.

◆ $is_tutor

bool ilExSubmission::$is_tutor
protected

Definition at line 45 of file class.ilExSubmission.php.

Referenced by isTutor().

◆ $lng

ilLanguage ilExSubmission::$lng
protected

Definition at line 39 of file class.ilExSubmission.php.

◆ $main_tpl

ilGlobalTemplateInterface ilExSubmission::$main_tpl
private

Definition at line 50 of file class.ilExSubmission.php.

◆ $peer_review

ilExPeerReview ilExSubmission::$peer_review = null
protected

Definition at line 44 of file class.ilExSubmission.php.

Referenced by getPeerReview().

◆ $public_submissions

bool ilExSubmission::$public_submissions
protected

Definition at line 46 of file class.ilExSubmission.php.

◆ $state

ilExcAssMemberState ilExSubmission::$state
protected

Definition at line 49 of file class.ilExSubmission.php.

◆ $sub_manager

ILIAS Exercise Submission SubmissionManager ilExSubmission::$sub_manager
protected

Definition at line 34 of file class.ilExSubmission.php.

◆ $team

ilExAssignmentTeam ilExSubmission::$team = null
protected

Definition at line 43 of file class.ilExSubmission.php.

Referenced by getTeam().

◆ $user

ilObjUser ilExSubmission::$user
protected

Definition at line 37 of file class.ilExSubmission.php.

Referenced by canView(), isInTeam(), and isOwner().

◆ $user_id

int ilExSubmission::$user_id
protected

Definition at line 42 of file class.ilExSubmission.php.

Referenced by getUserId(), and validatePeerReviews().

◆ TYPE_FILE

const ilExSubmission::TYPE_FILE = "File"

◆ TYPE_OBJECT

const ilExSubmission::TYPE_OBJECT = "Object"

◆ TYPE_REPO_OBJECT

const ilExSubmission::TYPE_REPO_OBJECT = "RepoObject"

◆ TYPE_TEXT

const ilExSubmission::TYPE_TEXT = "Text"

Definition at line 32 of file class.ilExSubmission.php.

Referenced by ilExAssTypeText\getSubmissionType().


The documentation for this class was generated from the following file: