drh can see all users/courses inside the session if the configuration['drh_can_access_all_session_content'] is set see BT#6770

1.9.x
Julio Montoya 12 years ago
parent 7049f78f5d
commit c03fe190e4
  1. 41
      main/inc/lib/sessionmanager.lib.php
  2. 59
      main/mySpace/course.php
  3. 5
      main/mySpace/myStudents.php
  4. 58
      main/mySpace/student.php
  5. 51
      main/mySpace/teachers.php
  6. 27
      main/tracking/courseLog.php

@ -2352,4 +2352,45 @@ class SessionManager
}
return $coaches;
}
/**
* @param int $userId
* @return array
*/
public static function getAllCoursesFromAllSessionFromDrh($userId)
{
$sessions = SessionManager::get_sessions_followed_by_drh($userId);
$coursesFromSession = array();
if (!empty($sessions)) {
foreach ($sessions as $session) {
$courseList = SessionManager::get_course_list_by_session_id($session['id']);
foreach ($courseList as $course) {
$coursesFromSession[] = $course['code'];
}
}
}
return $coursesFromSession;
}
/**
* @param int $userId
* @return array
*/
public static function getAllUsersFromCoursesFromAllSessionFromDrh($userId)
{
$sessions = SessionManager::get_sessions_followed_by_drh($userId);
$userList = array();
if (!empty($sessions)) {
foreach ($sessions as $session) {
$courseList = SessionManager::get_course_list_by_session_id($session['id']);
foreach ($courseList as $course) {
$users = CourseManager::get_user_list_from_course_code($course['code'], $session['id']);
foreach ($users as $user) {
$userList[] = $user['user_id'];
}
}
}
}
return $userList;
}
}

@ -63,6 +63,12 @@ Display :: display_header($nameTools);
$a_courses = array();
if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
$coursesFromSession = array();
if (api_is_drh()) {
if (api_drh_can_access_all_session_content()) {
$coursesFromSession = SessionManager::getAllCoursesFromAllSessionFromDrh(api_get_user_id());
}
}
$title = '';
if (empty($id_session)) {
@ -123,7 +129,8 @@ if (isset($_GET['action'])) {
if ($show_import_icon) {
echo "<div align=\"right\">";
echo '<a href="user_import.php?id_session='.$id_session.'&action=export&amp;type=xml">'.Display::return_icon('excel.gif', get_lang('ImportUserListXMLCSV')).'&nbsp;'.get_lang('ImportUserListXMLCSV').'</a>';
echo '<a href="user_import.php?id_session='.$id_session.'&action=export&amp;type=xml">'.
Display::return_icon('excel.gif', get_lang('ImportUserListXMLCSV')).'&nbsp;'.get_lang('ImportUserListXMLCSV').'</a>';
echo "</div><br />";
}
@ -132,6 +139,12 @@ if (!api_is_drh() && !api_is_session_admin() && !api_is_platform_admin()) {
$a_courses = array_keys($courses);
}
if (api_drh_can_access_all_session_content()) {
if (!isset($_GET['user_id'])) {
$a_courses = $coursesFromSession;
}
}
$nb_courses = count($a_courses);
$table = new SortableTable('tracking_list_course', 'count_courses');
@ -141,7 +154,6 @@ $table -> set_header(2, get_lang('TimeSpentInTheCourse').Display :: return_icon(
$table->set_header(3, get_lang('ThematicAdvance'), false);
$table->set_header(4, get_lang('AvgStudentsProgress').Display :: return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
$table->set_header(5, get_lang('AvgCourseScore').Display :: return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
//$table -> set_header(5, get_lang('AvgExercisesScore'), false);// no code for this?
$table->set_header(6, get_lang('AvgMessages'), false);
$table->set_header(7, get_lang('AvgAssignments'), false);
$table->set_header(8, get_lang('Details'), false);
@ -153,7 +165,6 @@ $csv_header[] = array(
get_lang('ThematicAdvance', ''),
get_lang('AvgStudentsProgress', ''),
get_lang('AvgCourseScore', ''),
//get_lang('AvgExercisesScore', ''),
get_lang('AvgMessages', ''),
get_lang('AvgAssignments', '')
);
@ -173,17 +184,18 @@ if (is_array($a_courses)) {
$rs = Database::query($sql);
$users = array();
while ($row = Database::fetch_array($rs)) { $users[] = $row['user_id']; }
while ($row = Database::fetch_array($rs)) {
$users[] = $row['user_id'];
}
if (count($users) > 0) {
$nb_students_in_course = count($users);
// tracking datas
// tracking data
$avg_progress_in_course = Tracking :: get_avg_student_progress ($users, $course_code, array(), $id_session);
$avg_score_in_course = Tracking :: get_avg_student_score ($users, $course_code, array(), $id_session);
$avg_time_spent_in_course = Tracking :: get_time_spent_on_the_course ($users, $course_code, $id_session);
$messages_in_course = Tracking :: count_student_messages ($users, $course_code, $id_session);
$assignments_in_course = Tracking :: count_student_assignments ($users, $course_code, $id_session);
$avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course);
$avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2);
@ -210,16 +222,27 @@ if (is_array($a_courses)) {
$tematic_advance_progress = '-';
}
$table_row = array();
$table_row[] = $course['title'];
$table_row[] = $nb_students_in_course;
$table_row[] = is_null($avg_time_spent_in_course)?'-':$avg_time_spent_in_course;
$table_row[] = $tematic_advance_progress;
$table_row[] = is_null($avg_progress_in_course) ? '-' : $avg_progress_in_course.'%';
$table_row[] = is_null($avg_score_in_course) ? '-' : $avg_score_in_course;
$table_row[] = is_null($messages_in_course)?'-':$messages_in_course;
$table_row[] = is_null($assignments_in_course)?'-':$assignments_in_course;
$table_row[] = '<a href="../tracking/courseLog.php?cidReq='.$course_code.'&id_session='.$id_session.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
$courseIcon = '<a href="../tracking/courseLog.php?cidReq='.$course_code.'&id_session='.$id_session.'">
<img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" />
</a>';
if (!empty($coursesFromSession)) {
if (!in_array($course_code, $coursesFromSession)) {
$courseIcon = Display::return_icon('2rightarrow_na.gif', get_lang('Course'), array());
}
}
$table_row = array(
$course['title'],
$nb_students_in_course,
is_null($avg_time_spent_in_course)?'-':$avg_time_spent_in_course,
$tematic_advance_progress,
is_null($avg_progress_in_course) ? '-' : $avg_progress_in_course.'%',
is_null($avg_score_in_course) ? '-' : $avg_score_in_course,
is_null($messages_in_course)?'-':$messages_in_course,
is_null($assignments_in_course)?'-':$assignments_in_course,
$courseIcon
);
$csv_content[] = array (
$course['title'],
@ -234,11 +257,7 @@ if (is_array($a_courses)) {
$table->addRow($table_row, 'align="right"');
}
// $csv_content = array_merge($csv_header, $csv_content); // Before this statement you are allowed to sort (in different way) the array $csv_content.
}
//$table -> setColAttributes(0);
//$table -> setColAttributes(7);
$table -> display();
Display :: display_footer();

@ -278,9 +278,8 @@ while ($row = Database :: fetch_array($rs)) {
if (!empty($student_id)) {
if (api_drh_can_access_all_session_content()) {
$sessions = SessionManager::get_sessions_followed_by_drh($user_id);
$sessionList = array_keys($sessions);
if (!in_array($session_id, $sessionList)) {
$users = SessionManager::getAllUsersFromCoursesFromAllSessionFromDrh(api_get_user_id());
if (!in_array($student_id, $users)) {
api_not_allowed();
}
} else {

@ -46,9 +46,6 @@ if (isset($_GET["user_id"]) && $_GET["user_id"]!="" && isset($_GET["type"]) && $
}
Display :: display_header($nameTools);
/*
FUNCTION
*/
function count_student_coached() {
global $students;
@ -73,9 +70,6 @@ function rsort_users($a, $b) {
}
}
/* MAIN CODE */
//if ($isCoach || api_is_platform_admin() || api_is_drh()) {
if (api_is_allowed_to_create_course() || api_is_drh()) {
if ($export_csv) {
$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
@ -121,10 +115,17 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
} else {
$coach_id = api_get_user_id();
}
if (api_is_drh()) {
if (api_drh_can_access_all_session_content()) {
$studentsAllowed = SessionManager::getAllUsersFromCoursesFromAllSessionFromDrh(api_get_user_id());
} else {
$studentsAllowed = array_keys(UserManager::get_users_followed_by_drh(api_get_user_id() , STUDENT));
}
$page_title = get_lang('YourStudents');
if (!isset($_GET['id_session'])) {
if (isset($_GET['user_id'])) {
$user_id = intval($_GET['user_id']);
$user_info = api_get_user_info($user_id);
@ -180,11 +181,7 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
$table->set_header(0, get_lang('LastName'), false);
$table->set_header(1, get_lang('FirstName'), false);
}
/* $table -> set_header(2, get_lang('Time'), false);
$table -> set_header(3, get_lang('Progress'), false);
$table -> set_header(4, get_lang('Score'), false);
$table -> set_header(5, get_lang('Student_publication'), false);
$table -> set_header(6, get_lang('Messages'), false);*/
$table->set_header(2, get_lang('FirstLogin'), false);
$table->set_header(3, get_lang('LatestLogin'), false);
$table->set_header(4, get_lang('Details'), false);
@ -194,11 +191,6 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
$csv_header[] = array (
get_lang('FirstName', ''),
get_lang('LastName', ''),
//get_lang('Time', ''),
//get_lang('Progress', ''),
//get_lang('Score', ''),
//get_lang('Student_publication', ''),
//get_lang('Messages', ''),
get_lang('FirstLogin', ''),
get_lang('LatestLogin', '')
);
@ -206,11 +198,6 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
$csv_header[] = array (
get_lang('LastName', ''),
get_lang('FirstName', ''),
//get_lang('Time', ''),
//get_lang('Progress', ''),
//get_lang('Score', ''),
//get_lang('Student_publication', ''),
//get_lang('Messages', ''),
get_lang('FirstLogin', ''),
get_lang('LatestLogin', '')
);
@ -221,6 +208,7 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
foreach ($students as $student_id) {
$student_data = UserManager :: get_user_info_by_id($student_id);
if (isset($_GET['id_session'])) {
$courses = Tracking :: get_course_list_in_session_from_student($student_id, $_GET['id_session']);
}
@ -259,15 +247,6 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
$row[] = $student_data['lastname'];
$row[] = $student_data['firstname'];
}
/*
$row[] = api_time_to_hms($avg_time_spent);
$row[] = is_null($avg_student_progress) ? null : round($avg_student_progress, 2).'%';
$row[] = is_null($avg_student_score) ? null : round($avg_student_score, 2).'%';
$row[] = $total_assignments;
$row[] = $total_messages;
*/
$string_date = Tracking :: get_last_connection_date($student_id, true);
$first_date = Tracking :: get_first_connection_date($student_id);
$row[] = $first_date;
@ -279,12 +258,24 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
$csv_content[] = $row;
}
if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
$row[] = '<a href="myStudents.php?student='.$student_id.'&id_coach='.$coach_id.'&id_session='.$_GET['id_session'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
$detailsLink = '<a href="myStudents.php?student='.$student_id.'&id_coach='.$coach_id.'&id_session='.$_GET['id_session'].'">
<img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
} else {
$row[] = '<a href="myStudents.php?student='.$student_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
$detailsLink = '<a href="myStudents.php?student='.$student_id.'">
<img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
}
if (api_is_drh()) {
if (!in_array($student_id, $studentsAllowed)) {
$detailsLink = Display::return_icon('2rightarrow_na.gif', get_lang('Details'));
}
}
$row[] = $detailsLink;
$all_datas[] = $row;
}
@ -315,5 +306,4 @@ if (api_is_allowed_to_create_course() || api_is_drh()) {
}
}
/* FOOTER */
Display :: display_footer();

@ -25,15 +25,36 @@ Display :: display_header($nameTools);
$formateurs = array();
if (api_is_drh() || api_is_platform_admin()) {
// Followed teachers by drh
if (api_drh_can_access_all_session_content()) {
$sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
if (!empty($sessions)) {
$formateurs = array();
foreach ($sessions as $session) {
$coursesFromSession = SessionManager::get_course_list_by_session_id($session['id']);
foreach ($coursesFromSession as $course) {
$teachers = CourseManager::get_teacher_list_from_course_code($course['code']);
foreach ($teachers as $teacher) {
if (isset($formateurs[$teacher['user_id']])) {
continue;
}
$formateurs[$teacher['user_id']] = $teacher;
}
}
}
}
// followed teachers by drh
} else {
$formateurs = UserManager::get_users_followed_by_drh($_user['user_id'], COURSEMANAGER);
$menu_items = array();
$menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" );
$menu_items[] = Display::url(Display::return_icon('user.png', get_lang('Students'), array(), 32), "index.php?view=drh_students&amp;display=yourstudents");
$menu_items[] = Display::return_icon('teacher_na.png', get_lang('Trainers'), array(), 32);
$menu_items[] = Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), 32), 'course.php');
$menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), 32), 'session.php');
}
$menu_items = array(
Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ),
Display::url(Display::return_icon('user.png', get_lang('Students'), array(), 32), "index.php?view=drh_students&amp;display=yourstudents"),
Display::return_icon('teacher_na.png', get_lang('Trainers'), array(), 32),
Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), 32), 'course.php'),
Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), 32), 'session.php')
);
echo '<div class="actions">';
$nb_menu_items = count($menu_items);
@ -146,9 +167,21 @@ if (count($formateurs) > 0) {
if ($i % 20 == 0 && $i != 0) {
if ($is_western_name_order) {
echo '<tr><th>'.get_lang('FirstName').'</th><th>'.get_lang('LastName').'</th><th>'.get_lang('Email').'</th><th>'.get_lang('AdminCourses').'</th><th>'.get_lang('Students').'</th></tr>';
echo '<tr>
<th>'.get_lang('FirstName').'</th>
<th>'.get_lang('LastName').'</th>
<th>'.get_lang('Email').'</th>
<th>'.get_lang('AdminCourses').'</th>
<th>'.get_lang('Students').'</th>
</tr>';
} else {
echo '<tr><th>'.get_lang('LastName').'</th><th>'.get_lang('FirstName').'</th><th>'.get_lang('Email').'</th><th>'.get_lang('AdminCourses').'</th><th>'.get_lang('Students').'</th></tr>';
echo '<tr>
<th>'.get_lang('LastName').'</th>
<th>'.get_lang('FirstName').'</th>
<th>'.get_lang('Email').'</th>
<th>'.get_lang('AdminCourses').'</th>
<th>'.get_lang('Students').'</th>
</tr>';
}
}
} else {

@ -46,13 +46,16 @@ if (!$is_allowedToTrack) {
if (api_is_drh()) {
// Blocking course for drh
if (api_drh_can_access_all_session_content()) {
$sessions = SessionManager::get_sessions_followed_by_drh($user_id);
$sessionList = array_keys($sessions);
if (!in_array($session_id, $sessionList)) {
$coursesFromSession = SessionManager::getAllCoursesFromAllSessionFromDrh(api_get_user_id());
$coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
$coursesFollowedList = array_keys($coursesFollowedList);
if (!in_array(api_get_course_id(), $coursesFollowedList)) {
if (!in_array(api_get_course_id(), $coursesFromSession)) {
api_not_allowed();
}
}
} else {
$coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
$coursesFollowedList = array_keys($coursesFollowedList);
@ -83,7 +86,7 @@ if ($export_csv) {
ob_start();
}
$csv_content = array();
// Scripts for reporting array hide / unhide columns
// Scripts for reporting array hide/show columns
$js = "<script>
// hide column and display the button to unhide it
function foldup(in_id) {
@ -116,12 +119,10 @@ $js = "<script>
</script>";
$htmlHeadXtra[] = "<style type='text/css'>
/*<![CDATA[*/
.secLine {background-color : #E6E6E6;}
.content {padding-left : 15px;padding-right : 15px; }
.specialLink{color : #0000FF;}
/*]]>*/
/* Style for reporting array hide / unhide columns */
/* Style for reporting array hide/show columns */
.unhide_button {
cursor : pointer;
border:1px solid black;
@ -133,9 +134,6 @@ $htmlHeadXtra[] = "<style type='text/css'>
div#reporting_table table th {
vertical-align:top;
}
</style>
<style media='print' type='text/css'>
</style>";
$htmlHeadXtra[] .= $js;
@ -175,7 +173,7 @@ if (empty($session_id)) {
$nbStudents = count($a_students);
// Gettting all the additional information of an additional profile field.
// Getting all the additional information of an additional profile field.
if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
$user_array = array();
foreach ($a_students as $key => $item) {
@ -186,7 +184,6 @@ if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_pro
$extra_info = UserManager::get_extra_field_information($_GET['additional_profile_field']);
}
/* MAIN CODE */
echo '<div class="actions">';
@ -211,7 +208,6 @@ echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$addional_pa
'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</span>';
echo '</div>';
@ -227,8 +223,7 @@ $form_search->addElement('style_submit_button', 'submit', get_lang('SearchUsers'
$form_search->display();
echo '</div>';
// BEGIN : form to remind inactives susers
// BEGIN : form to remind inactive users
if (count($a_students) > 0) {
$form = new FormValidator('reminder_form', 'get', api_get_path(REL_CODE_PATH).'announcements/announcements.php');

Loading…
Cancel
Save