Search in sources :

Example 56 with AssessmentTest

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

the class AssessmentTestComposerController method doNewSection.

private void doNewSection(UserRequest ureq, TreeNode selectedNode) {
    AbstractPart parentPart;
    TreeNode sectionNode = getNearestSection(selectedNode);
    if (sectionNode != null) {
        AssessmentSection section = (AssessmentSection) sectionNode.getUserObject();
        parentPart = section.getParent();
    } else if (selectedNode.getUserObject() instanceof TestPart) {
        parentPart = (TestPart) selectedNode.getUserObject();
    } else {
        TreeNode rootNode = menuTree.getTreeModel().getRootNode();
        AssessmentTest assessmentTest = (AssessmentTest) rootNode.getUserObject();
        List<TestPart> parts = assessmentTest.getTestParts();
        if (parts != null && parts.size() > 0) {
            parentPart = parts.get(0);
        } else {
            showWarning("error.cannot.create.section");
            return;
        }
    }
    AssessmentSection newSection;
    if (parentPart instanceof TestPart) {
        newSection = AssessmentTestFactory.appendAssessmentSection(translate("new.section"), (TestPart) parentPart);
    } else if (parentPart instanceof AssessmentSection) {
        newSection = AssessmentTestFactory.appendAssessmentSection(translate("new.section"), (AssessmentSection) parentPart);
    } else {
        showWarning("error.cannot.create.section");
        return;
    }
    // save the test
    URI testUri = resolvedAssessmentTest.getTestLookup().getSystemId();
    File testFile = new File(testUri);
    qtiService.updateAssesmentObject(testFile, resolvedAssessmentTest);
    assessmentChanged(ureq);
    // reload the test
    updateTreeModel(false);
    TreeNode newSectionNode = menuTree.getTreeModel().getNodeById(newSection.getIdentifier().toString());
    menuTree.setSelectedNode(newSectionNode);
    menuTree.open(newSectionNode);
    partEditorFactory(ureq, newSectionNode);
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AbstractPart(uk.ac.ed.ph.jqtiplus.node.test.AbstractPart) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) ArrayList(java.util.ArrayList) List(java.util.List) URI(java.net.URI) File(java.io.File)

Example 57 with AssessmentTest

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

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

the class AssessmentTestComposerController method doConfirmDelete.

private void doConfirmDelete(UserRequest ureq) {
    if (confirmDeleteCtrl != null)
        return;
    TreeNode selectedNode = menuTree.getSelectedNode();
    if (selectedNode == null) {
        showWarning("warning.atleastone");
        return;
    }
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof AssessmentTest) {
        showWarning("error.cannot.delete");
    } else if (uobject instanceof TestPart) {
        TestPart testPart = (TestPart) uobject;
        if (testPart.getParent().getTestParts().size() == 1) {
            showWarning("error.cannot.delete");
        }
        String msg = translate("delete.testPart");
        confirmDeleteCtrl = activateYesNoDialog(ureq, translate("tools.change.delete"), msg, confirmDeleteCtrl);
        confirmDeleteCtrl.setUserObject(selectedNode);
    } else {
        String msg;
        if (uobject instanceof AssessmentSection) {
            AssessmentSection section = (AssessmentSection) uobject;
            if (checkAtLeastOneSection(section)) {
                msg = translate("delete.section", selectedNode.getTitle());
            } else {
                showWarning("warning.atleastonesection");
                return;
            }
        } else if (uobject instanceof AssessmentItemRef) {
            msg = translate("delete.item", selectedNode.getTitle());
        } else {
            showError("error.cannot.delete");
            return;
        }
        confirmDeleteCtrl = activateYesNoDialog(ureq, translate("tools.change.delete"), msg, confirmDeleteCtrl);
        confirmDeleteCtrl.setUserObject(selectedNode);
    }
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) 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 59 with AssessmentTest

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

the class QTI21StatisticResourceResult method getSubTreeModel.

/**
 * Return the tree model for a course and a specific test.
 */
@Override
public TreeModel getSubTreeModel() {
    GenericTreeModel subTreeModel = new GenericTreeModel();
    StatisticResourceNode rootTreeNode = new StatisticResourceNode(courseNode, this);
    subTreeModel.setRootNode(rootTreeNode);
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest test = resolvedAssessmentTest.getTestLookup().getRootNodeHolder().getRootNode();
    buildRecursively(test, rootTreeNode);
    return subTreeModel;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) StatisticResourceNode(org.olat.course.statistic.StatisticResourceNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) File(java.io.File)

Example 60 with AssessmentTest

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

the class QTI21StatisticResourceResult method getTreeModel.

/**
 * Return the tree model for a test learn resource.
 *
 * @return
 */
public TreeModel getTreeModel() {
    GenericTreeModel treeModel = new GenericTreeModel();
    GenericTreeNode rootTreeNode = new GenericTreeNode();
    treeModel.setRootNode(rootTreeNode);
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest test = resolvedAssessmentTest.getTestLookup().getRootNodeHolder().getRootNode();
    rootTreeNode.setTitle(test.getTitle());
    rootTreeNode.setUserObject(test);
    rootTreeNode.setIconCssClass("o_icon o_icon-lg o_qtiassessment_icon");
    buildRecursively(test, rootTreeNode);
    return treeModel;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) File(java.io.File)

Aggregations

AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)60 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)48 File (java.io.File)34 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)22 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)20 FileResourceManager (org.olat.fileresource.FileResourceManager)12 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)12 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)12 IOException (java.io.IOException)10 URISyntaxException (java.net.URISyntaxException)10 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)10 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)10 ArrayList (java.util.ArrayList)8 TreeNode (org.olat.core.gui.components.tree.TreeNode)8 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)8 FileOutputStream (java.io.FileOutputStream)6 ManifestMetadataBuilder (org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)6 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)6 AssessmentTestBuilder (org.olat.ims.qti21.model.xml.AssessmentTestBuilder)5 CompleteAssessmentTestSessionEvent (org.olat.modules.assessment.ui.event.CompleteAssessmentTestSessionEvent)5