ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SampleSolutionRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
27{
29 protected \ilDBInterface $db;
30
31 public function __construct(
34 ) {
35 $this->db = $db;
36 $this->wrapper = $wrapper;
37 }
38
39 public function getIdStringForAssId(int $ass_id): string
40 {
41 $set = $this->db->queryF(
42 "SELECT solution_rid FROM exc_assignment " .
43 " WHERE id = %s ",
44 ["integer"],
45 [$ass_id]
46 );
47 $rec = $this->db->fetchAssoc($set);
48 return ($rec["solution_rid"] ?? "");
49 }
50
51 public function hasFile(int $ass_id): bool
52 {
53 $rid = $this->getIdStringForAssId($ass_id);
54 return ($rid !== "");
55 }
56
57 public function deliverFile(int $ass_id): void
58 {
59 $rid = $this->getIdStringForAssId($ass_id);
60 $this->wrapper->deliverFile($rid);
61 }
62
63 public function getFilename(int $ass_id): string
64 {
65 $rid = $this->getIdStringForAssId($ass_id);
66 if ($rid !== "") {
67 $info = $this->wrapper->getResourceInfo($rid);
68 return $info->getTitle();
69 }
70 return "";
71 }
72
73
74 public function importFromLegacyUpload(
75 int $ass_id,
76 array $file_input,
77 ResourceStakeholder $stakeholder
78 ): string {
79 $rcid = $this->wrapper->importFileFromLegacyUpload(
80 $file_input,
81 $stakeholder
82 );
83 if ($rcid !== "") {
84 $this->db->update(
85 "exc_assignment",
86 [
87 "fb_file" => ["text", $file_input["name"]],
88 "solution_rid" => ["text", $rcid]
89 ],
90 [ // where
91 "id" => ["integer", $ass_id]
92 ]
93 );
94 }
95 return $rcid;
96 }
97
98 public function clone(
99 int $from_ass_id,
100 int $to_ass_id
101 ): void {
102 $from_rid = $this->getIdStringForAssId($from_ass_id);
103 $to_rid = $this->wrapper->cloneResource($from_rid);
104 if ($to_rid !== "") {
105 $this->db->update(
106 "exc_assignment",
107 [
108 "solution_rid" => ["text", $to_rid]
109 ],
110 [ // where
111 "id" => ["integer", $to_ass_id]
112 ]
113 );
114 }
115 }
116}
__construct(IRSSWrapper $wrapper, \ilDBInterface $db)
importFromLegacyUpload(int $ass_id, array $file_input, ResourceStakeholder $stakeholder)
$info
Definition: entry_point.php:21
Interface ilDBInterface.