You are here

protected function LearningPathController::build_step_score_cell in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/Controller/LearningPathController.php \Drupal\opigno_learning_path\Controller\LearningPathController::build_step_score_cell()

Returns step score cell.

2 calls to LearningPathController::build_step_score_cell()
LearningPathController::build_course_row in src/Controller/LearningPathController.php
Returns course row.
LearningPathController::trainingContent in src/Controller/LearningPathController.php
Returns training content.

File

src/Controller/LearningPathController.php, line 24

Class

LearningPathController
Class LearningPathController.

Namespace

Drupal\opigno_learning_path\Controller

Code

protected function build_step_score_cell($step) {
  if (in_array($step['typology'], [
    'Module',
    'Course',
    'Meeting',
    'ILT',
  ])) {
    $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' => '',
        ],
      ],
    ];
  }
  else {
    return [
      '#markup' => '‐',
    ];
  }
}