diff --git a/classes/levelset.php b/classes/levelset.php index d42b049..2845085 100644 --- a/classes/levelset.php +++ b/classes/levelset.php @@ -366,7 +366,7 @@ class block_gradelevel_levelset { $levelup_points = $next_at - $current_at; $points_in_level = $points - $current_at; - if($levelup_points == 0){ // at max level + if($levelup_points <= 0){ // at max level $progress = 0; $points_in_level = 0; } @@ -379,9 +379,9 @@ class block_gradelevel_levelset { $result->level = $level; $result->badge_color = $badge_color; $result->progress = $progress; - $result->next_at = $next_at; - $result->levelup_total = $levelup_points; - $result->points_in_level = $points_in_level; + $result->next_at = round($next_at); + $result->levelup_total = round($levelup_points); + $result->points_in_level = round($points_in_level); return $result; } @@ -480,12 +480,19 @@ class block_gradelevel_levelset { return $html; } - public function render_demo_badge(int $size=100) + public function render_demo_badge(int $size=100, $level=null) { $levels = $this->badgelevels(); - $maxpoints = array_pop(array_keys($levels)); + if($level == null || $level > count($levels)) + { + $points = array_pop(array_keys($levels)); + } + else + { + $points = array_keys($levels)[$level - 1]; + } - return $this->render_badge($maxpoints, $size); + return $this->render_badge($points, $size); } diff --git a/version.php b/version.php index 5c3fab6..1fa2a85 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 = 2018112400; // YYYYMMDDHH (year, month, day, iteration) +$plugin->version = 2019082100; // 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 f2044ce..fe94361 100644 --- a/view-results.php +++ b/view-results.php @@ -57,7 +57,16 @@ if(count($course_groups > 0)) print "
  • "; print $skill->render_badge($pointstotal,BADGE_SIZE); print "
    {$usr->firstname} {$usr->lastname}
    "; - print "
    ".get_string('levelup_at','block_gradelevel')." {$level_info->points_in_level}/{$level_info->levelup_total}
    "; + + if($level_info->levelup_total > 0) + { + $this->content->footer = "
    ".get_string('levelup_at','block_gradelevel')." {$level_info->points_in_level}/{$level_info->levelup_total}
    "; + } + else + { + $this->content->footer = "
    ".get_string('levelup_done','block_gradelevel')."
    "; + } + print "
  • "; unset($remaining_users[$usr->id]); } @@ -79,7 +88,14 @@ foreach($remaining_users as $usr) print "
  • "; print $skill->render_badge($pointstotal,BADGE_SIZE); print "
    {$usr->firstname} {$usr->lastname}
    "; - print "
    ".get_string('levelup_at','block_gradelevel')." {$level_info->points_in_level}/{$level_info->levelup_total}
    "; + if($level_info->levelup_total > 0) + { + $this->content->footer = "
    ".get_string('levelup_at','block_gradelevel')." {$level_info->points_in_level}/{$level_info->levelup_total}
    "; + } + else + { + $this->content->footer = "
    ".get_string('levelup_done','block_gradelevel')."
    "; + } print "
  • "; }