Search in sources :

Example 21 with TestPlanNodeKey

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project openolat by klemens.

the class QTI21ServiceImpl method resumeItem.

private void resumeItem(TestPlanNodeKey lastEntryItemKey, TestSessionState testSessionState) {
    TestPlan plan = testSessionState.getTestPlan();
    Date now = new Date();
    for (TestPlanNode currentNode = plan.getNode(lastEntryItemKey); currentNode != null; currentNode = currentNode.getParent()) {
        TestNodeType type = currentNode.getTestNodeType();
        TestPlanNodeKey currentNodeKey = currentNode.getKey();
        switch(type) {
            case TEST_PART:
                {
                    TestPartSessionState state = testSessionState.getTestPartSessionStates().get(currentNodeKey);
                    if (state != null) {
                        state.setDurationIntervalStartTime(now);
                    }
                    break;
                }
            case ASSESSMENT_SECTION:
                {
                    AssessmentSectionSessionState sessionState = testSessionState.getAssessmentSectionSessionStates().get(currentNodeKey);
                    if (sessionState != null) {
                        sessionState.setDurationIntervalStartTime(now);
                    }
                    break;
                }
            case ASSESSMENT_ITEM_REF:
                {
                    ItemSessionState itemState = testSessionState.getItemSessionStates().get(currentNodeKey);
                    if (itemState != null) {
                        itemState.setDurationIntervalStartTime(now);
                    }
                    break;
                }
            default:
                {
                    // root doesn't match any session state
                    break;
                }
        }
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) TestPlan(uk.ac.ed.ph.jqtiplus.state.TestPlan) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) TestPartSessionState(uk.ac.ed.ph.jqtiplus.state.TestPartSessionState) AssessmentSectionSessionState(uk.ac.ed.ph.jqtiplus.state.AssessmentSectionSessionState) Date(java.util.Date) TestNodeType(uk.ac.ed.ph.jqtiplus.state.TestPlanNode.TestNodeType) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 22 with TestPlanNodeKey

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project openolat by klemens.

the class AssessmentTestComponent method getCurrentTestPartNode.

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

Example 23 with TestPlanNodeKey

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project openolat by klemens.

the class AssessmentTestComponent method getResponseUniqueIdentifier.

@Override
public String getResponseUniqueIdentifier(ItemSessionState itemSessionState, Interaction interaction) {
    TestPlanNodeKey tpnk = null;
    for (Map.Entry<TestPlanNodeKey, ItemSessionState> entry : testSessionController.getTestSessionState().getItemSessionStates().entrySet()) {
        if (entry.getValue() == itemSessionState) {
            tpnk = entry.getKey();
            break;
        }
    }
    String id = "oo" + (tpnk.toString().replace(":", "_")) + "_" + interaction.getResponseIdentifier().toString();
    responseIdentifiersMap.put(id, interaction);
    return id;
}
Also used : ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) HashMap(java.util.HashMap) Map(java.util.Map) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 24 with TestPlanNodeKey

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project openolat by klemens.

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 25 with TestPlanNodeKey

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project openolat by klemens.

the class CorrectionAssessmentItemListController method loadModel.

private void loadModel(boolean reset, boolean lastSessions) {
    if (lastSessions) {
        model.loadLastSessions();
    }
    ResolvedAssessmentTest resolvedAssessmentTest = model.getResolvedAssessmentTest();
    List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getAssessmentItemRefs();
    List<CorrectionAssessmentItemRow> itemRows = new ArrayList<>(itemRefs.size());
    Map<String, CorrectionAssessmentItemRow> itemRefIdToRows = new HashMap<>();
    for (AssessmentItemRef itemRef : itemRefs) {
        ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
        AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
        ManifestMetadataBuilder metadata = model.getMetadata(itemRef);
        FormLink toolsLink = uifactory.addFormLink("tools_" + (++counter), "tools", "", null, null, Link.NONTRANSLATED);
        toolsLink.setIconLeftCSS("o_icon o_icon_actions o_icon-lg");
        CorrectionAssessmentItemRow itemRow = new CorrectionAssessmentItemRow(itemRef, assessmentItem, metadata, toolsLink);
        toolsLink.setUserObject(itemRow);
        itemRows.add(itemRow);
        itemRefIdToRows.put(itemRef.getIdentifier().toString(), itemRow);
    }
    List<AssessmentItemSession> itemSessions = qtiService.getAssessmentItemSessions(model.getCourseEntry(), model.getSubIdent(), model.getTestEntry(), null);
    Map<ItemSessionKey, AssessmentItemSession> itemSessionMap = new HashMap<>();
    for (AssessmentItemSession itemSession : itemSessions) {
        AssessmentTestSession candidateSession = itemSession.getAssessmentTestSession();
        if (model.getReversedLastSessions().containsKey(candidateSession)) {
            // the map contains all test sessions the user is allowed to correct
            String itemRefIdentifier = itemSession.getAssessmentItemIdentifier();
            itemSessionMap.put(new ItemSessionKey(candidateSession.getKey(), itemRefIdentifier), itemSession);
        }
    }
    for (Map.Entry<Identity, AssessmentTestSession> entry : model.getLastSessions().entrySet()) {
        if (model.getLastSessions().containsKey(entry.getKey())) {
            TestSessionState testSessionState = model.getTestSessionStates().get(entry.getKey());
            for (Map.Entry<TestPlanNodeKey, ItemSessionState> itemEntry : testSessionState.getItemSessionStates().entrySet()) {
                String itemRefIdentifier = itemEntry.getKey().getIdentifier().toString();
                CorrectionAssessmentItemRow row = itemRefIdToRows.get(itemRefIdentifier);
                if (row != null) {
                    AssessmentItemSession itemSession = itemSessionMap.get(new ItemSessionKey(entry.getValue().getKey(), itemRefIdentifier));
                    appendStatistics(row, itemSession, itemEntry.getValue());
                }
            }
        }
    }
    tableModel.setObjects(itemRows);
    tableEl.reset(reset, reset, true);
}
Also used : TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ItemSessionKey(org.olat.ims.qti21.ui.assessment.model.ItemSessionKey) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) Identity(org.olat.core.id.Identity) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) CorrectionAssessmentItemRow(org.olat.ims.qti21.ui.assessment.model.CorrectionAssessmentItemRow) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) Map(java.util.Map) HashMap(java.util.HashMap) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Aggregations

TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)52 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)42 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)26 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)26 HashMap (java.util.HashMap)18 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)18 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)16 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)16 ArrayList (java.util.ArrayList)12 Date (java.util.Date)12 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)12 Map (java.util.Map)10 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)10 TestPlan (uk.ac.ed.ph.jqtiplus.state.TestPlan)10 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)10 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)8 TestPartSessionState (uk.ac.ed.ph.jqtiplus.state.TestPartSessionState)8 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)6 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)6 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)6