You are here

public static function LPStatus::getTrainingStartDate in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 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.

10 calls to LPStatus::getTrainingStartDate()
LearningPathAchievementController::build_course_steps in src/Controller/LearningPathAchievementController.php
Returns course steps renderable array.
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.
LearningPathAchievementTrait::getActivities in src/Traits/LearningPathAchievementTrait.php
Gets the activities list by the group and module.

... See full list

File

src/Entity/LPStatus.php, line 459

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;
}