diff --git a/main/admin/promotions.php b/main/admin/promotions.php index ecfa905254..6ad715e154 100644 --- a/main/admin/promotions.php +++ b/main/admin/promotions.php @@ -42,7 +42,7 @@ Display::display_header($tool_name); // Tool name if (isset($_GET['action']) && $_GET['action'] == 'add') { $tool = 'Add'; - $interbreadcrumb[] = array ('url' => api_get_self(), 'name' => get_lang('Promotion')); + $interbreadcrumb[] = array ('url' => api_get_self(), 'name' => get_lang('Promotion')); } if (isset($_GET['action']) && $_GET['action'] == 'edit') { $tool = 'Modify'; diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 589d59daf4..1e0227d339 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1218,8 +1218,8 @@ function get_all_exercises($course_info = null, $session_id = 0) { /** * Gets the position of the score based in a given score (result/weight) and the exe_id - * @param float user score to be compared - * @param int exe id of the exercise (this is necesary becase if 2 students have the same score the one with the minor exe_id will have a best position) + * @param float user score to be compared attention => score/weight + * @param int exe id of the exercise (this is necesary because if 2 students have the same score the one with the minor exe_id will have a best position, just to be fair and FIFO) * @param int exercise id * @param string course code * @param int session id @@ -1231,6 +1231,7 @@ function get_exercise_result_ranking($my_score, $my_exe_id, $exercise_id, $cours $session_id = 0; } $user_results = get_all_exercise_results($exercise_id, $course_code, $session_id); + if (empty($user_results)) { return 1; } else { @@ -1238,15 +1239,15 @@ function get_exercise_result_ranking($my_score, $my_exe_id, $exercise_id, $cours $my_ranking = array(); foreach($user_results as $result) { //print_r($result); - if (empty($result['exe_weighting']) || $result['exe_weighting'] == '0.00') { + if (empty($result['exe_weighting']) || $result['exe_weighting'] == '0.00') { $my_ranking[$result['exe_id']] = 0; } else { $my_ranking[$result['exe_id']] = $result['exe_result']/$result['exe_weighting']; - } - } + } + } asort($my_ranking); $position = count($my_ranking); - if (!empty($my_ranking)) + if (!empty($my_ranking)) { foreach($my_ranking as $exe_id=>$ranking) { if ($my_score >= $ranking) { if ($my_score == $ranking) { @@ -1258,6 +1259,7 @@ function get_exercise_result_ranking($my_score, $my_exe_id, $exercise_id, $cours } } } + } return $position; } } diff --git a/main/inc/lib/events.lib.inc.php b/main/inc/lib/events.lib.inc.php index cc1524e9fa..17eeb89576 100755 --- a/main/inc/lib/events.lib.inc.php +++ b/main/inc/lib/events.lib.inc.php @@ -606,7 +606,7 @@ function get_last_attempt_date_of_exercise($exe_id) { } /** - * Gets how many attempts exists by user, exercise + * Gets how many attempts exists by user, exercise, learning path * @param int user id * @param int exercise id * @param int lp id @@ -743,7 +743,13 @@ function get_all_exercise_results_by_user($user_id, $exercise_id, $course_code, } - +/** + * Gets all exercise events from a Learning Path within a Course nd Session + * @param int exercise id + * @param string course_code + * @param int session id + * @return array + */ function get_all_exercise_event_from_lp($exercise_id, $course_code, $session_id = 0) { $TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 3fbe860ac3..594c0d45c0 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -2068,19 +2068,21 @@ class Tracking { function show_course_detail($user_id, $course_code, $session_id) { $html = ''; if (isset($course_code)) { - $session_id = intval($session_id); - $user_id = intval($user_id); - - $course = Database::escape_string($course_code); + require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php'; + + $user_id = intval($user_id); + $session_id = intval($session_id); + $course = Database::escape_string($course_code); $course_info = CourseManager::get_course_information($course); + $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - $tbl_course_lp_view = Database :: get_course_table(TABLE_LP_VIEW, $course_info['db_name']); + $tbl_course_lp_view = Database :: get_course_table(TABLE_LP_VIEW, $course_info['db_name']); $tbl_course_lp_view_item = Database :: get_course_table(TABLE_LP_ITEM_VIEW, $course_info['db_name']); - $tbl_course_lp = Database :: get_course_table(TABLE_LP_MAIN, $course_info['db_name']); - $tbl_course_lp_item = Database :: get_course_table(TABLE_LP_ITEM, $course_info['db_name']); + $tbl_course_lp = Database :: get_course_table(TABLE_LP_MAIN, $course_info['db_name']); + $tbl_course_lp_item = Database :: get_course_table(TABLE_LP_ITEM, $course_info['db_name']); $tbl_course_quiz = Database :: get_course_table(TABLE_QUIZ_TEST, $course_info['db_name']); //get coach and session_name if there is one and if session_mode is activated @@ -2150,9 +2152,9 @@ class Tracking {
'.get_lang('Exercices').' | -'.get_lang('Score').' | -'.get_lang('Attempts').' | -'.get_lang('LatestAttempt').' | -|
---|---|---|---|---|
'.get_lang('Exercices').' | +'.get_lang('Attempts').' | +'.get_lang('LatestAttempt').' | +'.get_lang('Position').' | +'.get_lang('BestAttempt').' | +
'; - $html .= $exercices['title']; - $html .= ' | '; - if ($exercices['results_disabled'] == 0) { - $html .= ''; - if ($attempts > 0) { - $html .= $percentage_score.'%'; - } else { - $html .= '/'; + } + } + + $html .= ' | |||
'; - $html .= $attempts; - $html .= ' | -'; - if ($attempts > 0) { - $html .= ' '.Display::return_icon('quiz.gif', get_lang('Quiz')).' '; + $position = get_exercise_result_ranking($my_score, $exe_id, $exercices['id'], $course_info['code'], $session_id); + if (!empty($best_score_array)) { + $best_attempt_url .= ' '.Display::return_icon('quiz.gif', get_lang('Quiz')).' '; + $best_score = show_score($best_score_array['exe_result'], $best_score_array['exe_weighting']).' '.$best_attempt_url; } - $html .= ' | '; - } else { - // we show or not the results if the teacher wants to - $html .= ''; - $html .= get_lang('CantShowResults'); - $html .= ' | '; - $html .= ''; - $html .= ' -- '; - $html .= ' | -'; - $html .= ' -- '; - $html .= ' | '; - } - $html .= '
'.get_lang('NoEx').' |