$timestamp_login_date, 'logout' => $timestamp_logout_date); } return $connections; } /** * TODO: Not used, to b deleted? * Enter description here... * @param int $user_id * @param string $course_code * @param date $year * @param date $month * @param date $day * @return unknown */ function get_connections_to_course_by_time($user_id, $course_code, $year = '', $month = '', $day = '') { // Database table definitions $tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $tbl_main = Database :: get_main_table(TABLE_MAIN_COURSE); /*$sql_query = 'SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.Database :: escape_string($course_code).'";'; $result = Database::query($sql_query); $row_query = Database::fetch_array($result,'ASSOC'); $course_true = isset($row_query['course_code']) ? $row_query['course_code']: $course_code;*/ $sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . ' WHERE user_id = ' . intval($user_id) . ' AND course_code="' . Database::escape_string($course_code) . '" ORDER BY login_course_date DESC'; $rs = Database::query($sql); $connections = array(); while ($row = Database::fetch_array($rs)) { $login_date = $row['login_course_date']; $logout_date = $row['logout_course_date']; $timestamp_login_date = strtotime($login_date); $timestamp_logout_date = strtotime($logout_date); $connections[] = array('login' => $timestamp_login_date, 'logout' => $timestamp_logout_date); } 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 .= '
---|---|---|---|---|---|---|---|---|---|---|---|---|
'.cut($row[0], 20, true).' | '; // time spent in the course $return .= ''.api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_id, $row[0])).' | ';
// student progress in course
$return .= ' '.round(Tracking :: get_avg_student_progress($user_id, $row[0]), 2).' | ';
// student score
$avg_score = Tracking :: get_avg_student_score($user_id, $row[0]);
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, $row[0]),2).'% | ';
// student messages
$return .= ' '.Tracking :: count_student_messages($user_id, $row[0]).' | ';
// student assignments
$return .= ' '.Tracking :: count_student_assignments($user_id, $row[0]).' | ';
// student exercises results (obtained score, maximum score, number of exercises answered, score percentage)
$exercises_results = MySpace::exercises_results($user_id, $row[0]);
$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, $row[0]).' | '; // last connection $return .= ''.Tracking :: get_last_connection_date_on_the_course ($user_id, $row[0]).' | ';
$return .= '
'.get_lang('Course').' | '; $t_head .= ''.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).' | '; $t_head .= ''.cut(get_lang('AvgStudentsProgress'), 6, true).' | '; $t_head .= ''.cut(get_lang('AvgCourseScore'), 6, true).' | '; //$t_head .= ''.get_lang('AvgExercisesScore').' | ';
$t_head .= ' '.cut(get_lang('TotalNumberOfMessages'), 6, true).' | '; $t_head .= ''.cut(get_lang('TotalNumberOfAssignments'), 6, true).' | '; $t_head .= ''.get_lang('TotalExercisesScoreObtained').' | '; //$t_head .= ''.get_lang('TotalExercisesScorePossible').' | ';
$t_head .= ' '.cut(get_lang('TotalExercisesAnswered'), 6, true).' | '; //$t_head .= ''.get_lang('TotalExercisesScorePercentage').' | ';
//$t_head .= ' '.get_lang('FirstLogin').' | ';
$t_head .= ' '.get_lang('LatestLogin').' | '; $t_head .= '
---|
'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).' | '; $t_head .= ''.cut(get_lang('AvgStudentsProgress'), 6, true).' | '; $t_head .= ''.cut(get_lang('AvgCourseScore'), 6, true).' | '; //$t_head .= ''.get_lang('AvgExercisesScore').' | ';
$t_head .= ' '.cut(get_lang('TotalNumberOfMessages'), 6, true).' | '; $t_head .= ''.cut(get_lang('TotalNumberOfAssignments'), 6, true).' | '; $t_head .= ''.get_lang('TotalExercisesScoreObtained').' | '; //$t_head .= ''.get_lang('TotalExercisesScorePossible').' | ';
$t_head .= ' '.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 .= '
---|---|---|---|---|---|---|---|---|---|---|---|---|
'.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 .= ''.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).' | '; $t_head .= ''.cut(get_lang('AvgStudentsProgress'), 6, true).' | '; $t_head .= ''.cut(get_lang('AvgCourseScore'), 6, true).' | '; //$t_head .= ''.get_lang('AvgExercisesScore').' | ';
$t_head .= ' '.cut(get_lang('TotalNumberOfMessages'), 6, true).' | '; $t_head .= ''.cut(get_lang('TotalNumberOfAssignments'), 6, true).' | '; $t_head .= ''.get_lang('TotalExercisesScoreObtained').' | '; //$t_head .= ''.get_lang('TotalExercisesScorePossible').' | ';
$t_head .= ' '.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.course_code = '".$row->code."';"; $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->code, $session_id); $progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, 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->code, 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->code, $session_id); $nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->code, $session_id); $last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row_user->user_id, $row->code, $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->code, $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 .= '||||