Fixed bug with rendering level 0 demo badges

Added rounding of points
This commit is contained in:
PM 2019-10-09 22:08:44 +02:00
parent 2a5de0af0e
commit c2cb225fa6
4 changed files with 6 additions and 5 deletions

View File

@ -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);

View File

@ -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));
}

View File

@ -1,4 +1,4 @@
<?php
$plugin->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)

View File

@ -51,7 +51,7 @@ if(count($course_groups > 0))
print "<ul class='skill_results'>";
foreach($members as $usr)
{
$pointstotal = $skill->get_levelset_grade($usr->id);
$pointstotal = round($skill->get_levelset_grade($usr->id),1);
$level_info = $skill->calculate_level($pointstotal);
print "<li class='result_badge'>";
@ -84,7 +84,7 @@ usort( $remaining_users, function( $a, $b) {
print "<ul class='skill_results other'>";
foreach($remaining_users as $usr)
{
$pointstotal = $skill->get_levelset_grade($usr->id);
$pointstotal = round($skill->get_levelset_grade($usr->id),1);
$level_info = $skill->calculate_level($pointstotal);
print "<li class='result_badge'>";
print $skill->render_badge($pointstotal,BADGE_SIZE);