use of org.olat.ims.qti.questionimport.ItemAndMetadata in project OpenOLAT by OpenOLAT.
the class QTIEditorMainController method doExportSection.
private int doExportSection(Section section) {
if (section.getItems() != null) {
VFSContainer editorContainer = qtiPackage.getBaseDir();
for (Item item : section.getItems()) {
ItemAndMetadata itemAndMetadata = new ItemAndMetadata(item);
qtiQpoolServiceProvider.importBeecomItem(getIdentity(), itemAndMetadata, editorContainer, getLocale());
}
return section.getItems().size();
}
return 0;
}
use of org.olat.ims.qti.questionimport.ItemAndMetadata in project OpenOLAT by OpenOLAT.
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 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 klemens.
the class QTIEditorMainController method doExportSection.
private int doExportSection(Section section) {
if (section.getItems() != null) {
VFSContainer editorContainer = qtiPackage.getBaseDir();
for (Item item : section.getItems()) {
ItemAndMetadata itemAndMetadata = new ItemAndMetadata(item);
qtiQpoolServiceProvider.importBeecomItem(getIdentity(), itemAndMetadata, editorContainer, getLocale());
}
return section.getItems().size();
}
return 0;
}
use of org.olat.ims.qti.questionimport.ItemAndMetadata in project openolat by klemens.
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;
}
Aggregations