Search in sources :

Example 1 with SectionPart

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

the class AssessmentTestHelper method visit.

/**
 * Go through the section part (assessmentSection or assessmentItemRef), visit recursively
 * the sections and assessment item refs.
 *
 * @param sectionPart
 * @param visitor
 */
public static void visit(SectionPart sectionPart, AssessmentTestVisitor visitor) {
    visitor.visit(sectionPart);
    if (sectionPart instanceof AssessmentSection) {
        AssessmentSection section = (AssessmentSection) sectionPart;
        List<SectionPart> childParts = section.getChildAbstractParts();
        if (childParts != null && childParts.size() > 0) {
            for (SectionPart childPart : childParts) {
                visit(childPart, visitor);
            }
        }
    }
}
Also used : SectionPart(uk.ac.ed.ph.jqtiplus.node.test.SectionPart) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)

Example 2 with SectionPart

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

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 3 with SectionPart

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

the class QTI21ArchiveFormat method collectElementInfos.

private void collectElementInfos(AssessmentSection section) {
    numOfSections++;
    SectionInfos sectionInfos = new SectionInfos(section);
    elementInfos.add(sectionInfos);
    List<SectionPart> parts = section.getChildAbstractParts();
    for (SectionPart part : parts) {
        if (part instanceof AssessmentItemRef) {
            AssessmentItemRef itemRef = (AssessmentItemRef) part;
            ResolvedAssessmentItem resolvedItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
            AssessmentItem item = resolvedItem.getRootNodeLookup().extractIfSuccessful();
            if (item != null) {
                ItemInfos itemInfo = new ItemInfos(itemRef, item, item.getItemBody().findInteractions());
                elementInfos.add(itemInfo);
                sectionInfos.getItemInfos().add(itemInfo);
            }
        } else if (part instanceof AssessmentSection) {
            collectElementInfos((AssessmentSection) part);
        }
    }
}
Also used : SectionPart(uk.ac.ed.ph.jqtiplus.node.test.SectionPart) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) 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)

Example 4 with SectionPart

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

the class QTI21WordExport method renderAssessmentSection.

public void renderAssessmentSection(AssessmentSection assessmentSection, OpenXMLDocument document, boolean withResponses, Translator translator) {
    String title = assessmentSection.getTitle();
    document.appendHeading1(title, null);
    List<RubricBlock> rubricBlocks = assessmentSection.getRubricBlocks();
    for (RubricBlock rubricBlock : rubricBlocks) {
        String htmlRubric = htmlBuilder.blocksString(rubricBlock.getBlocks());
        document.appendHtmlText(htmlRubric, true);
    }
    for (SectionPart sectionPart : assessmentSection.getChildAbstractParts()) {
        if (sectionPart instanceof AssessmentSection) {
            renderAssessmentSection((AssessmentSection) sectionPart, document, withResponses, translator);
        } else if (sectionPart instanceof AssessmentItemRef) {
            AssessmentItemRef itemRef = (AssessmentItemRef) sectionPart;
            ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
            AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
            URI itemUri = resolvedAssessmentTest.getSystemIdByItemRefMap().get(itemRef);
            renderAssessmentItem(assessmentItem, new File(itemUri), mediaDir, document, withResponses, translator, htmlBuilder);
            document.appendPageBreak();
        }
    }
}
Also used : SectionPart(uk.ac.ed.ph.jqtiplus.node.test.SectionPart) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) 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) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) URI(java.net.URI) File(java.io.File)

Example 5 with SectionPart

use of uk.ac.ed.ph.jqtiplus.node.test.SectionPart 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)

Aggregations

SectionPart (uk.ac.ed.ph.jqtiplus.node.test.SectionPart)12 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)10 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)10 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)6 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)6 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)4 File (java.io.File)2 URI (java.net.URI)2 DoubleAdder (java.util.concurrent.atomic.DoubleAdder)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 AssessmentTestVisitor (org.olat.ims.qti21.AssessmentTestHelper.AssessmentTestVisitor)2 RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)2 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)2 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)2 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)2