"index.php", "name" => get_lang('MySpace'));
Display :: display_header($nameTools);
// Database Table Definitions
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$tbl_track_exercice = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
if (!empty($_GET['session'])) {
$sql_session = "SELECT name,id
FROM $tbl_session
ORDER BY name ASC";
$result_session = Database::query($sql_session);
echo "".get_lang('MoyCourse')."";
echo "
";
if (Database::num_rows($result_session) > 0) {
echo '
'.get_lang('Session').' | '.get_lang('MoyenneTest').' | '.get_lang('MoyenneExamen').' |
';
while ($session = Database::fetch_array($result_session)) {
$sql_course = "SELECT title, code, course.id
FROM $tbl_course as course
INNER JOIN $tbl_session_course AS rel_course
ON course.id = rel_course.c_id
AND rel_course.id_session = ".$session['id']."
ORDER BY title ASC";
$result_course = Database::query($sql_course);
$total_result = 0;
$total_weighting = 0;
while ($course = Database::fetch_array($result_course)) {
$sql_moy_test = "SELECT exe_result,exe_weighting FROM $tbl_track_exercice
WHERE c_id = '".$course['id']."'";
$result_moy_test = Database::query($sql_moy_test);
$result = 0;
$weighting = 0;
while ($moy_test = Database::fetch_array($result_moy_test)) {
$result = $result + $moy_test['exe_result'];
$weighting = $weighting + $moy_test['exe_weighting'];
}
$total_result = $total_result + $result;
$total_weighting = $total_weighting + $weighting;
}
if ($total_weighting != 0) {
$moyenne_test = round(($total_result * 100) / $total_weighting);
} else {
$moyenne_test = null;
}
echo ''.$session['name'].' | '.(is_null($moyenne_test) ? '' : $moyenne_test.'%').' | |
';
}
echo '
';
} else {
echo get_lang('NoSession');
}
} else {
$sql_course = "SELECT title, code, id FROM $tbl_course as course ORDER BY title ASC";
$result_course = Database::query($sql_course);
echo "".get_lang('MoySession')."";
echo "
";
if (Database::num_rows($result_course) > 0) {
echo ''.get_lang('Course').' | '.get_lang('MoyenneTest').' | '.get_lang('MoyenneExamen').' |
';
while ($course= Database::fetch_array($result_course)) {
$sql_moy_test = "SELECT exe_result,exe_weighting
FROM $tbl_track_exercice
WHERE c_id = '".$course['id']."'";
$result_moy_test = Database::query($sql_moy_test);
$result = 0;
$weighting = 0;
while ($moy_test = Database::fetch_array($result_moy_test)) {
$result = $result + $moy_test['exe_result'];
$weighting = $weighting + $moy_test['exe_weighting'];
}
if ($weighting != 0) {
$moyenne_test = round(($result * 100) / $weighting);
} else {
$moyenne_test = null;
}
echo ''.$course['title'].' | '.(is_null($moyenne_test) ? '' : $moyenne_test.'%').' | |
';
}
echo '
';
} else {
echo get_lang('NoCourse');
}
}
Display :: display_footer();