'.get_lang('Course').' | '; $head .= ''.cut(get_lang('Time'), 6, true).' | '; $head .= ''.cut(get_lang('Progress'), 6, true).' | '; $head .= ''.cut(get_lang('Average score in learning paths'), 6, true).' | '; $head .= ''.cut(get_lang('Total number of messages'), 6, true).' | '; $head .= ''.cut(get_lang('Total number of assignments'), 6, true).' | '; $head .= ''.get_lang('Total score obtained for tests').' | '; $head .= ''.cut(get_lang('Number of tests answered'), 6, true).' | '; $head .= ''.get_lang('Latest login').' | '; $head .= '
---|
'.$row->title.' | '; // get the users in the course $sql = "SELECT u.user_id FROM $tbl_user AS u INNER JOIN $tbl_session_rel_course_rel_user AS scu ON u.user_id = scu.user_id WHERE scu.session_id = '".$session_id."' AND scu.c_id = '".$courseId."'"; $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, $courseId, $session_id); $progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, [], $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, [], $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, $courseInfo, $session_id, false ); if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. $last_login_date = $last_login_date_tmp; } elseif ($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 = self::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 .= '
'; $html .= api_get_local_time($data['login']); $html .= ' | '; $html .= ''; $html .= api_time_to_hms(api_strtotime($data['logout']) - api_strtotime($data['login'])); $html .= ' |