Search in sources :

Example 6 with ResolvedAssessmentItem

use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doExportPool.

private void doExportPool(AssessmentItemRef itemRef) {
    ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
    RootNodeLookup<AssessmentItem> rootNode = resolvedAssessmentItem.getItemLookup();
    AssessmentItem assessmentItem = rootNode.extractIfSuccessful();
    ManifestBuilder clonedManifestBuilder = ManifestBuilder.read(new File(unzippedDirRoot, "imsmanifest.xml"));
    ResourceType resource = getResourceType(clonedManifestBuilder, itemRef);
    ManifestMetadataBuilder metadata = clonedManifestBuilder.getMetadataBuilder(resource, true);
    if (metadata == null) {
        // not in imsmanifest.xml?
        metadata = new ManifestMetadataBuilder();
    }
    File itemFile = new File(rootNode.getSystemId());
    qti21QPoolServiceProvider.importAssessmentItemRef(getIdentity(), assessmentItem, itemFile, metadata, getLocale());
}
Also used : ManifestBuilder(org.olat.ims.qti21.model.xml.ManifestBuilder) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResourceType(org.olat.imscp.xml.manifest.ResourceType) File(java.io.File) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)

Example 7 with ResolvedAssessmentItem

use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method recalculateMaxScoreAssessmentTest.

private void recalculateMaxScoreAssessmentTest(Map<AssessmentItemRef, AssessmentItem> flyingObjects) {
    DoubleAdder atomicMaxScore = new DoubleAdder();
    AssessmentTest assessmentTest = (AssessmentTest) menuTree.getTreeModel().getRootNode().getUserObject();
    AssessmentTestHelper.visit(assessmentTest, new AssessmentTestVisitor() {

        @Override
        public void visit(TestPart testPart) {
        /* */
        }

        @Override
        public void visit(SectionPart sectionPart) {
            if (sectionPart instanceof AssessmentItemRef) {
                AssessmentItemRef itemRef = (AssessmentItemRef) sectionPart;
                ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
                checkAndFixAbsolutePath(itemRef);
                AssessmentItem assessmentItem = null;
                if (resolvedAssessmentItem != null) {
                    assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
                }
                if (assessmentItem == null && flyingObjects != null && flyingObjects.containsKey(itemRef)) {
                    assessmentItem = flyingObjects.get(itemRef);
                }
                if (assessmentItem != null) {
                    Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
                    if (maxScore != null) {
                        atomicMaxScore.add(maxScore.doubleValue());
                    }
                }
            }
        }
    });
    double sumMaxScore = atomicMaxScore.sum();
    if (sumMaxScore > 0.0d) {
        assessmentTestBuilder.setMaxScore(sumMaxScore);
    } else {
        assessmentTestBuilder.setMaxScore(null);
    }
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) DoubleAdder(java.util.concurrent.atomic.DoubleAdder) SectionPart(uk.ac.ed.ph.jqtiplus.node.test.SectionPart) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestVisitor(org.olat.ims.qti21.AssessmentTestHelper.AssessmentTestVisitor)

Example 8 with ResolvedAssessmentItem

use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.

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)

Example 9 with ResolvedAssessmentItem

use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method partEditorFactory.

private void partEditorFactory(UserRequest ureq, TreeNode selectedNode) {
    // remove old one
    if (currentEditorCtrl != null) {
        mainVC.remove(currentEditorCtrl.getInitialComponent());
        removeAsListenerAndDispose(currentEditorCtrl);
        currentEditorCtrl = null;
    }
    // fill with the new
    mainVC.contextPut("cssClass", selectedNode.getIconCssClass());
    if (Settings.isDebuging()) {
        mainVC.contextPut("identifier", selectedNode.getIdent());
    }
    mainVC.contextPut("title", selectedNode.getTitle());
    mainVC.contextPut("restrictedEdit", restrictedEdit);
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof AssessmentTest) {
        AssessmentTest test = (AssessmentTest) uobject;
        URI testURI = resolvedAssessmentTest.getTestLookup().getSystemId();
        File testFile = new File(testURI);
        TestPart uniqueTestPart = test.getTestParts().size() == 1 ? test.getTestParts().get(0) : null;
        currentEditorCtrl = new AssessmentTestEditorController(ureq, getWindowControl(), assessmentTestBuilder, uniqueTestPart, unzippedDirRoot, unzippedContRoot, testFile, restrictedEdit);
    } else if (uobject instanceof TestPart) {
        currentEditorCtrl = new AssessmentTestPartEditorController(ureq, getWindowControl(), (TestPart) uobject, restrictedEdit, assessmentTestBuilder.isEditable());
    } else if (uobject instanceof AssessmentSection) {
        URI testURI = resolvedAssessmentTest.getTestLookup().getSystemId();
        File testFile = new File(testURI);
        currentEditorCtrl = new AssessmentSectionEditorController(ureq, getWindowControl(), (AssessmentSection) uobject, unzippedDirRoot, unzippedContRoot, testFile, restrictedEdit, assessmentTestBuilder.isEditable());
    } else if (uobject instanceof AssessmentItemRef) {
        AssessmentItemRef itemRef = (AssessmentItemRef) uobject;
        ResolvedAssessmentItem item = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
        if (item == null || item.getItemLookup() == null) {
            currentEditorCtrl = new BadResourceController(ureq, getWindowControl(), null, unzippedDirRoot, itemRef.getHref());
        } else if (item.getItemLookup().getBadResourceException() != null) {
            currentEditorCtrl = new BadResourceController(ureq, getWindowControl(), item.getItemLookup().getBadResourceException(), unzippedDirRoot, itemRef.getHref());
        } else {
            URI itemUri = resolvedAssessmentTest.getSystemIdByItemRefMap().get(itemRef);
            File itemFile = new File(itemUri);
            ManifestMetadataBuilder metadata = getMetadataBuilder(itemRef);
            currentEditorCtrl = new AssessmentItemEditorController(ureq, getWindowControl(), testEntry, item, itemRef, metadata, unzippedDirRoot, unzippedContRoot, itemFile, restrictedEdit);
        }
    }
    if (deleteLink != null) {
        if (uobject instanceof AssessmentSection || uobject instanceof AssessmentItemRef) {
            deleteLink.setEnabled(true);
        } else if (uobject instanceof TestPart) {
            TestPart testPart = (TestPart) uobject;
            deleteLink.setEnabled(testPart.getParent().getTestParts().size() > 1);
        } else {
            deleteLink.setEnabled(false);
        }
    }
    if (copyLink != null) {
        copyLink.setEnabled(uobject instanceof AssessmentItemRef);
    }
    if (currentEditorCtrl != null) {
        listenTo(currentEditorCtrl);
        mainVC.put("content", currentEditorCtrl.getInitialComponent());
    } else {
        mainVC.put("content", new Panel("empty"));
    }
}
Also used : URI(java.net.URI) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) StackedPanel(org.olat.core.gui.components.panel.StackedPanel) SimpleStackedPanel(org.olat.core.gui.components.panel.SimpleStackedPanel) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) Panel(org.olat.core.gui.components.panel.Panel) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) 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) File(java.io.File)

Example 10 with ResolvedAssessmentItem

use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.

the class QTI21StatisticResourceResult method buildRecursively.

private TreeNode buildRecursively(AssessmentItemRef itemRef, TreeNode parentNode) {
    GenericTreeNode itemNode = new GenericTreeNode();
    ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
    BadResourceException ex = resolvedAssessmentItem.getItemLookup().getBadResourceException();
    if (ex == null) {
        AssessmentItem assessmentItem = resolvedAssessmentItem.getItemLookup().getRootNodeHolder().getRootNode();
        itemNode.setTitle(assessmentItem.getTitle());
        QTI21QuestionType type = QTI21QuestionType.getTypeRelax(assessmentItem);
        if (type != null) {
            itemNode.setIconCssClass("o_icon ".concat(type.getCssClass()));
        } else {
            itemNode.setIconCssClass("o_icon o_mi_qtiunkown");
        }
        itemNode.setUserObject(itemRef);
        parentNode.addChild(itemNode);
    }
    return itemNode;
}
Also used : BadResourceException(uk.ac.ed.ph.jqtiplus.provision.BadResourceException) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)

Aggregations

ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)106 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)76 File (java.io.File)38 URI (java.net.URI)32 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)26 AssessmentObjectXmlLoader (uk.ac.ed.ph.jqtiplus.reading.AssessmentObjectXmlLoader)26 QtiXmlReader (uk.ac.ed.ph.jqtiplus.reading.QtiXmlReader)26 ResourceLocator (uk.ac.ed.ph.jqtiplus.xmlutils.locators.ResourceLocator)26 PathResourceLocator (org.olat.fileresource.types.ImsQTI21Resource.PathResourceLocator)22 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)22 IOException (java.io.IOException)20 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)20 URISyntaxException (java.net.URISyntaxException)16 ManifestMetadataBuilder (org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)16 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)14 ArrayList (java.util.ArrayList)12 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)12 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)12 BadResourceException (uk.ac.ed.ph.jqtiplus.provision.BadResourceException)12 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)12