Search in sources :

Example 41 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef 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 42 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class CorrectionAssessmentItemListController method doSelect.

private void doSelect(UserRequest ureq, CorrectionAssessmentItemRow row, Predicate<AssessmentItemListEntry> filter) {
    removeAsListenerAndDispose(identityItemCtrl);
    AssessmentItemRef itemRef = row.getItemRef();
    String itemRefIdentifier = row.getItemRef().getIdentifier().toString();
    List<AssessmentItemSession> allItemSessions = qtiService.getAssessmentItemSessions(model.getCourseEntry(), model.getSubIdent(), model.getTestEntry(), itemRefIdentifier);
    Map<AssessmentTestSession, AssessmentItemSession> testToItemSession = new HashMap<>();
    for (AssessmentItemSession itemSession : allItemSessions) {
        AssessmentTestSession testSession = itemSession.getAssessmentTestSession();
        testToItemSession.put(testSession, itemSession);
    }
    // reorder to match the list of identities
    int count = 1;
    List<Identity> assessedIdentities = model.getAssessedIdentities();
    List<AssessmentItemListEntry> reorderItemSessions = new ArrayList<>(assessedIdentities.size());
    for (Identity assessedIdentity : assessedIdentities) {
        AssessmentTestSession testSession = model.getLastSessions().get(assessedIdentity);
        if (testSession != null) {
            AssessmentItemSession itemSession = testToItemSession.get(testSession);
            String title;
            if (anonymous) {
                title = translate("number.assessed.identity", new String[] { Integer.toString(count++) });
            } else {
                title = userManager.getUserDisplayName(assessedIdentity);
            }
            AssessmentItemListEntry entry = new AssessmentItemListEntry(assessedIdentity, testSession, itemSession, itemRef, title, "o_icon_user");
            if (filter.test(entry)) {
                reorderItemSessions.add(entry);
            }
        }
    }
    if (!reorderItemSessions.isEmpty()) {
        doSelect(ureq, reorderItemSessions.get(0), reorderItemSessions);
    } else {
        showWarning("waring.atleast.one");
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) HashMap(java.util.HashMap) AssessmentItemListEntry(org.olat.ims.qti21.ui.assessment.model.AssessmentItemListEntry) ArrayList(java.util.ArrayList) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) Identity(org.olat.core.id.Identity)

Example 43 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef 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 AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doInsert.

private void doInsert(UserRequest ureq, AssessmentItemsPackage importPackage) {
    TreeNode selectedNode = menuTree.getSelectedNode();
    TreeNode sectionNode = getNearestSection(selectedNode);
    String firstItemId = null;
    boolean errorOnImport = false;
    Map<AssessmentItemRef, AssessmentItem> flyingObjects = new HashMap<>();
    try {
        AssessmentSection section = (AssessmentSection) sectionNode.getUserObject();
        List<AssessmentItemAndMetadata> itemsAndMetadata = importPackage.getItems();
        for (AssessmentItemAndMetadata itemAndMetadata : itemsAndMetadata) {
            if (itemAndMetadata.isHasError()) {
                errorOnImport = true;
                continue;
            }
            AssessmentItemBuilder itemBuilder = itemAndMetadata.getItemBuilder();
            AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
            AssessmentItemRef itemRef = doInsert(section, assessmentItem);
            ManifestMetadataBuilder metadata = manifestBuilder.getResourceBuilderByHref(itemRef.getHref().toString());
            metadata.setQtiMetadataInteractionTypes(itemBuilder.getInteractionNames());
            itemAndMetadata.toBuilder(metadata, getLocale());
            if (firstItemId == null) {
                firstItemId = itemRef.getIdentifier().toString();
            }
            flyingObjects.put(itemRef, assessmentItem);
        }
    } catch (URISyntaxException e) {
        errorOnImport = true;
        logError("", e);
    }
    if (errorOnImport) {
        showError("error.import.question");
    }
    if (firstItemId != null) {
        // persist metadata
        doSaveAssessmentTest(ureq, flyingObjects);
        doSaveManifest();
        updateTreeModel(false);
        TreeNode newItemNode = menuTree.getTreeModel().getNodeById(firstItemId);
        menuTree.setSelectedNode(newItemNode);
        menuTree.open(newItemNode);
        partEditorFactory(ureq, newItemNode);
    }
}
Also used : HashMap(java.util.HashMap) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) URISyntaxException(java.net.URISyntaxException) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) AssessmentItemBuilder(org.olat.ims.qti21.model.xml.AssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) AssessmentItemAndMetadata(org.olat.ims.qti21.questionimport.AssessmentItemAndMetadata) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)

Example 45 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doInsert.

private AssessmentItemRef doInsert(AssessmentSection section, AssessmentItem assessmentItem) throws URISyntaxException {
    AssessmentItemRef itemRef = new AssessmentItemRef(section);
    String itemId = assessmentItem.getIdentifier();
    itemRef.setIdentifier(Identifier.parseString(itemId));
    File itemFile = new File(unzippedDirRoot, itemId + ".xml");
    itemRef.setHref(new URI(itemFile.getName()));
    section.getSectionParts().add(itemRef);
    qtiService.persistAssessmentObject(itemFile, assessmentItem);
    URI testUri = resolvedAssessmentTest.getTestLookup().getSystemId();
    File testFile = new File(testUri);
    qtiService.updateAssesmentObject(testFile, resolvedAssessmentTest);
    manifestBuilder.appendAssessmentItem(itemFile.getName());
    doSaveManifest();
    return itemRef;
}
Also used : AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) File(java.io.File) URI(java.net.URI)

Aggregations

AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)70 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)34 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)32 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)28 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)22 TreeNode (org.olat.core.gui.components.tree.TreeNode)20 File (java.io.File)18 URI (java.net.URI)18 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)18 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)18 ArrayList (java.util.ArrayList)16 HashMap (java.util.HashMap)16 ManifestMetadataBuilder (org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)12 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)12 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)12 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)12 Identity (org.olat.core.id.Identity)10 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)10 SectionPart (uk.ac.ed.ph.jqtiplus.node.test.SectionPart)10 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)10