Search in sources :

Example 31 with ManifestMetadataBuilder

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

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

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

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)

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