use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentTestComposerController method doExportPool.
private void doExportPool(AssessmentItemRef itemRef) {
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
RootNodeLookup<AssessmentItem> rootNode = resolvedAssessmentItem.getItemLookup();
AssessmentItem assessmentItem = rootNode.extractIfSuccessful();
ManifestBuilder clonedManifestBuilder = ManifestBuilder.read(new File(unzippedDirRoot, "imsmanifest.xml"));
ResourceType resource = getResourceType(clonedManifestBuilder, itemRef);
ManifestMetadataBuilder metadata = clonedManifestBuilder.getMetadataBuilder(resource, true);
if (metadata == null) {
// not in imsmanifest.xml?
metadata = new ManifestMetadataBuilder();
}
File itemFile = new File(rootNode.getSystemId());
qti21QPoolServiceProvider.importAssessmentItemRef(getIdentity(), assessmentItem, itemFile, metadata, getLocale());
}
use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem 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.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentTestComposerController method doDeleteAssessmentItemRef.
private void doDeleteAssessmentItemRef(UserRequest ureq, AssessmentItemRef itemRef) {
ResourceType resource = getResourceType(itemRef);
if (resource != null) {
manifestBuilder.remove(resource);
}
boolean deleted = false;
boolean removed = itemRef.getParentSection().getSectionParts().remove(itemRef);
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
if (resolvedAssessmentItem != null) {
RootNodeLookup<AssessmentItem> rootNode = resolvedAssessmentItem.getItemLookup();
if (rootNode != null) {
URI itemUri = rootNode.getSystemId();
List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getItemRefsBySystemIdMap().get(itemUri);
if (itemRefs.size() <= 1) {
File itemFile = new File(itemUri);
deleted = itemFile.delete();
}
}
}
if (deleted) {
assessmentChanged(ureq);
}
logAudit(removed + " " + deleted + " removed item ref", null);
}
use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentTestComposerController method partEditorFactory.
private void partEditorFactory(UserRequest ureq, TreeNode selectedNode) {
// remove old one
if (currentEditorCtrl != null) {
mainVC.remove(currentEditorCtrl.getInitialComponent());
removeAsListenerAndDispose(currentEditorCtrl);
currentEditorCtrl = null;
}
// fill with the new
mainVC.contextPut("cssClass", selectedNode.getIconCssClass());
if (Settings.isDebuging()) {
mainVC.contextPut("identifier", selectedNode.getIdent());
}
mainVC.contextPut("title", selectedNode.getTitle());
mainVC.contextPut("restrictedEdit", restrictedEdit);
Object uobject = selectedNode.getUserObject();
if (uobject instanceof AssessmentTest) {
AssessmentTest test = (AssessmentTest) uobject;
URI testURI = resolvedAssessmentTest.getTestLookup().getSystemId();
File testFile = new File(testURI);
TestPart uniqueTestPart = test.getTestParts().size() == 1 ? test.getTestParts().get(0) : null;
currentEditorCtrl = new AssessmentTestEditorController(ureq, getWindowControl(), assessmentTestBuilder, uniqueTestPart, unzippedDirRoot, unzippedContRoot, testFile, restrictedEdit);
} else if (uobject instanceof TestPart) {
currentEditorCtrl = new AssessmentTestPartEditorController(ureq, getWindowControl(), (TestPart) uobject, restrictedEdit, assessmentTestBuilder.isEditable());
} else if (uobject instanceof AssessmentSection) {
URI testURI = resolvedAssessmentTest.getTestLookup().getSystemId();
File testFile = new File(testURI);
currentEditorCtrl = new AssessmentSectionEditorController(ureq, getWindowControl(), (AssessmentSection) uobject, unzippedDirRoot, unzippedContRoot, testFile, restrictedEdit, assessmentTestBuilder.isEditable());
} else if (uobject instanceof AssessmentItemRef) {
AssessmentItemRef itemRef = (AssessmentItemRef) uobject;
ResolvedAssessmentItem item = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
if (item == null || item.getItemLookup() == null) {
currentEditorCtrl = new BadResourceController(ureq, getWindowControl(), null, unzippedDirRoot, itemRef.getHref());
} else if (item.getItemLookup().getBadResourceException() != null) {
currentEditorCtrl = new BadResourceController(ureq, getWindowControl(), item.getItemLookup().getBadResourceException(), unzippedDirRoot, itemRef.getHref());
} else {
URI itemUri = resolvedAssessmentTest.getSystemIdByItemRefMap().get(itemRef);
File itemFile = new File(itemUri);
ManifestMetadataBuilder metadata = getMetadataBuilder(itemRef);
currentEditorCtrl = new AssessmentItemEditorController(ureq, getWindowControl(), testEntry, item, itemRef, metadata, unzippedDirRoot, unzippedContRoot, itemFile, restrictedEdit);
}
}
if (deleteLink != null) {
if (uobject instanceof AssessmentSection || uobject instanceof AssessmentItemRef) {
deleteLink.setEnabled(true);
} else if (uobject instanceof TestPart) {
TestPart testPart = (TestPart) uobject;
deleteLink.setEnabled(testPart.getParent().getTestParts().size() > 1);
} else {
deleteLink.setEnabled(false);
}
}
if (copyLink != null) {
copyLink.setEnabled(uobject instanceof AssessmentItemRef);
}
if (currentEditorCtrl != null) {
listenTo(currentEditorCtrl);
mainVC.put("content", currentEditorCtrl.getInitialComponent());
} else {
mainVC.put("content", new Panel("empty"));
}
}
use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.
the class QTI21StatisticResourceResult method buildRecursively.
private TreeNode buildRecursively(AssessmentItemRef itemRef, TreeNode parentNode) {
GenericTreeNode itemNode = new GenericTreeNode();
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
BadResourceException ex = resolvedAssessmentItem.getItemLookup().getBadResourceException();
if (ex == null) {
AssessmentItem assessmentItem = resolvedAssessmentItem.getItemLookup().getRootNodeHolder().getRootNode();
itemNode.setTitle(assessmentItem.getTitle());
QTI21QuestionType type = QTI21QuestionType.getTypeRelax(assessmentItem);
if (type != null) {
itemNode.setIconCssClass("o_icon ".concat(type.getCssClass()));
} else {
itemNode.setIconCssClass("o_icon o_mi_qtiunkown");
}
itemNode.setUserObject(itemRef);
parentNode.addChild(itemNode);
}
return itemNode;
}
Aggregations