ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilExcPeerReviewFileStakeholder.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
25 {
27 
28  public function getId(): string
29  {
30  return 'exc_peer_rev_file';
31  }
32 
33  public function getOwnerOfNewResources(): int
34  {
35  return $this->default_owner;
36  }
37 
38  public function canBeAccessedByCurrentUser(ResourceIdentification $identification): bool
39  {
40  global $DIC;
41 
42  $object_id = $this->resolveObjectId($identification);
43  if ($object_id === null) {
44  return true;
45  }
46 
47  $ref_ids = ilObject2::_getAllReferences($object_id);
48  foreach ($ref_ids as $ref_id) {
49  // one must have write permissions on the exercise to see the submission
50  if (
51  $DIC->access()->checkAccessOfUser($this->current_user, 'read', '', $ref_id) ||
52  $DIC->access()->checkAccessOfUser($this->current_user, 'write', '', $ref_id)) {
53  return true;
54  }
55  }
56 
57  return false;
58  }
59 
60  public function resourceHasBeenDeleted(ResourceIdentification $identification): bool
61  {
62  // at this place we could handle de deletion of a resource. not needed for instruction files IMO.
63 
64  return true;
65  }
66 
67  public function getLocationURIForResourceUsage(ResourceIdentification $identification): ?string
68  {
69  $this->initDB();
70  $object_id = $this->resolveObjectId($identification);
71  if ($object_id !== null) {
72  $references = ilObject::_getAllReferences($object_id);
73  $ref_id = array_shift($references);
74 
75  // we currently deliver the goto-url of the exercise in which the resource is used. if possible, you could deliver a more speficic url wo the assignment as well.
76  return ilLink::_getLink($ref_id, 'exc');
77  }
78  return null;
79  }
80 
81  private function resolveObjectId(ResourceIdentification $identification): ?int
82  {
83  $this->initDB();
84  $r = $this->database->queryF(
85  "SELECT ass_id FROM exc_crit_file WHERE rid = %s",
86  ['text'],
87  [$identification->serialize()]
88  );
89  if (($d = $this->database->fetchObject($r)) !== null) {
90  $r2 = $this->database->queryF(
91  "SELECT obj_id FROM exc_assignment WHERE ass_id = %s",
92  ['integer'],
93  [$d->ass_id]
94  );
95  $d2 = $this->database->fetchObject($r2);
96  }
97 
98  return (isset($d2->obj_id) ? (int) $d2->obj_id : null);
99  }
100 
101  private function initDB(): void
102  {
103  global $DIC;
104  if ($this->database === null) {
105  $this->database = $DIC->database();
106  }
107  }
108 }
resolveObjectId(ResourceIdentification $identification)
static _getAllReferences(int $id)
get all reference ids for object ID
getLocationURIForResourceUsage(ResourceIdentification $identification)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
canBeAccessedByCurrentUser(ResourceIdentification $identification)
global $DIC
Definition: shib_login.php:22
resourceHasBeenDeleted(ResourceIdentification $identification)
$r