Merge branch '1.9.x' of ssh://github.com/chamilo/chamilo-lms into chamilo19

1.9.x
Julio Montoya 11 years ago
commit a27d677b3d
  1. 2
      main/admin/resume_session.php
  2. 41
      main/admin/session_user_edit.php
  3. 3
      main/inc/lib/course.lib.php
  4. 5
      main/inc/lib/main_api.lib.php
  5. 17
      main/inc/lib/sessionmanager.lib.php
  6. 6
      main/tracking/courseLog.php

@ -459,7 +459,7 @@ if ($session['nbr_users']==0) {
if (isset($sessionInfo['duration']) && !empty($sessionInfo['duration'])) { if (isset($sessionInfo['duration']) && !empty($sessionInfo['duration'])) {
$editUrl = api_get_path(WEB_CODE_PATH) . 'admin/session_user_edit.php?session_id=' . $id_session . '&user_id=' . $user['user_id']; $editUrl = api_get_path(WEB_CODE_PATH) . 'admin/session_user_edit.php?session_id=' . $id_session . '&user_id=' . $user['user_id'];
$editUrl = Display::url( $editUrl = Display::url(
Display::return_icon('edit.png', get_lang('Edit')), Display::return_icon('agenda.png', get_lang('SessionDurationEdit')),
$editUrl $editUrl
); );
} }

@ -38,15 +38,54 @@ $interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$sessionId,
$form = new FormValidator('edit', 'post', api_get_self().'?session_id='.$sessionId.'&user_id='.$userId); $form = new FormValidator('edit', 'post', api_get_self().'?session_id='.$sessionId.'&user_id='.$userId);
$form->add_header(get_lang('EditUserSessionDuration')); $form->add_header(get_lang('EditUserSessionDuration'));
$data = SessionManager::getUserSession($userId, $sessionId); $data = SessionManager::getUserSession($userId, $sessionId);
$userInfo = api_get_user_info($userId);
$form->addElement('text', 'duration', array(get_lang('Duration'), null, get_lang('Days'))); // Show current end date for the session for this user, if any
$userAccess = CourseManager::getFirstCourseAccessPerSessionAndUser(
$sessionId,
$userId
);
if (count($userAccess) == 0) {
// User never accessed the session. End date is still open
$msg = sprintf(get_lang('UserNeverAccessedSessionDefaultDurationIsX'), $sessionInfo['duration']);
} else {
// The user already accessed the session. Show a clear detail of the days count.
$duration = $sessionInfo['duration'];
if (!empty($data['duration'])) {
$duration = $duration + $data['duration'];
}
$days = SessionManager::getDayLeftInSession($sessionId, $userId, $duration);
$firstAccess = api_strtotime($userAccess['login_course_date'], 'UTC');
$firstAccessString = api_convert_and_format_date($userAccess['login_course_date'], DATE_FORMAT_SHORT, 'UTC');
if ($days > 0) {
$msg = sprintf(get_lang('FirstAccessWasXSessionDurationYEndDateInZDays'), $firstAccessString, $duration, $days);
} else {
$endDateInSeconds = $firstAccess + $duration*24*60*60;
$last = api_convert_and_format_date($endDateInSeconds, DATE_FORMAT_SHORT);
$msg = sprintf(get_lang('FirstAccessWasXSessionDurationYEndDateWasZ'), $firstAccessString, $duration, $last);
}
}
$form->addElement('html', sprintf(get_lang('UserXSessionY'), $userInfo['complete_name'], $sessionInfo['name']));
$form->addElement('html', '<br>');
$form->addElement('html', $msg);
$form->addElement('text', 'duration', array(get_lang('ExtraDurationForUser'), null, get_lang('Days')));
$form->addElement('button', 'submit', get_lang('Send')); $form->addElement('button', 'submit', get_lang('Send'));
if (empty($data['duration'])) {
$data['duration'] = 0;
}
$form->setDefaults($data); $form->setDefaults($data);
$message = null; $message = null;
if ($form->validate()) { if ($form->validate()) {
$duration = $form->getSubmitValue('duration'); $duration = $form->getSubmitValue('duration');
// Only update if the duration is different from the default duration
if ($duration != 0) {
SessionManager::editUserSessionDuration($duration, $userId, $sessionId); SessionManager::editUserSessionDuration($duration, $userId, $sessionId);
$message = Display::return_message(get_lang('ItemUpdated'), 'confirmation'); $message = Display::return_message(get_lang('ItemUpdated'), 'confirmation');
} else {
$message = Display::return_message(get_lang('DurationIsSameAsDefault'), 'warning');
}
} }
// display the header // display the header

@ -4695,7 +4695,8 @@ class CourseManager
} }
/** /**
* Get information from the track_e_course_access table * Get login information from the track_e_course_access table, for any
* course in the given session
* @param int $sessionId * @param int $sessionId
* @param int $userId * @param int $userId
* @return array * @return array

@ -2024,6 +2024,11 @@ function api_get_session_visibility($session_id, $course_code = null, $ignore_vi
$session_id, $session_id,
api_get_user_id() api_get_user_id()
); );
// If there is a session duration but there is no previous
// access by the user, then the session is still available
if (count($courseAccess) == 0) {
return SESSION_AVAILABLE;
}
$currentTime = time(); $currentTime = time();
$firstAccess = 0; $firstAccess = 0;
if (isset($courseAccess['login_course_date'])) { if (isset($courseAccess['login_course_date'])) {

@ -4684,6 +4684,8 @@ class SessionManager
} }
/** /**
* Returns the number of days the student has left in a session when using
* sessions durations
* @param int $userId * @param int $userId
* @param int $sessionId * @param int $sessionId
* @param int $duration in days * @param int $duration in days
@ -4691,6 +4693,8 @@ class SessionManager
*/ */
public static function getDayLeftInSession($sessionId, $userId, $duration) public static function getDayLeftInSession($sessionId, $userId, $duration)
{ {
// Get an array with the details of the first access of the student to
// this session
$courseAccess = CourseManager::getFirstCourseAccessPerSessionAndUser( $courseAccess = CourseManager::getFirstCourseAccessPerSessionAndUser(
$sessionId, $sessionId,
$userId $userId
@ -4698,6 +4702,11 @@ class SessionManager
$currentTime = time(); $currentTime = time();
// If no previous access, return false
if (count($courseAccess) == 0) {
return false;
}
$firstAccess = api_strtotime($courseAccess['login_course_date'], 'UTC'); $firstAccess = api_strtotime($courseAccess['login_course_date'], 'UTC');
$endDateInSeconds = $firstAccess + $duration*24*60*60; $endDateInSeconds = $firstAccess + $duration*24*60*60;
@ -4728,10 +4737,10 @@ class SessionManager
} }
/** /**
* @param int $userId * Gets one row from the session_rel_user table
* @param int $sessionId * @param int The user ID
* * @param int The session ID
* @param return array * @return array
*/ */
public static function getUserSession($userId, $sessionId) public static function getUserSession($userId, $sessionId)
{ {

@ -379,14 +379,14 @@ if (count($a_students) > 0) {
$table->set_header(3, get_lang('Login'), false); $table->set_header(3, get_lang('Login'), false);
$tab_table_header[] = get_lang('Login'); $tab_table_header[] = get_lang('Login');
$table->set_header(4, get_lang('TrainingTime'), false); $table->set_header(4, get_lang('TrainingTime').'&nbsp;'.Display::return_icon('info3.gif', get_lang('TrainingTimeInfo'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;'));
$tab_table_header[] = get_lang('TrainingTime'); $tab_table_header[] = get_lang('TrainingTime');
$table->set_header(5, get_lang('CourseProgress').'&nbsp;'.Display::return_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;')); $table->set_header(5, get_lang('CourseProgress').'&nbsp;'.Display::return_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;'));
$tab_table_header[] = get_lang('CourseProgress'); $tab_table_header[] = get_lang('CourseProgress');
$table->set_header(6, get_lang('ExerciseProgress'), false); $table->set_header(6, get_lang('ExerciseProgress').'&nbsp;'.Display::return_icon('info3.gif', get_lang('ExerciseProgressInfo'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;'));
$tab_table_header[] = get_lang('ExerciseProgress'); $tab_table_header[] = get_lang('ExerciseProgress');
$table->set_header(7, get_lang('ExerciseAverage'), false); $table->set_header(7, get_lang('ExerciseAverage').'&nbsp;'.Display::return_icon('info3.gif', get_lang('ExerciseAverageInfo'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;'));
$tab_table_header[] = get_lang('ExerciseAverage'); $tab_table_header[] = get_lang('ExerciseAverage');
$table->set_header(8, get_lang('Score').'&nbsp;'.Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;')); $table->set_header(8, get_lang('Score').'&nbsp;'.Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;'));
$tab_table_header[] = get_lang('Score'); $tab_table_header[] = get_lang('Score');

Loading…
Cancel
Save