瀏覽代碼

Fix PHP warning

jmontoyaa 8 年之前
父節點
當前提交
365083395a
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7 2
      main/work/work.lib.php

+ 7 - 2
main/work/work.lib.php

@@ -3142,14 +3142,19 @@ function getLastWorkStudentFromParentByUser(
 function formatWorkScore($score, $weight)
 {
     $label = 'info';
-    $relativeScore = $score/$weight;
+    $weight = (int) $weight;
+    $relativeScore = 0;
+    if (!empty($weight)) {
+        $relativeScore = $score / $weight;
+    }
     if ($relativeScore < 0.5) {
         $label = 'important';
     } elseif ($relativeScore < 0.75) {
         $label = 'warning';
     }
+
     return Display::label(
-    api_number_format($score, 1) . ' / '.(int) $weight,
+    api_number_format($score, 1) . ' / '.$weight,
         $label
     );
 }