use of org.olat.ims.qti21.questionimport.AssessmentItemsPackage in project OpenOLAT by OpenOLAT.
the class AssessmentTestComposerController method doInsert.
private void doInsert(UserRequest ureq, AssessmentItemsPackage importPackage) {
TreeNode selectedNode = menuTree.getSelectedNode();
TreeNode sectionNode = getNearestSection(selectedNode);
String firstItemId = null;
boolean errorOnImport = false;
Map<AssessmentItemRef, AssessmentItem> flyingObjects = new HashMap<>();
try {
AssessmentSection section = (AssessmentSection) sectionNode.getUserObject();
List<AssessmentItemAndMetadata> itemsAndMetadata = importPackage.getItems();
for (AssessmentItemAndMetadata itemAndMetadata : itemsAndMetadata) {
if (itemAndMetadata.isHasError()) {
errorOnImport = true;
continue;
}
AssessmentItemBuilder itemBuilder = itemAndMetadata.getItemBuilder();
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
AssessmentItemRef itemRef = doInsert(section, assessmentItem);
ManifestMetadataBuilder metadata = manifestBuilder.getResourceBuilderByHref(itemRef.getHref().toString());
metadata.setQtiMetadataInteractionTypes(itemBuilder.getInteractionNames());
itemAndMetadata.toBuilder(metadata, getLocale());
if (firstItemId == null) {
firstItemId = itemRef.getIdentifier().toString();
}
flyingObjects.put(itemRef, assessmentItem);
}
} catch (URISyntaxException e) {
errorOnImport = true;
logError("", e);
}
if (errorOnImport) {
showError("error.import.question");
}
if (firstItemId != null) {
// persist metadata
doSaveAssessmentTest(ureq, flyingObjects);
doSaveManifest();
updateTreeModel(false);
TreeNode newItemNode = menuTree.getTreeModel().getNodeById(firstItemId);
menuTree.setSelectedNode(newItemNode);
menuTree.open(newItemNode);
partEditorFactory(ureq, newItemNode);
}
}
use of org.olat.ims.qti21.questionimport.AssessmentItemsPackage in project openolat by klemens.
the class AssessmentTestComposerController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (event instanceof AssessmentTestEvent) {
AssessmentTestEvent ate = (AssessmentTestEvent) event;
if (ate == AssessmentTestEvent.ASSESSMENT_TEST_CHANGED_EVENT) {
doSaveAssessmentTest(ureq, null);
}
} else if (event instanceof AssessmentTestPartEvent) {
AssessmentTestPartEvent atpe = (AssessmentTestPartEvent) event;
if (atpe == AssessmentTestPartEvent.ASSESSMENT_TEST_PART_CHANGED_EVENT) {
doSaveAssessmentTest(ureq, null);
}
} else if (event instanceof AssessmentSectionEvent) {
AssessmentSectionEvent ase = (AssessmentSectionEvent) event;
if (AssessmentSectionEvent.ASSESSMENT_SECTION_CHANGED.equals(ase.getCommand())) {
doSaveAssessmentTest(ureq, null);
doUpdate(ase.getSection().getIdentifier(), ase.getSection().getTitle());
doSaveManifest();
}
} else if (event instanceof AssessmentItemEvent) {
AssessmentItemEvent aie = (AssessmentItemEvent) event;
if (AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED.equals(aie.getCommand())) {
assessmentChanged(ureq);
doSaveAssessmentTest(ureq, null);
doUpdate(aie.getAssessmentItemRef().getIdentifier(), aie.getAssessmentItem().getTitle());
doSaveManifest();
} else if (AssessmentItemEvent.ASSESSMENT_ITEM_METADATA_CHANGED.equals(aie.getCommand())) {
doSaveManifest();
} else if (AssessmentItemEvent.ASSESSMENT_ITEM_NEED_RELOAD.equals(aie.getCommand())) {
doReloadItem(ureq);
}
} else if (event instanceof DetachFromPoolEvent) {
DetachFromPoolEvent dfpe = (DetachFromPoolEvent) event;
doDetachItemFromPool(ureq, dfpe.getItemRef());
} else if (selectQItemCtrl == source) {
cmc.deactivate();
cleanUp();
if (event instanceof QItemViewEvent) {
QItemViewEvent e = (QItemViewEvent) event;
List<QuestionItemView> items = e.getItemList();
doInsert(ureq, items);
}
} else if (importTableWizard == source) {
AssessmentItemsPackage importPackage = (AssessmentItemsPackage) importTableWizard.getRunContext().get("importPackage");
getWindowControl().pop();
cleanUp();
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
doInsert(ureq, importPackage);
}
} else if (confirmDeleteCtrl == source) {
if (DialogBoxUIFactory.isYesEvent(event)) {
// yes, delete
doDelete(ureq, (TreeNode) confirmDeleteCtrl.getUserObject());
}
cleanUp();
} else if (cmc == source) {
cleanUp();
}
super.event(ureq, source, event);
}
use of org.olat.ims.qti21.questionimport.AssessmentItemsPackage in project openolat by klemens.
the class AssessmentTestComposerController method doImportTable.
private void doImportTable(UserRequest ureq) {
removeAsListenerAndDispose(importTableWizard);
final AssessmentItemsPackage importPackage = new AssessmentItemsPackage();
final ImportOptions options = new ImportOptions();
options.setShuffle(!survey);
Step start = new QImport_1_InputStep(ureq, importPackage, options, null);
StepRunnerCallback finish = new StepRunnerCallback() {
@Override
public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
runContext.put("importPackage", importPackage);
return StepsMainRunController.DONE_MODIFIED;
}
};
importTableWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("tools.import.table"), "o_mi_table_import_wizard");
listenTo(importTableWizard);
getWindowControl().pushAsModalDialog(importTableWizard.getInitialComponent());
}
Aggregations