added time spent last week for teachers' report inside dashboard

skala
Cristian Fasanando 16 years ago
parent 9e5344a900
commit 911282e1a2
  1. 21
      main/inc/lib/text.lib.php
  2. 13
      main/inc/lib/tracking.lib.php
  3. 6
      main/inc/lib/usermanager.lib.php
  4. 27
      main/mySpace/teachers.php
  5. 2
      plugin/dashboard/block_course/block_course.class.php
  6. 4
      plugin/dashboard/block_student/block_student.class.php
  7. 25
      plugin/dashboard/block_teacher/block_teacher.class.php

@ -432,4 +432,25 @@ function float_format($number, $flag = 1)
}
}
/**
* Function to obtain last week timestamps
* @return array times for every day inside week
*/
function get_last_week() {
$week = date('W');
$year = date('Y');
$lastweek=$week-1;
if ($lastweek==0){
$week = 52;
$year--;
}
$lastweek=sprintf("%02d", $lastweek);
for ($i=1;$i<=7;$i++){
$arrdays[] = strtotime("$year". "W$lastweek"."$i");
}
return $arrdays;
}
?>

@ -15,14 +15,23 @@ class Tracking {
/**
* Calculates the time spent on the platform by a user
* @param integer $user_id the user id
* @param bool optionally show time spent last week
* @return timestamp $nb_seconds
*/
public static function get_time_spent_on_the_platform($user_id) {
public static function get_time_spent_on_the_platform($user_id, $last_week = false) {
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$cond_last_week = '';
if ($last_week) {
$a_last_week = get_last_week();
$fday_last_week = date('Y-m-d H:i:s',$a_last_week[0]);
$lday_last_week = date('Y-m-d H:i:s',$a_last_week[6]);
$cond_last_week = ' AND (login_date >= "'.$fday_last_week.'" AND login_date <= "'.$lday_last_week.'") ';
}
$sql = 'SELECT login_date, logout_date FROM ' . $tbl_track_login . '
WHERE login_user_id = ' . intval($user_id);
WHERE login_user_id = ' . intval($user_id).$cond_last_week;
$rs = Database::query($sql);

@ -2905,11 +2905,11 @@ class UserManager
$hr_dept_id = intval($hr_dept_id);
$assigned_users_to_hrm = array();
$condition_status = '';
if (!empty($status)) {
if (!empty($user_status)) {
$status = intval($status);
$condition_status = ' WHERE u.status = '.$status;
$condition_status = ' AND u.status = '.$user_status;
}
$sql = "SELECT u.user_id, u.username, u.lastname, u.firstname FROM $tbl_user u

@ -13,6 +13,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';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
$this_section = "session_my_space";
@ -95,20 +96,25 @@ if (!api_is_drh()) {
}
}
$a_last_week = get_last_week();
$last_week = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]);
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>';
echo '<table class="data_table"><tr><th>'.get_lang('FirstName').'</th><th>'.get_lang('LastName').'</th><th width="100px">'.get_lang('TimeSpentLastWeek').'<br />'.$last_week.'</th><th>'.get_lang('Email').'</th><th>'.get_lang('AdminCourses').'</th><th>'.get_lang('Students').'</th></tr>';
} else {
echo '<table class="data_table"><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 '<table class="data_table"><tr><th>'.get_lang('LastName').'</th><th>'.get_lang('FirstName').'</th><th>'.get_lang('TimeSpentLastWeek').'<br />'.$last_week.'</th><th>'.get_lang('Email').'</th><th>'.get_lang('AdminCourses').'</th><th>'.get_lang('Students').'</th></tr>';
}
if ($is_western_name_order) {
$header[] = get_lang('FirstName', '');
$header[] = get_lang('LastName', '');
$header[] = get_lang('FirstName');
$header[] = get_lang('LastName');
} else {
$header[] = get_lang('LastName', '');
$header[] = get_lang('FirstName', '');
$header[] = get_lang('LastName');
$header[] = get_lang('FirstName');
}
$header[] = get_lang('Email', '');
$header[] = get_lang('TimeSpentLastWeek');
$header[] = get_lang('Email');
$data = array();
@ -144,12 +150,15 @@ if (count($formateurs) > 0) {
$data[$user_id]["lastname"] = $lastname;
$data[$user_id]["firstname"] = $firstname;
}
$time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($user_id,true));
$data[$user_id]["timespentlastweek"] = $time_on_platform;
$data[$user_id]["email"] = $email;
if ($is_western_name_order) {
echo '<tr class="'.$css_class.'"><td>'.$firstname.'</td><td>'.$lastname.'</td><td><a href="mailto:'.$email.'">'.$email.'</a></td><td><a href="course.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td><td><a href="student.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td></tr>';
echo '<tr class="'.$css_class.'"><td>'.$firstname.'</td><td>'.$lastname.'</td><td align="right">'.$time_on_platform.'</td><td align="right"><a href="mailto:'.$email.'">'.$email.'</a></td><td align="right"><a href="course.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td><td align="right"><a href="student.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td></tr>';
} else {
echo '<tr class="'.$css_class.'"><td>'.$lastname.'</td><td>'.$firstname.'</td><td><a href="mailto:'.$email.'">'.$email.'</a></td><td><a href="course.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td><td><a href="student.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td></tr>';
echo '<tr class="'.$css_class.'"><td>'.$lastname.'</td><td>'.$firstname.'</td><td align="right">'.$time_on_platform.'</td><td align="right"><a href="mailto:'.$email.'">'.$email.'</a></td><td align="right"><a href="course.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td><td align="right"><a href="student.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td></tr>';
}
}
} else {

@ -144,7 +144,7 @@ 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_time_spent_in_course = api_time_to_hms(Tracking::get_time_spent_on_the_course($users, $course_code));
} else {
$avg_time_spent_in_course = null;
}

@ -133,7 +133,7 @@ class BlockStudent extends Block {
$content .= $students_table;
if (count($students) > 0) {
$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 style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/student.php">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
@ -193,7 +193,7 @@ class BlockStudent extends Block {
$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 style="text-align:right;margin-top: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;

@ -127,7 +127,7 @@ class BlockTeacher extends Block {
$content .= $teachers_table;
if (count($teachers) > 0) {
$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 style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
@ -141,16 +141,18 @@ class BlockTeacher extends Block {
$teachers = $this->teachers;
$content = '';
$content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourTeachers').'</font></h3>';
if (count($teachers) > 0) {
$content .= '<h3><font color="#000">'.get_lang('YourTeachers').'</font></h3>';
if (count($teachers) > 0) {
$a_last_week = get_last_week();
$last_week = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]);
$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>
<th>'.get_lang('TimeSpentLastWeek').'<br />'.$last_week.'</th>
</tr>
';
@ -160,16 +162,15 @@ class BlockTeacher extends Block {
$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'];
$time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($teacher_id,true));
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>
<td align="right">'.$time_on_platform.'</td>
</tr>';
$i++;
@ -182,7 +183,7 @@ class BlockTeacher extends Block {
$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 style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/teachers.php">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';

Loading…
Cancel
Save