function attempt(AssessmentTestSession $session, $identifier, array &$average = null) { $start = microtime(); $session->beginAttempt(); $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier($identifier))))); if (is_null($average) === false) { spentTime($start, microtime(), $average); } }
/** * Make the candidate interact with the current Assessment Item to be presented. A new attempt * will begin automatically if the candidate still has available attempts. Otherwise, * nothing happends. * * @param AssessmentTestSession $session The AssessmentTestSession you want to make the candidate interact with. */ public static function beginCandidateInteraction(AssessmentTestSession $session) { $itemSession = $session->getCurrentAssessmentItemSession(); $itemSessionState = $itemSession->getState(); $initial = $itemSessionState === AssessmentItemSessionState::INITIAL; $suspended = $itemSessionState === AssessmentItemSessionState::SUSPENDED; $remainingAttempts = $itemSession->getRemainingAttempts(); $attemptable = $remainingAttempts === -1 || $remainingAttempts > 0; if ($initial === true || $suspended === true && $attemptable === true) { // Begin the very first attempt. $session->beginAttempt(); } // Otherwise, the item is not attemptable bt the candidate. }