protected function LearningPathAchievementController::build_step_score in Opigno Learning path 8
Same name and namespace in other branches
- 3.x 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.
1 call to LearningPathAchievementController::build_step_score()
- LearningPathAchievementController::build_course_steps in src/Controller/ LearningPathAchievementController.php 
- Returns course steps renderable array.
File
- src/Controller/ LearningPathAchievementController.php, line 143 
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' => ' ',
  ];
}