Internal api update to allow rendering demo badges with a specific level
This commit is contained in:
parent
ed70b0de2c
commit
e46f7e2d30
|
@ -366,7 +366,7 @@ class block_gradelevel_levelset {
|
||||||
|
|
||||||
$levelup_points = $next_at - $current_at;
|
$levelup_points = $next_at - $current_at;
|
||||||
$points_in_level = $points - $current_at;
|
$points_in_level = $points - $current_at;
|
||||||
if($levelup_points == 0){ // at max level
|
if($levelup_points <= 0){ // at max level
|
||||||
$progress = 0;
|
$progress = 0;
|
||||||
$points_in_level = 0;
|
$points_in_level = 0;
|
||||||
}
|
}
|
||||||
|
@ -379,9 +379,9 @@ class block_gradelevel_levelset {
|
||||||
$result->level = $level;
|
$result->level = $level;
|
||||||
$result->badge_color = $badge_color;
|
$result->badge_color = $badge_color;
|
||||||
$result->progress = $progress;
|
$result->progress = $progress;
|
||||||
$result->next_at = $next_at;
|
$result->next_at = round($next_at);
|
||||||
$result->levelup_total = $levelup_points;
|
$result->levelup_total = round($levelup_points);
|
||||||
$result->points_in_level = $points_in_level;
|
$result->points_in_level = round($points_in_level);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,12 +480,19 @@ class block_gradelevel_levelset {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render_demo_badge(int $size=100)
|
public function render_demo_badge(int $size=100, $level=null)
|
||||||
{
|
{
|
||||||
$levels = $this->badgelevels();
|
$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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
$plugin->component = 'block_gradelevel'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494)
|
$plugin->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)
|
$plugin->requires = 2018050800; // YYYYMMDDHH (This is the release version for Moodle 3.5)
|
|
@ -57,7 +57,16 @@ if(count($course_groups > 0))
|
||||||
print "<li class='result_badge'>";
|
print "<li class='result_badge'>";
|
||||||
print $skill->render_badge($pointstotal,BADGE_SIZE);
|
print $skill->render_badge($pointstotal,BADGE_SIZE);
|
||||||
print "<figcaption><span class='namepart'>{$usr->firstname}</span> <span class='namepart'>{$usr->lastname}</span></figcaption>";
|
print "<figcaption><span class='namepart'>{$usr->firstname}</span> <span class='namepart'>{$usr->lastname}</span></figcaption>";
|
||||||
print "<div class='pointinfo'>".get_string('levelup_at','block_gradelevel')." <span class='currentpoints'>{$level_info->points_in_level}</span>/<span class='leveluppoints'>{$level_info->levelup_total}</span></div>";
|
|
||||||
|
if($level_info->levelup_total > 0)
|
||||||
|
{
|
||||||
|
$this->content->footer = "<div class='pointinfo'>".get_string('levelup_at','block_gradelevel')." <span class='currentpoints'>{$level_info->points_in_level}</span>/<span class='leveluppoints'>{$level_info->levelup_total}</span></div>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->content->footer = "<div class='pointinfo complete'>".get_string('levelup_done','block_gradelevel')."</div>";
|
||||||
|
}
|
||||||
|
|
||||||
print "</li>";
|
print "</li>";
|
||||||
unset($remaining_users[$usr->id]);
|
unset($remaining_users[$usr->id]);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +88,14 @@ foreach($remaining_users as $usr)
|
||||||
print "<li class='result_badge'>";
|
print "<li class='result_badge'>";
|
||||||
print $skill->render_badge($pointstotal,BADGE_SIZE);
|
print $skill->render_badge($pointstotal,BADGE_SIZE);
|
||||||
print "<figcaption><span class='namepart'>{$usr->firstname}</span> <span class='namepart'>{$usr->lastname}</span></figcaption>";
|
print "<figcaption><span class='namepart'>{$usr->firstname}</span> <span class='namepart'>{$usr->lastname}</span></figcaption>";
|
||||||
print "<div class='pointinfo'>".get_string('levelup_at','block_gradelevel')." <span class='currentpoints'>{$level_info->points_in_level}</span>/<span class='leveluppoints'>{$level_info->levelup_total}</span></div>";
|
if($level_info->levelup_total > 0)
|
||||||
|
{
|
||||||
|
$this->content->footer = "<div class='pointinfo'>".get_string('levelup_at','block_gradelevel')." <span class='currentpoints'>{$level_info->points_in_level}</span>/<span class='leveluppoints'>{$level_info->levelup_total}</span></div>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->content->footer = "<div class='pointinfo complete'>".get_string('levelup_done','block_gradelevel')."</div>";
|
||||||
|
}
|
||||||
print "</li>";
|
print "</li>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user