Search in sources :

Example 46 with TestPart

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

the class AssessmentTestComposerController method doNewTestPart.

/**
 * Create a new test part and a section. Test part need a section,
 * section ref as children, it's mandatory.
 *
 * @param ureq
 */
private void doNewTestPart(UserRequest ureq) {
    TestPart testPart = AssessmentTestFactory.createTestPart(assessmentTestBuilder.getAssessmentTest());
    AssessmentTestFactory.appendAssessmentSection(translate("new.section"), testPart);
    // save the test
    doSaveAssessmentTest(ureq, null);
    // reload the test
    updateTreeModel(false);
    TreeNode newTestPartNode = menuTree.getTreeModel().getNodeById(testPart.getIdentifier().toString());
    menuTree.setSelectedNode(newTestPartNode);
    menuTree.open(newTestPartNode);
    partEditorFactory(ureq, newTestPartNode);
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart)

Example 47 with TestPart

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

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

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

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

the class QTI21StatisticResourceResult method buildRecursively.

private void buildRecursively(AssessmentTest test, GenericTreeNode rootTreeNode) {
    // list all test parts
    List<TestPart> parts = test.getTestParts();
    if (parts.size() == 1) {
        TreeNode firstItem = null;
        List<AssessmentSection> sections = test.getTestParts().get(0).getAssessmentSections();
        for (AssessmentSection section : sections) {
            TreeNode itemNode = buildRecursively(section, rootTreeNode);
            if (firstItem == null) {
                firstItem = itemNode;
            }
        }
    } else {
        int counter = 0;
        for (TestPart part : parts) {
            buildRecursively(part, ++counter, rootTreeNode);
        }
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart)

Aggregations

TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)50 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)28 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)20 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)16 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)12 TreeNode (org.olat.core.gui.components.tree.TreeNode)12 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)12 File (java.io.File)8 ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)8 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)8 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)6 URI (java.net.URI)4 Date (java.util.Date)4 NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)4 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)4 RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)4 Ordering (uk.ac.ed.ph.jqtiplus.node.test.Ordering)4 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)3 FileOutputStream (java.io.FileOutputStream)2