Skip to content

Commit 162d135

Browse files
committed
Gradebook: Allow show flatview to HR users - refs BT#23089
1 parent 655c8f0 commit 162d135

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

main/gradebook/gradebook_flatview.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@
1010
api_protect_course_script(true);
1111

1212
api_block_anonymous_users();
13+
14+
$currentUserId = api_get_user_id();
15+
$sessionId = api_get_session_id();
16+
1317
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
14-
api_get_user_id(),
18+
$currentUserId,
1519
api_get_course_info()
1620
);
1721

18-
if (!$isDrhOfCourse) {
22+
$isDrhOfSession = $sessionId && !empty(SessionManager::getSessionFollowedByDrh($currentUserId, $sessionId));
23+
24+
if (!$isDrhOfCourse && !$isDrhOfSession) {
1925
GradebookUtils::block_students();
2026
}
2127

main/gradebook/lib/fe/displaygradebook.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ public static function header(
429429
}
430430

431431
// for course admin & platform admin add item buttons are added to the header
432+
$toolbarActions = [];
432433
$actionsLeft = '';
433434
$actionsRight = '';
434435
$my_api_cidreq = api_get_cidreq();
@@ -562,11 +563,13 @@ public static function header(
562563
}
563564

564565
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
565-
api_get_user_id(),
566+
$userId,
566567
api_get_course_info()
567568
);
568569

569-
if ($isDrhOfCourse) {
570+
$isDrhOfSession = $sessionId && !empty(SessionManager::getSessionFollowedByDrh($userId, $sessionId));
571+
572+
if ($isDrhOfCourse || $isDrhOfSession) {
570573
$actionsLeft .= '<a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'
571574
.Display::return_icon(
572575
'statistics.png',
@@ -578,9 +581,17 @@ public static function header(
578581
}
579582

580583
if ($isCoach || api_is_allowed_to_edit(null, true)) {
581-
echo $toolbar = Display::toolbarAction(
584+
$toolbarActions = [$actionsLeft, $actionsRight];
585+
}
586+
587+
if (empty($toolbarActions) && ($isDrhOfCourse || $isDrhOfSession)) {
588+
$toolbarActions = [$actionsLeft];
589+
}
590+
591+
if ($toolbarActions) {
592+
echo Display::toolbarAction(
582593
'gradebook-actions',
583-
[$actionsLeft, $actionsRight]
594+
$toolbarActions
584595
);
585596
}
586597

0 commit comments

Comments
 (0)