use of org.olat.modules.qpool.QPoolSPI in project OpenOLAT by OpenOLAT.
the class QuestionPoolServiceImpl method importItems.
@Override
public List<QuestionItem> importItems(Identity owner, Locale defaultLocale, String filename, File file) {
List<QuestionItem> importedItem = null;
List<QPoolSPI> providers = qpoolModule.getQuestionPoolProviders();
for (QPoolSPI provider : providers) {
if (provider.isCompatible(filename, file)) {
importedItem = provider.importItems(owner, defaultLocale, filename, file);
}
}
dbInstance.commit();
index(importedItem);
return importedItem;
}
use of org.olat.modules.qpool.QPoolSPI in project OpenOLAT by OpenOLAT.
the class QuestionPoolServiceImpl method convertItems.
@Override
public List<QuestionItem> convertItems(Identity cloner, List<QuestionItemShort> itemsToConvert, String format, Locale locale) {
QPoolSPI sp = qpoolModule.getQuestionPoolProvider(format);
List<QuestionItem> convertedQuestions = new ArrayList<>(itemsToConvert.size());
for (QuestionItemShort item : itemsToConvert) {
QuestionItem convertedQuestion = sp.convert(cloner, item, locale);
licenseService.copy(item, convertedQuestion);
if (convertedQuestion != null) {
convertedQuestions.add(convertedQuestion);
}
}
dbInstance.commit();
index(convertedQuestions);
return convertedQuestions;
}
use of org.olat.modules.qpool.QPoolSPI in project OpenOLAT by OpenOLAT.
the class QuestionPoolServiceImpl method exportItem.
@Override
public void exportItem(QuestionItemShort item, ZipOutputStream zout, Locale locale, Set<String> names) {
QPoolSPI provider = qpoolModule.getQuestionPoolProvider(item.getFormat());
if (provider == null) {
log.error("Not found provider for this format: " + item.getFormat());
} else {
QuestionItemFull fullItem;
if (item instanceof QuestionItemFull) {
fullItem = (QuestionItemFull) item;
} else {
fullItem = questionItemDao.loadById(item.getKey());
}
provider.exportItem(fullItem, zout, locale, names);
}
}
use of org.olat.modules.qpool.QPoolSPI in project OpenOLAT by OpenOLAT.
the class QuestionListController method doConfirmConversion.
private void doConfirmConversion(UserRequest ureq, List<QuestionItemShort> items) {
Map<String, List<QuestionItemShort>> formatToItems = new HashMap<>();
List<QPoolSPI> spies = qpoolModule.getQuestionPoolProviders();
for (QuestionItemShort item : items) {
for (QPoolSPI sp : spies) {
if (sp != null && sp.isConversionPossible(item)) {
List<QuestionItemShort> convertItems;
if (formatToItems.containsKey(sp.getFormat())) {
convertItems = formatToItems.get(sp.getFormat());
} else {
convertItems = new ArrayList<>(items.size());
formatToItems.put(sp.getFormat(), convertItems);
}
convertItems.add(item);
}
}
}
if (formatToItems.isEmpty()) {
showWarning("convert.item.not.possible");
} else {
conversionConfirmationCtrl = new ConversionConfirmationController(ureq, getWindowControl(), formatToItems, getSource());
listenTo(conversionConfirmationCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"), conversionConfirmationCtrl.getInitialComponent(), true, translate("convert.item"));
cmc.activate();
listenTo(cmc);
}
}
use of org.olat.modules.qpool.QPoolSPI in project openolat by klemens.
the class NewItemOptionsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// title
titleEl = uifactory.addTextElement("general.title", "general.title", 128, "", formLayout);
// type
List<QItemFactory> factories = new ArrayList<>();
for (QPoolSPI spi : qpoolModule.getQuestionPoolProviders()) {
for (QItemFactory factory : spi.getItemfactories()) {
factories.add(factory);
}
}
int count = 0;
String[] typeKeys = new String[factories.size()];
String[] valueKeys = new String[factories.size()];
for (QItemFactory factory : factories) {
String typeKey = "item.type." + count;
typeKeys[count] = typeKey;
keyToFactoryMap.put(typeKey, factory);
valueKeys[count] = factory.getLabel(getLocale());
count++;
}
typeEl = uifactory.addDropdownSingleselect("question.type", "menu.admin.types", formLayout, typeKeys, valueKeys, null);
// subject
taxonomyLevelEl = uifactory.addDropdownSingleselect("process.start.review.taxonomy.level", formLayout, qpoolTaxonomyTreeBuilder.getSelectableKeys(), qpoolTaxonomyTreeBuilder.getSelectableValues(), null);
if (selectedTaxonomyLevel != null) {
String selectedTaxonomyLevelKey = String.valueOf(selectedTaxonomyLevel.getKey());
for (String taxonomyKey : qpoolTaxonomyTreeBuilder.getSelectableKeys()) {
if (taxonomyKey.equals(selectedTaxonomyLevelKey)) {
taxonomyLevelEl.select(taxonomyKey, true);
}
}
}
taxonomyLevelEl.setVisible(qPoolSecurityCallback.canUseTaxonomy());
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonLayout.setRootForm(mainForm);
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("new.item", buttonLayout);
uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
Aggregations