Skip to content

Commit 91f9823

Browse files
committed
Gradebook: Add a global page for the user to be able to see all the requirement in all its courses where a gradebook is set -refs BT#21224
1 parent 87f83bf commit 91f9823

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed

main/gradebook/all_my_gradebooks.php

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
3+
/* For licensing terms, see /license.txt */
4+
5+
$cidReset = true;
6+
require_once __DIR__.'/../inc/global.inc.php';
7+
8+
if (api_get_configuration_value('show_all_my_gradebooks_page') !== true) {
9+
api_not_allowed(true);
10+
}
11+
12+
// Setting the tabs
13+
$this_section = SECTION_COURSES;
14+
15+
$htmlHeadXtra[] = '<script>
16+
var show_icon = "'.Display::returnIconPath('view_more_stats.gif').'";
17+
var hide_icon = "'.Display::returnIconPath('view_less_stats.gif').'";
18+
19+
$(function() {
20+
$("body").on("click", ".view_children", function() {
21+
var id = $(this).attr("data-cat-id");
22+
$(".hidden_"+id).removeClass("hidden");
23+
$(this).removeClass("view_children");
24+
$(this).find("img").attr("src", hide_icon);
25+
$(this).attr("class", "hide_children");
26+
});
27+
28+
$("body").on("click", ".hide_children", function(event) {
29+
var id = $(this).attr("data-cat-id");
30+
$(".hidden_"+id).addClass("hidden");
31+
$(this).removeClass("hide_children");
32+
$(this).addClass("view_children");
33+
$(this).find("img").attr("src", show_icon);
34+
});
35+
36+
for (i=0;i<$(".actions").length;i++) {
37+
if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null || $(".actions:eq("+i+")").html().split("<TBODY></TBODY>").length==2) {
38+
$(".actions:eq("+i+")").hide();
39+
}
40+
}
41+
});
42+
</script>';
43+
44+
Display::display_header(get_lang('GlobalGradebook'));
45+
46+
api_block_anonymous_users();
47+
48+
$user_id = api_get_user_id();
49+
$userCoursesList = CourseManager::get_courses_list_by_user_id ($user_id, true, false, false, [], true, true);
50+
51+
foreach ($userCoursesList as $course) {
52+
$course_code = $course['code'];
53+
$stud_id = $user_id;
54+
$session_id = $course['session_id'];
55+
$course_id = $course['real_id'];
56+
$courseInfo = api_get_course_info($course_code);
57+
58+
if (!empty($course['session_name'])) {
59+
$title = "<h2>" . $courseInfo['title'] . " (" . $course['session_name'] . ")</h2>";
60+
} else {
61+
$title = "<h2>" . $courseInfo['title'] . "</h2>";
62+
}
63+
64+
$cats = Category::load(
65+
null,
66+
null,
67+
$course_code,
68+
null,
69+
null,
70+
$session_id,
71+
false
72+
);
73+
74+
$showTitle = true;
75+
foreach ($cats as $cat) {
76+
$allcat = $cat->get_subcategories($stud_id, $course_code, $session_id);
77+
$alleval = $cat->get_evaluations($stud_id, false, $course_code, $session_id);
78+
$alllink = $cat->get_links($stud_id, true, $course_code, $session_id);
79+
80+
if ($cat->get_parent_id() != 0) {
81+
$i++;
82+
} else {
83+
if (empty($allcat) && empty($alleval) && empty($alllink)) {
84+
continue;
85+
}
86+
if ($showTitle) {
87+
echo $title;
88+
$showTitle = false;
89+
}
90+
// This is the father
91+
// Create gradebook/add gradebook links.
92+
DisplayGradebook::header(
93+
$cat,
94+
0,
95+
$cat->get_id(),
96+
false,
97+
false,
98+
null,
99+
false,
100+
false,
101+
[]
102+
);
103+
104+
$gradebookTable = new GradebookTable(
105+
$cat,
106+
$allcat,
107+
$alleval,
108+
$alllink,
109+
null,
110+
false,
111+
null,
112+
api_get_user_id(),
113+
[],
114+
[]
115+
);
116+
117+
$table = '';
118+
$table = $gradebookTable->return_table();
119+
echo $table;
120+
}
121+
}
122+
}
123+

main/inc/lib/userportal.lib.php

+8
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,14 @@ public function return_profile_block()
948948
];
949949
}
950950

951+
if (api_get_configuration_value('show_all_my_gradebooks_page')) {
952+
$items[] = [
953+
'icon' => Display::return_icon('gradebook.png', get_lang('GlobalGradebook')),
954+
'link' => api_get_path(WEB_CODE_PATH).'gradebook/all_my_gradebooks.php',
955+
'title' => get_lang('GlobalGradebook'),
956+
];
957+
}
958+
951959
if (api_get_configuration_value('show_missing_signatures_page') && api_get_configuration_value('enable_sign_attendance_sheet')) {
952960
$items[] = [
953961
'icon' => Display::return_icon('attendance.png', get_lang('MyMissingSignatures')),

main/install/configuration.dist.php

+4
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,10 @@
11791179
// Hide gradebook "download report in PDF" button
11801180
// $_configuration['gradebook_hide_pdf_report_button'] = false;
11811181

1182+
// Shows a link to the "Global gradebooks" page in the /index.php and /user_portal.php page.
1183+
// It also enables the main/gradebook/all_my_gradebooks.php page.
1184+
//$_configuration['show_all_my_gradebooks_page'] = false;
1185+
11821186
// Show pending survey link in user menu
11831187
// $_configuration['show_pending_survey_in_menu'] = false;
11841188

0 commit comments

Comments
 (0)