use of org.olat.ims.qti.questionimport.ItemAndMetadata in project OpenOLAT by OpenOLAT.
the class QTIQPoolServiceProvider method importBeecomItem.
public List<QuestionItem> importBeecomItem(Identity owner, List<ItemAndMetadata> items, Locale defaultLocale) {
int count = 0;
List<QuestionItem> qItems = new ArrayList<>(items.size());
for (ItemAndMetadata item : items) {
QuestionItem qItem = importBeecomItem(owner, item, null, defaultLocale);
qItems.add(qItem);
if (++count % 10 == 0) {
dbInstance.commitAndCloseSession();
}
}
return qItems;
}
use of org.olat.ims.qti.questionimport.ItemAndMetadata in project OpenOLAT by OpenOLAT.
the class QTIEditorMainController method doExportQItem.
private void doExportQItem() {
GenericQtiNode selectedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
if (selectedNode instanceof ItemNode) {
ItemNode itemNode = (ItemNode) selectedNode;
QTIObject qtiObject = itemNode.getUnderlyingQTIObject();
if (qtiObject instanceof Item) {
ItemAndMetadata item = new ItemAndMetadata((Item) qtiObject);
VFSContainer editorContainer = qtiPackage.getBaseDir();
qtiQpoolServiceProvider.importBeecomItem(getIdentity(), item, editorContainer, getLocale());
showInfo("export.qpool.successful", "1");
}
} else if (selectedNode instanceof SectionNode) {
SectionNode sectionNode = (SectionNode) selectedNode;
QTIObject qtiObject = sectionNode.getUnderlyingQTIObject();
if (qtiObject instanceof Section) {
int count = doExportSection((Section) qtiObject);
showInfo("export.qpool.successful", Integer.toString(count));
}
} else if (selectedNode instanceof AssessmentNode) {
AssessmentNode assessmentNode = (AssessmentNode) selectedNode;
QTIObject qtiObject = assessmentNode.getUnderlyingQTIObject();
if (qtiObject instanceof Assessment) {
int count = doExportAssessment((Assessment) qtiObject);
showInfo("export.qpool.successful", Integer.toString(count));
}
}
}
use of org.olat.ims.qti.questionimport.ItemAndMetadata in project OpenOLAT by OpenOLAT.
the class QTIEditorMainController method doInsert.
private void doInsert(UserRequest ureq, TreePosition tp, Object toInsert) {
// new node
GenericQtiNode parentTargetNode = (GenericQtiNode) tp.getParentTreeNode();
if (toInsert instanceof GenericQtiNode) {
doInsert(parentTargetNode, (GenericQtiNode) toInsert, tp.getChildpos());
} else if (toInsert instanceof QuestionItemView) {
QuestionItemView item = (QuestionItemView) toInsert;
GenericQtiNode insertNode = doConvertItemToQtiNode(item);
doInsert(parentTargetNode, insertNode, tp.getChildpos());
} else if (toInsert instanceof Collection) {
int position = tp.getChildpos();
@SuppressWarnings("unchecked") Collection<QuestionItemView> items = (Collection<QuestionItemView>) toInsert;
for (QuestionItemView item : items) {
GenericQtiNode insertNode = doConvertItemToQtiNode(item);
doInsert(parentTargetNode, insertNode, position++);
}
} else if (toInsert instanceof ItemsPackage) {
ItemsPackage itemsToImport = (ItemsPackage) toInsert;
List<ItemAndMetadata> items = itemsToImport.getItems();
int pos = tp.getChildpos();
for (ItemAndMetadata item : items) {
GenericQtiNode insertNode = new ItemNode(item.getItem(), qtiPackage);
doInsert(parentTargetNode, insertNode, pos++);
}
}
event(ureq, menuTree, new Event(MenuTree.COMMAND_TREENODE_CLICKED));
qtiPackage.serializeQTIDocument();
updateWarning();
}
use of org.olat.ims.qti.questionimport.ItemAndMetadata in project openolat by klemens.
the class QuestionListController method doOpenExcelImportQTI12.
private void doOpenExcelImportQTI12(UserRequest ureq) {
removeAsListenerAndDispose(excelImportWizard);
final ItemsPackage importPackage = new ItemsPackage();
Step additionalStep = null;
if (getSource().askEditable()) {
additionalStep = new EditableStep(ureq);
}
final org.olat.ims.qti.questionimport.ImportOptions options = new org.olat.ims.qti.questionimport.ImportOptions();
options.setShuffle(true);
Step start = new org.olat.ims.qti.questionimport.QImport_1_InputStep(ureq, importPackage, options, additionalStep);
StepRunnerCallback finish = new StepRunnerCallback() {
@Override
public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
List<ItemAndMetadata> itemsToImport = importPackage.getItems();
QTIQPoolServiceProvider spi = CoreSpringFactory.getImpl(QTIQPoolServiceProvider.class);
List<QuestionItem> importItems = spi.importBeecomItem(getIdentity(), itemsToImport, getLocale());
for (QuestionItem item : importItems) {
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_IMPORT);
builder.withAfter(item);
qpoolService.persist(builder.create());
}
boolean editable = true;
if (getSource().askEditable()) {
Object editableCtx = runContext.get("editable");
editable = (editableCtx instanceof Boolean) ? ((Boolean) editableCtx).booleanValue() : false;
}
qpoolService.index(importItems);
int postImported = getSource().postImport(importItems, editable);
if (postImported > 0) {
getItemsTable().reset();
}
return StepsMainRunController.DONE_MODIFIED;
}
};
excelImportWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("import.excellike.12"), "o_sel_qpool_excel_import_wizard");
listenTo(excelImportWizard);
getWindowControl().pushAsModalDialog(excelImportWizard.getInitialComponent());
}
use of org.olat.ims.qti.questionimport.ItemAndMetadata in project openolat by klemens.
the class QTIEditorMainController method doInsert.
private void doInsert(UserRequest ureq, TreePosition tp, Object toInsert) {
// new node
GenericQtiNode parentTargetNode = (GenericQtiNode) tp.getParentTreeNode();
if (toInsert instanceof GenericQtiNode) {
doInsert(parentTargetNode, (GenericQtiNode) toInsert, tp.getChildpos());
} else if (toInsert instanceof QuestionItemView) {
QuestionItemView item = (QuestionItemView) toInsert;
GenericQtiNode insertNode = doConvertItemToQtiNode(item);
doInsert(parentTargetNode, insertNode, tp.getChildpos());
} else if (toInsert instanceof Collection) {
int position = tp.getChildpos();
@SuppressWarnings("unchecked") Collection<QuestionItemView> items = (Collection<QuestionItemView>) toInsert;
for (QuestionItemView item : items) {
GenericQtiNode insertNode = doConvertItemToQtiNode(item);
doInsert(parentTargetNode, insertNode, position++);
}
} else if (toInsert instanceof ItemsPackage) {
ItemsPackage itemsToImport = (ItemsPackage) toInsert;
List<ItemAndMetadata> items = itemsToImport.getItems();
int pos = tp.getChildpos();
for (ItemAndMetadata item : items) {
GenericQtiNode insertNode = new ItemNode(item.getItem(), qtiPackage);
doInsert(parentTargetNode, insertNode, pos++);
}
}
event(ureq, menuTree, new Event(MenuTree.COMMAND_TREENODE_CLICKED));
qtiPackage.serializeQTIDocument();
updateWarning();
}
Aggregations