Search in sources :

Example 41 with TestPlanNodeKey

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

the class CorrectionIdentityListController method loadModel.

private void loadModel(boolean reset, boolean lastSessions) {
    if (lastSessions) {
        model.loadLastSessions();
    }
    List<AssessmentItemRef> itemRefs = model.getResolvedAssessmentTest().getAssessmentItemRefs();
    Map<String, AssessmentItemRef> identifierToItemRefMap = new HashMap<>();
    for (AssessmentItemRef itemRef : itemRefs) {
        identifierToItemRefMap.put(itemRef.getIdentifier().toString(), itemRef);
    }
    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);
        }
    }
    int count = 0;
    List<CorrectionIdentityRow> rows = new ArrayList<>(model.getNumberOfAssessedIdentities());
    Map<Identity, CorrectionIdentityRow> identityToRows = new HashMap<>();
    for (Map.Entry<Identity, AssessmentTestSession> entry : model.getLastSessions().entrySet()) {
        String user = translate("number.assessed.identity", new String[] { Integer.toString(++count) });
        CorrectionIdentityRow row = new CorrectionIdentityRow(user, entry.getKey(), entry.getValue(), userPropertyHandlers, getLocale());
        rows.add(row);
        identityToRows.put(entry.getKey(), row);
        TestSessionState testSessionState = model.getTestSessionStates().get(entry.getKey());
        for (Map.Entry<TestPlanNodeKey, ItemSessionState> itemEntry : testSessionState.getItemSessionStates().entrySet()) {
            String itemRefIdentifier = itemEntry.getKey().getIdentifier().toString();
            AssessmentItemRef itemRef = identifierToItemRefMap.get(itemRefIdentifier);
            AssessmentItemSession itemSession = itemSessionMap.get(new ItemSessionKey(entry.getValue().getKey(), itemRefIdentifier));
            appendStatistics(row, itemSession, itemEntry.getValue(), itemRef);
        }
    }
    tableModel.setObjects(rows);
    tableEl.reset(reset, reset, true);
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) HashMap(java.util.HashMap) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ArrayList(java.util.ArrayList) ItemSessionKey(org.olat.ims.qti21.ui.assessment.model.ItemSessionKey) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) Identity(org.olat.core.id.Identity) CorrectionIdentityRow(org.olat.ims.qti21.ui.assessment.model.CorrectionIdentityRow) Map(java.util.Map) HashMap(java.util.HashMap) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 42 with TestPlanNodeKey

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

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)

Example 43 with TestPlanNodeKey

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

the class CorrectionIdentityAssessmentItemListController method loadModel.

private void loadModel(boolean reset) {
    ResolvedAssessmentTest resolvedAssessmentTest = model.getResolvedAssessmentTest();
    Map<Identifier, AssessmentItemRef> identifierToRefs = new HashMap<>();
    for (AssessmentItemRef itemRef : resolvedAssessmentTest.getAssessmentItemRefs()) {
        identifierToRefs.put(itemRef.getIdentifier(), itemRef);
    }
    List<AssessmentItemSession> allItemSessions = qtiService.getAssessmentItemSessions(candidateSession);
    Map<String, AssessmentItemSession> identifierToItemSessions = new HashMap<>();
    for (AssessmentItemSession itemSession : allItemSessions) {
        identifierToItemSessions.put(itemSession.getAssessmentItemIdentifier(), itemSession);
    }
    // reorder to match the list of assessment items
    List<CorrectionIdentityAssessmentItemRow> rows = new ArrayList<>();
    TestSessionState testSessionState = model.getTestSessionStates().get(assessedIdentity);
    List<TestPlanNode> nodes = testSessionState.getTestPlan().getTestPlanNodeList();
    for (TestPlanNode node : nodes) {
        if (node.getTestNodeType() == TestNodeType.ASSESSMENT_ITEM_REF) {
            TestPlanNodeKey key = node.getKey();
            AssessmentItemRef itemRef = identifierToRefs.get(key.getIdentifier());
            AssessmentItemSession itemSession = identifierToItemSessions.get(key.getIdentifier().toString());
            ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
            ManifestMetadataBuilder metadata = model.getMetadata(itemRef);
            AssessmentItem item = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
            ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(key);
            boolean manualCorrection = model.isManualCorrection(itemRef);
            CorrectionIdentityAssessmentItemRow row = new CorrectionIdentityAssessmentItemRow(assessedIdentity, item, itemRef, metadata, candidateSession, itemSession, itemSessionState, manualCorrection);
            row.setTitle(title);
            row.setTitleCssClass("o_icon_user");
            rows.add(row);
        }
    }
    tableModel.setObjects(rows);
    tableEl.reset(reset, reset, true);
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) HashMap(java.util.HashMap) CorrectionIdentityAssessmentItemRow(org.olat.ims.qti21.ui.assessment.model.CorrectionIdentityAssessmentItemRow) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ArrayList(java.util.ArrayList) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 44 with TestPlanNodeKey

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

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey 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)

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