From efda107e9a813afe6ed5c44503812f65984436d7 Mon Sep 17 00:00:00 2001
From: Astor Bizard <astor.bizard@grenoble-inp.fr>
Date: Thu, 19 Mar 2020 14:13:42 +0100
Subject: [PATCH] Fixed graph total diff display conditions.

---
 views/vpl_grapher.class.php | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/views/vpl_grapher.class.php b/views/vpl_grapher.class.php
index 236aab2b..8c739670 100644
--- a/views/vpl_grapher.class.php
+++ b/views/vpl_grapher.class.php
@@ -184,9 +184,6 @@ class vpl_grapher {
                 $i++;
             }
             if ($diff && count($names) > 1) {
-                $names[] = get_string('total');
-                $series[get_string('total')] = $totalseries;
-
                 // Filter out all zero-diff files.
                 $names = array_filter($names, function($name) use(&$series){
                     foreach ($series[$name] as $value){
@@ -198,6 +195,12 @@ class vpl_grapher {
                     unset($series[$name]);
                     return false;
                 });
+
+                if (count($names) != 1) {
+                    // Add Total series.
+                    $names[] = get_string('total');
+                    $series[get_string('total')] = $totalseries;
+                }
             }
             self::draw( $title, get_string( 'submissions', VPL ) , get_string( "sizeb" ), $subsn, $series, $names );
         } catch (moodle_exception $e) {
-- 
GitLab