ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
TutorFeedbackFileRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
29{
32 protected \ilDBInterface $db;
33
34 public function __construct(
37 ) {
38 $this->db = $db;
39 $this->wrapper = $wrapper;
40 }
41
42 public function createCollection(int $ass_id, int $user_id): void
43 {
44 /*
45 if ($ass_id === 12) {
46 debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10);
47 exit;
48 }*/
49 $new_id = $this->wrapper->createEmptyCollection();
50 $this->db->update(
51 "exc_mem_ass_status",
52 [
53 "feedback_rcid" => ["text", $new_id]
54 ],
55 [ // where
56 "ass_id" => ["integer", $ass_id],
57 "usr_id" => ["integer", $user_id]
58 ]
59 );
60 }
61
62 public function getIdStringForAssIdAndUserId(int $ass_id, int $user_id): string
63 {
64 $set = $this->db->queryF(
65 "SELECT feedback_rcid FROM exc_mem_ass_status " .
66 " WHERE ass_id = %s AND usr_id = %s",
67 ["integer", "integer"],
69 );
70 $rec = $this->db->fetchAssoc($set);
71 return ($rec["feedback_rcid"] ?? "");
72 }
73
74 public function hasCollection(int $ass_id, int $user_id): bool
75 {
76 $rcid = $this->getIdStringForAssIdAndUserId($ass_id, $user_id);
77 return ($rcid !== "");
78 }
79
81 {
82 $rcid = $this->getIdStringForAssIdAndUserId($ass_id, $user_id);
83 if ($rcid !== "") {
84 // 93fd5322-6a06-464d-b233-1f20da4b596f
85 return $this->wrapper->getCollectionForIdString($rcid);
86 }
87 return null;
88 }
89
90 public function count(int $ass_id, int $user_id): int
91 {
92 if (!is_null($collection = $this->getCollection($ass_id, $user_id))) {
93 return $collection->count();
94 }
95 return 0;
96 }
97
98 public function deliverFile($ass_id, $participant_id, $file): void
99 {
101 foreach ($this->getCollectionResourcesInfo($ass_id, $participant_id) as $info) {
102 if ($file === $info->getTitle()) {
103 $this->wrapper->deliverFile($info->getRid());
104 }
105 }
106 throw new \ilExerciseException("Resource $file not found.");
107 }
108
109 public function getFilenameForRid(int $ass_id, int $part_id, string $rid): string
110 {
111 foreach ($this->getCollectionResourcesInfo($ass_id, $part_id) as $info) {
112 if ($rid === $info->getRid()) {
113 return $info->getTitle();
114 }
115 }
116 return "";
117 }
118
119 public function getParticipantIdForRcid(int $ass_id, string $rcid): int
120 {
121 $set = $this->db->queryF(
122 "SELECT usr_id FROM exc_mem_ass_status " .
123 " WHERE ass_id = %s AND feedback_rcid = %s",
124 ["integer", "text"],
125 [$ass_id, $rcid]
126 );
127 $rec = $this->db->fetchAssoc($set);
128 return (int) ($rec["usr_id"] ?? 0);
129 }
130
135 int $ass_id,
136 int $user_id
137 ): \Generator {
139 return $this->wrapper->getCollectionResourcesInfo($collection);
140 }
141
142 public function deleteCollection(
143 int $ass_id,
144 int $user_id,
145 ResourceStakeholder $stakeholder
146 ): void {
147 $rcid = $this->getIdStringForAssIdAndUserId($ass_id, $user_id);
148 if ($rcid === "") {
149 return;
150 }
151 $this->wrapper->deleteCollectionForIdString(
152 $rcid,
153 $stakeholder
154 );
155 }
156}
deleteCollection(int $ass_id, int $user_id, ResourceStakeholder $stakeholder)
$info
Definition: entry_point.php:21
Interface ilDBInterface.