Search in sources :

Example 26 with AssessmentResult

use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project openolat by klemens.

the class AssessmentItemDisplayController method requestSolution.

public void requestSolution(UserRequest ureq) {
    ItemSessionState itemSessionState = itemSessionController.getItemSessionState();
    /* Make sure caller may do this */
    // itemDeliverySettings.isAllowSolutionWhenOpen()
    boolean allowSolutionWhenOpen = true;
    if (!itemSessionState.isEnded() && !allowSolutionWhenOpen) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.SOLUTION_WHEN_INTERACTING_FORBIDDEN, null);
        logError("SOLUTION_WHEN_INTERACTING_FORBIDDEN", null);
        return;
    } else if (itemSessionState.isEnded()) /* && !itemDeliverySettings.isAllowSoftResetWhenEnded() */
    {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.SOLUTION_WHEN_ENDED_FORBIDDEN, null);
        logError("SOLUTION_WHEN_ENDED_FORBIDDEN", null);
        return;
    }
    /* End session if still open */
    final Date timestamp = ureq.getRequestTimestamp();
    boolean isClosingSession = false;
    if (!itemSessionState.isEnded()) {
        isClosingSession = true;
        try {
            itemSessionController.endItem(timestamp);
        } catch (final QtiCandidateStateException e) {
            candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.SOLUTION_WHEN_ENDED_FORBIDDEN, null);
            logError("SOLUTION_WHEN_ENDED_FORBIDDEN", e);
            return;
        } catch (final RuntimeException e) {
            logError("", e);
            // handleExplosion(e, candidateSession);
            return;
        }
    }
    /* Record current result state, and maybe close session */
    final AssessmentResult assessmentResult = computeAndRecordItemAssessmentResult(ureq);
    if (isClosingSession) {
        qtiService.finishItemSession(candidateSession, assessmentResult, timestamp);
    }
    /* Record and log event */
    final CandidateEvent candidateEvent = qtiService.recordCandidateItemEvent(candidateSession, null, entry, CandidateItemEventType.SOLUTION, itemSessionState);
    candidateAuditLogger.logCandidateEvent(candidateEvent);
    lastEvent = candidateEvent;
}
Also used : QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 27 with AssessmentResult

use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project openolat by klemens.

the class AssessmentItemDisplayController method updateSessionFinishedStatus.

private AssessmentTestSession updateSessionFinishedStatus(UserRequest ureq) {
    /* Record current result state and maybe close session */
    final ItemSessionState itemSessionState = itemSessionController.getItemSessionState();
    final AssessmentResult assessmentResult = computeAndRecordItemAssessmentResult(ureq);
    if (itemSessionState.isEnded()) {
        qtiService.finishItemSession(candidateSession, assessmentResult, null);
    } else {
        if (candidateSession != null && candidateSession.getFinishTime() != null) {
            /* (Session is being reopened) */
            candidateSession.setFinishTime(null);
            candidateSession = qtiService.updateAssessmentTestSession(candidateSession);
        }
    }
    return candidateSession;
}
Also used : ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)

Example 28 with AssessmentResult

use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project openolat by klemens.

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 29 with AssessmentResult

use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project openolat by klemens.

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 30 with AssessmentResult

use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project openolat by klemens.

the class AssessmentTestDisplayController method computeAndRecordTestAssessmentResult.

private AssessmentResult computeAndRecordTestAssessmentResult(Date requestTimestamp, TestSessionState testSessionState, boolean submit) {
    AssessmentResult assessmentResult = computeTestAssessmentResult(requestTimestamp, candidateSession);
    TestPlanInfos testPlanInfos = new TestPlanInfos();
    testSessionController.visitTestPlan(testPlanInfos);
    candidateSession.setNumOfQuestions(testPlanInfos.getNumOfItems());
    candidateSession.setNumOfAnsweredQuestions(testPlanInfos.getNumOfAnsweredItems());
    synchronized (this) {
        candidateSession = qtiService.recordTestAssessmentResult(candidateSession, testSessionState, assessmentResult, candidateAuditLogger);
    }
    processOutcomeVariables(assessmentResult.getTestResult(), testPlanInfos, submit);
    return assessmentResult;
}
Also used : AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)

Aggregations

AssessmentResult (uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)30 Date (java.util.Date)20 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)20 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)16 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)14 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)12 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)10 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)7 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)6 File (java.io.File)4 HashMap (java.util.HashMap)4 List (java.util.List)4 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)4 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)4 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)4 CandidateTestEventType (org.olat.ims.qti21.model.audit.CandidateTestEventType)4 StringInput (org.olat.ims.qti21.ui.ResponseInput.StringInput)4 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)4 FileResponseData (uk.ac.ed.ph.jqtiplus.types.FileResponseData)4 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4