Search in sources :

Example 26 with AssessmentItemRef

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

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

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 28 with AssessmentItemRef

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

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

the class AssessmentTestComposerController method doDelete.

private void doDelete(UserRequest ureq, TreeNode selectedNode) {
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof TestPart) {
        doDeleteTestPart(ureq, (TestPart) uobject);
    } else if (uobject instanceof AssessmentSection) {
        AssessmentSection section = (AssessmentSection) uobject;
        if (checkAtLeastOneSection(section)) {
            doDeleteAssessmentSection(ureq, section);
        } else {
            showWarning("warning.atleastonesection");
        }
    } else if (uobject instanceof AssessmentItemRef) {
        doDeleteAssessmentItemRef(ureq, (AssessmentItemRef) uobject);
    } else {
        // cannot delete test or test part
        return;
    }
    doSaveAssessmentTest(ureq, null);
    doSaveManifest();
    updateTreeModel(false);
    if (selectedNode != null && selectedNode.getParent() != null) {
        TreeNode parentNode = (TreeNode) selectedNode.getParent();
        menuTree.setSelectedNode(parentNode);
        menuTree.open(parentNode);
        partEditorFactory(ureq, parentNode);
    }
}
Also used : 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) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)

Example 30 with AssessmentItemRef

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

the class AssessmentTestComposerController method doDeleteAssessmentItemRef.

private void doDeleteAssessmentItemRef(UserRequest ureq, AssessmentItemRef itemRef) {
    ResourceType resource = getResourceType(itemRef);
    if (resource != null) {
        manifestBuilder.remove(resource);
    }
    boolean deleted = false;
    boolean removed = itemRef.getParentSection().getSectionParts().remove(itemRef);
    ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
    if (resolvedAssessmentItem != null) {
        RootNodeLookup<AssessmentItem> rootNode = resolvedAssessmentItem.getItemLookup();
        if (rootNode != null) {
            URI itemUri = rootNode.getSystemId();
            List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getItemRefsBySystemIdMap().get(itemUri);
            if (itemRefs.size() <= 1) {
                File itemFile = new File(itemUri);
                deleted = itemFile.delete();
            }
        }
    }
    if (deleted) {
        assessmentChanged(ureq);
    }
    logAudit(removed + " " + deleted + " removed item ref", null);
}
Also used : ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) ResourceType(org.olat.imscp.xml.manifest.ResourceType) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) URI(java.net.URI) File(java.io.File)

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