added information for blocks in dashboards

skala
Cristian Fasanando 15 years ago
parent efa71972d8
commit 81ec406ca9
  1. 4
      main/admin/dashboard_add_courses_to_user.php
  2. 4
      main/admin/dashboard_add_sessions_to_user.php
  3. 5
      main/admin/dashboard_add_users_to_user.php
  4. 39
      main/attendance/attendance_controller.php
  5. 237
      main/attendance/attendance_sheet.php
  6. 2
      main/course_description/listing.php
  7. 1
      main/course_home/course_home.php
  8. 2
      main/course_info/download.php
  9. 1
      main/dashboard/dashboard_controller.php
  10. 2
      main/dashboard/index.php
  11. 130
      main/inc/lib/attendance.lib.php
  12. 118
      main/inc/lib/dashboard.lib.php
  13. 9
      main/inc/lib/main_api.lib.php
  14. 8
      main/inc/lib/sessionmanager.lib.php
  15. 61
      main/mySpace/course.php
  16. 34
      main/mySpace/index.php
  17. 27
      main/mySpace/myStudents.php
  18. 52
      main/mySpace/session.php
  19. 59
      main/mySpace/student.php
  20. 84
      main/mySpace/teachers.php
  21. 2
      main/tracking/courseLog.php
  22. 2
      main/tracking/courseLogCSV.php
  23. 50
      plugin/dashboard/block_course/block_course.class.php
  24. 99
      plugin/dashboard/block_session/block_session.class.php
  25. 108
      plugin/dashboard/block_student/block_student.class.php
  26. 99
      plugin/dashboard/block_teacher/block_teacher.class.php

@ -66,7 +66,7 @@ function search_courses($needle,$type) {
$charset = api_get_setting('platform_charset');
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$assigned_courses_to_hrm = CourseManager::get_assigned_courses_to_hr_manager($hrm_id);
$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($hrm_id);
$assigned_courses_code = array_keys($assigned_courses_to_hrm);
foreach ($assigned_courses_code as &$value) {
$value = "'".$value."'";
@ -167,7 +167,7 @@ echo '<div class="row"><div class="form_header">'.get_lang('AssignedCoursesTo').
// *******************
$assigned_courses_to_hrm = CourseManager::get_assigned_courses_to_hr_manager($hrm_id);
$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($hrm_id);
$assigned_courses_code = array_keys($assigned_courses_to_hrm);
foreach ($assigned_courses_code as &$value) {
$value = "'".$value."'";

@ -67,7 +67,7 @@ function search_sessions($needle,$type) {
$charset = api_get_setting('platform_charset');
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$assigned_sessions_to_hrm = SessionManager::get_assigned_sessions_to_hr_manager($hrm_id);
$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($hrm_id);
$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
@ -170,7 +170,7 @@ echo '<div class="row"><div class="form_header">'.get_lang('AssignedSessionsTo')
// *******************
$assigned_sessions_to_hrm = SessionManager::get_assigned_sessions_to_hr_manager($hrm_id);
$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($hrm_id);
$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
$without_assigned_sessions = '';
if (count($assigned_sessions_id) > 0) {

@ -65,7 +65,7 @@ function search_users($needle,$type) {
$charset = api_get_setting('platform_charset');
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$assigned_users_to_hrm = UserManager::get_assigned_users_to_hr_manager($hrm_id);
$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($hrm_id);
$assigned_users_id = array_keys($assigned_users_to_hrm);
$without_assigned_users = '';
if (count($assigned_users_id) > 0) {
@ -164,8 +164,7 @@ echo '<div class="row"><div class="form_header">'.get_lang('AssignedUsersTo').'&
// *******************
$assigned_users_to_hrm = UserManager::get_assigned_users_to_hr_manager($hrm_id);
$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($hrm_id);
$assigned_users_id = array_keys($assigned_users_to_hrm);
$without_assigned_users = '';
if (count($assigned_users_id) > 0) {

@ -156,18 +156,24 @@
* @param string action
* @param int attendance id
*/
public function attendance_sheet($action,$attendance_id) {
public function attendance_sheet($action, $attendance_id, $student_id = 0) {
$attendance = new Attendance();
$data = array();
$data['attendance_id'] = $attendance_id;
$data['users_in_course'] = $attendance->get_users_rel_course($attendance_id);
$data['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id);
if (api_is_allowed_to_edit(null, true)) {
$data['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id);
} else {
$data['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id, api_get_user_id());
$data['faults'] = $attendance->get_faults_of_user(api_get_user_id(), $attendance_id);
if (!empty($student_id)) {
$user_id = intval($student_id);
} else {
$user_id = api_get_user_id();
}
$data['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id, $user_id);
$data['faults'] = $attendance->get_faults_of_user($user_id, $attendance_id);
$data['user_id'] = $user_id;
}
$data['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id);
@ -175,6 +181,8 @@
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
$presences = array();
$check_values = array();
$users_present = array();
if (isset($_POST['check_presence'])) {
$presences = $_POST['check_presence'];
$calendar_tmp = array();
@ -186,12 +194,23 @@
if (in_array($calendar_id, $calendar_tmp)) {
$check_values[$calendar_id][] = $user_id;
}
}
}
foreach ($check_values as $cal_id => $value) {
$users_present = $value;
$affected_rows = $attendance->attendance_sheet_add($cal_id,$users_present,$attendance_id);
}
}
// save when is present at least one user
foreach ($check_values as $cal_id => $value) {
$users_present = $value;
$affected_rows = $attendance->attendance_sheet_add($cal_id,$users_present,$attendance_id);
}
} else {
// save attendance done with all absents students
if (isset($_POST['datetime_column'])) {
foreach ($_POST['datetime_column'] as $key=>$date_time_col) {
$cal_id = $key;
$affected_rows = $attendance->attendance_sheet_add($cal_id,$users_present,$attendance_id);
}
}
}
$data['users_in_course'] = $attendance->get_users_rel_course($attendance_id);
$data['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id);
$data['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id);

@ -8,140 +8,139 @@
*/
if (api_is_allowed_to_edit(null, true)) {
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.$_SESSION['gradebook'];
}
echo '<div class="actions" style="margin-bottom:30px">';
echo '<a href="index?'.api_get_cidreq().'&action=calendar_list&attendance_id='.$attendance_id.$param_gradebook.'">'.Display::return_icon('calendar_up.gif',get_lang('AttendanceCalendar')).' '.get_lang('AttendanceCalendar').'</a>';
echo '</div>';
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.$_SESSION['gradebook'];
}
echo '<div class="actions" style="margin-bottom:30px">';
echo '<a href="index?'.api_get_cidreq().'&action=calendar_list&attendance_id='.$attendance_id.$param_gradebook.'">'.Display::return_icon('calendar_up.gif',get_lang('AttendanceCalendar')).' '.get_lang('AttendanceCalendar').'</a>';
echo '</div>';
$message_information = get_lang('informationAttendanceSheet');
if (!empty($message_information)) {
$message = '<strong>'.get_lang('Information').'</strong><br />';
$message .= $message_information;
Display::display_normal_message($message, false);
}
$message_information = get_lang('informationAttendanceSheet');
if (!empty($message_information)) {
$message = '<strong>'.get_lang('Information').'</strong><br />';
$message .= $message_information;
Display::display_normal_message($message, false);
}
?>
<?php
if (count($users_in_course) > 0) {
?>
<form method="post" action="index?action=attendance_sheet_add&<?php echo api_get_cidreq().$param_gradebook ?>&attendance_id=<?php echo $attendance_id?>" >
<div class="attendance-sheet-content" style="width:100%;background-color:#E1E1E1;border:1px solid gray;margin-top:20px;">
<div class="attendance-users-table" style="width:450px;float:left;">
<table class="data_table" width="100%">
<tr class="row_odd" >
<th height="60px" width="35px" ><?php echo get_lang('Order')?></th>
<th width="45px" ><?php echo get_lang('Photo')?></th>
<th><?php echo get_lang('LastName')?></th>
<th><?php echo get_lang('FirstName')?></th>
<th width="90px"><?php echo get_lang('faults')?></th>
</tr>
<?php
$i = 1;
$class = '';
foreach ($users_in_course as $data) {
$faults = 0;
if ($i%2 == 0) {$class='row_odd';}
else {$class='row_even';}
?>
<tr class="<?php echo $class ?>">
<td height="50px"><center><?php echo $i ?></center></td>
<td><?php echo $data['photo'] ?></td>
<td><?php echo $data['lastname'] ?></td>
<td><?php echo $data['firstname'] ?></td>
<td><center><div class="attendance-faults-bar" style="background-color:<?php echo (!empty($data['result_color_bar'])?$data['result_color_bar']:'none') ?>"><?php echo $data['attendance_result'] ?></div></center></td>
</tr>
<?php
$i++;
}
?>
</table>
if (count($users_in_course) > 0) {
?>
<form method="post" action="index?action=attendance_sheet_add&<?php echo api_get_cidreq().$param_gradebook ?>&attendance_id=<?php echo $attendance_id?>" >
<div class="attendance-sheet-content" style="width:100%;background-color:#E1E1E1;border:1px solid gray;margin-top:20px;">
</div>
<div class="attendance-users-table" style="width:450px;float:left;">
<div class="attendance-calendar-table" style="overflow:auto;overflow-y:hidden;">
<table class="data_table" width="100%">
<tr class="row_odd">
<?php
if (count($attendant_calendar) > 0 ) {
foreach ($attendant_calendar as $calendar) {
//$datetime = explode(' ',$calendar['date_time']);
$date = $calendar['date'];
$time = $calendar['time'];
$datetime = $date.'<br />'.$time;
$checked_date = '';
if (!empty($calendar['done_attendance'])){
$datetime = '<font color="blue">'.$date.'<br />'.$time.'</font>';
}
if ($next_attendance_calendar_id == $calendar['id']) {
$checked_date = 'checked';
}
<table class="data_table" width="100%">
<tr class="row_odd" >
<th height="60px" width="35px" ><?php echo get_lang('Order')?></th>
<th width="45px" ><?php echo get_lang('Photo')?></th>
<th><?php echo get_lang('LastName')?></th>
<th><?php echo get_lang('FirstName')?></th>
<th width="90px"><?php echo get_lang('faults')?></th>
</tr>
<?php
$i = 1;
$class = '';
foreach ($users_in_course as $data) {
$faults = 0;
if ($i%2 == 0) {$class='row_odd';}
else {$class='row_even';}
?>
<th height="60px" style="padding:5px;"><?php echo '<span style="font-size:10px;">'.$datetime.'<br /><input type="checkbox" id="datetime_column_'.$calendar['id'].'" '.$checked_date.'/></span>' ?></th>
<?php }
} else { ?>
<th height="60px" style="padding:5px;"><span><a href="index?<?php echo api_get_cidreq() ?>&action=calendar_list&attendance_id=<?php echo $attendance_id.$param_gradebook ?>">
<?php echo Display::return_icon('calendar_up.gif',get_lang('AttendanceCalendar')).' '.get_lang('GoToAttendanceCalendar') ?></a></span></th>
<?php } ?>
</tr>
<?php
$i = 0;
foreach ($users_in_course as $user) {
$class = '';
if ($i%2==0) {$class = 'row_even';}
else {$class = 'row_odd';}
?>
<tr class="<?php echo $class ?>">
<tr class="<?php echo $class ?>">
<td height="50px"><center><?php echo $i ?></center></td>
<td><?php echo $data['photo'] ?></td>
<td><?php echo $data['lastname'] ?></td>
<td><?php echo $data['firstname'] ?></td>
<td><center><div class="attendance-faults-bar" style="background-color:<?php echo (!empty($data['result_color_bar'])?$data['result_color_bar']:'none') ?>"><?php echo $data['attendance_result'] ?></div></center></td>
</tr>
<?php
$i++;
}
?>
</table>
</div>
<div class="attendance-calendar-table" style="overflow:auto;overflow-y:hidden;">
<table class="data_table" width="100%">
<tr class="row_odd">
<?php
if (count($attendant_calendar) > 0 ) {
foreach ($attendant_calendar as $calendar) {
$checked = 'checked';
if (isset($users_presence[$user['user_id']][$calendar['id']]['presence'])) {
$presence = $users_presence[$user['user_id']][$calendar['id']]['presence'];
if (intval($presence) == 1) {
$checked = 'checked';
} else {
$checked = '';
}
}
$disabled = 'disabled';
$style_td = '';
foreach ($attendant_calendar as $calendar) {
//$datetime = explode(' ',$calendar['date_time']);
$date = $calendar['date'];
$time = $calendar['time'];
$datetime = $date.'<br />'.$time;
$checked_date = '';
if (!empty($calendar['done_attendance'])){
$datetime = '<font color="blue">'.$date.'<br />'.$time.'</font>';
}
if ($next_attendance_calendar_id == $calendar['id']) {
$style_td = 'background-color:#e1e1e1';
$disabled = '';
}
?>
<td height="50px" style="<?php echo $style_td ?>" class="checkboxes_col_<?php echo $calendar['id'] ?>"><center><input type="checkbox" name="check_presence[]" value="cal_<?php echo $calendar['id'] ?>_user_<?php echo $user['user_id'] ?>" <?php echo $disabled.' '.$checked ?> /><span class="<?php echo 'anchor_'.$calendar['id'] ?>"></span></center></td>
<?php }
$checked_date = 'checked';
}
?>
<th height="60px" style="padding:5px;"><?php echo '<span style="font-size:10px;">'.$datetime.'<br /><input type="checkbox" name="datetime_column['.$calendar['id'].']" id="datetime_column_'.$calendar['id'].'" '.$checked_date.'/></span>' ?></th>
<?php }
} else { ?>
<td height="50px" class="checkboxes_col_<?php echo $calendar['id'] ?>"><center>&nbsp;</center></td>
<?php } ?>
</tr>
<?php $i++ ;
}
?>
</table>
<th height="60px" style="padding:5px;"><span><a href="index?<?php echo api_get_cidreq() ?>&action=calendar_list&attendance_id=<?php echo $attendance_id.$param_gradebook ?>">
<?php echo Display::return_icon('calendar_up.gif',get_lang('AttendanceCalendar')).' '.get_lang('GoToAttendanceCalendar') ?></a></span></th>
<?php } ?>
</tr>
<?php
$i = 0;
foreach ($users_in_course as $user) {
$class = '';
if ($i%2==0) {$class = 'row_even';}
else {$class = 'row_odd';}
?>
<tr class="<?php echo $class ?>">
<?php
if (count($attendant_calendar) > 0 ) {
foreach ($attendant_calendar as $calendar) {
$checked = 'checked';
if (isset($users_presence[$user['user_id']][$calendar['id']]['presence'])) {
$presence = $users_presence[$user['user_id']][$calendar['id']]['presence'];
if (intval($presence) == 1) {
$checked = 'checked';
} else {
$checked = '';
}
}
$disabled = 'disabled';
$style_td = '';
if ($next_attendance_calendar_id == $calendar['id']) {
$style_td = 'background-color:#e1e1e1';
$disabled = '';
}
?>
<td height="50px" style="<?php echo $style_td ?>" class="checkboxes_col_<?php echo $calendar['id'] ?>"><center><input type="checkbox" name="check_presence[]" value="cal_<?php echo $calendar['id'] ?>_user_<?php echo $user['user_id'] ?>" <?php echo $disabled.' '.$checked ?> /><span class="<?php echo 'anchor_'.$calendar['id'] ?>"></span></center></td>
<?php }
} else { ?>
<td height="50px" class="checkboxes_col_<?php echo $calendar['id'] ?>"><center>&nbsp;</center></td>
<?php } ?>
</tr>
<?php $i++ ;
}
?>
</table>
</div>
</div>
</div>
<div class="clear"></div>
<div style="margin-top:20px;"><button type="submit" class="save"><?php echo get_lang('SaveAttendanceSheet') ?></button></div>
</form>
<?php } else {
echo '<div><a href="'.api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'">'.get_lang('ThereAreNoRegisteredLearnersInsidetheCourse').'</a></div>';
}
<div class="clear"></div>
<div style="margin-top:20px;"><button type="submit" class="save"><?php echo get_lang('SaveAttendanceSheet') ?></button></div>
</form>
<?php } else {
echo '<div><a href="'.api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'">'.get_lang('ThereAreNoRegisteredLearnersInsidetheCourse').'</a></div>';
}
} else {
// View for students
$user_id = api_get_user_id();
?>
<h3><?php echo get_lang('AttendanceSheetReport') ?></h3>
<div>

@ -71,7 +71,7 @@ if (isset($descriptions) && count($descriptions) > 0) {
$progress = (isset($description['progress'])?$description['progress'].'%':'');
if ($description['description_type'] == THEMATIC_ADVANCE) {
echo '<a name="thematic_advance"></a>';
echo get_lang('ThematicAdvance').' : '.$description['title'].' - '.$progress;
} else {
echo $description['title'];

@ -162,7 +162,6 @@ if ($is_speacialcourse==true){
}
}
/*
-----------------------------------------------------------
Is the user allowed here?

@ -49,7 +49,7 @@ if (empty($extension) || !file_exists($archive_path.$archive_file)) {
$content_type = '';
if (in_array(strtolower($extension), array('xml','csv')) && api_is_platform_admin(true)) {
if (in_array(strtolower($extension), array('xml','csv')) && (api_is_platform_admin(true) || api_is_drh())) {
$content_type = 'application/force-download';
}
elseif (strtolower($extension) == 'zip' && $_cid && $is_courseAdmin) {

@ -37,6 +37,7 @@ class DashboardController { // extends Controller {
$data = array();
$user_id = $this->user_id;
$block_data_without_plugin = DashboardManager::get_block_data_without_plugin();
$dashboard_blocks = DashboardManager::get_enabled_dashboard_blocks();
$user_block_data = DashboardManager::get_user_block_data($user_id);
$user_blocks_id = array_keys($user_block_data);

@ -12,9 +12,7 @@ $language_file = array ('registration', 'index', 'tracking', 'userInfo');
// including files
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'dashboard.lib.php';
require_once api_get_path(LIBRARY_PATH).'display.lib.php';
require_once api_get_path(LIBRARY_PATH).'app_view.php';
require_once 'dashboard_controller.php';
require_once 'block.class.php';

@ -39,6 +39,34 @@ class Attendance
return $obj->total_number_of_items;
}
/**
* Get attendance list
* @param string course code (optional)
* @param int session id (optional)
* @return array attendances list
*/
function get_attendances_list($course_code = '', $session_id = 0) {
// initializing database table and variables
$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
$session_id = intval($session_id);
$data = array();
if (!empty($course_code)) {
$course_info = api_get_course_info($course_code);
$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE, $course_info['dbName']);
}
// get attendance data
$sql = "SELECT * FROM $tbl_attendance WHERE session_id='$session_id'";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0){
while ($row = Database::fetch_array($rs)) {
$data[$row['id']] = $row;
}
}
return $data;
}
/**
* Get the attendaces to display on the current page (fill the sortable-table)
* @param int offset of first user to recover
@ -73,7 +101,13 @@ class Attendance
}
while ($attendance = Database::fetch_row($res)) {
$attendance[1] = '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance[0].$param_gradebook.'">'.$attendance[1].'</a>';
$student_param = '';
if (api_is_drh() && ($_GET['student_id'])) {
$student_param = '&student_id='.Security::remove_XSS($_GET['student_id']);
}
$attendance[1] = '<a href="index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance[0].$param_gradebook.$student_param.'">'.$attendance[1].'</a>';
$attendance[3] = '<center>'.$attendance[3].'</center>';
if (api_is_allowed_to_edit(null, true)) {
$actions = '';
@ -247,7 +281,8 @@ class Attendance
foreach ($a_course_users as $key => $value) {
$uid = intval($value['user_id']);
if ($uid <= 1) continue;
$status = $value['status'];
if ($uid <= 1 || $status == DRH) continue;
if (!empty($attendance_id)) {
$attendance_id = intval($attendance_id);
$user_faults = $this->get_faults_of_user($uid, $attendance_id);
@ -409,13 +444,16 @@ class Attendance
* @return array results containing number of faults, total done attendance, porcent of faults and color depend on result (red, orange)
*/
public function get_faults_of_user($user_id, $attendance_id) {
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
// initializing database table and variables
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
$user_id = intval($user_id);
$attendance_id = intval($attendance_id);
$results = array();
$attendance_data = $this->get_attendance_by_id($attendance_id);
$total_done_attendance = $attendance_data['attendance_qualify_max'];
$attendance_user_score = $this->get_user_score($user_id, $attendance_id);
// calculate results
$faults = $total_done_attendance-$attendance_user_score;
$faults = $faults > 0 ? $faults:0;
@ -432,6 +470,92 @@ class Attendance
$results['color_bar'] = $color_bar;
return $results;
}
/**
* Get results of faults average for all courses by user
* @param int user id
* @return array results containing number of faults, total done attendance, porcent of faults and color depend on result (red, orange)
*/
public function get_faults_average_inside_courses($user_id) {
// get all courses of current user
$courses = CourseManager::get_courses_list_by_user_id($user_id, true);
$user_id = intval($user_id);
$results = array();
$total_faults = $total_weight = $porcent = 0;
foreach ($courses as $course) {
$course_code = $course['code'];
$course_info = api_get_course_info($course_code);
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT, $course_info['dbName']);
$attendances_by_course = $this->get_attendances_list($course_code);
foreach ($attendances_by_course as $attendance) {
// get total faults and total weight
$attendance_id = $attendance['id'];
$total_done_attendance = $attendance['attendance_qualify_max'];
$sql = "SELECT score FROM $tbl_attendance_result WHERE user_id='$user_id' AND attendance_id='$attendance_id'";
$rs = Database::query($sql);
$score = 0;
if (Database::num_rows($rs) > 0) {
$row = Database::fetch_array($rs);
$score = $row['score'];
}
$faults = $total_done_attendance-$score;
$faults = $faults > 0 ? $faults:0;
$total_faults += $faults;
$total_weight += $total_done_attendance;
}
}
$porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0;
$results['faults'] = $total_faults;
$results['total'] = $total_weight;
$results['porcent'] = $porcent;
return $results;
}
/**
* Get results of faults average by course
* @param int user id
* @return array results containing number of faults, total done attendance, porcent of faults and color depend on result (red, orange)
*/
public function get_faults_average_by_course($user_id, $course_code) {
// Database tables and variables
$course_info = api_get_course_info($course_code);
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT, $course_info['dbName']);
$user_id = intval($user_id);
$results = array();
$total_faults = $total_weight = $porcent = 0;
$attendances_by_course = $this->get_attendances_list($course_code);
foreach ($attendances_by_course as $attendance) {
// get total faults and total weight
$attendance_id = $attendance['id'];
$total_done_attendance = $attendance['attendance_qualify_max'];
$sql = "SELECT score FROM $tbl_attendance_result WHERE user_id='$user_id' AND attendance_id='$attendance_id'";
$rs = Database::query($sql);
$score = 0;
if (Database::num_rows($rs) > 0) {
$row = Database::fetch_array($rs);
$score = $row['score'];
}
$faults = $total_done_attendance-$score;
$faults = $faults > 0 ? $faults:0;
$total_faults += $faults;
$total_weight += $total_done_attendance;
}
$porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0;
$results['faults'] = $total_faults;
$results['total'] = $total_weight;
$results['porcent'] = $porcent;
return $results;
}
/**
* Get registered users' attendance sheet inside current course

@ -7,11 +7,13 @@
* @package chamilo.dashboard
*/
// required files
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
/**
* DashboardManager can be used to manage dashboard
* @package chamilo.dashboard
*/
class DashboardManager
{
/**
@ -42,7 +44,7 @@ class DashboardManager
echo '<th>'.get_lang('Description').'</th>';
echo '</tr>';
$disabled_block_data = self::get_block_data_without_plugin();
$disabled_blocks_data = self::get_block_data_without_plugin();
// We display all the possible enabled or disabled plugins
foreach ($possibleplugins as $testplugin) {
@ -68,16 +70,14 @@ class DashboardManager
}
echo '</tr>';
}
// display all disabled block data
if (count($disabled_block_data) > 0) {
foreach ($disabled_block_data as $disabled_block) {
if (count($disabled_blocks_data) > 0) {
foreach ($disabled_blocks_data as $disabled_block) {
echo '<tr style="background-color:#eee">';
echo '<td><center><input type="checkbox" name="disabled_block" value="true" disabled /></center>';
echo '<td><center><input type="checkbox" name="disabled_block" value="true" checked disabled /></center>';
for ($j = 0 ; $j < count($table_cols); $j++) {
if (isset($disabled_block[strtolower($table_cols[$j])])) {
if ($j == 2) {
echo '<td>';
echo '<font color="#aaa">'.$disabled_block[$table_cols[$j]].'</font><br />';
@ -88,8 +88,6 @@ class DashboardManager
echo '<font color="#aaa">'.$disabled_block[$table_cols[$j]].'</font>';
echo '</td>';
}
} else {
echo '<td>&nbsp;</td>';
}
@ -97,7 +95,7 @@ class DashboardManager
echo '</tr>';
}
}
echo '</table>';
echo '<br />';
echo '<button class="save" type="submit" name="submit_dashboard_plugins" value="'.get_lang('EnableDashboardPlugins').'">'.get_lang('EnableDashboardPlugins').'</button></form>';
@ -141,30 +139,73 @@ class DashboardManager
$dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/';
$possibleplugins = self::get_posible_dashboard_plugins_path();
$condition_path = '';
if (count($possibleplugins) > 0) {
$tmp_possibleplugins = $possibleplugins;
foreach ($tmp_possibleplugins as &$plugins) {
$plugins = "'".$plugins."'";
}
$condition_path = ' WHERE path IN('.implode(',',$tmp_possibleplugins).')';
// clean block table for adding paths
$sql = "SELECT id FROM $tbl_block $condition_path ";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
$sql_del = "DELETE FROM $tbl_block $condition_path ";
Database::query($sql_del);
$selected_plugins = array_intersect(array_keys($plugin_paths),$possibleplugins);
$not_selected_plugins = array_diff($possibleplugins,array_keys($plugin_paths));
// get blocks id from not selected path
$not_selected_blocks_id = array();
foreach ($not_selected_plugins as $plugin) {
$block_data = self::get_enabled_dashboard_blocks($plugin);
if (!empty($block_data[$plugin])) {
$not_selected_blocks_id[] = $block_data[$plugin]['id'];
}
}
/* clean not selected plugins for extra user data and block data */
// clean from extra user data
$field_variable = 'dashboard';
$extra_user_data = UserManager::get_extra_user_data_by_field_variable($field_variable);
foreach ($extra_user_data as $key => $user_data) {
$user_id = $key;
$user_block_data = self::get_user_block_data($user_id);
$user_block_id = array_keys($user_block_data);
// clean disabled block data
foreach ($user_block_id as $block_id) {
if (in_array($block_id, $not_selected_blocks_id)) {
unset($user_block_data[$block_id]);
}
}
// get columns and blocks id for updating extra user data
$columns = array();
$user_blocks_id = array();
foreach ($user_block_data as $data) {
$user_blocks_id[$data['block_id']] = true;
$columns[$data['block_id']] = $data['column'];
}
// get selected plugins
$selected_plugins = array();
if (!empty($plugin_paths)) {
$selected_plugins = array_intersect(array_keys($plugin_paths),$possibleplugins);
// update extra user blocks data
$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
}
// clean from block data
if (!empty($not_selected_blocks_id)) {
$sql_check = "SELECT id FROM $tbl_block WHERE id IN(".implode(',',$not_selected_blocks_id).")";
$rs_check = Database::query($sql_check);
if (Database::num_rows($rs_check) > 0) {
$del = "DELETE FROM $tbl_block WHERE id IN(".implode(',',$not_selected_blocks_id).")";
Database::query($del);
}
}
if (count($selected_plugins) > 0) {
foreach ($selected_plugins as $testplugin) {
// store selected plugins
foreach ($selected_plugins as $testplugin) {
$selected_path = Database::escape_string($testplugin);
// check if the path already stored inside block table for updating or adding it
$sql = "SELECT path FROM $tbl_block WHERE path = '$selected_path'";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
// update
$upd = "UPDATE $tbl_block SET active = 1 WHERE path = '$selected_path'";
Database::query($upd);
} else {
// insert
$plugin_info_file = $dashboard_pluginpath.$testplugin."/$testplugin.info";
$plugin_info = array();
if (file_exists($plugin_info_file)) {
@ -190,13 +231,14 @@ class DashboardManager
$plugin_controller = Database::escape_string($plugin_info['controller']);
}
$sql_ins = "INSERT INTO $tbl_block(name, description, path, controller) VALUES ('$plugin_name', '$plugin_description', '$plugin_path', '$plugin_controller')";
Database::query($sql_ins);
$affected_rows = Database::affected_rows();
$ins = "INSERT INTO $tbl_block(name, description, path, controller) VALUES ('$plugin_name', '$plugin_description', '$plugin_path', '$plugin_controller')";
Database::query($ins);
}
}
$affected_rows = Database::affected_rows();
}
}
return $affected_rows;
}
@ -242,7 +284,6 @@ class DashboardManager
} else {
$active = 1;
}
// update active
$upd = "UPDATE $tbl_block SET active = '$active' WHERE path = '".$row['path']."'";
Database::query($upd);
@ -272,10 +313,10 @@ class DashboardManager
$condition_path = '';
if (!empty($path)) {
$path = Database::escape_string($path);
$condition_path = ' WHERE path = "'.$path.'" ';
$condition_path = ' AND path = "'.$path.'" ';
}
$sql = "SELECT * FROM $tbl_block $condition_path WHERE active = 1";
$sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path ";
$rs = Database::query($sql);
$block_data = array();
if (Database::num_rows($rs) > 0) {
@ -293,6 +334,7 @@ class DashboardManager
*/
public static function display_user_dashboard_list($user_id) {
$block_data_without_plugin = self::get_block_data_without_plugin();
$enabled_dashboard_plugins = self::get_enabled_dashboard_blocks();
$user_block_data = self::get_user_block_data($user_id);

@ -1740,6 +1740,15 @@ function api_is_session_admin() {
return $_user['status'] == SESSIONADMIN;
}
/**
* Check if the current user is a human resources manager
* @return boolean True if current user is a human resources manager
*/
function api_is_drh() {
global $_user;
return $_user['status'] == DRH;
}
/**
* This function check is a session is assigned into a category
* @param int - session id

@ -1055,11 +1055,11 @@ class SessionManager {
}
/**
* Get assigned sessions to human resources manager
* @param int Human resources manager id
* @return array assigned sessions
* Get sessions followed by human resources manager
* @param int Human resources manager id
* @return array sessions
*/
public static function get_assigned_sessions_to_hr_manager($hr_manager_id) {
public static function get_sessions_followed_by_drh($hr_manager_id) {
// Database Table Definitions
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);

@ -13,6 +13,7 @@ require '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
$this_section = "session_my_space";
$id_session = intval($_GET['id_session']);
@ -58,6 +59,33 @@ if (api_get_setting('add_users_by_coach') == 'true') {
Display :: display_header($nameTools);
$a_courses = array();
if (api_is_drh()) {
$a_courses = array_keys(CourseManager::get_courses_followed_by_drh($_user['user_id']));
$menu_items[] = '<a href="index.php?view=drh_students">'.get_lang('Learners').'</a>';
$menu_items[] = '<a href="teachers.php">'.get_lang('Teachers').'</a>';
$menu_items[] = get_lang('Trainings');
$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
echo '<div class="actions-title" style ="font-size:10pt;">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
echo $item;
if ($key != $nb_menu_items - 1) {
echo '&nbsp;|&nbsp;';
}
}
}
if (count($a_courses) > 0) {
echo '&nbsp;&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';
}
echo '</div>';
echo '<br />';
}
// Database Table Definitions
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_user_course = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@ -82,24 +110,29 @@ if ($show_import_icon) {
echo "</div><br />";
}
$a_courses = Tracking :: get_courses_followed_by_coach($_user['user_id'], $id_session);
if (!api_is_drh()) {
$a_courses = Tracking :: get_courses_followed_by_coach($_user['user_id'], $id_session);
}
$nb_courses = count($a_courses);
$table = new SortableTable('tracking_list_course', 'count_courses');
$table -> set_header(0, get_lang('CourseTitle'), false, 'align="center"');
$table -> set_header(1, get_lang('NbStudents'), false);
$table -> set_header(2, get_lang('TimeSpentInTheCourse'), false);
$table -> set_header(3, get_lang('AvgStudentsProgress'), false);
$table -> set_header(4, get_lang('AvgCourseScore'), false);
$table -> set_header(3, get_lang('ThematicAdvance'), false);
$table -> set_header(4, get_lang('AvgStudentsProgress'), false);
$table -> set_header(5, get_lang('AvgCourseScore'), false);
//$table -> set_header(5, get_lang('AvgExercisesScore'), false);// no code for this?
$table -> set_header(5, get_lang('AvgMessages'), false);
$table -> set_header(6, get_lang('AvgAssignments'), false);
$table -> set_header(7, get_lang('Details'), 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);
$csv_header[] = array(
get_lang('CourseTitle', ''),
get_lang('NbStudents', ''),
get_lang('TimeSpentInTheCourse', ''),
get_lang('ThematicAdvance', ''),
get_lang('AvgStudentsProgress', ''),
get_lang('AvgCourseScore', ''),
//get_lang('AvgExercisesScore', ''),
@ -149,11 +182,24 @@ if (is_array($a_courses)) {
$avg_messages_in_course = null;
$avg_assignments_in_course = null;
}
$tematic_advance_progress = 0;
$course_description = new CourseDescription();
$course_description->set_session_id(0);
$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
if (!empty($tematic_advance)) {
$tematic_advance_csv = $tematic_advance_progress.'%';
$tematic_advance_progress = '<a title="'.get_lang('GoToThematicAdvance').'" href="'.api_get_path(WEB_CODE_PATH).'course_description/?cidReq='.$course_code.'#thematic_advance">'.$tematic_advance['progress'].'%</a>';
} else {
$tematic_advance_progress = '0%';
}
$table_row = array();
$table_row[] = $course['title'];
$table_row[] = $nb_students_in_course;
$table_row[] = $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[] = $avg_messages_in_course;
@ -164,6 +210,7 @@ if (is_array($a_courses)) {
$course['title'],
$nb_students_in_course,
$avg_time_spent_in_course,
$tematic_advance_csv,
is_null($avg_progress_in_course) ? null : $avg_progress_in_course.'%',
is_null($avg_score_in_course) ? null : $avg_score_in_course.'%',
$avg_messages_in_course,

@ -15,6 +15,7 @@ require_once '../inc/global.inc.php';
// including additional libraries
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
// the section (for the tabs)
@ -124,6 +125,7 @@ if (api_is_allowed_to_create_course()) {
}
}
}
if ($is_coach) {
if ($nb_teacher_courses == 0 && !$is_platform_admin) {
$view = 'coach';
@ -135,6 +137,7 @@ if ($is_coach) {
$menu_items[] = '<a href="'.api_get_self().'?view=coach">'.get_lang('CoachInterface').'</a>';
}
}
if ($is_platform_admin) {
if (!$is_coach && $nb_teacher_courses == 0) {
$view = 'admin';
@ -146,24 +149,27 @@ if ($is_platform_admin) {
$menu_items[] = '<a href="'.api_get_self().'?view=admin">'.get_lang('AdminInterface').'</a>';
}
}
if ($_user['status'] == DRH) {
$view = 'drh';
$title = get_lang('DrhInterface');
$menu_items[] = '<a href="'.api_get_self().'?view=drh">'.get_lang('DrhInterface').'</a>';
if (api_is_drh()) {
$view = 'drh_students';
$menu_items[] = get_lang('Learners');
$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
$menu_items[] = '<a href="course.php">'.get_lang('Trainings').'</a>';
$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
}
echo '<div class="actions">';
echo '<div class="actions-title" style ="font-size:10pt;">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
echo $item;
if ($key != $nb_menu_items - 1) {
echo ' | ';
echo '&nbsp;|&nbsp;';
}
}
}
echo '&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';
echo '&nbsp;&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';
if ($view == 'admin') {
echo (isset($_GET['display']) && $_GET['display'] == 'useroverview')? '<a href="'.api_get_self().'?display=useroverview&export=csv&view='.$view.'"><img align="absbottom" src="../img/csv.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>' : '';
} else {
@ -172,9 +178,10 @@ if ($view == 'admin') {
echo '</div>';
echo '<h4>'.$title.'</h4>';
if ($_user['status'] == DRH && $view == 'drh') {
$students = Tracking :: get_student_followed_by_drh($_user['user_id']);
$courses_of_the_platform = CourseManager :: get_real_course_list();
if (api_is_drh() && $view == 'drh_students') {
// get data for human resources manager
$students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT));
$courses_of_the_platform = CourseManager :: get_real_course_list();
foreach ($courses_of_the_platform as $course) {
$courses[$course['code']] = $course['code'];
}
@ -185,9 +192,9 @@ if ($is_coach && $view == 'coach') {
$courses = Tracking :: get_courses_followed_by_coach($_user['user_id']);
}
if ($view == 'coach' || $view == 'drh') {
$nb_students = count($students);
if ($view == 'coach' || $view == 'drh_students') {
$nb_students = count($students);
$total_time_spent = 0;
$total_courses = 0;
$avg_total_progress = 0;
@ -335,11 +342,12 @@ if ($view == 'coach' || $view == 'drh') {
'.(is_null($nb_assignments) ? '' : round($nb_assignments, 2)).'
</td>
</tr>
</table>
</table><br />
<a href="student.php">'.get_lang('SeeStudentList').'</a>
</div>';
}
}
if ($view == 'coach') {
/****************************************
* Infos about sessions of the coach

@ -17,6 +17,7 @@ require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php';
require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
$htmlHeadXtra[] = '<script type="text/javascript">
@ -104,13 +105,14 @@ if (isset ($_GET['details'])) {
"name" => get_lang("MyStudents")
);
$interbreadcrumb[] = array (
"url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']),
"url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']),
"name" => get_lang("StudentDetails")
);
}
}
$nameTools = get_lang("DetailsStudentInCourse");
} else {
if (!empty ($_GET['origin']) && $_GET['origin'] == 'resume_session') {
$interbreadcrumb[] = array (
'url' => '../admin/index.php',
@ -447,7 +449,7 @@ if (!empty ($_GET['student'])) {
<?php echo get_lang('TimeSpentInTheCourse') ?>
</td>
<td align="left">
<?php echo $time_spent_on_the_course ?>
<?php echo $time_spent_on_the_course ?>
</td>
</tr>
<tr>
@ -1049,6 +1051,9 @@ if (!empty ($_GET['student'])) {
<th>
<?php echo get_lang('Time'); ?>
</th>
<th>
<?php echo get_lang('AttendanceFaults'); ?>
</th>
<th>
<?php echo get_lang('Progress'); ?>
</th>
@ -1074,13 +1079,26 @@ if (!empty ($_GET['student'])) {
$csv_content[] = array (
get_lang('Course', ''),
get_lang('Time', ''),
get_lang('AttendanceFaults', ''),
get_lang('Progress', ''),
get_lang('Score', '')
);
$attendance = new Attendance();
foreach ($courses as $course_code) {
if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
$course_info = CourseManager :: get_course_information($course_code);
$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($info_user['user_id'], $course_code));
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_by_course($student_id, $course_code);
if (!empty($results_faults_avg)) {
$attendances_faults_avg = '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$course_code.'&student_id='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
} else {
$attendances_faults_avg = '0%';
}
$progress = Tracking :: get_avg_student_progress($info_user['user_id'], $course_code);
$score = Tracking :: get_avg_student_score($info_user['user_id'], $course_code);
$progress = empty($progress) ? '0%' : $progress.'%';
@ -1100,8 +1118,11 @@ if (!empty ($_GET['student'])) {
' . $time_spent_on_course . '
</td>
<td align="right">
' . $progress . '
'. $attendances_faults_avg . '
</td>
<td align="right">
' . $progress . '
</td>
<td align="right">
' . $score . '
</td>';

@ -12,6 +12,7 @@ $cidReset = true;
require '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
api_block_anonymous_users();
@ -76,8 +77,36 @@ if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
} else {
$id_coach = $_user['user_id'];
}
if (api_is_drh()) {
$a_sessions = SessionManager::get_sessions_followed_by_drh($_user['user_id']);
$menu_items[] = '<a href="index.php?view=drh_students">'.get_lang('Learners').'</a>';
$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
$menu_items[] = '<a href="course.php">'.get_lang('Trainings').'</a>';
$menu_items[] = get_lang('Sessions');
echo '<div class="actions-title" style ="font-size:10pt;">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
echo $item;
if ($key != $nb_menu_items - 1) {
echo '&nbsp;|&nbsp;';
}
}
}
if (count($a_sessions) > 0) {
echo '&nbsp;&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';
echo '<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
}
echo '</div>';
} else {
$a_sessions = Tracking :: get_sessions_coached_by_user($id_coach);
}
$a_sessions = Tracking :: get_sessions_coached_by_user($id_coach);
$nb_sessions = count($a_sessions);
if ($export_csv) {
@ -85,21 +114,24 @@ if ($export_csv) {
}
if ($nb_sessions > 0) {
echo '<div align="right">
<a href="javascript: void(0);" onclick="javascript: window.print();"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
</div>';
if (!api_is_drh()) {
echo '<div align="right">
<a href="javascript: void(0);" onclick="javascript: window.print();"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
</div>';
}
$table = new SortableTable('tracking', 'count_sessions_coached');
$table -> set_header(0, get_lang('Title'));
$table -> set_header(1, get_lang('Status'));
$table -> set_header(2, get_lang('Date'));
$table -> set_header(3, get_lang('Details'), false);
//$table -> set_header(1, get_lang('Status'));
$table -> set_header(1, get_lang('Date'));
$table -> set_header(2, get_lang('Details'), false);
$all_data = array();
foreach ($a_sessions as $session) {
$row = array();
$row[] = $session['name'];
$row[] = $session['status'];
//$row[] = $session['status'];
if ($session['date_start'] != '0000-00-00' && $session['date_end'] != '0000-00-00') {
$row[] = get_lang('From').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($session['date_start'])).' '.get_lang('To').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($session['date_end']));
@ -137,7 +169,7 @@ if ($nb_sessions > 0) {
$table -> addRow($row);
}
$table -> setColAttributes(3, array('align' => 'center'));
$table -> setColAttributes(2, array('align' => 'center'));
$table -> display();
if ($export_csv) {

@ -95,7 +95,7 @@ function rsort_users($a, $b)
===============================================================================
*/
if ($isCoach || api_is_platform_admin() || $_user['status'] == DRH) {
if ($isCoach || api_is_platform_admin() || api_is_drh()) {
if ($export_csv) {
$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
@ -103,13 +103,45 @@ if ($isCoach || api_is_platform_admin() || $_user['status'] == DRH) {
$is_western_name_order = api_is_western_name_order();
}
$sort_by_first_name = api_sort_by_first_name();
echo '<div align="left" style="float:left"><h4>'.$title.'</h4></div>
<div align="right">
<a href="javascript: void(0);" onclick="javascript: window.print();"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
</div><div class="clear"></div>';
if (api_is_drh()) {
if (!isset($_GET['id_session'])) {
$students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT));
$courses_of_the_platform = CourseManager :: get_real_course_list();
foreach ($courses_of_the_platform as $course) {
$courses[$course['code']] = $course['code'];
}
}
$menu_items[] = get_lang('Learners');
$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
$menu_items[] = '<a href="course.php">'.get_lang('Trainings').'</a>';
$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
echo '<div class="actions-title" style ="font-size:10pt;">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
echo $item;
if ($key != $nb_menu_items - 1) {
echo '&nbsp;|&nbsp;';
}
}
}
if (count($students) > 0) {
echo '&nbsp;&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';
echo '<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
}
echo '</div>';
} else {
echo '<div align="left" style="float:left"><h4>'.$title.'</h4></div>
<div align="right">
<a href="javascript: void(0);" onclick="javascript: window.print();"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
</div><div class="clear"></div>';
}
if (isset($_GET['id_coach'])) {
$coach_id = intval($_GET['id_coach']);
} else {
@ -120,14 +152,7 @@ if ($isCoach || api_is_platform_admin() || $_user['status'] == DRH) {
if ($isCoach) {
$courses = Tracking :: get_courses_followed_by_coach($coach_id);
$students = Tracking :: get_student_followed_by_coach($coach_id);
}
elseif ($_user['status'] == DRH) {
$students = Tracking :: get_student_followed_by_drh($_user['user_id']);
$courses_of_the_platform = CourseManager :: get_real_course_list();
foreach ($courses_of_the_platform as $course) {
$courses[$course['code']] = $course['code'];
}
}
}
} else {
$students = Tracking :: get_student_followed_by_coach_in_a_session($_GET['id_session'], $coach_id);
}
@ -264,7 +289,7 @@ if ($isCoach || api_is_platform_admin() || $_user['status'] == DRH) {
$table -> setColAttributes(9, array('align' => 'center'));
$table -> display();
} else {
echo get_lang('NoStudent');
echo '<p>'.get_lang('NoStudent').'</p>';
}
// send the csv file if asked

@ -12,6 +12,7 @@ $cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
$this_section = "session_my_space";
@ -21,7 +22,38 @@ api_block_anonymous_users();
$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
Display :: display_header($nameTools);
api_display_tool_title($nameTools);
$formateurs = array();
if (api_is_drh()) {
// followed teachers by drh
$formateurs = UserManager::get_users_followed_by_drh($_user['user_id'], COURSEMANAGER);
$menu_items[] = '<a href="index.php?view=drh_students">'.get_lang('Learners').'</a>';
$menu_items[] = get_lang('Trainers');
$menu_items[] = '<a href="course.php">'.get_lang('Trainings').'</a>';
$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
echo '<div class="actions-title" style ="font-size:10pt;">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
echo $item;
if ($key != $nb_menu_items - 1) {
echo '&nbsp;|&nbsp;';
}
}
}
if (count($formateurs) > 0) {
echo '&nbsp;&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';
echo '<a href="'.api_get_self().'?export=xls"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsXLS').'</a>';
}
echo '</div>';
echo '<br />';
}
if (!api_is_drh()) {
api_display_tool_title($nameTools);
}
// Database Table Definitions
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
@ -42,20 +74,27 @@ if (isset($_POST['export'])) {
}
$sort_by_first_name = api_sort_by_first_name();
$order_clause = $sort_by_first_name ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
if (isset($_GET["teacher_id"]) && $_GET["teacher_id"] != 0) {
$teacher_id = intval($_GET["teacher_id"]);
$sql_formateurs = "SELECT user_id,lastname,firstname,email
FROM $tbl_user
WHERE user_id='$teacher_id'".$order_clause;
} else {
$sql_formateurs = "SELECT user_id,lastname,firstname,email
FROM $tbl_user
WHERE status = 1".$order_clause;
if (!api_is_drh()) {
$order_clause = $sort_by_first_name ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
if (isset($_GET["teacher_id"]) && $_GET["teacher_id"] != 0) {
$teacher_id = intval($_GET["teacher_id"]);
$sql_formateurs = "SELECT user_id,lastname,firstname,email
FROM $tbl_user
WHERE user_id='$teacher_id'".$order_clause;
} else {
$sql_formateurs = "SELECT user_id,lastname,firstname,email
FROM $tbl_user
WHERE status = 1".$order_clause;
}
$result_formateurs = Database::query($sql_formateurs);
if (Database::num_rows($result_formateurs) > 0) {
while ($row_formateurs = Database::fetch_array($result_formateurs)) {
$formateurs[] = $row_formateurs;
}
}
}
$result_formateurs = Database::query($sql_formateurs);
if ($is_western_name_order) {
echo '<table class="data_table"><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 {
@ -73,15 +112,14 @@ $header[] = get_lang('Email', '');
$data = array();
if (Database::num_rows($result_formateurs) > 0) {
if (count($formateurs) > 0) {
$i = 1;
while ($formateurs = Database::fetch_array($result_formateurs)) {
$user_id = $formateurs["user_id"];
$lastname = $formateurs["lastname"];
$firstname = $formateurs["firstname"];
$email = $formateurs["email"];
foreach ($formateurs as $formateur) {
$user_id = $formateur["user_id"];
$lastname = $formateur["lastname"];
$firstname = $formateur["firstname"];
$email = $formateur["email"];
if ($i % 2 == 0) {
$css_class = "row_odd";
@ -120,12 +158,14 @@ if (Database::num_rows($result_formateurs) > 0) {
}
echo '</table>';
if (isset($_POST['export'])) {
if (isset($_POST['export']) || (api_is_drh() && isset($_GET['export']))) {
export_csv($header, $data, 'teachers.csv');
}
echo "<br /><br />";
echo "<form method='post' action='teachers.php'><input type='submit' name='export' value='".get_lang('exportExcel')."'/><form>";
if (!api_is_drh()) {
echo "<form method='post' action='teachers.php'><input type='submit' name='export' value='".get_lang('exportExcel')."'/><form>";
}
/*
==============================================================================

@ -35,7 +35,7 @@ if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
}
// access restrictions
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin || api_is_drh();
if (!$is_allowedToTrack) {
Display :: display_header(null);

@ -105,7 +105,7 @@ $interbreadcrumb[] = array ("url" => api_get_self()."?view=0000000", "name" => g
include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
include("../resourcelinker/resourcelinker.inc.php");
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin;
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || api_is_drh();
/*
==============================================================================

@ -28,8 +28,12 @@ class BlockCourse extends Block {
* Constructor
*/
public function __construct ($user_id) {
$this->user_id = $user_id;
$this->courses = CourseManager::get_assigned_courses_to_hr_manager($user_id);
$this->user_id = $user_id;
if (api_is_platform_admin()) {
$this->courses = CourseManager::get_real_course_list();
} else if (api_is_drh()) {
$this->courses = CourseManager::get_courses_followed_by_drh($user_id);
}
$this->path = 'block_course';
}
@ -71,16 +75,14 @@ class BlockCourse extends Block {
public function get_content_html() {
$course_data = $this->get_course_information_data();
$content = '';
$content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourCourseList').'</font></h3>';
if (!empty($course_data)) {
$data_table = '<table class="data_table" width:"95%">';
$data_table .= '<tr>
<th>'.get_lang('CourseTitle').'</th>
<th width="10%">'.get_lang('NbStudents').'</th>
<th width="10%">'.get_lang('AvgTimeSpentInTheCourse').'</th>
<th width="10%">'.get_lang('AvgStudentsProgress').'</th>
<th width="10%">'.get_lang('AvgCourseScore').'</th>
<th width="10%">'.get_lang('AvgExercisesScore').'</th>
<th width="10%">'.get_lang('AvgTimeSpentInTheCourse').'</th>
<th width="10%">'.get_lang('ThematicAdvance').'</th>
</tr>';
$i = 1;
@ -97,12 +99,10 @@ class BlockCourse extends Block {
$data_table .= '</table>';
} else {
$data_table .= get_lang('ThereAreNoInformationsAboutYoursCourses');
}
$content .= '<div style="margin:15px;"><h3>'.get_lang('YourCourseList').'</h3>';
}
$content .= $data_table;
if (!empty($course_data)) {
$content .= '<div style="text-align:right;margin-top:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/course.php">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
@ -128,7 +128,8 @@ class BlockCourse extends Block {
$a_course_students = array();
$course_data = array();
$courses = $this->courses;
$course_description = new CourseDescription();
foreach ($courses as $row_course) {
$course_code = $row_course['code'];
@ -144,38 +145,25 @@ class BlockCourse extends Block {
if (count($users) > 0) {
$nb_students_in_course = count($users);
$avg_time_spent_in_course = Tracking::get_time_spent_on_the_course($users, $course_code);
$avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code);
$avg_score_in_course = Tracking :: get_avg_student_score($users, $course_code);
$avg_score_in_exercise = Tracking::get_avg_student_exercise_score($users, $course_code);
$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);
$avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2);
$avg_score_in_exercise = round($avg_score_in_exercise / $nb_students_in_course, 2);
} else {
$avg_time_spent_in_course = null;
$avg_progress_in_course = null;
$avg_score_in_course = null;
$avg_score_in_exercise = null;
}
$tematic_advance_progress = 0;
$course_description = new CourseDescription();
$tematic_advance_progress = 0;
$course_description->set_session_id(0);
$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
if (!empty($tematic_advance)) {
$tematic_advance_progress = $tematic_advance['progress'];
$tematic_advance_progress = '<a title="'.get_lang('GoToThematicAdvance').'" href="'.api_get_path(WEB_CODE_PATH).'course_description/?cidReq='.$course_code.'#thematic_advance">'.$tematic_advance['progress'].'%</a>';
} else {
$tematic_advance_progress = '0%';
}
$table_row = array();
$table_row[] = $row_course['title'];
$table_row[] = $nb_students_in_course;
$table_row[] = $avg_time_spent_in_course;
$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($avg_score_in_exercise) ? '' : $avg_score_in_exercise.'%';
$table_row[] = $tematic_advance_progress.'%';
$table_row[] = $avg_time_spent_in_course;
$table_row[] = $tematic_advance_progress;
$course_data[] = $table_row;
}

@ -30,8 +30,12 @@ class BlockSession extends Block {
*/
public function __construct ($user_id) {
$this->user_id = $user_id;
$this->sessions = SessionManager::get_assigned_sessions_to_hr_manager($user_id);
$this->path = 'block_session';
if (api_is_platform_admin()) {
$this->sessions = SessionManager::get_sessions_list();
} else if (api_is_drh()) {
$this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
}
$this->path = 'block_session';
}
/**
@ -54,7 +58,6 @@ class BlockSession extends Block {
<h3>'.get_lang('SessionsInformation').'</h3>
<div class="widget-actions"><a onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">'.Display::return_icon('close.gif',get_lang('Close')).'</a></div>
</div>
<div class="widget-content">
'.$content.'
</div>
@ -77,80 +80,42 @@ class BlockSession extends Block {
$sessions = $this->sessions;
$content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourTrainingsSessionList').'</font></h3>';
if (count($sessions) > 0) {
$content .= '<h3><font color="#000">'.get_lang('YourSessionsList').'</font></h3>';
if (count($sessions) > 0) {
$sessions_table = '<table class="data_table" width:"95%">';
$sessions_table .= '<tr>
<th >'.get_lang('Title').'</th>
<th >'.get_lang('Date').'</th>
</tr>';
$i = 1;
foreach ($sessions as $session) {
$session_id = intval($session['id']);
$content .= '<div style="margin-top:10px;"><strong>'.$session['name'].'</strong> - '.get_lang('From').' '.$session['date_start'].' '.get_lang('To').' '.$session['date_end'].'</div>';
$courses = Tracking ::get_courses_list_from_session($session_id);
$courses_table = '';
if (count($courses)) {
$courses_table = '<div style="margin:10px;margin-bottom:20px;"><table class="data_table" width:"95%">';
$courses_table .= '<tr>
<th>'.get_lang('Course').'</th>
<th width="10%">'.get_lang('Time').'</th>
<th width="10%">'.get_lang('Progress').'</th>
<th width="10%">'.get_lang('Score').'</th>
<th width="10%">'.get_lang('TematicAdvance').'</th>
</tr>';
$i = 1;
foreach ($courses as $course) {
$course_code = Database::escape_string($course['course_code']);
$course_info = CourseManager :: get_course_information($course_code);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
// students directly subscribed to the course
$sql = "SELECT id_user FROM $tbl_session_course_user srcu WHERE srcu. course_code='$course_code'";
$rs = Database::query($sql);
$users = array();
while ($row = Database::fetch_array($rs)) {
$users[] = $row['id_user'];
}
$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($users, $course_code));
$progress = Tracking :: get_avg_student_progress($users, $course_code);
$score = Tracking :: get_avg_student_score($users, $course_code);
$progress = empty($progress) ? '0%' : $progress.'%';
$score = empty($score) ? '0%' : $score.'%';
$tematic_advance_progress = 0;
$course_description = new CourseDescription();
$course_description->set_session_id($session_id);
$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
if (!empty($tematic_advance)) {
$tematic_advance_progress = $tematic_advance['progress'];
}
if ($i%2 == 0) $class_tr = 'row_odd';
else $class_tr = 'row_even';
$courses_table .= '<tr class="'.$class_tr.'">
<td align="right">'.$course_info['title'].'</td>
<td align="right">'.$time_spent_on_course.'</td>
<td align="right">'.$progress.'</td>
<td align="right">'.$score.'</td>
<td align="right">'.$tematic_advance_progress.'%</td>
</tr>';
$i++;
}
$courses_table .= '</table></div>';
$title = $session['name'];
if ($session['date_start'] != '0000-00-00' && $session['date_end'] != '0000-00-00') {
$date = get_lang('From').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($session['date_start'])).' '.get_lang('To').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($session['date_end']));
} else {
$courses_table .= '<div style="margin:10px;">'.get_lang('ThereAreNoCoursesInformationsInsideThisSession').'</div>';
$date = ' - ';
}
$content .= $courses_table;
if ($i%2 == 0) $class_tr = 'row_odd';
else $class_tr = 'row_even';
$sessions_table .= '<tr class="'.$class_tr.'">
<td align="right">'.$title.'</td>
<td align="right">'.$date.'</td>
</tr>';
$i++;
}
$sessions_table .= '</table>';
$content .= $sessions_table;
} else {
$content .= '<div style="margin:20px;">'.get_lang('ThereAreNoInformationsAboutYoursSessions').'</div>';
$content .= get_lang('ThereAreNoInformationsAboutYoursSessions');
}
if (count($sessions) > 0) {
$content .= '<div style="text-align:right;margin-top:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/session.php">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';

@ -12,6 +12,7 @@
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
/**
* This class is used like controller for student block plugin,
@ -28,8 +29,12 @@ class BlockStudent extends Block {
* Constructor
*/
public function __construct ($user_id) {
$this->user_id = $user_id;
$this->students = UserManager::get_assigned_users_to_hr_manager($user_id, STUDENT);
$this->user_id = $user_id;
if (api_is_platform_admin()) {
$this->students = UserManager::get_user_list(array('status' => STUDENT));
} else if (api_is_drh()) {
$this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT);
}
$this->path = 'block_student';
}
@ -45,8 +50,12 @@ class BlockStudent extends Block {
$column = 1;
$data = array();
$student_content_html = $this->get_students_content_html();
if (api_is_platform_admin()) {
$student_content_html = $this->get_students_content_html_for_platform_admin();
} else if (api_is_drh()) {
$student_content_html = $this->get_students_content_html_for_drh();
}
$html = '
<li class="widget color-blue" id="intro">
<div class="widget-head">
@ -70,26 +79,24 @@ class BlockStudent extends Block {
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html
*/
public function get_students_content_html() {
public function get_students_content_html_for_platform_admin() {
$students = $this->students;
$content = '';
$content = '<div style="margin:20px;margin-right:30px;">';
$content .= '<h3><font color="#000">'.get_lang('StudentsOverview').'</font></h3>';
$content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourStudents').'</font></h3>';
if (count($students) > 0) {
$students_table = '<div style="margin:10px;width:100%"><table class="data_table" width:"90%">';
$students_table = '<table class="data_table" width:"95%">';
$students_table .= '
<tr>
<th width="10%" rowspan="2">'.get_lang('FirtName').'</th>
<th width="10%" rowspan="2">'.get_lang('LastName').'</th>
<th width="30%" colspan="4">'.get_lang('TrainingInformations').'</th>
<th width="30%" colspan="2">'.get_lang('TrainingInformations').'</th>
</tr>
<tr>
<th width="10%">'.get_lang('Training').'</th>
<th width="10%">'.get_lang('Time').'</th>
<th width="10%">'.get_lang('Progress').'</th>
<th width="10%">'.get_lang('Score').'</th>
<th width="10%">'.get_lang('Time').'</th>
</tr>
';
@ -110,35 +117,88 @@ class BlockStudent extends Block {
foreach ($courses_by_user as $course) {
$course_code = $course['code'];
$course_title = $course['title'];
$time = api_time_to_hms(Tracking :: get_time_spent_on_the_course($student['user_id'], $course_code));
$progress = round(Tracking :: get_avg_student_progress($student['user_id'], $course_code), 2);
$score = round(Tracking :: get_avg_student_score($student['user_id'], $course_code), 2);
$time = api_time_to_hms(Tracking :: get_time_spent_on_the_course($student['user_id'], $course_code));
$students_table .= '<tr '.$style.'>
<td>'.$course_title.'</td>
<td>'.$time.'</td>
<td>'.$progress.'</td>
<td>'.$score.'</td>
<td>'.$time.'</td>
</tr>';
}
$i++;
}
$students_table .= '</table></div>';
$students_table .= '</table>';
} else {
$students_table .= '<div style="margin:20px">'.get_lang('ThereAreNoInformationAboutStudents').'</div>';
$students_table .= get_lang('ThereAreNoInformationAboutStudents');
}
$content .= $students_table;
if (count($students) > 0) {
$content .= '<div style="text-align:right;margin:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
$content .= '<div style="text-align:right;margin:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/student.php">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
return $content;
}
public function get_students_content_html_for_drh() {
$attendance = new Attendance();
$students = $this->students;
$content = '';
$content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourStudents').'</font></h3>';
if (count($students) > 0) {
$students_table = '<table class="data_table" width:"95%">';
$students_table .= '
<tr>
<th>'.get_lang('FirtName').'</th>
<th>'.get_lang('LastName').'</th>
<th>'.get_lang('AttendancesFaults').'</th>
<th>'.get_lang('Evaluations').'</th>
</tr>
';
$i = 1;
foreach ($students as $student) {
$student_id = $student['user_id'];
$firstname = $student['firstname'];
$lastname = $student['lastname'];
$evaluations_avg = 0;
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_inside_courses($student_id);
if (!empty($results_faults_avg)) {
$attendances_faults_avg = '<a title="'.get_lang('GoToStudentDetails').'" href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
} else {
$attendances_faults_avg = '0%';
}
if ($i%2 == 0) $class_tr = 'row_odd';
else $class_tr = 'row_even';
$students_table .= '<tr class="'.$class_tr.'">
<td>'.$firstname.'</td>
<td>'.$lastname.'</td>
<td align="right">'.$attendances_faults_avg.'</td>
<td align="right">'.$evaluations_avg.'%</td>
</tr>';
$i++;
}
$students_table .= '</table>';
} else {
$students_table .= get_lang('ThereAreNoInformationAboutStudents');
}
$content .= $students_table;
if (count($students) > 0) {
$content .= '<div style="text-align:right;margin:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin&display=useroverview">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
return $content;
}
/**
* Get number of sessions
* @return int

@ -28,8 +28,12 @@ class BlockTeacher extends Block {
* Controller
*/
public function __construct ($user_id) {
$this->user_id = $user_id;
$this->teachers = UserManager::get_assigned_users_to_hr_manager($user_id, COURSEMANAGER);
$this->user_id = $user_id;
if (api_is_platform_admin()) {
$this->teachers = UserManager::get_user_list(array('status' => COURSEMANAGER));
} else if (api_is_drh()) {
$this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
}
$this->path = 'block_teacher';
}
@ -44,9 +48,13 @@ class BlockTeacher extends Block {
$column = 1;
$data = array();
$teacher_content_html = $this->get_teachers_content_html();
if (api_is_platform_admin()) {
$teacher_content_html = $this->get_teachers_content_html_for_platform_admin();
} else if (api_is_drh()) {
$teacher_content_html = $this->get_teachers_content_html_for_drh();
}
$html = '
<li class="widget color-blue" id="intro">
<div class="widget-head">
@ -70,24 +78,21 @@ class BlockTeacher extends Block {
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html
*/
public function get_teachers_content_html() {
public function get_teachers_content_html_for_platform_admin() {
$teachers = $this->teachers;
$content = '';
$content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('TeachersOverview').'</font></h3>';
$content .= '<h3><font color="#000">'.get_lang('YourTeachers').'</font></h3>';
if (count($teachers) > 0) {
$teachers_table = '<div style="margin:10px;margin-bottom:20px;"><table class="data_table" width:"80%">';
$teachers_table = '<table class="data_table" width:"95%">';
$teachers_table .= '
<tr>
<th>'.get_lang('FirtName').'</th>
<th>'.get_lang('LastName').'</th>
<th>'.get_lang('TimeSpentOnThePlatform').'</th>
<th>'.get_lang('LastConnexion').'</th>
<th>'.get_lang('NbStudents').'</th>
<th>'.get_lang('CountCours').'</th>
<th>'.get_lang('NumberOfSessions').'</th>
<th>'.get_lang('LastConnexion').'</th>
</tr>
';
@ -98,10 +103,7 @@ class BlockTeacher extends Block {
$firtname = $teacher['firstname'];
$lastname = $teacher['lastname'];
$time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($teacher_id));
$last_connection = Tracking :: get_last_connection_date($teacher_id);
$nb_students = count(Tracking :: get_student_followed_by_coach($teacher_id));
$nb_courses = count(Tracking :: get_courses_followed_by_coach($teacher_id));
$nb_sessions = count(Tracking :: get_sessions_coached_by_user($teacher_id));
$last_connection = Tracking :: get_last_connection_date($teacher_id);
if ($i%2 == 0) $class_tr = 'row_odd';
else $class_tr = 'row_even';
@ -111,24 +113,21 @@ class BlockTeacher extends Block {
<td>'.$firtname.'</td>
<td>'.$lastname.'</td>
<td>'.$time_on_platform.'</td>
<td>'.$last_connection.'</td>
<td>'.$nb_students.'</td>
<td>'.$nb_courses.'</td>
<td>'.$nb_sessions.'</td>
<td>'.$last_connection.'</td>
</tr>
';
$i++;
}
$teachers_table .= '</table></div>';
$teachers_table .= '</table>';
} else {
$teachers_table .= '<div style="margin:20px">'.get_lang('ThereAreNoInformationAboutTeachers').'</div>';
$teachers_table .= get_lang('ThereAreNoInformationAboutTeachers');
}
$content .= $teachers_table;
if (count($teachers) > 0) {
$content .= '<div style="text-align:right;margin:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
$content .= '<div style="text-align:right;margin:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
@ -136,6 +135,60 @@ class BlockTeacher extends Block {
return $content;
}
public function get_teachers_content_html_for_drh() {
$teachers = $this->teachers;
$content = '';
$content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourTeachers').'</font></h3>';
if (count($teachers) > 0) {
$teachers_table = '<table class="data_table" width:"95%">';
$teachers_table .= '
<tr>
<th>'.get_lang('FirtName').'</th>
<th>'.get_lang('LastName').'</th>
<th>'.get_lang('Time').'</th>
<th>'.get_lang('Email').'</th>
</tr>
';
$i = 1;
foreach ($teachers as $teacher) {
$teacher_id = $teacher['user_id'];
$firstname = $teacher['firstname'];
$lastname = $teacher['lastname'];
$time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($teacher_id));
$email = $teacher['email'];
if ($i%2 == 0) $class_tr = 'row_odd';
else $class_tr = 'row_even';
$teachers_table .= '<tr class="'.$class_tr.'">
<td>'.$firstname.'</td>
<td>'.$lastname.'</td>
<td>'.$time_on_platform.'</td>
<td>'.$email.'</td>
</tr>';
$i++;
}
$teachers_table .= '</table>';
} else {
$teachers_table .= get_lang('ThereAreNoInformationAboutTeachers');
}
$content .= $teachers_table;
if (count($teachers) > 0) {
$content .= '<div style="text-align:right;margin:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/teachers.php">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
return $content;
}
/**
* Get number of sessions

Loading…
Cancel
Save