ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager Class Reference
+ Collaboration diagram for ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager:

Public Member Functions

 __construct (InternalRepoService $repo, InternalDomainService $domain, \ilExcTutorFeedbackZipStakeholder $stakeholder, \ilExcTutorFeedbackFileStakeholder $user_feedback_stakeholder)
 
 getMultiFeedbackStructureFile (\ilExAssignment $assignment, \ilObjExercise $exercise)
 
 importFromUploadResult (int $ass_id, int $tutor_id, UploadResult $result)
 
 getFiles (\ilObjExercise $exc, int $ass_id, int $tutor_id)
 
 getFileMd5 (int $user_id, string $filename)
 
 saveMultiFeedbackFiles (\ilObjExercise $exc, int $ass_id, int $tutor_id, array $file_md5s)
 

Protected Member Functions

 toAscii (string $filename)
 

Protected Attributes

ilExcTutorFeedbackFileStakeholder $user_feedback_stakeholder
 
TutorFeedbackFileRepository $participant_repo
 
ilExcTutorFeedbackZipStakeholder $stakeholder
 
int $ass_id
 
InternalDomainService $domain
 
TutorFeedbackZipRepository $repo
 

Detailed Description

Definition at line 27 of file TutorFeedbackZipManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::__construct ( InternalRepoService  $repo,
InternalDomainService  $domain,
\ilExcTutorFeedbackZipStakeholder  $stakeholder,
\ilExcTutorFeedbackFileStakeholder  $user_feedback_stakeholder 
)

Member Function Documentation

◆ getFileMd5()

ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::getFileMd5 ( int  $user_id,
string  $filename 
)

Definition at line 115 of file TutorFeedbackZipManager.php.

Referenced by ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager\saveMultiFeedbackFiles().

115  : string
116  {
117  return md5($user_id . ":" . $filename);
118  }
$filename
Definition: buildRTE.php:78
+ Here is the caller graph for this function:

◆ getFiles()

ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::getFiles ( \ilObjExercise  $exc,
int  $ass_id,
int  $tutor_id 
)

Definition at line 107 of file TutorFeedbackZipManager.php.

Referenced by ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager\saveMultiFeedbackFiles().

107  : array
108  {
109  $exmem = new \ilExerciseMembers($exc);
110  $mems = $exmem->getMembers();
111 
112  return $this->repo->getFiles($ass_id, $tutor_id, $mems);
113  }
+ Here is the caller graph for this function:

◆ getMultiFeedbackStructureFile()

ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::getMultiFeedbackStructureFile ( \ilExAssignment  $assignment,
\ilObjExercise  $exercise 
)

Definition at line 55 of file TutorFeedbackZipManager.php.

References $res, ilObjUser\_lookupName(), ilExAssignment\getId(), ilObject\getRefId(), ilExAssignment\getTitle(), and ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager\toAscii().

58  : object {
59  $access = $this->domain->access();
60  $exmem = new \ilExerciseMembers($exercise);
61 
62  $tmp_file = tmpfile();
63  $tmp_location = stream_get_meta_data($tmp_file)['uri'];
64  $zip = new \ZipArchive();
65  $res = $zip->open($tmp_location, \ZipArchive::OVERWRITE);
66 
67  // send and delete the zip file
68  $base_name = trim(str_replace(" ", "_", $assignment->getTitle() . "_" . $assignment->getId()));
69  $base_name = "multi_feedback_" . $this->toAscii($base_name);
70 
71  // create subfolders <lastname>_<firstname>_<id> for each participant
72  $mems = $exmem->getMembers();
73 
74  $mems = $access->filterUserIdsByRbacOrPositionOfCurrentUser(
75  'edit_submissions_grades',
76  'edit_submissions_grades',
77  $exercise->getRefId(),
78  $mems
79  );
80  foreach ($mems as $mem) {
81  $name = \ilObjUser::_lookupName($mem);
82  $subdir = $name["lastname"] . "_" . $name["firstname"] . "_" . $name["login"] . "_" . $name["user_id"];
83  $subdir = $this->toAscii($subdir);
84  $zip->addEmptyDir($base_name . "/" . $subdir);
85  }
86  $zip->close();
87  $ret = new \StdClass();
88  $ret->content = file_get_contents($tmp_location);
89  $ret->filename = $base_name . ".zip";
90  return $ret;
91  }
$res
Definition: ltiservices.php:66
static _lookupName(int $a_user_id)
lookup user name
+ Here is the call graph for this function:

◆ importFromUploadResult()

ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::importFromUploadResult ( int  $ass_id,
int  $tutor_id,
UploadResult  $result 
)

Definition at line 93 of file TutorFeedbackZipManager.php.

97  : string {
98  $this->repo->deleteCurrent($ass_id, $tutor_id, $this->stakeholder);
99  return $this->repo->importFromUploadResult(
100  $ass_id,
101  $tutor_id,
102  $result,
103  $this->stakeholder
104  );
105  }

◆ saveMultiFeedbackFiles()

ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::saveMultiFeedbackFiles ( \ilObjExercise  $exc,
int  $ass_id,
int  $tutor_id,
array  $file_md5s 
)

Definition at line 120 of file TutorFeedbackZipManager.php.

References $user_id, ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager\getFileMd5(), ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager\getFiles(), ilObject\getRefId(), ILIAS\Repository\int(), and null.

125  {
126  $notification = $this->domain->notification($exc->getRefId());
127  foreach ($this->getFiles($exc, $ass_id, $tutor_id) as $file) {
128  $user_id = (int) $file["user_id"];
129  $md5 = $this->getFileMd5((int) $file["user_id"], $file["file"]);
130  if (is_array($file_md5s[$user_id] ?? null) && in_array($md5, $file_md5s[$user_id])) {
131  $target_collection = $this->participant_repo->getCollection($ass_id, $user_id);
132  if ($target_collection) {
133  $this->repo->addFileFromZipToCollection(
134  $ass_id,
135  $tutor_id,
136  $file["full_entry"],
137  $target_collection,
138  $this->user_feedback_stakeholder
139  );
140  }
141 
142  $ass = new \ilExAssignment($ass_id);
143  $submission = new \ilExSubmission($ass, $user_id);
144  $feedback_id = $submission->getFeedbackId();
145  $noti_rec_ids = $submission->getUserIds();
146 
147  if ($feedback_id) {
148  if ($noti_rec_ids) {
149  foreach ($noti_rec_ids as $user_id) {
150  $member_status = $ass->getMemberStatus($user_id);
151  $member_status->setFeedback(true);
152  $member_status->update();
153  }
154 
155  $notification->sendFeedbackNotification(
156  $ass->getId(),
157  $noti_rec_ids,
158  $file["file"]
159  );
160  }
161  }
162  }
163  }
164  }
getFiles(\ilObjExercise $exc, int $ass_id, int $tutor_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ toAscii()

ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::toAscii ( string  $filename)
protected

Definition at line 49 of file TutorFeedbackZipManager.php.

References $DIC.

Referenced by ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager\getMultiFeedbackStructureFile().

49  : string
50  {
51  global $DIC;
52  return (new \ilFileServicesPolicy($DIC->fileServiceSettings()))->ascii($filename);
53  }
Class ilFileServicesPolicy.
global $DIC
Definition: shib_login.php:22
$filename
Definition: buildRTE.php:78
+ Here is the caller graph for this function:

Field Documentation

◆ $ass_id

int ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::$ass_id
protected

Definition at line 32 of file TutorFeedbackZipManager.php.

◆ $domain

InternalDomainService ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::$domain
protected

◆ $participant_repo

TutorFeedbackFileRepository ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::$participant_repo
protected

Definition at line 30 of file TutorFeedbackZipManager.php.

◆ $repo

TutorFeedbackZipRepository ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::$repo
protected

Definition at line 34 of file TutorFeedbackZipManager.php.

◆ $stakeholder

ilExcTutorFeedbackZipStakeholder ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::$stakeholder
protected

◆ $user_feedback_stakeholder

ilExcTutorFeedbackFileStakeholder ILIAS\Exercise\TutorFeedbackFile\TutorFeedbackZipManager::$user_feedback_stakeholder
protected

The documentation for this class was generated from the following file: