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