ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExcSubmissionStakeholder.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_submission';
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 if ($object_id === null) {
43 return true;
44 }
45
46 $ref_ids = ilObject2::_getAllReferences($object_id);
47 foreach ($ref_ids as $ref_id) {
48 // one must have write permissions on the exercise to see the submission
49 if (
50 $DIC->access()->checkAccessOfUser($this->current_user, 'read', '', $ref_id) ||
51 $DIC->access()->checkAccessOfUser($this->current_user, 'write', '', $ref_id)) {
52 return true;
53 }
54 }
55
56 return false;
57 }
58
59 public function resourceHasBeenDeleted(ResourceIdentification $identification): bool
60 {
61 // at this place we could handle de deletion of a resource. not needed for instruction files IMO.
62
63 return true;
64 }
65
66 public function getLocationURIForResourceUsage(ResourceIdentification $identification): ?string
67 {
68 $this->initDB();
69 $object_id = $this->resolveObjectId($identification);
70 if ($object_id !== null) {
71 $references = ilObject::_getAllReferences($object_id);
72 $ref_id = array_shift($references);
73
74 // 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.
75 return ilLink::_getLink($ref_id, 'exc');
76 }
77 return null;
78 }
79
80 private function resolveObjectId(ResourceIdentification $identification): ?int
81 {
82 $this->initDB();
83 $r = $this->database->queryF(
84 "SELECT obj_id FROM exc_returned WHERE exc_returned.solution_rid = %s;",
85 ['text'],
86 [$identification->serialize()]
87 );
88 $d = $this->database->fetchObject($r);
89
90 return (isset($d->obj_id) ? (int) $d->obj_id : null);
91 }
92
93 private function initDB(): void
94 {
95 global $DIC;
96 if ($this->database === null) {
97 $this->database = $DIC->database();
98 }
99 }
100}
getLocationURIForResourceUsage(ResourceIdentification $identification)
resourceHasBeenDeleted(ResourceIdentification $identification)
resolveObjectId(ResourceIdentification $identification)
canBeAccessedByCurrentUser(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