Search in sources :

Example 1 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class QTI21ArchiveFormat method calculateSectionScore.

private BigDecimal calculateSectionScore(SessionResponses responses, SectionInfos section) {
    BigDecimal sectionScore = BigDecimal.valueOf(0l);
    for (ItemInfos item : section.getItemInfos()) {
        AssessmentItemRef itemRef = item.getAssessmentItemRef();
        String itemRefIdentifier = itemRef.getIdentifier().toString();
        AssessmentItemSession itemSession = responses.getItemSession(itemRefIdentifier);
        if (itemSession != null) {
            if (itemSession.getManualScore() != null) {
                sectionScore = sectionScore.add(itemSession.getManualScore());
            } else if (itemSession.getScore() != null) {
                sectionScore = sectionScore.add(itemSession.getScore());
            }
        }
    }
    return sectionScore;
}
Also used : AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) BigDecimal(java.math.BigDecimal)

Example 2 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class AssessmentTestHelper method getParentSection.

public static ParentPartItemRefs getParentSection(TestPlanNodeKey itemKey, TestSessionState testSessionState, ResolvedAssessmentTest resolvedAssessmentTest) {
    ParentPartItemRefs parentParts = new ParentPartItemRefs();
    try {
        TestPlanNode currentItem = testSessionState.getTestPlan().getNode(itemKey);
        List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getItemRefsBySystemIdMap().get(currentItem.getItemSystemId());
        AssessmentItemRef itemRef = null;
        if (itemRefs.size() == 1) {
            itemRef = itemRefs.get(0);
        } else {
            Identifier itemId = itemKey.getIdentifier();
            for (AssessmentItemRef ref : itemRefs) {
                if (ref.getIdentifier().equals(itemId)) {
                    itemRef = ref;
                    break;
                }
            }
        }
        if (itemRef != null) {
            for (QtiNode parentPart = itemRef.getParent(); parentPart != null; parentPart = parentPart.getParent()) {
                if (parentParts.getSectionIdentifier() == null && parentPart instanceof AssessmentSection) {
                    AssessmentSection section = (AssessmentSection) parentPart;
                    parentParts.setSectionIdentifier(section.getIdentifier().toString());
                } else if (parentParts.getTestPartIdentifier() == null && parentPart instanceof TestPart) {
                    TestPart testPart = (TestPart) parentPart;
                    parentParts.setTestPartIdentifier(testPart.getIdentifier().toString());
                }
            }
        }
    } catch (Exception e) {
        log.error("", e);
    }
    return parentParts;
}
Also used : ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) 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) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Example 3 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class BigAssessmentTestPackageBuilder method openBigTest_sub.

public long openBigTest_sub() {
    final File resourceFile = new File("/HotCoffee/QTI/20160219-180424/testfa908329-ab44-4821-a20d-ca634b6afb06.xml");
    final QtiXmlReader qtiXmlReader = UnitTestHelper.createUnitTestQtiXmlReader();
    final ResourceLocator fileResourceLocator = new FileResourceLocator();
    final long start = System.nanoTime();
    final AssessmentObjectXmlLoader assessmentObjectXmlLoader = new AssessmentObjectXmlLoader(qtiXmlReader, fileResourceLocator);
    final ResolvedAssessmentTest resolvedTest = assessmentObjectXmlLoader.loadAndResolveAssessmentTest(resourceFile.toURI());
    Assert.assertNotNull(resolvedTest);
    final AssessmentTest test = resolvedTest.getTestLookup().extractIfSuccessful();
    Assert.assertNotNull(test);
    final long time = (System.nanoTime() - start);
    final AssessmentItemRef itemRef = resolvedTest.getAssessmentItemRefs().get(0);
    final ResolvedAssessmentItem resolvedItem = resolvedTest.getResolvedAssessmentItem(itemRef);
    Assert.assertNotNull(resolvedItem);
    final AssessmentItem item = resolvedItem.getRootNodeLookup().extractIfSuccessful();
    Assert.assertNotNull(item);
    Assert.assertEquals(1, item.getItemBody().findInteractions().size());
    return time;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) AssessmentObjectXmlLoader(uk.ac.ed.ph.jqtiplus.reading.AssessmentObjectXmlLoader) QtiXmlReader(uk.ac.ed.ph.jqtiplus.reading.QtiXmlReader) FileResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.FileResourceLocator) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) 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) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File) ResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ResourceLocator) FileResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.FileResourceLocator)

Example 4 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doDelete.

private void doDelete(UserRequest ureq, TreeNode selectedNode) {
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof TestPart) {
        doDeleteTestPart(ureq, (TestPart) uobject);
    } else if (uobject instanceof AssessmentSection) {
        AssessmentSection section = (AssessmentSection) uobject;
        if (checkAtLeastOneSection(section)) {
            doDeleteAssessmentSection(ureq, section);
        } else {
            showWarning("warning.atleastonesection");
        }
    } else if (uobject instanceof AssessmentItemRef) {
        doDeleteAssessmentItemRef(ureq, (AssessmentItemRef) uobject);
    } else {
        // cannot delete test or test part
        return;
    }
    doSaveAssessmentTest(ureq, null);
    doSaveManifest();
    updateTreeModel(false);
    if (selectedNode != null && selectedNode.getParent() != null) {
        TreeNode parentNode = (TreeNode) selectedNode.getParent();
        menuTree.setSelectedNode(parentNode);
        menuTree.open(parentNode);
        partEditorFactory(ureq, parentNode);
    }
}
Also used : 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 5 with AssessmentItemRef

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doExportPool.

private void doExportPool() {
    TreeNode selectedNode = menuTree.getSelectedNode();
    if (selectedNode == null)
        return;
    AtomicInteger counter = new AtomicInteger();
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof AssessmentItemRef) {
        doExportPool((AssessmentItemRef) uobject);
        counter.incrementAndGet();
    } else if (uobject instanceof QtiNode) {
        QtiNode qtiNode = (QtiNode) uobject;
        QueryUtils.walkTree(new TreeWalkNodeHandler() {

            @Override
            public boolean handleNode(QtiNode node) {
                if (node instanceof AssessmentItemRef) {
                    doExportPool((AssessmentItemRef) node);
                    counter.incrementAndGet();
                }
                return true;
            }
        }, qtiNode);
    }
    if (counter.get() > 0) {
        showInfo("export.qpool.successful", counter.toString());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TreeWalkNodeHandler(uk.ac.ed.ph.jqtiplus.utils.TreeWalkNodeHandler) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Aggregations

AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)70 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)34 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)32 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)28 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)22 TreeNode (org.olat.core.gui.components.tree.TreeNode)20 File (java.io.File)18 URI (java.net.URI)18 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)18 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)18 ArrayList (java.util.ArrayList)16 HashMap (java.util.HashMap)16 ManifestMetadataBuilder (org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)12 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)12 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)12 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)12 Identity (org.olat.core.id.Identity)10 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)10 SectionPart (uk.ac.ed.ph.jqtiplus.node.test.SectionPart)10 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)10