Search in sources :

Example 26 with Event

use of org.olat.ims.qti21.ui.QTIWorksAssessmentTestEvent.Event in project openolat by klemens.

the class AssessmentItemDisplayController method endSession.

public void endSession(UserRequest ureq) {
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    // final ItemSessionController itemSessionController = candidateDataService.createItemSessionController(mostRecentEvent, notificationRecorder);
    ItemSessionState itemSessionState = itemSessionController.getItemSessionState();
    if (itemSessionState.isEnded()) {
        logError("END_SESSION_WHEN_ALREADY_ENDED", null);
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.END_SESSION_WHEN_ALREADY_ENDED, null);
        return;
    }
    /* else if (!itemDeliverySettings.isAllowEnd()) {
            candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.END_SESSION_WHEN_INTERACTING_FORBIDDEN);
            return null;
        }*/
    /* Update state */
    final Date timestamp = ureq.getRequestTimestamp();
    try {
        itemSessionController.endItem(timestamp);
    } catch (QtiCandidateStateException e) {
        String msg = itemSessionState.isEnded() ? "END_SESSION_WHEN_ALREADY_ENDED" : "END_SESSION_WHEN_INTERACTING_FORBIDDEN";
        logError(msg, e);
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, itemSessionState.isEnded() ? CandidateExceptionReason.END_SESSION_WHEN_ALREADY_ENDED : CandidateExceptionReason.END_SESSION_WHEN_INTERACTING_FORBIDDEN, null);
        return;
    } catch (final RuntimeException e) {
        logError("", e);
        // handleExplosion(e, candidateSession);
        return;
    }
    /* Record current result state */
    final AssessmentResult assessmentResult = computeAndRecordItemAssessmentResult(ureq);
    /* Record and log event */
    final CandidateEvent candidateEvent = qtiService.recordCandidateItemEvent(candidateSession, null, entry, CandidateItemEventType.END, itemSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateEvent);
    lastEvent = candidateEvent;
    /* Close session */
    qtiService.finishItemSession(candidateSession, assessmentResult, timestamp);
}
Also used : QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) 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 27 with Event

use of org.olat.ims.qti21.ui.QTIWorksAssessmentTestEvent.Event in project openolat by klemens.

the class AssessmentTestDisplayController method processReviewTestPart.

private void processReviewTestPart() {
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    // assertSessionNotTerminated(candidateSession);
    if (testSessionState.getCurrentTestPartKey() == null || !testSessionState.getCurrentTestPartSessionState().isEnded()) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_REVIEW_TEST_PART, null);
        logError("CANNOT_REVIEW_TEST_PART", null);
        return;
    }
    /* Record and log event */
    final CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.REVIEW_TEST_PART, null, null, testSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateTestEvent);
    this.lastEvent = candidateTestEvent;
}
Also used : TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 28 with Event

use of org.olat.ims.qti21.ui.QTIWorksAssessmentTestEvent.Event in project openolat by klemens.

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)

Example 29 with Event

use of org.olat.ims.qti21.ui.QTIWorksAssessmentTestEvent.Event in project openolat by klemens.

the class AssessmentTestDisplayController method processAdvanceTestPart.

private void processAdvanceTestPart(UserRequest ureq) {
    /* Get current JQTI state and create JQTI controller */
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    /* Perform action */
    final TestPlanNode nextTestPart;
    final Date currentTimestamp = ureq.getRequestTimestamp();
    try {
        nextTestPart = testSessionController.enterNextAvailableTestPart(currentTimestamp);
    } catch (final QtiCandidateStateException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_ADVANCE_TEST_PART, e);
        logError("CANNOT_ADVANCE_TEST_PART", e);
        return;
    } catch (final RuntimeException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_ADVANCE_TEST_PART, e);
        logError("RuntimeException", e);
        // handleExplosion(e, candidateSession);
        return;
    }
    CandidateTestEventType eventType;
    if (nextTestPart != null) {
        /* Moved into next test part */
        eventType = CandidateTestEventType.ADVANCE_TEST_PART;
    } else {
        /* No more test parts.
             *
             * For single part tests, we terminate the test completely now as the test feedback was shown with the testPart feedback.
             * For multi-part tests, we shall keep the test open so that the test feedback can be viewed.
             */
        if (testSessionState.getTestPlan().getTestPartNodes().size() == 1) {
            eventType = CandidateTestEventType.EXIT_TEST;
            testSessionController.exitTest(currentTimestamp);
            candidateSession.setTerminationTime(currentTimestamp);
            candidateSession = qtiService.updateAssessmentTestSession(candidateSession);
        } else {
            eventType = CandidateTestEventType.ADVANCE_TEST_PART;
        }
    }
    boolean terminated = isTerminated();
    /* Record current result state */
    computeAndRecordTestAssessmentResult(currentTimestamp, testSessionState, terminated);
    /* Record and log event */
    final CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, eventType, testSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateTestEvent);
    this.lastEvent = candidateTestEvent;
    if (terminated) {
        qtiWorksCtrl.updateStatusAndResults(ureq);
        doExitTest(ureq);
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) CandidateTestEventType(org.olat.ims.qti21.model.audit.CandidateTestEventType) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 30 with Event

use of org.olat.ims.qti21.ui.QTIWorksAssessmentTestEvent.Event in project openolat by klemens.

the class AssessmentTestDisplayController method processFinishLinearItem.

// public CandidateSession finishLinearItem(final CandidateSessionContext candidateSessionContext)
// throws CandidateException {
private void processFinishLinearItem(UserRequest ureq) {
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    try {
        if (!testSessionController.mayAdvanceItemLinear()) {
            candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_FINISH_LINEAR_TEST_ITEM, null);
            logError("CANNOT_FINISH_LINEAR_TEST_ITEM", null);
            return;
        }
    } catch (RuntimeException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_FINISH_LINEAR_TEST_ITEM, e);
        logError("CANNOT_FINISH_LINEAR_TEST_ITEM", e);
        return;
    }
    // Update state
    final Date requestTimestamp = ureq.getRequestTimestamp();
    final TestPlanNode nextItemNode = testSessionController.advanceItemLinear(requestTimestamp);
    boolean terminated = nextItemNode == null && testSessionController.findNextEnterableTestPart() == null;
    // Record current result state
    final AssessmentResult assessmentResult = computeAndRecordTestAssessmentResult(requestTimestamp, testSessionState, terminated);
    /* If we ended the testPart and there are now no more available testParts, then finish the session now */
    if (terminated) {
        candidateSession = qtiService.finishTestSession(candidateSession, testSessionState, assessmentResult, requestTimestamp, getDigitalSignatureOptions(), getIdentity());
    }
    // Record and log event
    final CandidateTestEventType eventType = nextItemNode != null ? CandidateTestEventType.FINISH_ITEM : CandidateTestEventType.FINISH_FINAL_ITEM;
    final CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, eventType, null, null, testSessionState, notificationRecorder);
    this.lastEvent = candidateTestEvent;
    candidateAuditLogger.logCandidateEvent(candidateTestEvent);
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) CandidateTestEventType(org.olat.ims.qti21.model.audit.CandidateTestEventType) 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)

Aggregations

CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)46 Date (java.util.Date)36 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)32 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)32 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)22 AssessmentResult (uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)20 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)19 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)18 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)16 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)14 HashMap (java.util.HashMap)12 List (java.util.List)10 RetrieveAssessmentTestSessionEvent (org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent)10 OLATResourceable (org.olat.core.id.OLATResourceable)8 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)8 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)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