You are here

protected function StepsBlock::buildScore in Opigno Learning path 8

Builds the score.

Parameters

array $step:

Return value

mixed|null

1 call to StepsBlock::buildScore()
StepsBlock::build in src/Plugin/Block/StepsBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Plugin/Block/StepsBlock.php, line 292

Class

StepsBlock
Provides a 'article' block.

Namespace

Drupal\opigno_learning_path\Plugin\Block

Code

protected function buildScore(array $step) {
  $is_attempted = $step['attempts'] > 0;
  if ($is_attempted) {
    $score = [
      '#type' => 'html_tag',
      '#tag' => 'span',
      '#value' => $step['best score'],
      '#attributes' => [
        'class' => [
          'lp_steps_block_score',
        ],
      ],
    ];
  }
  else {
    $score = [
      '#markup' => '‐',
    ];
  }
  return [
    'data' => $score,
  ];
}