You are here

public function LearningPathStepsController::listSteps in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 src/Controller/LearningPathStepsController.php \Drupal\opigno_learning_path\Controller\LearningPathStepsController::listSteps()

Steps list.

Parameters

Group $group:

Return value

array

1 string reference to 'LearningPathStepsController::listSteps'
opigno_learning_path.routing.yml in ./opigno_learning_path.routing.yml
opigno_learning_path.routing.yml

File

src/Controller/LearningPathStepsController.php, line 714

Class

LearningPathStepsController
Class LearningPathStepsController.

Namespace

Drupal\opigno_learning_path\Controller

Code

public function listSteps(Group $group) {

  /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
  $date_formatter = \Drupal::service('date.formatter');
  $group_id = $group
    ->id();
  $uid = \Drupal::currentUser()
    ->id();
  $steps = opigno_learning_path_get_steps($group_id, $uid);
  $rows = array_map(function ($step) use ($date_formatter) {
    return [
      $step['name'],
      $step['typology'],
      $date_formatter
        ->formatInterval($step['time spent']),
      $step['best score'],
    ];
  }, $steps);
  return [
    '#type' => 'table',
    '#header' => [
      $this
        ->t('Name'),
      $this
        ->t('Typology'),
      $this
        ->t('Total time spent'),
      $this
        ->t('Best score achieved'),
    ],
    '#rows' => $rows,
  ];
}