public function testResponseProcessingExitTest() { $outcomeProcessing = $this->createComponentFromXml(' <outcomeProcessing> <exitTest/> </outcomeProcessing> '); $engine = new OutcomeProcessingEngine($outcomeProcessing); try { $engine->process(); // An exception must be raised because of the Test termination. // In other words, the following code must be not reachable. $this->assertTrue(false); } catch (ProcessingException $e) { $this->assertInstanceOf('qtism\\runtime\\rules\\RuleProcessingException', $e); $this->assertEquals(RuleProcessingException::EXIT_TEST, $e->getCode()); } }
/** * Apply outcome processing at test-level. * * @throws AssessmentTestSessionException If an error occurs at OutcomeProcessing time or at result submission time. */ protected function outcomeProcessing() { if ($this->getAssessmentTest()->hasOutcomeProcessing() === true) { // As per QTI Spec: // The values of the test's outcome variables are always reset to their defaults prior // to carrying out the instructions described by the outcomeRules. $this->resetOutcomeVariables(); $outcomeProcessing = $this->getAssessmentTest()->getOutcomeProcessing(); try { $outcomeProcessingEngine = new OutcomeProcessingEngine($outcomeProcessing, $this); $outcomeProcessingEngine->process(); if ($this->getTestResultsSubmission() === TestResultsSubmission::OUTCOME_PROCESSING) { $this->submitTestResults(); } } catch (ProcessingException $e) { $msg = "An error occured while processing OutcomeProcessing."; throw new AssessmentTestSessionException($msg, AssessmentTestSessionException::OUTCOME_PROCESSING_ERROR, $e); } } }
/** * 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); }