Search in sources :

Example 61 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState 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 62 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState 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 63 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project OpenOLAT by OpenOLAT.

the class AssessmentTestComponentRenderer method renderTestFeeback.

private void renderTestFeeback(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestFeedback testFeedback, URLBuilder ubu, Translator translator) {
    if (component.isHideFeedbacks())
        return;
    TestSessionState testSessionState = component.getTestSessionController().getTestSessionState();
    if (testFeedbackVisible(testFeedback, testSessionState)) {
        sb.append("<div class='o_info clearfix'>");
        sb.append("<h3>");
        if (StringHelper.containsNonWhitespace(testFeedback.getTitle())) {
            sb.append(StringHelper.escapeHtml(testFeedback.getTitle()));
        } else {
            sb.append(translator.translate("assessment.test.modal.feedback"));
        }
        sb.append("</h3>");
        testFeedback.getChildren().forEach((flow) -> renderFlow(renderer, sb, component, null, null, flow, ubu, translator));
        sb.append("</div>");
    }
}
Also used : TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState)

Example 64 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project OpenOLAT by OpenOLAT.

the class AssessmentTreeComponentRenderer method renderAssessmentItemLink.

/**
 * @param sb
 * @param component
 * @param itemNode
 * @return The event used or null
 */
private Event renderAssessmentItemLink(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator) {
    String key = itemNode.getKey().toString();
    Form form = component.getQtiItem().getRootForm();
    String dispatchId = component.getQtiItem().getFormDispatchId();
    TestSessionController testSessionController = component.getTestSessionController();
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    TestPart testPart = testSessionController.getCurrentTestPart();
    TestPlanNodeKey currentTestPartKey = testSessionState.getCurrentTestPartKey();
    TestPartSessionState currentTestPartSessionState = testSessionState.getTestPartSessionStates().get(currentTestPartKey);
    Event event;
    if (testPart == null || testPart.getNavigationMode() == NavigationMode.NONLINEAR) {
        if (testSessionState.isEnded() || currentTestPartSessionState.isEnded()) {
            if (itemNode.getEffectiveItemSessionControl().isAllowReview() || itemNode.getEffectiveItemSessionControl().isShowFeedback()) {
                event = Event.reviewItem;
            } else {
                event = null;
            }
        } else {
            event = Event.selectItem;
        }
    } else {
        event = null;
    }
    if (event == null) {
        sb.append("<span class='o_assessmentitem_nav_disabled'>");
    } else {
        sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRFnCallFor(form, dispatchId, 1, true, true, new NameValuePair("cid", event.name()), new NameValuePair("item", key))).append(";\" class='o_sel_assessmentitem'>");
    }
    String title;
    if (component.isShowTitles()) {
        title = StringHelper.escapeHtml(itemNode.getSectionPartTitle());
    } else {
        int num = component.getCandidateSessionContext().getNumber(itemNode);
        title = translator.translate("question.title", new String[] { Integer.toString(num) });
    }
    sb.append("<span class='questionTitle'>").append(title).append("</span>");
    if (event == null) {
        sb.append("</span>");
    } else {
        sb.append("</a>");
    }
    return event;
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) Form(org.olat.core.gui.components.form.flexible.impl.Form) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) Event(org.olat.ims.qti21.ui.QTIWorksAssessmentTestEvent.Event) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent) TestPartSessionState(uk.ac.ed.ph.jqtiplus.state.TestPartSessionState) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 65 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project OpenOLAT by OpenOLAT.

the class AssessmentTreeComponent method getCurrentTestPartNode.

public TestPlanNode getCurrentTestPartNode() {
    TestSessionState sessionState = getTestSessionController().getTestSessionState();
    TestPlanNodeKey testPlanNodeKey = sessionState.getCurrentTestPartKey();
    return testPlanNodeKey == null ? null : sessionState.getTestPlan().getNode(testPlanNodeKey);
}
Also used : TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Aggregations

TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)78 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)42 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)34 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)32 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)30 Date (java.util.Date)24 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)24 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)19 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)18 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)18 HashMap (java.util.HashMap)15 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)13 AssessmentResult (uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)12 TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)12 ArrayList (java.util.ArrayList)10 CandidateTestEventType (org.olat.ims.qti21.model.audit.CandidateTestEventType)10 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)10 Identity (org.olat.core.id.Identity)9 File (java.io.File)8 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)8