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);
}
}
}
}
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);
}
}
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);
}
}
}
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();
}
}
}
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);
}
}
Aggregations