Search in sources :

Example 6 with NotificationRecorder

use of uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder in project OpenOLAT by OpenOLAT.

the class AssessmentTestDisplayController method enterSession.

// private CandidateSession enterCandidateSession(final CandidateSession candidateSession)
private TestSessionController enterSession(UserRequest ureq) {
    /* Set up listener to record any notifications */
    final NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    /* Create fresh JQTI+ state & controller for it */
    testSessionController = createNewTestSessionStateAndController(notificationRecorder);
    if (testSessionController == null) {
        return null;
    }
    /* Initialise test state and enter test */
    final TestSessionState testSessionState = testSessionController.getTestSessionState();
    final Date timestamp = ureq.getRequestTimestamp();
    try {
        testSessionController.initialize(timestamp);
        final int testPartCount = testSessionController.enterTest(timestamp);
        if (testPartCount == 1) {
            /* If there is only testPart, then enter this (if possible).
                 * (Note that this may cause the test to exit immediately if there is a failed
                 * preCondition on this part.)
                 */
            testSessionController.enterNextAvailableTestPart(timestamp);
        } else {
        /* Don't enter first testPart yet - we shall tell candidate that
                 * there are multiple parts and let them enter manually.
                 */
        }
    } catch (final RuntimeException e) {
        logError("", e);
        return null;
    }
    /* Record and log event */
    final CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.ENTER_TEST, testSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateEvent);
    this.lastEvent = candidateEvent;
    boolean ended = testSessionState.isEnded();
    /* Record current result state */
    final AssessmentResult assessmentResult = computeAndRecordTestAssessmentResult(timestamp, testSessionState, ended);
    /* Handle immediate end of test session */
    if (ended) {
        candidateSession = qtiService.finishTestSession(candidateSession, testSessionState, assessmentResult, timestamp, getDigitalSignatureOptions(), getIdentity());
    } else {
        TestPart currentTestPart = testSessionController.getCurrentTestPart();
        if (currentTestPart != null && currentTestPart.getNavigationMode() == NavigationMode.NONLINEAR) {
            // go to the first assessment item
            if (testSessionController.hasFollowingNonLinearItem()) {
                testSessionController.selectFollowingItemNonLinear(currentRequestTimestamp);
            }
        }
    }
    return testSessionController;
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 7 with NotificationRecorder

use of uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder in project OpenOLAT by OpenOLAT.

the class AssessmentTestDisplayController method processExitTestAfterTimeLimit.

private void processExitTestAfterTimeLimit(UserRequest ureq) {
    synchronized (testSessionController) {
        // make sure the ajax call and a user click don't close both the session
        NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
        TestSessionState testSessionState = testSessionController.getTestSessionState();
        if (testSessionState.isEnded() || testSessionState.isExited())
            return;
        // close duration
        testSessionController.touchDurations(currentRequestTimestamp);
        final Date requestTimestamp = ureq.getRequestTimestamp();
        testSessionController.exitTestIncomplete(requestTimestamp);
        candidateSession.setTerminationTime(requestTimestamp);
        // Record current result state
        final AssessmentResult assessmentResult = computeAndRecordTestAssessmentResult(requestTimestamp, testSessionState, true);
        candidateSession = qtiService.finishTestSession(candidateSession, testSessionState, assessmentResult, requestTimestamp, getDigitalSignatureOptions(), getIdentity());
        qtiWorksCtrl.updateStatusAndResults(ureq);
        /* Record and log event */
        final CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.EXIT_DUE_TIME_LIMIT, testSessionState, notificationRecorder);
        candidateAuditLogger.logCandidateEvent(candidateTestEvent);
        this.lastEvent = candidateTestEvent;
    }
    doExitTest(ureq);
}
Also used : TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 8 with NotificationRecorder

use of uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder in project OpenOLAT by OpenOLAT.

the class AssessmentTestDisplayController method processItemSolution.

private void processItemSolution(UserRequest ureq, String key) {
    TestPlanNodeKey itemKey = TestPlanNodeKey.fromString(key);
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    // assertSessionNotTerminated(candidateSession);
    try {
        if (!testSessionController.mayAccessItemSolution(itemKey)) {
            candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_SOLUTION_TEST_ITEM, null);
            logError("CANNOT_SOLUTION_TEST_ITEM", null);
            return;
        }
    } catch (final QtiCandidateStateException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_SOLUTION_TEST_ITEM, e);
        logError("CANNOT_SOLUTION_TEST_ITEM", e);
        return;
    } catch (final RuntimeException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_SOLUTION_TEST_ITEM, e);
        logError("Exploded", e);
        // handleExplosion(e, candidateSession);
        return;
    }
    /* Record current result state */
    computeAndRecordTestAssessmentResult(ureq.getRequestTimestamp(), testSessionState, false);
    /* Record and log event */
    CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.SOLUTION_ITEM, null, itemKey, testSessionState, notificationRecorder);
    this.lastEvent = candidateTestEvent;
    candidateAuditLogger.logCandidateEvent(candidateTestEvent);
}
Also used : QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 9 with NotificationRecorder

use of uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder in project OpenOLAT by OpenOLAT.

the class AssessmentTestDisplayController method processReviewItem.

private void processReviewItem(UserRequest ureq, String key) {
    TestPlanNodeKey itemKey = TestPlanNodeKey.fromString(key);
    // Assert.notNull(itemKey, "itemKey");
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    // assertSessionNotTerminated(candidateSession);
    try {
        if (!testSessionController.mayReviewItem(itemKey)) {
            logError("CANNOT_REVIEW_TEST_ITEM", null);
            candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_REVIEW_TEST_ITEM, null);
            return;
        }
    } catch (final QtiCandidateStateException e) {
        logError("CANNOT_REVIEW_TEST_ITEM", e);
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_REVIEW_TEST_ITEM, e);
        return;
    } catch (final RuntimeException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_REVIEW_TEST_ITEM, e);
        logError("CANNOT_REVIEW_TEST_ITEM", e);
        // handleExplosion(e, candidateSession);
        return;
    }
    /* Record current result state */
    computeAndRecordTestAssessmentResult(ureq.getRequestTimestamp(), testSessionState, false);
    /* Record and log event */
    final CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.REVIEW_ITEM, null, itemKey, testSessionState, notificationRecorder);
    this.lastEvent = candidateTestEvent;
    candidateAuditLogger.logCandidateEvent(candidateTestEvent);
}
Also used : QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 10 with NotificationRecorder

use of uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder in project OpenOLAT by OpenOLAT.

the class AssessmentTestDisplayController method processExitTest.

/**
 * Exit multi-part tests
 */
private void processExitTest(UserRequest ureq) {
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    /* Perform action */
    final Date currentTimestamp = ureq.getRequestTimestamp();
    try {
        testSessionController.exitTest(currentTimestamp);
    } catch (final QtiCandidateStateException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_EXIT_TEST, e);
        logError("CANNOT_EXIT_TEST", null);
        return;
    } catch (final RuntimeException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_EXIT_TEST, e);
        logError("Exploded", null);
        // handleExplosion(e, candidateSession);
        return;
    }
    /* Update CandidateSession as appropriate */
    candidateSession.setTerminationTime(currentTimestamp);
    candidateSession = qtiService.updateAssessmentTestSession(candidateSession);
    /* Record current result state (final) */
    computeAndRecordTestAssessmentResult(currentTimestamp, testSessionState, true);
    /* Record and log event */
    final CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.EXIT_TEST, testSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateTestEvent);
    this.lastEvent = candidateTestEvent;
    doExitTest(ureq);
}
Also used : QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Aggregations

NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)42 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)36 Date (java.util.Date)34 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)30 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)20 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)18 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)17 AssessmentResult (uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)16 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)16 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)16 ItemSessionController (uk.ac.ed.ph.jqtiplus.running.ItemSessionController)10 HashMap (java.util.HashMap)8 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)8 StringInput (org.olat.ims.qti21.ui.ResponseInput.StringInput)8 FileResponseData (uk.ac.ed.ph.jqtiplus.types.FileResponseData)8 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)8 ResponseData (uk.ac.ed.ph.jqtiplus.types.ResponseData)8 StringResponseData (uk.ac.ed.ph.jqtiplus.types.StringResponseData)8 CandidateItemEventType (org.olat.ims.qti21.model.audit.CandidateItemEventType)6 CandidateTestEventType (org.olat.ims.qti21.model.audit.CandidateTestEventType)6