/** * Build an array where each cell represent a time constraint (a.k.a. time limits) * in force. Each cell is actually an array with two keys: * * * 'source': The identifier of the QTI component emitting the constraint (e.g. AssessmentTest, TestPart, AssessmentSection, AssessmentItemRef). * * 'seconds': The number of remaining seconds until it times out. * * @param AssessmentTestSession $session An AssessmentTestSession object. * @return array */ public static function buildTimeConstraints(AssessmentTestSession $session) { $constraints = array(); foreach ($session->getTimeConstraints() as $tc) { // Only consider time constraints in force. if ($tc->getMaximumRemainingTime() !== false) { $label = method_exists($tc->getSource(), 'getTitle') ? $tc->getSource()->getTitle() : $tc->getSource()->getIdentifier(); $constraints[] = array('label' => $label, 'source' => $tc->getSource()->getIdentifier(), 'seconds' => $tc->getMaximumRemainingTime()->getSeconds(true), 'allowLateSubmission' => $tc->allowLateSubmission(), 'qtiClassName' => $tc->getSource()->getQtiClassName()); } } return $constraints; }