Search in sources :

Example 26 with AssessmentTest

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

the class AssessmentTestComposerController method doDrop.

private void doDrop(UserRequest ureq, String droppedNodeId, String targetnodeId, boolean asChild) {
    TreeNode droppedNode = menuTree.getTreeModel().getNodeById(droppedNodeId);
    TreeNode targetNode = menuTree.getTreeModel().getNodeById(targetnodeId);
    if (droppedNode == null || targetNode == null)
        return;
    Object droppedObject = droppedNode.getUserObject();
    Object targetObject = targetNode.getUserObject();
    if (droppedObject == null || targetObject == null || droppedObject == targetObject)
        return;
    if (asChild) {
        if (droppedObject instanceof AssessmentItemRef && (targetObject instanceof AssessmentSection || targetObject instanceof AssessmentItemRef)) {
            AssessmentItemRef droppedItemRef = (AssessmentItemRef) droppedObject;
            droppedItemRef.getParentSection().getSectionParts().remove(droppedItemRef);
            if (targetObject instanceof AssessmentSection) {
                AssessmentSection targetSection = (AssessmentSection) targetObject;
                targetSection.getSectionParts().add(droppedItemRef);
            } else if (targetObject instanceof AssessmentItemRef) {
                AssessmentItemRef targetItemRef = (AssessmentItemRef) targetObject;
                AssessmentSection targetSection = targetItemRef.getParentSection();
                int pos = targetSection.getChildAbstractParts().indexOf(targetItemRef);
                targetSection.getChildAbstractParts().add(pos, droppedItemRef);
            }
        } else if (droppedObject instanceof AssessmentSection && (targetObject instanceof AssessmentSection || targetObject instanceof TestPart || (targetObject instanceof AssessmentTest && ((AssessmentTest) targetObject).getTestParts().size() == 1))) {
            AssessmentSection droppedSection = (AssessmentSection) droppedObject;
            if (droppedSection.getParentSection() != null) {
                droppedSection.getParentSection().getSectionParts().remove(droppedSection);
            } else {
                droppedSection.getParent().getChildAbstractParts().remove(droppedSection);
            }
            if (targetObject instanceof AssessmentSection) {
                AssessmentSection targetSection = (AssessmentSection) targetObject;
                targetSection.getChildAbstractParts().add(droppedSection);
            } else if (targetObject instanceof TestPart) {
                TestPart targetTestPart = (TestPart) targetObject;
                targetTestPart.getAssessmentSections().add(droppedSection);
            } else if (targetObject instanceof AssessmentTest) {
                TestPart targetTestPart = ((AssessmentTest) targetObject).getTestParts().get(0);
                targetTestPart.getAssessmentSections().add(droppedSection);
            }
        }
    } else {
        if (droppedObject instanceof AssessmentItemRef && targetObject instanceof AssessmentItemRef) {
            AssessmentItemRef droppedItemRef = (AssessmentItemRef) droppedObject;
            droppedItemRef.getParentSection().getSectionParts().remove(droppedItemRef);
            AssessmentItemRef targetItemRef = (AssessmentItemRef) targetObject;
            AssessmentSection targetSection = targetItemRef.getParentSection();
            int pos = targetSection.getChildAbstractParts().indexOf(targetItemRef) + 1;
            if (pos < 0) {
                targetSection.getChildAbstractParts().add(droppedItemRef);
            } else if (pos >= targetSection.getChildAbstractParts().size()) {
                targetSection.getChildAbstractParts().add(droppedItemRef);
            } else {
                targetSection.getChildAbstractParts().add(pos, droppedItemRef);
            }
        } else if (droppedObject instanceof AssessmentSection && targetObject instanceof AssessmentSection) {
            AssessmentSection droppedSection = (AssessmentSection) droppedObject;
            if (droppedSection.getParentSection() != null) {
                droppedSection.getParentSection().getSectionParts().remove(droppedSection);
            } else {
                droppedSection.getParent().getChildAbstractParts().remove(droppedSection);
            }
            AssessmentSection targetSection = (AssessmentSection) targetObject;
            if (targetSection.getParentSection() != null) {
                AssessmentSection targetParentSection = targetSection.getParentSection();
                int pos = targetParentSection.getChildAbstractParts().indexOf(targetSection) + 1;
                if (pos >= targetParentSection.getChildAbstractParts().size()) {
                    targetParentSection.getChildAbstractParts().add(droppedSection);
                } else {
                    targetParentSection.getChildAbstractParts().add(pos, droppedSection);
                }
            } else if (targetSection.getParent() instanceof TestPart) {
                TestPart targetTestPart = (TestPart) targetSection.getParent();
                int pos = targetTestPart.getChildAbstractParts().indexOf(targetSection) + 1;
                if (pos >= targetTestPart.getChildAbstractParts().size()) {
                    targetTestPart.getChildAbstractParts().add(droppedSection);
                } else {
                    targetTestPart.getChildAbstractParts().add(pos, droppedSection);
                }
            }
        }
    }
    // quickly saved the assessment test with wrong parent
    doSaveAssessmentTest(ureq, null);
    // reload a clean instance
    updateTreeModel(false);
    TreeNode droppedItemNode = menuTree.getTreeModel().getNodeById(droppedNode.getIdent());
    if (droppedItemNode != null) {
        menuTree.setSelectedNode(droppedItemNode);
        menuTree.open(droppedItemNode);
        partEditorFactory(ureq, droppedItemNode);
    }
}
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 27 with AssessmentTest

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

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

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

the class QTI21RuntimeController method getAssessableElement.

private AssessableResource getAssessableElement(RepositoryEntry testEntry) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
    AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
    Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentTest);
    Double minScore = QtiNodesExtractor.extractMinScore(assessmentTest);
    boolean hasScore = assessmentTest.getOutcomeDeclaration(QTI21Constants.SCORE_IDENTIFIER) != null;
    boolean hasPassed = assessmentTest.getOutcomeDeclaration(QTI21Constants.PASS_IDENTIFIER) != null;
    return new QTI21AssessableResource(hasScore, hasPassed, true, true, minScore, maxScore, null);
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File)

Example 29 with AssessmentTest

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

the class QTI21AssessmentRunController method getAssessmentTestMaxTimeLimit.

/**
 * @return The maximum time limit in seconds.
 */
private Long getAssessmentTestMaxTimeLimit() {
    if (overrideOptions != null && overrideOptions.getAssessmentTestMaxTimeLimit() != null) {
        Long timeLimits = overrideOptions.getAssessmentTestMaxTimeLimit();
        return timeLimits.longValue() > 0 ? timeLimits.longValue() : null;
    }
    FileResourceManager frm = FileResourceManager.getInstance();
    File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
    AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
    if (assessmentTest != null && assessmentTest.getTimeLimits() != null && assessmentTest.getTimeLimits().getMaximum() != null) {
        return assessmentTest.getTimeLimits().getMaximum().longValue();
    }
    return null;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File)

Example 30 with AssessmentTest

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

the class QTI21StatisticResourceResult method getController.

public Controller getController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, TreeNode selectedNode, boolean printMode) {
    if (selectedNode instanceof StatisticResourceNode) {
        return createAssessmentController(ureq, wControl, stackPanel, printMode);
    } else {
        Object uobject = selectedNode.getUserObject();
        if (uobject instanceof AssessmentItemRef) {
            TreeNode parentNode = (TreeNode) selectedNode.getParent();
            String sectionTitle = parentNode.getTitle();
            return createAssessmentItemController(ureq, wControl, (AssessmentItemRef) uobject, sectionTitle, printMode);
        } else if (uobject instanceof AssessmentTest) {
            return createAssessmentController(ureq, wControl, stackPanel, printMode);
        }
    }
    return null;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) StatisticResourceNode(org.olat.course.statistic.StatisticResourceNode) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)

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