You are here

protected function StatisticsPageTrait::buildScore in Opigno statistics 8

Same name and namespace in other branches
  1. 3.x src/StatisticsPageTrait.php \Drupal\opigno_statistics\StatisticsPageTrait::buildScore()

Builds render array for a score value.

Parameters

int $value: Score.

Return value

array Render array.

7 calls to StatisticsPageTrait::buildScore()
DashboardForm::buildSkillsTable in src/Form/DashboardForm.php
Builds skills listing.
TrainingForm::buildUsersResultsClass in src/Form/TrainingForm.php
Builds users results for Classes.
TrainingForm::buildUsersResultsLp in src/Form/TrainingForm.php
Builds users results for Learning paths.
UserController::buildCourseDetails in src/Controller/UserController.php
Builds render array for a user course details.
UserController::buildSkillsTable in src/Controller/UserController.php
Builds render array for a user skills table.

... See full list

File

src/StatisticsPageTrait.php, line 106

Class

StatisticsPageTrait
Common helper methods for a statistics pages.

Namespace

Drupal\opigno_statistics

Code

protected function buildScore($value) {
  return [
    '#type' => 'container',
    'score' => [
      '#type' => 'html_tag',
      '#tag' => 'span',
      '#value' => $this
        ->t('@score%', [
        '@score' => $value,
      ]),
    ],
    'score_bar' => [
      '#type' => 'container',
      '#attributes' => [
        'class' => [
          'score-bar',
        ],
      ],
      'score_bar_inner' => [
        '#type' => 'container',
        '#attributes' => [
          'class' => [
            'score-bar-inner',
          ],
          'style' => "width: {$value}%;",
        ],
      ],
    ],
  ];
}