diff --git a/main/admin/usergroup_users.php b/main/admin/usergroup_users.php index fb8580227e..fc5f1d0b68 100644 --- a/main/admin/usergroup_users.php +++ b/main/admin/usergroup_users.php @@ -133,13 +133,14 @@ $column_model = [ ]; if (api_get_plugin_setting('lp_calendar', 'enabled') === 'true') { + $calendarPlugin = LpCalendarPlugin::create(); $columns = [ get_lang('Name'), get_lang('Calendar'), - get_lang('Examn'), - get_lang('TimeSpentInTheCourse'), - get_lang('Jours de parcours réalisés'), - get_lang('Différence de nombre de jours avec le plan issu du learning_calendar '), + get_lang('ClassroomActivity'), + get_lang('TimeSpentByStudentsInCourses'), + $calendarPlugin->get_lang('NumberDaysAccumulatedInCalendar'), + $calendarPlugin->get_lang('DifferenceOfDaysAndCalendar'), get_lang('Actions'), ]; @@ -154,7 +155,13 @@ if (api_get_plugin_setting('lp_calendar', 'enabled') === 'true') { 'sortable' => 'false', 'formatter' => 'extra_formatter', ], - ['name' => 'examn', 'index' => 'examn', 'width' => '35', 'align' => 'left', 'sortable' => 'false'], + [ + 'name' => 'gradebook_items', + 'index' => 'gradebook_items', + 'width' => '35', + 'align' => 'left', + 'sortable' => 'false', + ], ['name' => 'time_spent', 'index' => 'time_spent', 'width' => '35', 'align' => 'left', 'sortable' => 'false'], [ 'name' => 'lp_day_completed', diff --git a/main/extra/myStudents.php b/main/extra/myStudents.php index ca331dd7d3..99d0f78e05 100644 --- a/main/extra/myStudents.php +++ b/main/extra/myStudents.php @@ -9,8 +9,8 @@ if (empty($allow)) { } api_block_anonymous_users(); -$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false; -$course_code = isset($_GET['course']) ? Security:: remove_XSS($_GET['course']) : null; +$export_csv = isset($_GET['export']) && $_GET['export'] === 'csv' ? true : false; +$course_code = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null; $_course = api_get_course_info(); $coment = ''; @@ -217,7 +217,7 @@ switch ($action) { } break; case 'reset_lp': - $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : ''; + $lp_id = isset($_GET['lp_id']) ? (int) $_GET['lp_id'] : ''; if (api_is_allowed_to_edit() && !empty($lp_id) && @@ -273,8 +273,8 @@ if (api_is_session_admin() || api_is_drh()) { // Teacher or admin if (!empty($sessions_coached_by_user)) { foreach ($sessions_coached_by_user as $session_coached_by_user) { - $sid = intval($session_coached_by_user['id']); - $courses_followed_by_coach = Tracking:: get_courses_followed_by_coach(api_get_user_id(), $sid); + $sid = (int) $session_coached_by_user['id']; + $courses_followed_by_coach = Tracking::get_courses_followed_by_coach(api_get_user_id(), $sid); $courses_in_session_by_coach[$sid] = $courses_followed_by_coach; } } diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 0cf9f5b5e1..af118ab826 100755 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -796,7 +796,7 @@ switch ($action) { $columns = [ 'name', 'calendar', - 'examn', + 'gradebook_items', 'time_spent', 'lp_day_completed', 'days_diff', diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index f68bf89ede..7413651473 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -5417,7 +5417,8 @@ class Tracking $pluginCalendar = api_get_plugin_setting('lp_calendar', 'enabled') === 'true'; if ($pluginCalendar) { $course_in_session[0] = $courseIdList; - $html .= LpCalendarPlugin::getUserStatsPanel($user_id, $course_in_session); + $plugin = LpCalendarPlugin::create(); + $html .= $plugin->getUserStatsPanel($user_id, $course_in_session); } return $html; diff --git a/main/inc/lib/usergroup.lib.php b/main/inc/lib/usergroup.lib.php index f965eadb11..384b39423d 100755 --- a/main/inc/lib/usergroup.lib.php +++ b/main/inc/lib/usergroup.lib.php @@ -131,7 +131,7 @@ class UserGroup extends Model $stats = LpCalendarPlugin::getUserStats($userId, $courseAndSessionList); - $data['examn'] = 'examn'; + $data['gradebook_items'] = '@todo'; $totalTime = 0; foreach ($courseAndSessionList as $sessionId => $course) { foreach ($course as $courseId) { @@ -140,11 +140,8 @@ class UserGroup extends Model } $data['time_spent'] = api_time_to_hms($totalTime); - $data['lp_day_completed'] = $stats['completed']; $data['days_diff'] = $stats['diff']; - - } $data['id'] = $data['user_id']; $list[] = $data; diff --git a/main/mySpace/index.php b/main/mySpace/index.php index 9fe9571eca..ab3b6e2334 100755 --- a/main/mySpace/index.php +++ b/main/mySpace/index.php @@ -101,8 +101,9 @@ if ($is_platform_admin) { $pluginCalendar = api_get_plugin_setting('lp_calendar', 'enabled') === 'true'; if ($pluginCalendar) { + $lpCalendar = LpCalendarPlugin::create(); $menu_items[] = Display::url( - Display::return_icon('agenda.png', get_lang('LearningCalendar'), [], ICON_SIZE_MEDIUM), + Display::return_icon('agenda.png', $lpCalendar->get_lang('LearningCalendar'), [], ICON_SIZE_MEDIUM), api_get_path(WEB_PLUGIN_PATH).'lp_calendar/start.php' ); } diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index b0fa891c8f..5701ff9f13 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -16,7 +16,7 @@ require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); $export = isset($_GET['export']) ? $_GET['export'] : false; -$sessionId = isset($_GET['id_session']) ? intval($_GET['id_session']) : 0; +$sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0; $origin = api_get_origin(); $course_code = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : ''; $courseInfo = api_get_course_info($course_code); @@ -367,7 +367,7 @@ if (api_is_session_admin() || api_is_drh()) { // Teacher or admin if (!empty($sessions_coached_by_user)) { foreach ($sessions_coached_by_user as $session_coached_by_user) { - $sid = intval($session_coached_by_user['id']); + $sid = (int) $session_coached_by_user['id']; $courses_followed_by_coach = Tracking::get_courses_followed_by_coach(api_get_user_id(), $sid); $courses_in_session_by_coach[$sid] = $courses_followed_by_coach; } @@ -1875,7 +1875,7 @@ if ($allow && (api_is_drh() || api_is_platform_admin())) { $pluginCalendar = api_get_plugin_setting('lp_calendar', 'enabled') === 'true'; if ($pluginCalendar) { $plugin = LpCalendarPlugin::create(); - echo LpCalendarPlugin::getUserStatsPanel($student_id, $courses_in_session); + echo $plugin->getUserStatsPanel($student_id, $courses_in_session); } if ($export) { diff --git a/plugin/lp_calendar/LpCalendarPlugin.php b/plugin/lp_calendar/LpCalendarPlugin.php index 909f6b4745..c380b5e8b8 100644 --- a/plugin/lp_calendar/LpCalendarPlugin.php +++ b/plugin/lp_calendar/LpCalendarPlugin.php @@ -257,7 +257,7 @@ class LpCalendarPlugin extends Plugin } $list = []; - $link = api_get_path(WEB_PLUGIN_PATH).'lp_calendar/start.php'; + //$link = api_get_path(WEB_PLUGIN_PATH).'lp_calendar/start.php'; while ($row = Database::fetch_array($result, 'ASSOC')) { $list[] = $row; } @@ -633,35 +633,32 @@ class LpCalendarPlugin extends Plugin * * @return string */ - public static function getUserStatsPanel($userId, $courseAndSessionList) + public function getUserStatsPanel($userId, $courseAndSessionList) { // @todo use translation // get events from this year to today $stats = self::getUserStats($userId, $courseAndSessionList); - - $html = "Nombre de jours cumulés dans le calendrier: ".$stats['user_event_count']; + $html = $this->get_lang('NumberDaysAccumulatedInCalendar').$stats['user_event_count']; if (!empty($courseAndSessionList)) { - $count = $stats['completed']; $html .= '
'; - $html .= "Nombre de jours cumulés dans les parcours réalisés: ".$stats['completed']; + $html .= $this->get_lang('NumberDaysAccumulatedInLp').$stats['completed']; $html .= '
'; - $html .= 'Nombre de jour de retard ou d\'avance à la date d\'aujourd\'hui '.$stats['diff']; + $html .= $this->get_lang('NumberDaysInRetard').' '.$stats['diff']; } - $html = Display::panel($html, get_lang('CalendarStats')); + $html = Display::panel($html, $this->get_lang('LearningCalendar')); return $html; } /** - * @param int $userId - * @param int $courseAndSessionList + * @param int $userId + * @param array $courseAndSessionList * * @return array */ public static function getUserStats($userId, $courseAndSessionList) { - // @todo use translation - // get events from this year to today + // Get events from this year to today $takenCount = self::getUserEvents( $userId, strtotime(date('Y-01-01')), @@ -673,11 +670,13 @@ class LpCalendarPlugin extends Plugin $completed = 0; $diff = 0; - $html = "Nombre de jours cumulés dans le calendrier: $takenCount"; if (!empty($courseAndSessionList)) { $completed = self::getItemCountChecked($userId, $courseAndSessionList); - $diff = $takenCount - $completed; + if ($takenCount > $completed) { + $diff = $takenCount - $completed; + } } + return [ 'user_event_count' => $takenCount, 'completed' => $completed, diff --git a/plugin/lp_calendar/lang/english.php b/plugin/lp_calendar/lang/english.php index ec86bddf7e..dc6274cc1d 100644 --- a/plugin/lp_calendar/lang/english.php +++ b/plugin/lp_calendar/lang/english.php @@ -4,3 +4,8 @@ $strings['plugin_title'] = 'Learning path calendar'; $strings['plugin_comment'] = ''; $strings['enabled'] = 'Enabled'; +$strings['LearningCalendar'] = 'Learning calendar'; +$strings['NumberDaysAccumulatedInCalendar'] = 'Number of days accumulated in the calendar: '; +$strings['NumberDaysAccumulatedInLp'] = 'Number of days accumulated in the LP: '; +$strings['NumberDaysInRetard'] = 'Number of days in retard: '; +$strings['DifferenceOfDaysAndCalendar'] = 'Difference of days and calendar'; \ No newline at end of file diff --git a/plugin/lp_calendar/lang/french.php b/plugin/lp_calendar/lang/french.php index ec86bddf7e..67d6949017 100644 --- a/plugin/lp_calendar/lang/french.php +++ b/plugin/lp_calendar/lang/french.php @@ -4,3 +4,8 @@ $strings['plugin_title'] = 'Learning path calendar'; $strings['plugin_comment'] = ''; $strings['enabled'] = 'Enabled'; +$strings['LearningCalendar'] = 'Learning calendar'; +$strings['NumberDaysAccumulatedInCalendar'] = 'Nombre de jours cumulés dans le calendrier: '; +$strings['NumberDaysAccumulatedInLp'] = 'Nombre de jours cumulés dans les parcours réalisés: '; +$strings['NumberDaysInRetard'] = "Nombre de jour de retard ou d'avance à la date d'aujourd'hui: "; +$strings['DifferenceOfDaysAndCalendar'] = 'Différence de nombre de jours avec le plan issu du learning_calendar'; diff --git a/plugin/lp_calendar/lang/spanish.php b/plugin/lp_calendar/lang/spanish.php index 38b4be3dbe..5b1b10eb3f 100644 --- a/plugin/lp_calendar/lang/spanish.php +++ b/plugin/lp_calendar/lang/spanish.php @@ -4,3 +4,4 @@ $strings['plugin_title'] = 'Learning path calendar'; $strings['plugin_comment'] = ''; $strings['enabled'] = 'Activado'; +$strings['LearningCalendar'] = 'Learning calendar'; \ No newline at end of file