use of org.olat.ims.qti.qpool.QTIQPoolServiceProvider in project OpenOLAT by OpenOLAT.
the class QTIHandler method createResource.
protected RepositoryEntry createResource(String type, FileResource ores, Identity initialAuthor, String displayname, String description, Object object, Locale locale) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(ores);
RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
DBFactory.getInstance().commit();
File fRepositoryQTI = new File(FileResourceManager.getInstance().getFileResourceRoot(re.getOlatResource()), "qti.zip");
QTIEditorPackageImpl qtiPackage = new QTIEditorPackageImpl(displayname, type, locale);
if (object instanceof QItemList) {
QItemList itemToImport = (QItemList) object;
QTIQPoolServiceProvider provider = (QTIQPoolServiceProvider) CoreSpringFactory.getBean("qtiPoolServiceProvider");
provider.exportToEditorPackage(qtiPackage, itemToImport.getItems(), true);
}
qtiPackage.savePackageTo(fRepositoryQTI);
return re;
}
use of org.olat.ims.qti.qpool.QTIQPoolServiceProvider 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.qpool.QTIQPoolServiceProvider in project openolat by klemens.
the class QuestionListController method doImportResource.
private void doImportResource(UserRequest ureq, RepositoryEntry repositoryEntry) {
List<QuestionItem> importItems = null;
if (ImsQTI21Resource.TYPE_NAME.equals(repositoryEntry.getOlatResource().getResourceableTypeName())) {
QTI21QPoolServiceProvider spi = CoreSpringFactory.getImpl(QTI21QPoolServiceProvider.class);
importItems = spi.importRepositoryEntry(getIdentity(), repositoryEntry, getLocale());
} else {
QTIQPoolServiceProvider spi = (QTIQPoolServiceProvider) CoreSpringFactory.getBean("qtiPoolServiceProvider");
importItems = spi.importRepositoryEntry(getIdentity(), repositoryEntry, getLocale());
}
for (QuestionItem item : importItems) {
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_IMPORT);
builder.withAfter(item);
qpoolService.persist(builder.create());
}
if (getSource().askEditable()) {
removeAsListenerAndDispose(shareItemsToSourceCtrl);
shareItemsToSourceCtrl = new ShareItemSourceOptionController(ureq, getWindowControl(), importItems, getSource());
listenTo(shareItemsToSourceCtrl);
removeAsListenerAndDispose(cmcShareItemToSource);
cmcShareItemToSource = new CloseableModalController(getWindowControl(), translate("close"), shareItemsToSourceCtrl.getInitialComponent(), true, translate("import.item"));
cmcShareItemToSource.activate();
listenTo(cmcShareItemToSource);
} else {
qpoolService.index(importItems);
int postImported = getSource().postImport(importItems, true);
if (postImported > 0) {
getItemsTable().reset();
}
if (importItems.isEmpty()) {
showWarning("import.failed");
} else {
showInfo("import.success", Integer.toString(importItems.size()));
getItemsTable().reset();
}
}
}
use of org.olat.ims.qti.qpool.QTIQPoolServiceProvider in project OpenOLAT by OpenOLAT.
the class QuestionListController method doImportResource.
private void doImportResource(UserRequest ureq, RepositoryEntry repositoryEntry) {
List<QuestionItem> importItems = null;
if (ImsQTI21Resource.TYPE_NAME.equals(repositoryEntry.getOlatResource().getResourceableTypeName())) {
QTI21QPoolServiceProvider spi = CoreSpringFactory.getImpl(QTI21QPoolServiceProvider.class);
importItems = spi.importRepositoryEntry(getIdentity(), repositoryEntry, getLocale());
} else {
QTIQPoolServiceProvider spi = (QTIQPoolServiceProvider) CoreSpringFactory.getBean("qtiPoolServiceProvider");
importItems = spi.importRepositoryEntry(getIdentity(), repositoryEntry, getLocale());
}
for (QuestionItem item : importItems) {
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_IMPORT);
builder.withAfter(item);
qpoolService.persist(builder.create());
}
if (getSource().askEditable()) {
removeAsListenerAndDispose(shareItemsToSourceCtrl);
shareItemsToSourceCtrl = new ShareItemSourceOptionController(ureq, getWindowControl(), importItems, getSource());
listenTo(shareItemsToSourceCtrl);
removeAsListenerAndDispose(cmcShareItemToSource);
cmcShareItemToSource = new CloseableModalController(getWindowControl(), translate("close"), shareItemsToSourceCtrl.getInitialComponent(), true, translate("import.item"));
cmcShareItemToSource.activate();
listenTo(cmcShareItemToSource);
} else {
qpoolService.index(importItems);
int postImported = getSource().postImport(importItems, true);
if (postImported > 0) {
getItemsTable().reset();
}
if (importItems.isEmpty()) {
showWarning("import.failed");
} else {
showInfo("import.success", Integer.toString(importItems.size()));
getItemsTable().reset();
}
}
}
use of org.olat.ims.qti.qpool.QTIQPoolServiceProvider 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());
}
Aggregations