use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.
the class AssessmentItemEditorController method initItemEditor.
private QTI21QuestionType initItemEditor(UserRequest ureq) {
AssessmentItem item = resolvedAssessmentItem.getItemLookup().getRootNodeHolder().getRootNode();
QTI21QuestionType type = QTI21QuestionType.getType(item);
switch(type) {
case sc:
itemBuilder = initSingleChoiceEditors(ureq, item);
break;
case mc:
itemBuilder = initMultipleChoiceEditors(ureq, item);
break;
case fib:
itemBuilder = initFIBEditors(ureq, type, item);
break;
case numerical:
itemBuilder = initFIBEditors(ureq, type, item);
break;
case kprim:
itemBuilder = initKPrimChoiceEditors(ureq, item);
break;
case match:
itemBuilder = initMatchChoiceEditors(ureq, item);
break;
case matchdraganddrop:
itemBuilder = initMatchDragAndDropEditors(ureq, item);
break;
case matchtruefalse:
itemBuilder = initMatchTrueFalseEditors(ureq, item);
break;
case hotspot:
itemBuilder = initHotspotEditors(ureq, item);
break;
case essay:
itemBuilder = initEssayEditors(ureq, item);
break;
case upload:
itemBuilder = initUploadEditors(ureq, item);
break;
case drawing:
itemBuilder = initDrawingEditors(ureq, item);
break;
case hottext:
itemBuilder = initHottextEditors(ureq, item);
break;
default:
initItemCreatedByUnkownEditor(ureq, item);
break;
}
return type;
}
use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.
the class QuestionTypeFlexiCellRenderer method render.
@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
if (cellValue instanceof QTI21QuestionType) {
QTI21QuestionType type = (QTI21QuestionType) cellValue;
target.append("<i class='o_icon o_icon-fw ").append(type.getCssClass()).append("'> </i> ").append(translator.translate("new." + type));
}
}
use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.
the class AssessmentTestComposerController method doCopy.
private void doCopy(UserRequest ureq) {
TreeNode selectedNode = menuTree.getSelectedNode();
if (selectedNode == null || !(selectedNode.getUserObject() instanceof AssessmentItemRef))
return;
AssessmentItemRef itemRefToCopy = (AssessmentItemRef) selectedNode.getUserObject();
AssessmentSection section = itemRefToCopy.getParentSection();
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRefToCopy);
AssessmentItem originalAssessmentItem = resolvedAssessmentItem.getItemLookup().extractIfSuccessful();
if (originalAssessmentItem == null) {
showError("error.assessment.item");
return;
}
QTI21QuestionType type = QTI21QuestionType.getType(originalAssessmentItem);
File itemFile = null;
try {
AssessmentItemRef itemRef = new AssessmentItemRef(section);
String itemId = IdentifierGenerator.newAsString(getTypePrefix(type));
itemRef.setIdentifier(Identifier.parseString(itemId));
itemFile = new File(unzippedDirRoot, itemId + ".xml");
itemRef.setHref(new URI(itemFile.getName()));
try (OutputStream out = new FileOutputStream(itemFile)) {
// make the copy
qtiService.qtiSerializer().serializeJqtiObject(originalAssessmentItem, out);
// change identifier and title
ResolvedAssessmentItem resolvedCopyItem = qtiService.loadAndResolveAssessmentItemForCopy(itemFile.toURI(), unzippedDirRoot);
AssessmentItem copiedAssessmentItem = resolvedCopyItem.getRootNodeLookup().extractIfSuccessful();
copiedAssessmentItem.setIdentifier(IdentifierGenerator.newAsString(getTypePrefix(type)));
copiedAssessmentItem.setTitle(originalAssessmentItem.getTitle() + " (Copy)");
qtiService.updateAssesmentObject(itemFile, resolvedCopyItem);
// add to section
section.getSectionParts().add(itemRef);
Map<AssessmentItemRef, AssessmentItem> flyingObjects = Collections.singletonMap(itemRef, copiedAssessmentItem);
doSaveAssessmentTest(ureq, flyingObjects);
manifestBuilder.appendAssessmentItem(itemFile.getName());
doSaveManifest();
} catch (Exception e) {
logError("", e);
}
updateTreeModel(false);
TreeNode newItemNode = menuTree.getTreeModel().getNodeById(itemId);
menuTree.setSelectedNode(newItemNode);
menuTree.open(newItemNode);
partEditorFactory(ureq, newItemNode);
} catch (URISyntaxException e) {
logError("", e);
}
}
use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.
the class AssessmentTestEditorAndComposerTreeModel method buildRecursively.
private TreeNode buildRecursively(AssessmentItemRef itemRef, TreeNode parentNode) {
GenericTreeNode itemNode = new GenericTreeNode(itemRef.getIdentifier().toString());
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
if (resolvedAssessmentItem == null || resolvedAssessmentItem.getItemLookup() == null || resolvedAssessmentItem.getItemLookup().getRootNodeHolder() == null) {
itemNode.setTitle("ERROR - Not found");
itemNode.setIconCssClass("o_icon o_icon_error");
itemNode.setUserObject(itemRef);
parentNode.addChild(itemNode);
} else {
BadResourceException ex = resolvedAssessmentItem.getItemLookup().getBadResourceException();
if (ex != null) {
itemNode.setTitle("ERROR");
itemNode.setIconCssClass("o_icon o_icon_error");
itemNode.setUserObject(itemRef);
parentNode.addChild(itemNode);
} else {
AssessmentItem assessmentItem = resolvedAssessmentItem.getItemLookup().getRootNodeHolder().getRootNode();
itemNode.setTitle(assessmentItem.getTitle());
QTI21QuestionType type = QTI21QuestionType.getType(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;
}
use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.
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