Search in sources :

Example 16 with ManifestMetadataBuilder

use of org.olat.ims.qti21.model.xml.ManifestMetadataBuilder in project openolat by klemens.

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 17 with ManifestMetadataBuilder

use of org.olat.ims.qti21.model.xml.ManifestMetadataBuilder in project openolat by klemens.

the class AssessmentTestComposerController method doInsert.

private void doInsert(UserRequest ureq, List<QuestionItemView> items) {
    TreeNode selectedNode = menuTree.getSelectedNode();
    TreeNode sectionNode = getNearestSection(selectedNode);
    boolean allOk = true;
    String firstItemId = null;
    Map<AssessmentItemRef, AssessmentItem> flyingObjects = new HashMap<>();
    try {
        AssessmentSection section = (AssessmentSection) sectionNode.getUserObject();
        for (QuestionItemView item : items) {
            QuestionItemFull qItem = qti21QPoolServiceProvider.getFullQuestionItem(item);
            AssessmentItem assessmentItem = qti21QPoolServiceProvider.exportToQTIEditor(qItem, getLocale(), unzippedDirRoot);
            if (assessmentItem != null) {
                AssessmentItemRef itemRef = doInsert(section, assessmentItem);
                if (firstItemId == null) {
                    firstItemId = itemRef.getIdentifier().toString();
                }
                flyingObjects.put(itemRef, assessmentItem);
                ManifestMetadataBuilder metadata = manifestBuilder.getResourceBuilderByHref(itemRef.getHref().toString());
                metadata.appendMetadataFrom(qItem, assessmentItem, getLocale());
                metadata.setOpenOLATMetadataCopiedAt(new Date());
            } else {
                allOk &= false;
            }
        }
    } catch (IOException | URISyntaxException e) {
        showError("error.import.question");
        logError("", e);
    }
    if (!allOk) {
        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) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) Date(java.util.Date) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) 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) QuestionItemView(org.olat.modules.qpool.QuestionItemView)

Example 18 with ManifestMetadataBuilder

use of org.olat.ims.qti21.model.xml.ManifestMetadataBuilder in project openolat by klemens.

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 19 with ManifestMetadataBuilder

use of org.olat.ims.qti21.model.xml.ManifestMetadataBuilder in project openolat by klemens.

the class AssessmentTestComposerController method doDetachItemFromPool.

private TreeNode doDetachItemFromPool(UserRequest ureq, AssessmentItemRef itemRef) {
    ManifestMetadataBuilder metadata = manifestBuilder.getResourceBuilderByHref(itemRef.getHref().toString());
    String identifier = metadata.getOpenOLATMetadataIdentifier();
    metadata.setOpenOLATMetadataMasterIdentifier(identifier);
    metadata.setOpenOLATMetadataIdentifier(UUID.randomUUID().toString());
    doSaveManifest();
    return doReloadItem(ureq);
}
Also used : ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)

Example 20 with ManifestMetadataBuilder

use of org.olat.ims.qti21.model.xml.ManifestMetadataBuilder 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)

Aggregations

ManifestMetadataBuilder (org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)32 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)22 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)18 File (java.io.File)16 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)16 ResourceType (org.olat.imscp.xml.manifest.ResourceType)14 IOException (java.io.IOException)12 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)12 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)10 URISyntaxException (java.net.URISyntaxException)8 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)8 URI (java.net.URI)6 Path (java.nio.file.Path)6 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)6 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)6 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)6 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)4 TreeNode (org.olat.core.gui.components.tree.TreeNode)4