Skip to content

Commit 7518a6b

Browse files
committed
WIP: Improve left navigation bar see #2215
- Left menu code centralized in one function. - New language translation added "EventsReport" - @todo missing icon.
1 parent c60cbcd commit 7518a6b

File tree

8 files changed

+130
-125
lines changed

8 files changed

+130
-125
lines changed

main/inc/lib/tracking.lib.php

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7566,4 +7566,115 @@ public static function getTotalTimeReport(
75667566
return $users;
75677567
}
75687568

7569+
/**
7570+
* @param string $current
7571+
*/
7572+
public static function actionsLeft($current, $sessionId = 0)
7573+
{
7574+
$usersLink = Display::url(
7575+
Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM),
7576+
'courseLog.php?'.api_get_cidreq(true, false)
7577+
);
7578+
7579+
$groupsLink = Display::url(
7580+
Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
7581+
'course_log_groups.php?'.api_get_cidreq()
7582+
);
7583+
7584+
$resourcesLink = Display::url(
7585+
Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM),
7586+
'course_log_resources.php?'.api_get_cidreq(true, false)
7587+
);
7588+
7589+
$courseLink = Display::url(
7590+
Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
7591+
'course_log_tools.php?'.api_get_cidreq(true, false)
7592+
);
7593+
7594+
$examLink = Display::url(
7595+
Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), ICON_SIZE_MEDIUM),
7596+
api_get_path(WEB_CODE_PATH).'tracking/exams.php?'.api_get_cidreq()
7597+
);
7598+
7599+
$eventsLink = Display::url(
7600+
Display::return_icon('changeme.png', get_lang('EventsReport'), array(), ICON_SIZE_MEDIUM),
7601+
api_get_path(WEB_CODE_PATH).'tracking/course_log_events.php?'.api_get_cidreq()
7602+
);
7603+
7604+
$attendanceLink = '';
7605+
if (!empty($sessionId)) {
7606+
$attendanceLink = Display::url(
7607+
Display::return_icon('attendance_list.png', get_lang('Logins'), '', ICON_SIZE_MEDIUM),
7608+
api_get_path(WEB_CODE_PATH).'attendance/index.php?'.api_get_cidreq().'&action=calendar_logins'
7609+
);
7610+
}
7611+
7612+
switch ($current) {
7613+
case 'users':
7614+
$usersLink = Display::url(
7615+
Display::return_icon(
7616+
'user_na.png',
7617+
get_lang('StudentsTracking'),
7618+
array(),
7619+
ICON_SIZE_MEDIUM
7620+
),
7621+
'#'
7622+
);
7623+
break;
7624+
case 'groups':
7625+
$groupsLink = Display::url(
7626+
Display::return_icon('group_na.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
7627+
'#'
7628+
);
7629+
break;
7630+
case 'courses':
7631+
$courseLink = Display::url(
7632+
Display::return_icon('course_na.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
7633+
'#'
7634+
);
7635+
break;
7636+
case 'resources':
7637+
$resourcesLink = Display::url(
7638+
Display::return_icon(
7639+
'tools_na.png',
7640+
get_lang('ResourcesTracking'),
7641+
array(),
7642+
ICON_SIZE_MEDIUM
7643+
), '#'
7644+
);
7645+
break;
7646+
case 'exams':
7647+
$examLink = Display::url(
7648+
Display::return_icon('quiz_na.png', get_lang('ExamTracking'), array(), ICON_SIZE_MEDIUM),
7649+
'#'
7650+
);
7651+
break;
7652+
case 'logs':
7653+
$eventsLink = Display::url(
7654+
Display::return_icon('changeme_na.png', get_lang('EventsReport'), array(), ICON_SIZE_MEDIUM),
7655+
'#'
7656+
);
7657+
break;
7658+
case 'attendance':
7659+
if (!empty($sessionId)) {
7660+
$attendanceLink = Display::url(
7661+
Display::return_icon('attendance_list.png', get_lang('Logins'), '', ICON_SIZE_MEDIUM),
7662+
'#'
7663+
);
7664+
}
7665+
break;
7666+
}
7667+
7668+
$items = [
7669+
$usersLink,
7670+
$groupsLink,
7671+
$courseLink,
7672+
$resourcesLink,
7673+
$examLink,
7674+
$eventsLink,
7675+
$attendanceLink
7676+
];
7677+
7678+
return implode('', $items).' ';
7679+
}
75697680
}

main/tracking/courseLog.php

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* @package chamilo.tracking
88
*/
99

10-
$pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
11-
12-
// Including the global initialization file
1310
require_once __DIR__.'/../inc/global.inc.php';
1411
$current_course_tool = TOOL_TRACKING;
1512

@@ -219,36 +216,7 @@ function(index) {
219216

220217
/* MAIN CODE */
221218

222-
$actionsLeft = Display::return_icon(
223-
'user_na.png',
224-
get_lang('StudentsTracking'),
225-
array(),
226-
ICON_SIZE_MEDIUM
227-
);
228-
$actionsLeft .= Display::url(
229-
Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
230-
'course_log_groups.php?'.api_get_cidreq()
231-
);
232-
$actionsLeft .= Display::url(
233-
Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
234-
'course_log_tools.php?'.api_get_cidreq()
235-
);
236-
237-
$actionsLeft .= Display::url(
238-
Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM),
239-
'course_log_resources.php?'.api_get_cidreq()
240-
);
241-
$actionsLeft .= Display::url(
242-
Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), ICON_SIZE_MEDIUM),
243-
api_get_path(WEB_CODE_PATH).'tracking/exams.php?'.api_get_cidreq()
244-
);
245-
246-
if (!empty($sessionId)) {
247-
$actionsLeft .= Display::url(
248-
Display::return_icon('attendance_list.png', get_lang('Logins'), '', ICON_SIZE_MEDIUM),
249-
api_get_path(WEB_CODE_PATH).'attendance/index.php?'.api_get_cidreq().'&action=calendar_logins'
250-
);
251-
}
219+
$actionsLeft = TrackingCourseLog::actionsLeft('users', $sessionId);
252220

253221
$actionsRight = '<div class="pull-right">';
254222
$actionsRight .= '<a href="javascript: void(0);" onclick="javascript: window.print();">'.
@@ -309,6 +277,7 @@ function(index) {
309277
ICON_SIZE_SMALL
310278
).' '.$courseInfo['name'];
311279
}
280+
312281
$teacherList = CourseManager::getTeacherListFromCourseCodeToString(
313282
$courseInfo['code'],
314283
',',
@@ -542,6 +511,7 @@ function(index) {
542511
}
543512

544513
echo Display::panel($html, $titleSession);
514+
545515
// Send the csv file if asked.
546516
if ($export_csv) {
547517
$csv_headers = [];

main/tracking/course_log_events.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,8 @@
128128
Display::display_header();
129129

130130
echo '<div class="actions">';
131-
echo Display::url(
132-
Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM),
133-
'courseLog.php?'.api_get_cidreq(true, false)
134-
);
135-
echo Display::url(Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM), '#');
136-
echo Display::url(
137-
Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
138-
'course_log_tools.php?'.api_get_cidreq(true, false)
139-
);
140-
echo Display::url(
141-
Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM),
142-
'course_log_resources.php?'.api_get_cidreq(true, false)
143-
);
131+
echo TrackingCourseLog::actionsLeft('logs', api_get_session_id());
132+
144133
echo '</div>';
145134

146135
$form = new FormValidator(

main/tracking/course_log_groups.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,7 @@ function action_formatter(cellvalue, options, rowObject) {
125125
Display::display_header();
126126

127127
echo '<div class="actions">';
128-
echo Display::url(
129-
Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM),
130-
'courseLog.php?'.api_get_cidreq(true, false)
131-
);
132-
echo Display::url(Display::return_icon('group_na.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM), '#');
133-
echo Display::url(
134-
Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
135-
'course_log_tools.php?'.api_get_cidreq(true, false)
136-
);
137-
echo Display::url(
138-
Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM),
139-
'course_log_resources.php?'.api_get_cidreq(true, false)
140-
);
128+
echo TrackingCourseLog::actionsLeft('groups', $sessionId);
141129
echo '</div>';
142130

143131
echo Display::grid_html('group_users');

main/tracking/course_log_resources.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,7 @@ function (&$item) {
9999
Display::display_header($nameTools, 'Tracking');
100100

101101
echo '<div class="actions">';
102-
echo Display::url(
103-
Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM),
104-
api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?'.api_get_cidreq()
105-
);
106-
107-
echo Display::url(
108-
Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
109-
'course_log_groups.php?'.api_get_cidreq(true, false)
110-
);
111-
112-
echo Display::url(
113-
Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
114-
api_get_path(WEB_CODE_PATH).'tracking/course_log_tools.php?'.api_get_cidreq()
115-
);
116-
117-
echo Display::return_icon('tools_na.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM);
102+
echo TrackingCourseLog::actionsLeft('resources', api_get_session_id());
118103
echo '<span style="float:right; padding-top:0px;">';
119104
echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.
120105
Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).

main/tracking/course_log_tools.php

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -105,35 +105,7 @@
105105

106106
echo '<div class="actions">';
107107

108-
echo Display::url(
109-
Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM),
110-
'courseLog.php?'.api_get_cidreq()
111-
);
112-
113-
if (empty($groupId)) {
114-
echo Display::url(
115-
Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
116-
'course_log_groups.php?'.api_get_cidreq()
117-
);
118-
echo Display::url(
119-
Display::return_icon('course_na.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
120-
'#'
121-
);
122-
} else {
123-
echo Display::url(
124-
Display::return_icon('group_na.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
125-
'#'
126-
);
127-
echo Display::url(
128-
Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
129-
'course_log_tools.php?'.api_get_cidreq(true, false).'&gidReq=0'
130-
);
131-
}
132-
133-
echo Display::url(
134-
Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM),
135-
'course_log_resources.php?'.api_get_cidreq()
136-
);
108+
echo TrackingCourseLog::actionsLeft('courses', api_get_session_id());
137109

138110
echo '<span style="float:right; padding-top:0px;">';
139111
echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.

main/tracking/exams.php

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,8 @@
116116
}
117117
}
118118
} else {
119-
$actionsLeft .= Display::url(
120-
Display::return_icon('user.png', get_lang('StudentsTracking'), array(), 32),
121-
'courseLog.php?'.api_get_cidreq().'&studentlist=true'
122-
);
123-
$actionsLeft .= Display::url(
124-
Display::return_icon('course.png', get_lang('CourseTracking'), array(), 32),
125-
'courseLog.php?'.api_get_cidreq().'&studentlist=false'
126-
);
127-
$actionsLeft .= Display::url(
128-
Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), 32),
129-
'courseLog.php?'.api_get_cidreq().'&studentlist=resouces'
130-
);
119+
$actionsLeft = TrackingCourseLog::actionsLeft('exams', api_get_session_id());
120+
131121
$actionsLeft .= Display::url(
132122
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), array(), 32),
133123
api_get_self().'?'.api_get_cidreq().'&export=1&score='.$filter_score.'&exercise_id='.$exerciseId
@@ -290,10 +280,12 @@
290280
);
291281

292282
$html .= $result['html'];
293-
$export_array_global = array_merge(
294-
$export_array_global,
295-
$result['export_array_global']
296-
);
283+
if (is_array($result['export_array_global'])) {
284+
$export_array_global = array_merge(
285+
$export_array_global,
286+
$result['export_array_global']
287+
);
288+
}
297289
} else {
298290
$result = processStudentList(
299291
$filter_score,
@@ -542,8 +534,9 @@ function processStudentList($filter_score, $global, $exercise, $courseInfo, $ses
542534

543535
$total_with_parameter_score = 0;
544536
$taken = 0;
545-
$export_array_global = array();
546-
$studentResult = array();
537+
$export_array_global = [];
538+
$studentResult = [];
539+
$export_array = [];
547540

548541
foreach ($students as $student) {
549542
$studentId = isset($student['user_id']) ? $student['user_id'] : $student['id_user'];

main/tracking/total_time.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* @package chamilo.tracking
88
*/
99

10-
$pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
11-
12-
// Including the global initialization file
1310
require_once __DIR__.'/../inc/global.inc.php';
1411
$current_course_tool = TOOL_TRACKING;
1512

0 commit comments

Comments
 (0)