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

1.9.x
Yannick Warnier 11 years ago
commit 66c59086ef
  1. 20
      main/admin/add_users_to_session.php
  2. 2
      main/attendance/index.php
  3. 52
      main/inc/lib/sessionmanager.lib.php
  4. 2
      main/install/configuration.dist.php
  5. 10
      main/mySpace/course.php
  6. 101
      main/tracking/courseLog.php

@ -22,6 +22,7 @@ $xajax->registerFunction('search_users');
$this_section = SECTION_PLATFORM_ADMIN;
$id_session = intval($_GET['id_session']);
$countSessionCoursesList = SessionManager::get_course_list_by_session_id($id_session, null, null, true);
$addProcess = isset($_GET['add']) ? Security::remove_XSS($_GET['add']) : null;
@ -365,6 +366,25 @@ if ($ajax_search) {
foreach ($users as $user) {
$sessionUsersList[$user['user_id']] = $user ;
}
$sessionUserInfo = SessionManager::getTotalUserCoursesInSession($id_session);
// Filter the user list in all courses in the session
foreach ($sessionUserInfo as $sessionUser) {
// filter students in session
if ($sessionUser['status_in_session'] != 0) {
continue;
}
if (!array_key_exists($sessionUser['user_id'], $sessionUsersList)) {
continue;
}
if ($sessionUser['count'] != $countSessionCoursesList) {
unset($sessionUsersList[$sessionUser['user_id']]);
}
}
unset($users); //clean to free memory
} else {
//Filter by Extra Fields

@ -332,7 +332,7 @@ switch ($action) {
$attendanceController->attendance_calendar($action, $attendance_id, $calendar_id);
break;
case 'calendar_logins':
if (api_is_allowed_to_edit(null, true)) {
if (api_is_allowed_to_edit(null, true) || api_is_drh()) {
$attendanceController->getAttendanceBaseInLogin(false, true);
}
break;

@ -2975,23 +2975,32 @@ class SessionManager
}
/**
* Gets the list of courses by session filtered by access_url
* @param int $session_id
* @param string $course_name
* @return array list of courses
* Gets the list (or the count) of courses by session filtered by access_url
* @param int $session_id The session id
* @param string $course_name The course code
* @param string $orderBy Field to order the data
* @param boolean $getCount Optional. Count the session courses
* @return array|int List of courses. Whether $getCount is true, return the count
*/
public static function get_course_list_by_session_id(
$session_id,
$course_name = '',
$orderBy = null
$orderBy = null,
$getCount = false
) {
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$session_id = intval($session_id);
$sqlSelect = "SELECT *";
if ($getCount) {
$sqlSelect = "SELECT COUNT(1)";
}
// select the courses
$sql = "SELECT * FROM $tbl_course c
$sql = "$sqlSelect FROM $tbl_course c
INNER JOIN $tbl_session_rel_course src
ON c.code = src.course_code
WHERE src.id_session = '$session_id' ";
@ -3017,6 +3026,12 @@ class SessionManager
$num_rows = Database::num_rows($result);
$courses = array();
if ($num_rows > 0) {
if ($getCount) {
$count = Database::fetch_array($result);
return intval($count[0]);
}
while ($row = Database::fetch_array($result,'ASSOC')) {
$courses[$row['id']] = $row;
}
@ -5491,4 +5506,29 @@ class SessionManager
)
));
}
/**
* Get the count of user courses in session
* @param int $sessionId The session id
* @return array
*/
public static function getTotalUserCoursesInSession($sessionId)
{
$sql = "SELECT COUNT(1) as count, u.user_id, scu.status status_in_session, u.status user_status "
. "FROM session_rel_course_rel_user scu "
. "INNER JOIN user u ON scu.id_user = u.user_id "
. "WHERE scu.id_session = " . intval($sessionId) . " "
. "GROUP BY u.user_id";
$result = Database::query($sql);
$list = array();
while ($data = Database::fetch_assoc($result)) {
$list[] = $data;
}
return $list;
}
}

@ -293,3 +293,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['prevent_session_admins_to_manage_all_users'] = false;
// Show delete option in attendance
//$_configuration['allow_delete_attendance'] = false;
// Course log - Default columns to hide
//$_configuration['course_log_hide_columns'] = array(1, 9);

@ -279,6 +279,12 @@ function get_courses($from, $limit, $column, $direction)
$data['title'],
$courseInfo['course_public_url'].'?id_session='.$sessionId
);
$attendanceLink = Display::url(
Display::return_icon('attendance_list.png', get_lang('Attendance'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$courseCode.'&id_session='.$sessionId.'&action=calendar_logins'
);
$courseList[] = array(
$title,
$countStudents,
@ -288,6 +294,7 @@ function get_courses($from, $limit, $column, $direction)
is_null($avgScoreInCourse) ? '-' : $avgScoreInCourse,
is_null($messagesInCourse) ? '-' : $messagesInCourse,
is_null($assignmentsInCourse) ? '-' : $assignmentsInCourse,
$attendanceLink,
$courseIcon
);
}
@ -313,7 +320,8 @@ $table->set_header(4, get_lang('AvgStudentsProgress').Display :: return_icon('in
$table->set_header(5, get_lang('AvgCourseScore').Display :: return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
$table->set_header(6, get_lang('AvgMessages'), false);
$table->set_header(7, get_lang('AvgAssignments'), false);
$table->set_header(8, get_lang('Details'), false);
$table->set_header(8, get_lang('Attendances'), false);
$table->set_header(9, get_lang('Details'), false);
$form = new FormValidator('search_course', 'get', api_get_path(WEB_CODE_PATH).'mySpace/course.php');
$form->addElement('text', 'keyword', get_lang('Keyword'));

@ -50,21 +50,28 @@ if (api_is_drh()) {
if (api_drh_can_access_all_session_content()) {
// If the drh has been configured to be allowed to see all session content, give him access to the session courses
$coursesFromSession = SessionManager::getAllCoursesFollowedByUser(api_get_user_id(), null);
$coursesFromSessionCodeList = array();
if (!empty($coursesFromSession)) {
$coursesFromSession = array_keys($coursesFromSession);
foreach ($coursesFromSession as $course) {
$coursesFromSessionCodeList[$course['code']] = $course['code'];
}
}
$coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
if (!empty($coursesFollowedList)) {
$coursesFollowedList = array_keys($coursesFollowedList);
}
if (!in_array($courseCode, $coursesFollowedList)) {
if (!in_array($courseCode, $coursesFromSession)) {
if (!in_array($courseCode, $coursesFromSessionCodeList)) {
api_not_allowed();
}
}
} else {
// If the drh has *not* been configured to be allowed to see all session content, then check if he has also been given access to the corresponding courses
// If the drh has *not* been configured to be allowed to see all session content,
// then check if he has also been given access to the corresponding courses
$coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
$coursesFollowedList = array_keys($coursesFollowedList);
if (!in_array(api_get_course_id(), $coursesFollowedList)) {
@ -93,6 +100,9 @@ if ($export_csv) {
}
ob_start();
}
$columnsToHideFromSetting = api_get_configuration_value('course_log_hide_columns');
$columnsToHide = empty($columnsToHideFromSetting) ? array(1, 9, 10, 11, 12) : $columnsToHideFromSetting;
$columnsToHide = json_encode($columnsToHide);
$csv_content = array();
// Scripts for reporting array hide/show columns
@ -123,14 +133,14 @@ $js = "<script>
// hide some column at startup
// be sure that these columns always exists
// see tab_table_header = array(); // tab of header texts
// see headers = array();
// tab of header texts
$(document).ready( function() {
init_hide();
foldup(1);
foldup(9);
foldup(10);
foldup(11);
foldup(12);
var columnsToHide = ".$columnsToHide.";
columnsToHide.forEach(function(id) {
foldup(id);
});
})
</script>";
@ -177,9 +187,6 @@ if (isset($_GET['origin']) && $_GET['origin'] == 'resume_session') {
$view = isset($_REQUEST['view']) ? $_REQUEST['view'] : '';
$nameTools = get_lang('Tracking');
// Display the header.
Display::display_header($nameTools, 'Tracking');
// getting all the students of the course
if (empty($session_id)) {
// Registered students in a course outside session.
@ -217,6 +224,9 @@ if (isset($_GET['additional_profile_field']) &&
);
}
// Display the header.
Display::display_header($nameTools, 'Tracking');
/* MAIN CODE */
echo '<div class="actions">';
@ -359,7 +369,8 @@ if (count($a_students) > 0) {
$el = $form->addElement(
'select',
'since',
'<img width="ICON_SIZE_SMALL" align="middle" src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" border="0" />'.get_lang('RemindInactivesLearnersSince'),
'<img align="middle" src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" border="0" />'.
get_lang('RemindInactivesLearnersSince'),
$options
);
$el->setSelected(7);
@ -397,78 +408,84 @@ if (count($a_students) > 0) {
$parameters['from'] = isset($_GET['myspace']) ? Security::remove_XSS($_GET['myspace']) : null;
$table->set_additional_parameters($parameters);
$tab_table_header = array();
$headers = array();
// tab of header texts
$table->set_header(0, get_lang('OfficialCode'), true);
$tab_table_header[] = get_lang('OfficialCode');
$headers['official_code'] = get_lang('OfficialCode');
if ($is_western_name_order) {
$table->set_header(1, get_lang('FirstName'), true);
$tab_table_header[] = get_lang('FirstName');
$headers['firstname'] = get_lang('FirstName');
$table->set_header(2, get_lang('LastName'), true);
$tab_table_header[] = get_lang('LastName');
$headers['lastname'] = get_lang('LastName');
} else {
$table->set_header(1, get_lang('LastName'), true);
$tab_table_header[] = get_lang('LastName');
$headers['lastname'] = get_lang('LastName');
$table->set_header(2, get_lang('FirstName'), true);
$tab_table_header[] = get_lang('FirstName');
$headers['firstname'] = get_lang('FirstName');
}
$table->set_header(3, get_lang('Login'), false);
$tab_table_header[] = get_lang('Login');
$headers['login'] = get_lang('Login');
$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');
$headers['training_time'] = 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;'));
$tab_table_header[] = get_lang('CourseProgress');
$headers['course_progress'] = get_lang('CourseProgress');
$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');
$headers['exercise_progress'] = get_lang('ExerciseProgress');
$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');
$headers['exercise_average'] = 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;'));
$tab_table_header[] = get_lang('Score');
$headers['score'] = get_lang('Score');
$table->set_header(9, get_lang('Student_publication'), false);
$tab_table_header[] = get_lang('Student_publication');
$headers['student_publication'] = get_lang('Student_publication');
$table->set_header(10, get_lang('Messages'), false);
$tab_table_header[] = get_lang('Messages');
$headers['messages'] = get_lang('Messages');
if (empty($session_id)) {
$table->set_header(11, get_lang('Survey'), false);
$tab_table_header[] = get_lang('Survey');
$headers['survey'] = get_lang('Survey');
$table->set_header(12, get_lang('FirstLogin'), false);
$tab_table_header[] = get_lang('FirstLogin');
$headers['first_login'] = get_lang('FirstLogin');
$table->set_header(13, get_lang('LatestLogin'), false);
$tab_table_header[] = get_lang('LatestLogin');
$headers['latest_login'] = get_lang('LatestLogin');
if (isset($_GET['additional_profile_field']) and is_numeric($_GET['additional_profile_field'])) {
$table->set_header(14, $extra_info['field_display_text'], false);
$tab_table_header[] = $extra_info['field_display_text'];
$headers['field_display_text'] = $extra_info['field_display_text'];
$table->set_header(15, get_lang('Details'), false);
$tab_table_header[] = get_lang('Details');
$headers['details'] = get_lang('Details');
} else {
$table->set_header(14, get_lang('Details'), false);
$tab_table_header[] = get_lang('Details');
$headers['details'] = get_lang('Details');
}
} else {
$table->set_header(11, get_lang('FirstLogin'), false);
$tab_table_header[] = get_lang('FirstLogin');
$headers['first_login'] = get_lang('FirstLogin');
$table->set_header(12, get_lang('LatestLogin'), false);
$tab_table_header[] = get_lang('LatestLogin');
$headers['latest_login'] = get_lang('LatestLogin');
if (isset($_GET['additional_profile_field']) and is_numeric($_GET['additional_profile_field'])) {
$table->set_header(13, $extra_info['field_display_text'], false);
$tab_table_header[] = $extra_info['field_display_text'];
$headers['field_display_text'] = $extra_info['field_display_text'];
$table->set_header(14, get_lang('Details'), false);
$tab_table_header[] = get_lang('Details');
$headers['Details'] = get_lang('Details');
} else {
$table->set_header(13, get_lang('Details'), false);
$tab_table_header[] = get_lang('Details');
$headers['Details'] = get_lang('Details');
}
}
// display buttons to un hide hidden columns
echo "<br/><br/><div id='unhideButtons'>";
for ($i=0; $i < count($tab_table_header); $i++) {
$index = $i + 1;
echo "<span title='".get_lang('DisplayColumn')." ".$tab_table_header[$i]."' class='unhide_button hide' onclick='foldup($index)'>".Display :: return_icon('move.png', get_lang('DisplayColumn'), array('align'=>'absmiddle', 'hspace'=>'3px'), 16)." ".$tab_table_header[$i]."</span>";
$index = 0;
foreach ($headers as $header) {
echo "<span title='".get_lang('DisplayColumn')." ".$header."' class='unhide_button hide' onclick='foldup($index)'>".
Display :: return_icon(
'move.png',
get_lang('DisplayColumn'),
array('align'=>'absmiddle', 'hspace'=>'3px'),
16
)." ".$header."</span>";
$index++;
}
echo "</div>";
// Display the table

Loading…
Cancel
Save