use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project openolat by klemens.
the class AssessmentTestComposerController method doNewSection.
private void doNewSection(UserRequest ureq, TreeNode selectedNode) {
AbstractPart parentPart;
TreeNode sectionNode = getNearestSection(selectedNode);
if (sectionNode != null) {
AssessmentSection section = (AssessmentSection) sectionNode.getUserObject();
parentPart = section.getParent();
} else if (selectedNode.getUserObject() instanceof TestPart) {
parentPart = (TestPart) selectedNode.getUserObject();
} else {
TreeNode rootNode = menuTree.getTreeModel().getRootNode();
AssessmentTest assessmentTest = (AssessmentTest) rootNode.getUserObject();
List<TestPart> parts = assessmentTest.getTestParts();
if (parts != null && parts.size() > 0) {
parentPart = parts.get(0);
} else {
showWarning("error.cannot.create.section");
return;
}
}
AssessmentSection newSection;
if (parentPart instanceof TestPart) {
newSection = AssessmentTestFactory.appendAssessmentSection(translate("new.section"), (TestPart) parentPart);
} else if (parentPart instanceof AssessmentSection) {
newSection = AssessmentTestFactory.appendAssessmentSection(translate("new.section"), (AssessmentSection) parentPart);
} else {
showWarning("error.cannot.create.section");
return;
}
// save the test
URI testUri = resolvedAssessmentTest.getTestLookup().getSystemId();
File testFile = new File(testUri);
qtiService.updateAssesmentObject(testFile, resolvedAssessmentTest);
assessmentChanged(ureq);
// reload the test
updateTreeModel(false);
TreeNode newSectionNode = menuTree.getTreeModel().getNodeById(newSection.getIdentifier().toString());
menuTree.setSelectedNode(newSectionNode);
menuTree.open(newSectionNode);
partEditorFactory(ureq, newSectionNode);
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project openolat by klemens.
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.node.test.AssessmentTest in project openolat by klemens.
the class AssessmentTestComposerController method doConfirmDelete.
private void doConfirmDelete(UserRequest ureq) {
if (confirmDeleteCtrl != null)
return;
TreeNode selectedNode = menuTree.getSelectedNode();
if (selectedNode == null) {
showWarning("warning.atleastone");
return;
}
Object uobject = selectedNode.getUserObject();
if (uobject instanceof AssessmentTest) {
showWarning("error.cannot.delete");
} else if (uobject instanceof TestPart) {
TestPart testPart = (TestPart) uobject;
if (testPart.getParent().getTestParts().size() == 1) {
showWarning("error.cannot.delete");
}
String msg = translate("delete.testPart");
confirmDeleteCtrl = activateYesNoDialog(ureq, translate("tools.change.delete"), msg, confirmDeleteCtrl);
confirmDeleteCtrl.setUserObject(selectedNode);
} else {
String msg;
if (uobject instanceof AssessmentSection) {
AssessmentSection section = (AssessmentSection) uobject;
if (checkAtLeastOneSection(section)) {
msg = translate("delete.section", selectedNode.getTitle());
} else {
showWarning("warning.atleastonesection");
return;
}
} else if (uobject instanceof AssessmentItemRef) {
msg = translate("delete.item", selectedNode.getTitle());
} else {
showError("error.cannot.delete");
return;
}
confirmDeleteCtrl = activateYesNoDialog(ureq, translate("tools.change.delete"), msg, confirmDeleteCtrl);
confirmDeleteCtrl.setUserObject(selectedNode);
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project openolat by klemens.
the class QTI21StatisticResourceResult method getSubTreeModel.
/**
* Return the tree model for a course and a specific test.
*/
@Override
public TreeModel getSubTreeModel() {
GenericTreeModel subTreeModel = new GenericTreeModel();
StatisticResourceNode rootTreeNode = new StatisticResourceNode(courseNode, this);
subTreeModel.setRootNode(rootTreeNode);
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
AssessmentTest test = resolvedAssessmentTest.getTestLookup().getRootNodeHolder().getRootNode();
buildRecursively(test, rootTreeNode);
return subTreeModel;
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project openolat by klemens.
the class QTI21StatisticResourceResult method getTreeModel.
/**
* Return the tree model for a test learn resource.
*
* @return
*/
public TreeModel getTreeModel() {
GenericTreeModel treeModel = new GenericTreeModel();
GenericTreeNode rootTreeNode = new GenericTreeNode();
treeModel.setRootNode(rootTreeNode);
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
AssessmentTest test = resolvedAssessmentTest.getTestLookup().getRootNodeHolder().getRootNode();
rootTreeNode.setTitle(test.getTitle());
rootTreeNode.setUserObject(test);
rootTreeNode.setIconCssClass("o_icon o_icon-lg o_qtiassessment_icon");
buildRecursively(test, rootTreeNode);
return treeModel;
}
Aggregations