You are here

function QuizResult::isTimeReached in Quiz 6.x

Determine if the time limit has been reached for this attempt.

Return value

bool

File

src/Entity/QuizResult.php, line 640

Class

QuizResult
Defines the Quiz entity class.

Namespace

Drupal\quiz\Entity

Code

function isTimeReached() {
  $quiz = $this
    ->getQuiz();
  $config = \Drupal::config('quiz.settings');
  $time_limit = $quiz
    ->get('time_limit')
    ->getString();
  $time_limit_buffer = $config
    ->get('time_limit_buffer', 5);
  $time_start = $this
    ->get('time_start')
    ->getString();
  $request_time = \Drupal::time()
    ->getRequestTime();
  return $time_limit > 0 && $request_time > $time_start + $time_limit + $time_limit_buffer;
}