Browse Source

Fix PHP warning

jmontoyaa 7 years ago
parent
commit
67ce8dca35

+ 4 - 2
main/gradebook/lib/GradebookUtils.php

@@ -876,7 +876,9 @@ class GradebookUtils
             }
             $user_results = $flatviewtable->datagen->get_data_to_graph2(false);
             foreach ($user_results as $user_result) {
-                $total[$user_result[count($user_result) - 1][1]]++;
+                $item = $user_result[count($user_result) - 1];
+
+                $total[$item[1]]++;
             }
         }
 
@@ -966,7 +968,7 @@ class GradebookUtils
             'course_code' => $course_code,
             'add_signatures' => ['Drh', 'Teacher', 'Date']
         );
-
+exit;
         $page_format = $params['orientation'] == 'landscape' ? 'A4-L' : 'A4';
         ob_start();
         $pdf = new PDF($page_format, $page_format, $pdfParams);

+ 1 - 1
main/gradebook/lib/flatview_data_generator.class.php

@@ -630,7 +630,7 @@ class FlatViewDataGenerator
             $score = $item->calc_score($user_id);
 
             $real_score = $score;
-            $divide = isset($score[1]) && !empty($score[1]) ? $score[1] : 1;
+            $divide = isset($score[1]) && !empty($score[1]) && $score[1] > 0 ? $score[1] : 1;
 
             // Sub cat weight
             //$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];

+ 1 - 1
main/gradebook/lib/scoredisplay.class.php

@@ -323,7 +323,7 @@ class ScoreDisplay
         }
 
         if ($this->coloring_enabled && $no_color != false) {
-            $my_score_denom = isset($score[1]) && !empty($score[1]) ? $score[1] : 1;
+            $my_score_denom = isset($score[1]) && !empty($score[1]) && $score[1] > 0 ? $score[1] : 1;
             $scoreCleaned = isset($score[0]) ? $score[0] : 0;
             if (($scoreCleaned / $my_score_denom) < ($this->color_split_value / 100)) {
                 $display = Display::tag('font', $display, array('color'=>'red'));