You are here

public static function LPStatus::getTrainingStartDate in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/Entity/LPStatus.php \Drupal\opigno_learning_path\Entity\LPStatus::getTrainingStartDate()

Returns training start date for displaying statistics.

Parameters

\Drupal\group\Entity\Group $group: Group object.

int $uid: User ID.

Return value

int|null Training start date timestamp if exists, null otherwise.

8 calls to LPStatus::getTrainingStartDate()
LearningPathAchievementController::build_lp_steps in src/Controller/LearningPathAchievementController.php
Returns LP steps.
LearningPathAchievementController::build_module_panel in src/Controller/LearningPathAchievementController.php
Returns module panel renderable array.
LearningPathAchievementController::build_training_timeline in src/Controller/LearningPathAchievementController.php
Returns training timeline.
LearningPathController::trainingContent in src/Controller/LearningPathController.php
Returns training content.
opigno_learning_path_save_achievements in ./opigno_learning_path.module
Stores training achievements data.

... See full list

File

src/Entity/LPStatus.php, line 465

Class

LPStatus
Defines the User Learning Path attempt status entity.

Namespace

Drupal\opigno_learning_path\Entity

Code

public static function getTrainingStartDate(Group $group, $uid) {
  $start_date = NULL;
  $expiration_set = LPStatus::isCertificateExpireSet($group);
  if ($expiration_set) {

    // If certificate expiration set for training.
    // Get certificate expire timestamp.
    $gid = $group
      ->id();
    if ($expire_timestamp = LPStatus::getCertificateExpireTimestamp($gid, $uid)) {
      if (time() >= $expire_timestamp) {

        // Certificate expired.
        $start_date = $expire_timestamp;
      }
      else {

        // Certificate not expired.
        // Get latest certification timestamp.
        if ($existing_cert_date = LPStatus::getLatestCertificateTimestamp($gid, $uid)) {
          $start_date = $existing_cert_date;
        }
      }
    }
  }
  return $start_date;
}