protected function LearningPathAchievementController::build_step_score in Opigno Learning path 3.x
Same name and namespace in other branches
- 8 src/Controller/LearningPathAchievementController.php \Drupal\opigno_learning_path\Controller\LearningPathAchievementController::build_step_score()
Returns step score renderable array.
Parameters
array $step: Step.
Return value
array Step score renderable array.
File
- src/
Controller/ LearningPathAchievementController.php, line 158
Class
- LearningPathAchievementController
- Class LearningPathAchievementController.
Namespace
Drupal\opigno_learning_path\ControllerCode
protected function build_step_score(array $step) {
$uid = $this
->currentUser()
->id();
if (opigno_learning_path_is_attempted($step, $uid)) {
$score = $step['best score'];
return [
'#type' => 'container',
[
'#type' => 'html_tag',
'#tag' => 'span',
'#value' => $score . '%',
],
[
'#type' => 'container',
'#attributes' => [
'class' => [
'lp_step_result_bar',
],
],
[
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => [
'class' => [
'lp_step_result_bar_value',
],
'style' => "width: {$score}%",
],
'#value' => '',
],
],
];
}
return [
'#markup' => ' ',
];
}