/** * Set time reference of current assessment item session to <i>now</i> instead of time of last update. * This ensures that time when delivery execution was paused will not be taken in account. * Make sure that method invoked right after retrieving assessment test session * and before the first AssessmentTestSession::updateDuration method call * @param AssessmentTestSession $session * @param \DateTime|null $time Time to be specified. Current time by default. Make sure that $time has UTC timezone. */ public function updateTimeReference(AssessmentTestSession $session, \DateTime $time = null) { if ($time === null) { $time = new \DateTime('now', new \DateTimeZone('UTC')); } $itemSession = $session->getCurrentAssessmentItemSession(); if ($itemSession) { $itemSession->setTimeReference($time); $session->updateDuration(); } }