From c2cb225fa6cd9abf707c807b0e9ae0280980be53 Mon Sep 17 00:00:00 2001 From: PM Date: Wed, 9 Oct 2019 22:08:44 +0200 Subject: [PATCH] Fixed bug with rendering level 0 demo badges Added rounding of points --- block_gradelevel.php | 3 ++- classes/levelset.php | 2 +- version.php | 2 +- view-results.php | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/block_gradelevel.php b/block_gradelevel.php index fb9019f..e4bff3c 100644 --- a/block_gradelevel.php +++ b/block_gradelevel.php @@ -53,8 +53,9 @@ class block_gradelevel extends block_base { } else { // below can be a single call to $this->levelset->get_user_leveldata() once the need for debugging (fixed point total) is gone - $pointstotal = $this->levelset->get_levelset_grade($USER->id); + $pointstotal = round($this->levelset->get_levelset_grade($USER->id),1); $level_info = $this->levelset->calculate_level($pointstotal); + $this->content->text = $this->levelset->render_badge($pointstotal); diff --git a/classes/levelset.php b/classes/levelset.php index ca0d3af..fa383d7 100644 --- a/classes/levelset.php +++ b/classes/levelset.php @@ -483,7 +483,7 @@ class block_gradelevel_levelset { public function render_demo_badge(int $size=100, $level=null) { $levels = $this->badgelevels(); - if($level == null || $level > count($levels)) + if($level === null || $level > count($levels)) { $points = array_pop(array_keys($levels)); } diff --git a/version.php b/version.php index ff43ecd..5ea2e88 100644 --- a/version.php +++ b/version.php @@ -1,4 +1,4 @@ component = 'block_gradelevel'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494) -$plugin->version = 2019091300; // YYYYMMDDHH (year, month, day, iteration) +$plugin->version = 2019100900; // YYYYMMDDHH (year, month, day, iteration) $plugin->requires = 2018050800; // YYYYMMDDHH (This is the release version for Moodle 3.5) \ No newline at end of file diff --git a/view-results.php b/view-results.php index f46f582..8b1a04e 100644 --- a/view-results.php +++ b/view-results.php @@ -51,7 +51,7 @@ if(count($course_groups > 0)) print "