Skip to content

Commit 12162e3

Browse files
committed
improve 47328: Failed test: Musterlösung
1 parent 44ecfd0 commit 12162e3

5 files changed

Lines changed: 78 additions & 0 deletions

File tree

components/ILIAS/Exercise/Assignment/class.ilExAssignment.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,8 @@ public static function sendFeedbackNotifications(
14761476
global $DIC;
14771477

14781478
$ilDB = $DIC->database();
1479+
$gui = $DIC->exercise()->internal()->gui();
1480+
$domain = $DIC->exercise()->internal()->domain();
14791481
$log = ilLoggerFactory::getLogger("exc");
14801482

14811483
$ass = new self($a_ass_id);
@@ -1504,6 +1506,24 @@ public static function sendFeedbackNotifications(
15041506
$ntf->setSubjectLangId("exc_feedback_notification_subject");
15051507
$ntf->setIntroductionLangId("exc_feedback_notification_body");
15061508
$ntf->addAdditionalInfo("exc_assignment", $ass->getTitle());
1509+
$ref_id = 0;
1510+
if ($a_user_id) { // link to assignment
1511+
$ref_id = $domain->permission()->getFirstRefIdWithPermission(
1512+
"read",
1513+
$ass->getExerciseId(),
1514+
$a_user_id
1515+
);
1516+
} else {
1517+
$ref_ids = ilObject::_getAllReferences($ass->getExerciseId());
1518+
if (count($ref_ids) === 1) {
1519+
$ref_id = current($ref_ids);
1520+
}
1521+
}
1522+
if ($ref_id > 0) {
1523+
$perm_link = $gui->permanentLink()->getPermanentLink($ref_id, $ass->getId());
1524+
$ntf->addAdditionalInfo("exc_link_to_assignment", $perm_link);
1525+
}
1526+
15071527
$ntf->setGotoLangId("exc_feedback_notification_link");
15081528
$ntf->setReasonLangId("exc_feedback_notification_reason");
15091529

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* This file is part of ILIAS, a powerful learning management system
5+
* published by ILIAS open source e-Learning e.V.
6+
*
7+
* ILIAS is licensed with the GPL-3.0,
8+
* see https://www.gnu.org/licenses/gpl-3.0.en.html
9+
* You should have received a copy of said license along with the
10+
* source code, too.
11+
*
12+
* If this is not the case or you just want to try ILIAS, you'll find
13+
* us at:
14+
* https://www.ilias.de
15+
* https://github.com/ILIAS-eLearning
16+
*
17+
*********************************************************************/
18+
19+
declare(strict_types=1);
20+
21+
namespace ILIAS\Exercise\Permission;
22+
23+
use ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder;
24+
use ILIAS\Exercise\InternalDomainService;
25+
26+
class PermissionManager
27+
{
28+
public function __construct(
29+
protected InternalDomainService $domain
30+
) {
31+
}
32+
33+
public function getFirstRefIdWithPermission(
34+
string $perm,
35+
int $obj_id,
36+
int $user_id
37+
): int {
38+
$access = $this->domain->access();
39+
40+
foreach (\ilObject::_getAllReferences($obj_id) as $ref_id) {
41+
if ($access->checkAccessOfUser($user_id, $perm, "", $ref_id)) {
42+
return $ref_id;
43+
}
44+
}
45+
return 0;
46+
}
47+
48+
}

components/ILIAS/Exercise/Service/classes/class.InternalDomainService.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use ILIAS\Exercise\PeerReview\DomainService;
3131
use ILIAS\Exercise\Settings\SettingsManager;
3232
use ILIAS\Exercise\User\UserEvent;
33+
use ILIAS\Exercise\Permission\PermissionManager;
3334

3435
class InternalDomainService
3536
{
@@ -136,4 +137,11 @@ public function userEvent(): UserEvent
136137
);
137138
}
138139

140+
public function permission(): PermissionManager
141+
{
142+
return $this->instance["perm"] ??= new PermissionManager(
143+
$this
144+
);
145+
}
146+
139147
}

lang/ilias_de.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9403,6 +9403,7 @@ exc#:#exc_late_submission_warning#:#Abgaben nach %s werden als verspätet gekenn
94039403
exc#:#exc_lead_request_idl#:#Abgabefrist anfragen
94049404
exc#:#exc_lead_wait_for_idl#:#Wartet auf individuelle Abgabefrist
94059405
exc#:#exc_limit_characters#:#Anzahl der Zeichen beschränken
9406+
exc#:#exc_link_to_assignment#:#Link zur Übungseinheit
94069407
exc#:#exc_list_submission#:#Alle Lösungsabgaben
94079408
exc#:#exc_list_text_assignment#:#Liste aller Abgaben
94089409
exc#:#exc_mail_context_grade_reminder_info#:#Personen, welche in einer Übungseinheit die Erinnerungen aktiviert haben, werden an die Bewertung der Einreichungen erinnert.

lang/ilias_en.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9377,6 +9377,7 @@ exc#:#exc_late_submission_warning#:#Submissions after %s are marked as late.
93779377
exc#:#exc_lead_request_idl#:#Request Deadline
93789378
exc#:#exc_lead_wait_for_idl#:#Waiting For Individual Deadline
93799379
exc#:#exc_limit_characters#:#Limit of characters
9380+
exc#:#exc_link_to_assignment#:#Link to assignment
93809381
exc#:#exc_list_submission#:#List All Submissions
93819382
exc#:#exc_list_text_assignment#:#List All Submissions
93829383
exc#:#exc_mail_context_grade_reminder_info#:#Reminder Tutors/Teachers to Grade an Assignment

0 commit comments

Comments
 (0)