LpCalendarPlugin (WIP) fix php notices, use plugin lang vars BT#14608

pull/2591/head
Julio Montoya 7 years ago
parent d425200768
commit d44da64f0e
  1. 17
      main/admin/usergroup_users.php
  2. 10
      main/extra/myStudents.php
  3. 2
      main/inc/ajax/model.ajax.php
  4. 3
      main/inc/lib/tracking.lib.php
  5. 5
      main/inc/lib/usergroup.lib.php
  6. 3
      main/mySpace/index.php
  7. 6
      main/mySpace/myStudents.php
  8. 23
      plugin/lp_calendar/LpCalendarPlugin.php
  9. 5
      plugin/lp_calendar/lang/english.php
  10. 5
      plugin/lp_calendar/lang/french.php
  11. 1
      plugin/lp_calendar/lang/spanish.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',

@ -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;
}
}

@ -796,7 +796,7 @@ switch ($action) {
$columns = [
'name',
'calendar',
'examn',
'gradebook_items',
'time_spent',
'lp_day_completed',
'days_diff',

@ -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;

@ -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;

@ -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'
);
}

@ -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) {

@ -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 .= '<br />';
$html .= "Nombre de jours cumulés dans les parcours réalisés: ".$stats['completed'];
$html .= $this->get_lang('NumberDaysAccumulatedInLp').$stats['completed'];
$html .= '<br />';
$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 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);
if ($takenCount > $completed) {
$diff = $takenCount - $completed;
}
}
return [
'user_event_count' => $takenCount,
'completed' => $completed,

@ -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';

@ -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';

@ -4,3 +4,4 @@
$strings['plugin_title'] = 'Learning path calendar';
$strings['plugin_comment'] = '';
$strings['enabled'] = 'Activado';
$strings['LearningCalendar'] = 'Learning calendar';
Loading…
Cancel
Save