ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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.

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

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.
global $DIC
Definition: shib_login.php:22
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
+ 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 691 of file class.ilExSubmission.php.

References $db, $ilDB, getAssignment(), getSubmissionsForFilename(), getSubmissionType(), getTeam(), getUserId(), isLate(), ilUtil\now(), and TYPE_REPO_OBJECT.

Referenced by ilObjPortfolioGUI\linkPortfolioToAssignment(), and updateTextSubmission().

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

◆ canAddFile()

ilExSubmission::canAddFile ( )

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

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

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  }
+ Here is the call graph for this function:

◆ canSubmit()

ilExSubmission::canSubmit ( )

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

References isOwner().

Referenced by canAddFile(), canView(), ilExSubmissionTextGUI\getOverviewContent(), ilExSubmissionFileGUI\getOverviewContent(), ilExSubmissionObjectGUI\getOverviewContentBlog(), ilExSubmissionObjectGUI\getOverviewContentPortfolio(), and ilExAssTypeWikiTeamGUI\renderOverviewContent().

189  : bool
190  {
191  return ($this->isOwner() &&
192  $this->state->isSubmissionAllowed());
193  }
+ 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.

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

Referenced by ilExSubmissionGUI\executeCommand().

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)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAllFiles()

ilExSubmission::deleteAllFiles ( )

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

References getUserId().

Referenced by deleteResourceObject().

370  : void
371  {
372  $this->sub_manager->deleteAllSubmissionsOfUser($this->getUserId());
373  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteResourceObject()

ilExSubmission::deleteResourceObject ( )

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

References deleteAllFiles().

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

741  : void
742  {
743  $this->deleteAllFiles();
744  }
+ Here is the call graph for this function:
+ 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.

References $DIC, ilExAssignment\getInstancesByExercise(), ilDBInterface\manipulateF(), and ilExAssignmentTeam\removeTeamMember().

Referenced by ilExerciseMembers\deassignMember().

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  $member_status = $ass->getMemberStatus($a_user_id);
461  $member_status->setStatus("notgraded");
462  $member_status->update();
463 
464  $db->manipulateF(
465  "DELETE FROM exc_usr_tutor " .
466  "WHERE ass_id = %s AND usr_id = %s",
467  array("integer", "integer"),
468  array($ass->getId(), $a_user_id)
469  );
470  }
471  }
removeTeamMember(int $a_user_id, ?int $a_exc_ref_id=null)
manipulateF(string $query, array $types, array $values)
global $DIC
Definition: shib_login.php:22
ilExAssignmentTeam $team
static getInstancesByExercise(int $a_exc_id)
+ 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 612 of file class.ilExSubmission.php.

References ILIAS\Exercise\Submission\Submission\getRid(), and ILIAS\Exercise\Submission\Submission\getUserId().

Referenced by getLastDownloadTime().

615  : void {
616  $this->domain->submission($this->assignment->getId())->deliverFile(
617  $sub->getUserId(),
618  $sub->getRid(),
619  $title
620  );
621  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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.

References $DIC, $ilDB, and $res.

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

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:66
global $DIC
Definition: shib_login.php:22
+ 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 986 of file class.ilExSubmission.php.

References $DIC, $ilDB, and $res.

Referenced by ilExerciseManagementGUI\saveGradesObject().

989  : array {
990  global $DIC;
991 
992  $ilDB = $DIC->database();
993 
994  $participants = array();
995  $query = "SELECT user_id FROM exc_returned WHERE ass_id = " .
996  $ilDB->quote($a_ass_id, "integer") .
997  " AND obj_id = " .
998  $ilDB->quote($a_exercise_id, "integer");
999 
1000  $res = $ilDB->query($query);
1001 
1002  while ($row = $ilDB->fetchAssoc($res)) {
1003  $participants[] = $row['user_id'];
1004  }
1005 
1006  return $participants;
1007  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ getDirectoryNameFromUserData()

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

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

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

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

975  : string
976  {
977  $userName = ilObjUser::_lookupName($a_user_id);
979  trim($userName["lastname"]) . "_" .
980  trim($userName["firstname"]) . "_" .
981  trim($userName["login"]) . "_" .
982  $userName["user_id"]
983  );
984  }
static _lookupName(int $a_user_id)
lookup user name
static getASCIIFilename(string $a_filename)
+ 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.

References getUserId().

150  : string
151  {
152  if ($this->team) {
153  return "t" . $this->team->getId();
154  } else {
155  return (string) $this->getUserId();
156  }
157  }
+ 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 477 of file class.ilExSubmission.php.

References $db, $ilDB, $lng, $q, $user, ilObjUser\_lookupName(), ilObject\_lookupTitle(), downloadSingleFile(), getAssignment(), ILIAS\Survey\Mode\getId(), getTeam(), getUserId(), getUserIds(), null, ilLanguage\txt(), ilExAssignment\TYPE_BLOG, ilExAssignment\TYPE_PORTFOLIO, ilExAssignment\TYPE_WIKI_TEAM, and updateTutorDownloadTime().

479  : string {
480  $ilDB = $this->db;
481  $ilUser = $this->user;
482 
483  $q = "SELECT download_time FROM exc_usr_tutor WHERE " .
484  " ass_id = " . $ilDB->quote($this->getAssignment()->getId(), "integer") . " AND " .
485  $ilDB->in("usr_id", $a_user_ids, "", "integer") . " AND " .
486  " tutor_id = " . $ilDB->quote($ilUser->getId(), "integer") .
487  " ORDER BY download_time DESC";
488  $lu_set = $ilDB->query($q);
489  $lu_rec = $ilDB->fetchAssoc($lu_set);
490  return $lu_rec["download_time"] ?? "";
491  }
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

◆ 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 663 of file class.ilExSubmission.php.

References $data, $q, $res, getTableUserWhere(), and null.

663  : ?string
664  {
665  $this->db->setLimit(1, 0);
666 
667  $q = "SELECT web_dir_access_time FROM exc_returned" .
668  " WHERE ass_id = " . $this->db->quote($this->assignment->getId(), "integer") .
669  " AND (filename IS NOT NULL OR atext IS NOT NULL)" .
670  " AND web_dir_access_time IS NOT NULL" .
671  " AND " . $this->getTableUserWhere() .
672  " ORDER BY web_dir_access_time DESC";
673 
674  $res = $this->db->query($q);
675 
676  $data = $this->db->fetchAssoc($res);
677 
678  return $data["web_dir_access_time"] ?? null;
679  }
$res
Definition: ltiservices.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

◆ 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 642 of file class.ilExSubmission.php.

References $db, $ilDB, $q, getTableUserWhere(), and null.

Referenced by ilExSubmissionTeamGUI\buildSubmissionPropertiesAndActions(), ilExSubmissionTeamGUI\getOverviewContent(), and updateTextSubmission().

642  : ?string
643  {
644  $ilDB = $this->db;
645 
646  $ilDB->setLimit(1, 0);
647 
648  $q = "SELECT obj_id,user_id,ts FROM exc_returned" .
649  " WHERE ass_id = " . $ilDB->quote($this->assignment->getId(), "integer") .
650  " AND " . $this->getTableUserWhere() .
651  " AND (filename IS NOT NULL OR atext IS NOT NULL)" .
652  " AND ts IS NOT NULL" .
653  " ORDER BY ts DESC";
654  $usr_set = $ilDB->query($q);
655  $array = $ilDB->fetchAssoc($usr_set);
656  return ($array["ts"] ?? null);
657  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPeerReview()

ilExSubmission::getPeerReview ( )

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

References $peer_review.

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

110  : ?ilExPeerReview
111  {
112  return $this->peer_review;
113  }
ilExPeerReview $peer_review
Exercise peer review.
+ Here is the caller graph for this function:

◆ getSelectedObject()

ilExSubmission::getSelectedObject ( )

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

References getUserId().

Referenced by ilExSubmissionObjectGUI\askUnlinkBlogObject(), ilExSubmissionObjectGUI\askUnlinkPortfolioObject(), ilObjWikiGUI\getAssignmentButtons(), ilExSubmissionObjectGUI\getOverviewContentBlog(), ilExSubmissionObjectGUI\getOverviewContentPortfolio(), and ilExAssTypeWikiTeamGUI\renderOverviewContent().

184  : ?Submission
185  {
186  return $this->sub_manager->getSubmissionsOfUser($this->getUserId())->current();
187  }
+ 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.

References getTeam(), and getUserId().

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  }
+ 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 946 of file class.ilExSubmission.php.

References $DIC, ilDBInterface\fetchAssoc(), ilDBInterface\in(), ilDBInterface\query(), and ilDBInterface\quote().

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

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

Referenced by addResourceObject(), and ilExSubmissionGUI\executeCommand().

95  : string
96  {
97  return $this->assignment->getAssignmentType()->getSubmissionType();
98  }
+ Here is the caller graph for this function:

◆ getSubmittedEntry()

ilExSubmission::getSubmittedEntry ( bool  $print = false)

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

References getUserId(), and null.

Referenced by hasSubmittedPrintVersion().

173  : ?Submission
174  {
175  return $this->sub_manager->getSubmissionsOfUser(
176  $this->getUserId(),
177  null,
178  false,
179  null,
180  $print
181  )->current();
182  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableUserWhere()

ilExSubmission::getTableUserWhere ( )

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

References $db, $ilDB, getAssignment(), getTeam(), and getUserIds().

Referenced by getLastOpeningHTMLView(), getLastSubmission(), and lookupNewFiles().

624  : string
625  {
626  $ilDB = $this->db;
627 
628  if ($this->getAssignment()->getAssignmentType()->isSubmissionAssignedToTeam()) {
629  $team_id = $this->getTeam()->getId();
630  $where = " team_id = " . $ilDB->quote($team_id, "integer") . " ";
631  } else {
632  $where = " " . $ilDB->in("user_id", $this->getUserIds(), "", "integer") . " ";
633  }
634  return $where;
635  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTeam()

ilExSubmission::getTeam ( )

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

References $team.

Referenced by addResourceObject(), ilExSubmissionTeamGUI\buildSubmissionPropertiesAndActions(), getLastDownloadTime(), ilExSubmissionTeamGUI\getOverviewContent(), getStorageId(), getTableUserWhere(), and ilExAssTypeWikiTeamGUI\renderOverviewContent().

106  {
107  return $this->team;
108  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilExAssignmentTeam $team
+ Here is the caller graph for this function:

◆ getUserId()

◆ getUserIds()

ilExSubmission::getUserIds ( )

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

References hasNoTeamYet().

Referenced by getLastDownloadTime(), getTableUserWhere(), ilExAssTypeWikiTeam\handleNewUpload(), isInTeam(), updateTutorDownloadTime(), and validatePeerReviews().

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  }
+ 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.

Referenced by ilExSubmissionFileGUI\getOverviewContent(), and getUserIds().

224  : bool
225  {
226  if ($this->assignment->hasTeam() &&
227  !$this->team->getId()) {
228  return true;
229  }
230  return false;
231  }
+ 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.

References getUserId(), and null.

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

159  : bool
160  {
161  return (bool) $this->sub_manager->getSubmissionsOfUser(
162  $this->getUserId(),
163  null,
164  true
165  )->current();
166  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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.

References getSubmittedEntry().

168  : bool
169  {
170  return ($this->getSubmittedEntry(true)?->getRid() != "");
171  }
getSubmittedEntry(bool $print=false)
+ 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.

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

Referenced by canView().

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  }
+ 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.

Referenced by addResourceObject(), and updateTextSubmission().

279  : bool
280  {
281  $dl = $this->state->getOfficialDeadline();
282  //$dl = $this->assignment->getPersonalDeadline($this->getUserId());
283  return ($dl && $dl < time());
284  }
+ Here is the caller graph for this function:

◆ isOwner()

ilExSubmission::isOwner ( )

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

References $user, and getUserId().

Referenced by canSubmit().

243  : bool
244  {
245  $ilUser = $this->user;
246 
247  return ($ilUser->getId() == $this->getUserId());
248  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isTutor()

ilExSubmission::isTutor ( )

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

References $is_tutor.

Referenced by canView().

219  : bool
220  {
221  return $this->is_tutor;
222  }
+ 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.

References $DIC, and $ilDB.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

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  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ 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.

References $db, $ilDB, $q, $user, getAssignment(), ILIAS\Survey\Mode\getId(), ilObject\getId(), and getTableUserWhere().

Referenced by updateTextSubmission().

302  : array {
303  $ilDB = $this->db;
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  }
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processZipFile()

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

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

References ilFileUtilsException\$BROKEN_FILE, $DIC, ilFileUtilsException\$DOUBLETTES_FOUND, ilFileUtilsException\$INFECTED_FILE, ilFileUtils\delDir(), ilFileUtils\moveUploadedFile(), null, ilFileUtils\recursive_dirscan(), ilLanguage\txt(), ilFileUtils\utf8_encode(), and ilVirusScanner\virusHandling().

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

◆ updateTextSubmission()

ilExSubmission::updateTextSubmission ( string  $a_text)

Handle text assignment submissions.

Exceptions
ilExcUnknownAssignmentTypeException
ilExerciseException

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

References $ctrl, $db, $id, $ilDB, $lng, addResourceObject(), ilDatePresentation\formatDate(), getLastSubmission(), getUserId(), IL_CAL_DATETIME, isLate(), lookupNewFiles(), ilUtil\now(), null, ilLanguage\txt(), ilExAssignment\TYPE_BLOG, ilExAssignment\TYPE_PORTFOLIO, ilExAssignment\TYPE_TEXT, ilExAssignment\TYPE_UPLOAD, ilExAssignment\TYPE_UPLOAD_TEAM, and ilExAssignment\TYPE_WIKI_TEAM.

751  : ?int
752  {
753  $ilDB = $this->db;
754 
755  // no text = remove submission
756  if (!trim($a_text)) {
757  $this->sub_manager->deleteAllSubmissionsOfUser($this->getUserId());
758  return null;
759  }
760 
761  $sub = $this->sub_manager->getSubmissionsOfUser($this->getUserId())->current();
762 
763  if (!$sub) {
764  return $this->addResourceObject("TEXT", $a_text);
765  } else {
766  $id = $sub->getId();
767  if ($id) {
768  $ilDB->manipulate("UPDATE exc_returned" .
769  " SET atext = " . $ilDB->quote($a_text, "text") .
770  ", ts = " . $ilDB->quote(ilUtil::now(), "timestamp") .
771  ", late = " . $ilDB->quote($this->isLate(), "integer") .
772  " WHERE returned_id = " . $ilDB->quote($id, "integer"));
773  return $id;
774  }
775  }
776  return null;
777  }
addResourceObject(string $a_wsp_id, ?string $a_text=null)
Add personal resource or repository object (ref_id) to assigment.
static now()
Return current timestamp in Y-m-d H:i:s format.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ updateTutorDownloadTime()

ilExSubmission::updateTutorDownloadTime ( )

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

References $ass_id, $db, $ilDB, $user, getUserIds(), and ilUtil\now().

Referenced by getLastDownloadTime().

587  : void
588  {
589  $ilUser = $this->user;
590  $ilDB = $this->db;
591 
592  $exc_id = $this->assignment->getExerciseId();
593  $ass_id = $this->assignment->getId();
594 
595  foreach ($this->getUserIds() as $user_id) {
596  $ilDB->manipulateF(
597  "DELETE FROM exc_usr_tutor " .
598  "WHERE ass_id = %s AND usr_id = %s AND tutor_id = %s",
599  array("integer", "integer", "integer"),
600  array($ass_id, $user_id, $ilUser->getId())
601  );
602 
603  $ilDB->manipulateF(
604  "INSERT INTO exc_usr_tutor (ass_id, obj_id, usr_id, tutor_id, download_time) VALUES " .
605  "(%s, %s, %s, %s, %s)",
606  array("integer", "integer", "integer", "integer", "timestamp"),
607  array($ass_id, $exc_id, $user_id, $ilUser->getId(), ilUtil::now())
608  );
609  }
610  }
static now()
Return current timestamp in Y-m-d H:i:s format.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validatePeerReviews()

ilExSubmission::validatePeerReviews ( )

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

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

Referenced by ilExAssTypeWikiTeam\handleNewUpload().

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 
126  $res[$user_id] = $valid;
127  }
128  return $res;
129  }
$res
Definition: ltiservices.php:66
$valid
+ Here is the call graph for this function:
+ Here is the caller 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.

Referenced by updateTextSubmission().

◆ $db

◆ $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.

Referenced by getLastDownloadTime(), and updateTextSubmission().

◆ $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

◆ $user_id

int ilExSubmission::$user_id
protected

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

Referenced by __construct(), getUserId(), and validatePeerReviews().

◆ TYPE_FILE

const ilExSubmission::TYPE_FILE = "File"

◆ TYPE_OBJECT

const ilExSubmission::TYPE_OBJECT = "Object"

◆ TYPE_REPO_OBJECT

◆ 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: