/** * @param Exercise $objExercise * @param float $score * @param float $weight * @param bool $check_pass_percentage * @return string */ function get_question_ribbon($objExercise, $score, $weight, $check_pass_percentage = false) { $ribbon = '<div class="ribbon">'; if ($check_pass_percentage) { $is_success = is_success_exercise_result($score, $weight, $objExercise->selectPassPercentage()); // Color the final test score if pass_percentage activated $ribbon_total_success_or_error = ""; if (is_pass_pourcentage_enabled($objExercise->selectPassPercentage())) { if ($is_success) { $ribbon_total_success_or_error = ' ribbon-total-success'; } else { $ribbon_total_success_or_error = ' ribbon-total-error'; } } $ribbon .= '<div class="rib rib-total ' . $ribbon_total_success_or_error . '">'; } else { $ribbon .= '<div class="rib rib-total">'; } $ribbon .= '<h3>' . get_lang('YourTotalScore') . ": "; $ribbon .= show_score($score, $weight, false, true); $ribbon .= '</h3>'; $ribbon .= '</div>'; if ($check_pass_percentage) { $ribbon .= show_success_message($score, $weight, $objExercise->selectPassPercentage()); } $ribbon .= '</div>'; return $ribbon; }
function show_success_message($score, $weight, $pass_percentage) { $res = ""; if (is_pass_pourcentage_enabled($pass_percentage)) { $is_success = is_success_exercise_result($score, $weight, $pass_percentage); if ($is_success) { $html = get_lang('CongratulationsYouPassedTheTest'); $icon = Display::return_icon('completed.png', get_lang('Correct'), array(), ICON_SIZE_MEDIUM); } else { //$html .= Display::return_message(get_lang('YouDidNotReachTheMinimumScore'), 'warning'); $html = get_lang('YouDidNotReachTheMinimumScore'); $icon = Display::return_icon('warning.png', get_lang('Wrong'), array(), ICON_SIZE_MEDIUM); } $html = Display::tag('h4', $html); $html .= Display::tag('h5', $icon, array('style' => 'width:40px; padding:2px 10px 0px 0px')); $res = $html; } return $res; }