You are here

protected function LearningPathStepsController::requiredStepMessage in Opigno Learning path 8

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

Provide the required step messages.

Parameters

string $name: Step name.

int $required: Minimum score.

string $link: Link to try again.

Return value

string Message.

2 calls to LearningPathStepsController::requiredStepMessage()
LearningPathStepsController::nextStep in src/Controller/LearningPathStepsController.php
Redirect the user to the next step.
LearningPathStepsController::start in src/Controller/LearningPathStepsController.php
Start the learning path.

File

src/Controller/LearningPathStepsController.php, line 803

Class

LearningPathStepsController
Class LearningPathStepsController.

Namespace

Drupal\opigno_learning_path\Controller

Code

protected function requiredStepMessage($name, $required = NULL, $link = '') {
  if (empty($required)) {

    // The simple message.
    return $this
      ->t('A required step: %step should be done first.', [
      '%step' => $name,
    ]);
  }
  else {
    $text = 'You should first get a minimum score of %required to the step %step before going further.';
    if (!empty($link)) {
      return $this
        ->t("{$text} <a href=':link'>Try again.</a>", [
        '%step' => $name,
        '%required' => $required,
        ':link' => $link,
      ]);
    }
    else {
      return $this
        ->t("{$text}", [
        '%step' => $name,
        '%required' => $required,
      ]);
    }
  }
}