$timestamp_login_date, 'logout' => $timestamp_logout_date); } return $connections; } static function get_connections_from_course_list($user_id, $course_list, $session_id = 0) { // Database table definitions $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); if (empty($course_list)) { return false; } $user_id = intval($user_id); $session_id = intval($session_id); $new_course_list = array();; foreach ($course_list as $course_item) { $new_course_list[] = '"'.Database::escape_string($course_item['real_id']).'"'; } $course_list = implode(', ', $new_course_list); if (empty($course_list)) { return false; } $sql = 'SELECT login_course_date, logout_course_date, c_id FROM '.$tbl_track_course.' WHERE user_id = '.$user_id.' AND c_id IN ('.$course_list.') AND session_id = '.$session_id.' ORDER BY login_course_date ASC'; $rs = Database::query($sql); $connections = array(); while ($row = Database::fetch_array($rs)) { $timestamp_login_date = api_strtotime($row['login_course_date'], 'UTC'); $timestamp_logout_date = api_strtotime($row['logout_course_date'], 'UTC'); $connections[] = array('login' => $timestamp_login_date, 'logout' => $timestamp_logout_date, 'c_id' => $row['c_id']); } return $connections; } /** * Creates a small table in the last column of the table with the user overview * * @param integer $user_id the id of the user * @param array $url_params additonal url parameters * @param array $row the row information (the other columns) * @return string html code */ function course_info_tracking_filter($user_id, $url_params, $row) { // the table header $return = '
'.get_lang('Course').' | '; $return .= ''.get_lang('AvgTimeSpentInTheCourse').' | '; $return .= ''.get_lang('AvgStudentsProgress').' | '; $return .= ''.get_lang('AvgCourseScore').' | '; $return .= ''.get_lang('AvgExercisesScore').' | '; $return .= ''.get_lang('AvgMessages').' | '; $return .= ''.get_lang('AvgAssignments').' | '; $return .= ''.get_lang('TotalExercisesScoreObtained').' | '; $return .= ''.get_lang('TotalExercisesScorePossible').' | '; $return .= ''.get_lang('TotalExercisesAnswered').' | '; $return .= ''.get_lang('TotalExercisesScorePercentage').' | '; $return .= ''.get_lang('FirstLogin').' | '; $return .= ''.get_lang('LatestLogin').' | '; $return .= '
---|---|---|---|---|---|---|---|---|---|---|---|---|
'.Text::cut($courseInfo['code'], 20, true).' | '; // time spent in the course $return .= ''.api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_id, $courseId)).' | ';
// student progress in course
$return .= ' '.round(Tracking :: get_avg_student_progress($user_id, $courseId), 2).' | ';
// student score
$avg_score = Tracking :: get_avg_student_score($user_id, $courseId);
if (is_numeric($avg_score)) {
$avg_score = round($avg_score,2);
} else {
$$avg_score = '-';
}
$return .= ' '.$avg_score.' | ';
// student tes score
//$return .= ' '.round(Tracking :: get_avg_student_exercise_score ($user_id, $courseCode),2).'% | ';
// student messages
$return .= ' '.Tracking :: count_student_messages($user_id, $courseId).' | ';
// student assignments
$return .= ' '.Tracking :: count_student_assignments($user_id, $courseId).' | ';
// student exercises results (obtained score, maximum score, number of exercises answered, score percentage)
$exercises_results = MySpace::exercises_results($user_id, $courseId);
$return .= ' '.(is_null($exercises_results['percentage']) ? '' : $exercises_results['score_obtained'].'/'.$exercises_results['score_possible'].' ( '.$exercises_results['percentage'].'% )').' | ';
//$return .= ' '.$exercises_results['score_possible'].' | ';
$return .= ' '.$exercises_results['questions_answered'].' | ';
//$return .= ' '.$exercises_results['percentage'].'% | ';
// first connection
//$return .= ' '.Tracking :: get_first_connection_date_on_the_course ($user_id, $courseCode).' | '; // last connection $return .= ''.Tracking :: get_last_connection_date_on_the_course ($user_id, $courseId).' | ';
$return .= '
'.get_lang('Course').' | '; $t_head .= ''.Text::cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).' | '; $t_head .= ''.Text::cut(get_lang('AvgStudentsProgress'), 6, true).' | '; $t_head .= ''.Text::cut(get_lang('AvgCourseScore'), 6, true).' | '; //$t_head .= ''.get_lang('AvgExercisesScore').' | ';
$t_head .= ' '.Text::cut(get_lang('TotalNumberOfMessages'), 6, true).' | '; $t_head .= ''.Text::cut(get_lang('TotalNumberOfAssignments'), 6, true).' | '; $t_head .= ''.get_lang('TotalExercisesScoreObtained').' | '; //$t_head .= ''.get_lang('TotalExercisesScorePossible').' | ';
$t_head .= ' '.Text::cut(get_lang('TotalExercisesAnswered'), 6, true).' | '; //$t_head .= ''.get_lang('TotalExercisesScorePercentage').' | ';
//$t_head .= ' '.get_lang('FirstLogin').' | ';
$t_head .= ' '.get_lang('LatestLogin').' | '; $t_head .= '
---|
'.Text::cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).' | '; $t_head .= ''.Text::cut(get_lang('AvgStudentsProgress'), 6, true).' | '; $t_head .= ''.Text::cut(get_lang('AvgCourseScore'), 6, true).' | '; //$t_head .= ''.get_lang('AvgExercisesScore').' | ';
$t_head .= ' '.Text::cut(get_lang('TotalNumberOfMessages'), 6, true).' | '; $t_head .= ''.Text::cut(get_lang('TotalNumberOfAssignments'), 6, true).' | '; $t_head .= ''.get_lang('TotalExercisesScoreObtained').' | '; //$t_head .= ''.get_lang('TotalExercisesScorePossible').' | ';
$t_head .= ' '.Text::cut(get_lang('TotalExercisesAnswered'), 6, true).' | '; //$t_head .= ''.get_lang('TotalExercisesScorePercentage').' | ';
//$t_head .= ' '.get_lang('FirstLogin').' | ';
$t_head .= ' '.get_lang('LatestLogin').' | '; $t_head .= '
---|
'.api_time_to_hms($time_spent).' | '; // student progress in course $return .= ''.$avg_progress.' | '; // student score $return .= ''.$avg_score.' | '; // student messages $return .= ''.$nb_messages.' | '; // student assignments $return .= ''.$nb_assignments.' | '; // student exercises results (obtained score, maximum score, number of exercises answered, score percentage) $return .= ''.$total_score.' | '; $return .= ''.$total_questions_answered.' | '; // last connection $return .= ''.$last_login_date.' | '; $return .= '
'.get_lang('Course').' | '; $t_head .= ''.Text::cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).' | '; $t_head .= ''.Text::cut(get_lang('AvgStudentsProgress'), 6, true).' | '; $t_head .= ''.Text::cut(get_lang('AvgCourseScore'), 6, true).' | '; //$t_head .= ''.get_lang('AvgExercisesScore').' | ';
$t_head .= ' '.Text::cut(get_lang('TotalNumberOfMessages'), 6, true).' | '; $t_head .= ''.Text::cut(get_lang('TotalNumberOfAssignments'), 6, true).' | '; $t_head .= ''.get_lang('TotalExercisesScoreObtained').' | '; //$t_head .= ''.get_lang('TotalExercisesScorePossible').' | ';
$t_head .= ' '.Text::cut(get_lang('TotalExercisesAnswered'), 6, true).' | '; //$t_head .= ''.get_lang('TotalExercisesScorePercentage').' | ';
//$t_head .= ' '.get_lang('FirstLogin').' | ';
$t_head .= ' '.get_lang('LatestLogin').' | '; $t_head .= '
---|
'.get_lang('Course').' | '; $return .= ''.get_lang('AvgTimeSpentInTheCourse').' | '; $return .= ''.get_lang('AvgStudentsProgress').' | '; $return .= ''.get_lang('AvgCourseScore').' | '; $return .= ''.get_lang('AvgExercisesScore').' | '; $return .= ''.get_lang('AvgMessages').' | '; $return .= ''.get_lang('AvgAssignments').' | '; $return .= ''.get_lang('TotalExercisesScoreObtained').' | '; $return .= ''.get_lang('TotalExercisesScorePossible').' | '; $return .= ''.get_lang('TotalExercisesAnswered').' | '; $return .= ''.get_lang('TotalExercisesScorePercentage').' | '; $return .= ''.get_lang('FirstLogin').' | '; $return .= ''.get_lang('LatestLogin').' | '; $return .= '
---|---|---|---|---|---|---|---|---|---|---|---|---|
'.$row->title.' | '; // get the users in the course $sql = "SELECT user_id FROM $tbl_user AS u INNER JOIN $tbl_session_rel_course_rel_user AS scu ON u.user_id = scu.id_user WHERE scu.id_session = '".$session_id."' AND scu.c_id = '".$row->id."'"; $result_users = Database::query($sql); $time_spent = 0; $progress = 0; $nb_progress_lp = 0; $score = 0; $nb_score_lp = 0; $nb_messages = 0; $nb_assignments = 0; $last_login_date = false; $total_score_obtained = 0; $total_score_possible = 0; $total_questions_answered = 0; while ($row_user = Database::fetch_object($result_users)) { // get time spent in the course and session $time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $row->id, $session_id); $progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->id, array(), $session_id, true); $progress += $progress_tmp[0]; $nb_progress_lp += $progress_tmp[1]; $score_tmp = Tracking :: get_avg_student_score($row_user->user_id, $row->id, array(), $session_id, true); if (is_array($score_tmp)) { $score += $score_tmp[0]; $nb_score_lp += $score_tmp[1]; } $nb_messages += Tracking::count_student_messages($row_user->user_id, $row->id, $session_id); $nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->id, $session_id); $last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row_user->user_id, $row->id, $session_id, false); if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. $last_login_date = $last_login_date_tmp; } else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition! To be cleaned. // Find the max and assign it to first_login_date if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { $last_login_date = $last_login_date_tmp; } } $exercise_results_tmp = MySpace::exercises_results($row_user->user_id, $row->id, $session_id); $total_score_obtained += $exercise_results_tmp['score_obtained']; $total_score_possible += $exercise_results_tmp['score_possible']; $total_questions_answered += $exercise_results_tmp['questions_answered']; } if ($nb_progress_lp > 0) { $avg_progress = round($progress / $nb_progress_lp, 2); } else { $avg_progress = 0; } if($nb_score_lp > 0) { $avg_score = round($score / $nb_score_lp, 2); } else { $avg_score = '-'; } if($last_login_date) { $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); } else { $last_login_date = '-'; } if($total_score_possible > 0) { $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); } else { $total_score_percentage = 0; } if($total_score_percentage > 0) { $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)'; } else { $total_score = '-'; } // time spent in the course $return .= ''.api_time_to_hms($time_spent).' | ';
// student progress in course
$return .= ' '.$avg_progress.' | ';
// student score
$return .= ' '.$avg_score.' | ';
// student messages
$return .= ' '.$nb_messages.' | ';
// student assignments
$return .= ' '.$nb_assignments.' | ';
// student exercises results (obtained score, maximum score, number of exercises answered, score percentage)
$return .= ''.$total_score.' | '; $return .= ''.$total_questions_answered.' | '; // last connection $return .= ''.$last_login_date.' | ';
$return .= '||||
'.date('d-m-Y (H:i:s)', $data['login']).' | '.api_time_to_hms($data['logout'] - $data['login']).' |
'.date('d-m-Y (H:i:s)', $data['login']).' | '.api_time_to_hms($data['logout'] - $data['login']).' |