protected function LearningPathController::build_step_score_cell in Opigno Learning path 3.x
Same name and namespace in other branches
- 8 src/Controller/LearningPathController.php \Drupal\opigno_learning_path\Controller\LearningPathController::build_step_score_cell()
Returns step score cell.
@opigno_deprecated
1 call to LearningPathController::build_step_score_cell()
- LearningPathController::build_course_row in src/Controller/ LearningPathController.php 
- Returns course row.
File
- src/Controller/ LearningPathController.php, line 28 
Class
- LearningPathController
- Class LearningPathController.
Namespace
Drupal\opigno_learning_path\ControllerCode
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' => '‐',
    ];
  }
}