Search in sources :

Example 11 with CandidateSessionContext

use of org.olat.ims.qti21.ui.CandidateSessionContext in project OpenOLAT by OpenOLAT.

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 (QtiCandidateStateException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_FINISH_LINEAR_TEST_ITEM, e);
        logError("CANNOT_FINISH_LINEAR_TEST_ITEM", e);
        return;
    } catch (RuntimeException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_FINISH_LINEAR_TEST_ITEM, e);
        logError("CANNOT_FINISH_LINEAR_TEST_ITEM", e);
        // handleExplosion(e, candidateSession);
        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, false);
    /* If we ended the testPart and there are now no more available testParts, then finish the session now */
    if (nextItemNode == null && testSessionController.findNextEnterableTestPart() == null) {
        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) 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) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 12 with CandidateSessionContext

use of org.olat.ims.qti21.ui.CandidateSessionContext in project OpenOLAT by OpenOLAT.

the class AssessmentTestComponentRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    AssessmentTestComponent cmp = (AssessmentTestComponent) source;
    TestSessionController testSessionController = cmp.getTestSessionController();
    if (testSessionController.getTestSessionState().isEnded()) {
        renderTerminated(sb, translator);
    } else {
        /* Create appropriate options that link back to this controller */
        TestSessionState testSessionState = testSessionController.getTestSessionState();
        CandidateSessionContext candidateSessionContext = cmp.getCandidateSessionContext();
        final AssessmentTestSession candidateSession = candidateSessionContext.getCandidateSession();
        if (candidateSession.isExploded()) {
            renderExploded(sb, translator);
        } else if (candidateSessionContext.isTerminated()) {
            renderTerminated(sb, translator);
        } else {
            /* Touch the session's duration state if appropriate */
            if (testSessionState.isEntered() && !testSessionState.isEnded()) {
                final Date timestamp = candidateSessionContext.getCurrentRequestTimestamp();
                testSessionController.touchDurations(timestamp);
            }
            /* Render event */
            AssessmentRenderer renderHints = new AssessmentRenderer(renderer);
            renderTestEvent(testSessionController, renderHints, sb, cmp, ubu, translator);
        }
    }
}
Also used : CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) Date(java.util.Date)

Example 13 with CandidateSessionContext

use of org.olat.ims.qti21.ui.CandidateSessionContext in project OpenOLAT by OpenOLAT.

the class AssessmentTestComponentRenderer method renderTestEvent.

private void renderTestEvent(TestSessionController testSessionController, AssessmentRenderer renderer, StringOutput target, AssessmentTestComponent component, URLBuilder ubu, Translator translator) {
    CandidateSessionContext candidateSessionContext = component.getCandidateSessionContext();
    CandidateEvent candidateEvent = candidateSessionContext.getLastEvent();
    CandidateTestEventType testEventType = candidateEvent.getTestEventType();
    /* If session has terminated, render appropriate state and exit */
    final TestSessionState testSessionState = testSessionController.getTestSessionState();
    if (candidateSessionContext.isTerminated() || testSessionState.isExited()) {
        renderTerminated(target, translator);
    } else if (testEventType == CandidateTestEventType.REVIEW_ITEM) {
        renderer.setReviewMode(true);
        TestPlanNodeKey itemKey = extractTargetItemKey(candidateEvent);
        RenderingRequest options = RenderingRequest.getItemReview();
        renderTestItem(renderer, target, component, itemKey, ubu, translator, options);
    } else if (testEventType == CandidateTestEventType.SOLUTION_ITEM) {
        renderer.setSolutionMode(true);
        TestPlanNodeKey itemKey = extractTargetItemKey(candidateEvent);
        RenderingRequest options = RenderingRequest.getItemSolution();
        renderTestItem(renderer, target, component, itemKey, ubu, translator, options);
    } else {
        /* Render current state */
        final TestPlanNodeKey currentTestPartKey = testSessionState.getCurrentTestPartKey();
        if (testSessionState.isEnded()) {
            /* At end of test, so show overall test feedback */
            renderTestPartFeedback(renderer, target, component, ubu, translator);
        } else if (currentTestPartKey != null) {
            final TestPartSessionState currentTestPartSessionState = testSessionState.getTestPartSessionStates().get(currentTestPartKey);
            final TestPlanNodeKey currentItemKey = testSessionState.getCurrentItemKey();
            if (currentItemKey != null) {
                /* An item is selected, so render it in appropriate state */
                RenderingRequest options = RenderingRequest.getItem(testSessionController);
                renderTestItem(renderer, target, component, currentItemKey, ubu, translator, options);
            } else {
                /* No item selected */
                if (currentTestPartSessionState.isEnded()) {
                    /* testPart has ended, so must be showing testPart feedback */
                    renderTestPartFeedback(renderer, target, component, ubu, translator);
                } else {
                    /* testPart not ended, so we must be showing the navigation menu in nonlinear mode */
                    renderNavigation(renderer, target, component, ubu, translator);
                }
            }
        } else {
            /* No current testPart == start of multipart test */
            renderTestEntry(target, component, translator);
        }
    }
}
Also used : CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) CandidateTestEventType(org.olat.ims.qti21.model.audit.CandidateTestEventType) TestPartSessionState(uk.ac.ed.ph.jqtiplus.state.TestPartSessionState) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 14 with CandidateSessionContext

use of org.olat.ims.qti21.ui.CandidateSessionContext in project OpenOLAT by OpenOLAT.

the class AssessmentTreeComponentRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    AssessmentTreeComponent component = (AssessmentTreeComponent) source;
    TestSessionController testSessionController = component.getTestSessionController();
    if (!testSessionController.getTestSessionState().isEnded()) {
        CandidateSessionContext candidateSessionContext = component.getCandidateSessionContext();
        final AssessmentTestSession candidateSession = candidateSessionContext.getCandidateSession();
        if (!candidateSession.isExploded() && !candidateSessionContext.isTerminated()) {
            CandidateEvent candidateEvent = candidateSessionContext.getLastEvent();
            CandidateTestEventType testEventType = candidateEvent.getTestEventType();
            RenderingRequest options;
            if (testEventType == CandidateTestEventType.REVIEW_ITEM) {
                options = RenderingRequest.getItemReview();
            } else if (testEventType == CandidateTestEventType.SOLUTION_ITEM) {
                options = RenderingRequest.getItemSolution();
            } else {
                options = RenderingRequest.getItem(testSessionController);
            }
            AssessmentRenderer renderHints = new AssessmentRenderer(renderer);
            renderTestEvent(testSessionController, renderHints, sb, component, ubu, translator, options);
        }
    }
}
Also used : CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) CandidateTestEventType(org.olat.ims.qti21.model.audit.CandidateTestEventType) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 15 with CandidateSessionContext

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

the class AssessmentTestComponentRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    AssessmentTestComponent cmp = (AssessmentTestComponent) source;
    TestSessionController testSessionController = cmp.getTestSessionController();
    if (testSessionController.getTestSessionState().isEnded()) {
        renderTerminated(sb, translator);
    } else {
        /* Create appropriate options that link back to this controller */
        TestSessionState testSessionState = testSessionController.getTestSessionState();
        CandidateSessionContext candidateSessionContext = cmp.getCandidateSessionContext();
        final AssessmentTestSession candidateSession = candidateSessionContext.getCandidateSession();
        if (candidateSession.isExploded()) {
            renderExploded(sb, translator);
        } else if (candidateSessionContext.isTerminated()) {
            renderTerminated(sb, translator);
        } else {
            /* Touch the session's duration state if appropriate */
            if (testSessionState.isEntered() && !testSessionState.isEnded()) {
                final Date timestamp = candidateSessionContext.getCurrentRequestTimestamp();
                testSessionController.touchDurations(timestamp);
            }
            /* Render event */
            AssessmentRenderer renderHints = new AssessmentRenderer(renderer);
            renderTestEvent(testSessionController, renderHints, sb, cmp, ubu, translator);
        }
    }
}
Also used : CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) Date(java.util.Date)

Aggregations

CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)14 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)12 Date (java.util.Date)10 CandidateTestEventType (org.olat.ims.qti21.model.audit.CandidateTestEventType)10 CandidateSessionContext (org.olat.ims.qti21.ui.CandidateSessionContext)10 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)6 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)6 AssessmentResult (uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)6 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)6 TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)4 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)4 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)4 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)4 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)3 File (java.io.File)2 HashMap (java.util.HashMap)2 List (java.util.List)2 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)2 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)2 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)2