Use bccomp to compare floats instead of '>=' fixes BT#15438

pull/2865/head
Julio Montoya 7 years ago
parent a2b78ea31c
commit 457e2fe725
  1. 1
      composer.json
  2. 9
      main/inc/lib/exercise.lib.php

@ -45,6 +45,7 @@
"ext-libxml": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-bcmath": "*",
"twig/twig": "1.*",
"twig/extensions": "~1.0",
"doctrine/orm": "~2.4",

@ -4654,14 +4654,16 @@ EOT;
$score = [];
if ($show_results) {
$compareResult = bccomp($my_total_score, $my_total_weight, 3);
$scorePassed = $compareResult === 1 || $compareResult === 0;
$score = [
'result' => self::show_score(
$my_total_score,
$my_total_weight,
false,
true
false
),
'pass' => $my_total_score >= $my_total_weight ? true : false,
'pass' => $scorePassed,
'score' => $my_total_score,
'weight' => $my_total_weight,
'comments' => $comnt,
@ -4683,7 +4685,6 @@ EOT;
$question_content = '';
if ($show_results) {
$question_content = '<div class="question_row_answer">';
if ($showQuestionScore == false) {
$score = [];
}

Loading…
Cancel
Save