/** * QTISM endTestSession method overriding. * * It consists of including an additional processing when the test ends, * in order to send the LtiOutcome * * @see http://www.imsglobal.org/lis/ Outcome Management Service * @throws taoQtiTest_helpers_TestSessionException If the session is already ended or if an error occurs whil transmitting/processing the result. */ public function endTestSession() { $sessionMemento = $this->getSessionMemento(); parent::endTestSession(); common_Logger::i('Ending test session.'); try { // Compute the LtiOutcome variable for LTI support. $this->setVariable(new OutcomeVariable('LtiOutcome', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(0.0))); $outcomeProcessingEngine = new OutcomeProcessingEngine($this->buildLtiOutcomeProcessing(), $this); $outcomeProcessingEngine->process(); // if numberPresented returned 0, division by 0 -> null. $testUri = $this->getTest()->getUri(); $var = $this->getVariable('LtiOutcome'); $varIdentifier = $var->getIdentifier(); common_Logger::t("Submitting test result '{$varIdentifier}' related to test '{$testUri}'."); $this->getResultTransmitter()->transmitTestVariable($var, $this->getSessionId(), $testUri); $this->unsetVariable('LtiOutcome'); } catch (ProcessingException $e) { $msg = "An error occured while processing the 'LtiOutcome' outcome variable."; throw new taoQtiTest_helpers_TestSessionException($msg, taoQtiTest_helpers_TestSessionException::RESULT_SUBMISSION_ERROR, $e); } catch (taoQtiCommon_helpers_ResultTransmissionException $e) { $msg = "An error occured during test-level outcome results transmission."; throw new taoQtiTest_helpers_TestSessionException($msg, taoQtiTest_helpers_TestSessionException::RESULT_SUBMISSION_ERROR, $e); } $this->triggerEventChange($sessionMemento); }