ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExcTutorFeedbackFileStakeholder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
22
24{
25 protected ?ilDBInterface $database = null;
26
27 public function getId(): string
28 {
29 return 'exc_tutor_feedback';
30 }
31
32 public function getOwnerOfNewResources(): int
33 {
35 }
36
37 public function canBeAccessedByCurrentUser(ResourceIdentification $identification): bool
38 {
39 global $DIC;
40
41 $object_id = $this->resolveObjectId($identification);
42 $is_recipient = $this->isRecipient($identification);
43
44 if ($object_id === null) {
45 return true;
46 }
47
48 $ref_ids = ilObject2::_getAllReferences($object_id);
49 foreach ($ref_ids as $ref_id) {
50 if ($DIC->access()->checkAccessOfUser($this->current_user, 'write', '', $ref_id)) {
51 return true;
52 }
53 if ($is_recipient &&
54 $DIC->access()->checkAccessOfUser($this->current_user, 'read', '', $ref_id)) {
55 return true;
56 }
57 }
58
59 return false;
60 }
61
62 public function resourceHasBeenDeleted(ResourceIdentification $identification): bool
63 {
64 // at this place we could handle de deletion of a resource. not needed for instruction files IMO.
65
66 return true;
67 }
68
69 public function getLocationURIForResourceUsage(ResourceIdentification $identification): ?string
70 {
71 $this->initDB();
72 $object_id = $this->resolveObjectId($identification);
73 if ($object_id !== null) {
74 $references = ilObject::_getAllReferences($object_id);
75 $ref_id = array_shift($references);
76
77 // 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.
78 return ilLink::_getLink($ref_id, 'exc');
79 }
80 return null;
81 }
82
83 private function isRecipient(ResourceIdentification $identification): bool
84 {
85 $this->initDB();
86 $r = $this->database->queryF(
87 "SELECT exc_mem_ass_status.usr_id FROM il_resource_rca JOIN exc_mem_ass_status ON exc_mem_ass_status.feedback_rcid = il_resource_rca.rcid WHERE il_resource_rca.rid = %s;",
88 ['text'],
89 [$identification->serialize()]
90 );
91 $d = $this->database->fetchAssoc($r);
92 $user_id = (int) ($d["usr_id"] ?? 0);
93
94 return ($user_id === $this->current_user);
95 }
96
97 private function resolveObjectId(ResourceIdentification $identification): ?int
98 {
99 $this->initDB();
100 $r = $this->database->queryF(
101 "SELECT exc_id, rcid FROM il_resource_rca JOIN exc_mem_ass_status ON exc_mem_ass_status.feedback_rcid = il_resource_rca.rcid JOIN exc_assignment ON (exc_assignment.id = exc_mem_ass_status.ass_id) WHERE il_resource_rca.rid = %s;",
102 ['text'],
103 [$identification->serialize()]
104 );
105 $d = $this->database->fetchObject($r);
106
107 return (isset($d->exc_id) ? (int) $d->exc_id : null);
108 }
109
110 private function initDB(): void
111 {
112 global $DIC;
113 if ($this->database === null) {
114 $this->database = $DIC->database();
115 }
116 }
117}
resourceHasBeenDeleted(ResourceIdentification $identification)
getLocationURIForResourceUsage(ResourceIdentification $identification)
resolveObjectId(ResourceIdentification $identification)
canBeAccessedByCurrentUser(ResourceIdentification $identification)
isRecipient(ResourceIdentification $identification)
static _getAllReferences(int $id)
get all reference ids for object ID
Interface ilDBInterface.
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26