use of org.olat.modules.qpool.QPoolSPI in project openolat by klemens.
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 klemens.
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 klemens.
the class QuestionItemDetailsController method setQuestionController.
private void setQuestionController(UserRequest ureq, QuestionItem item, QuestionItemSecurityCallback securityCallback) {
removeAsListenerAndDispose(questionCtrl);
questionCtrl = null;
QPoolSPI spi = poolModule.getQuestionPoolProvider(item.getFormat());
boolean canEditContent = securityCallback.canEditQuestion() && (spi != null && spi.isTypeEditable());
if (canEditContent && !lock.isSuccess()) {
canEditContent = false;
String displayName = "???";
if (lock.getOwner() != null) {
displayName = userManager.getUserDisplayName(lock.getOwner());
}
showWarning("locked.readonly", new String[] { displayName });
}
if (spi != null) {
if (canEditContent) {
questionCtrl = spi.getEditableController(ureq, getWindowControl(), item);
} else {
questionCtrl = spi.getReadOnlyController(ureq, getWindowControl(), item);
}
}
if (questionCtrl == null && spi != null) {
questionCtrl = spi.getPreviewController(ureq, getWindowControl(), item, false);
}
if (questionCtrl == null) {
questionCtrl = new QuestionItemRawController(ureq, getWindowControl());
}
listenTo(questionCtrl);
if (mainVC != null) {
mainVC.put("type_specifics", questionCtrl.getInitialComponent());
}
}
use of org.olat.modules.qpool.QPoolSPI in project openolat by klemens.
the class QuestionItemPreviewController method updateItem.
public void updateItem(UserRequest ureq, QuestionItem updatedItem) {
this.item = updatedItem;
removeAsListenerAndDispose(previewCtrl);
if (updatedItem == null) {
previewCtrl = null;
previewPanel.setContent(null);
} else {
Component content;
QPoolSPI spi = poolModule.getQuestionPoolProvider(updatedItem.getFormat());
if (spi == null) {
content = getRawContent();
} else {
previewCtrl = spi.getPreviewController(ureq, getWindowControl(), updatedItem, true);
if (previewCtrl == null) {
content = getRawContent();
} else {
listenTo(previewCtrl);
content = previewCtrl.getInitialComponent();
}
}
previewPanel.setContent(content);
}
}
use of org.olat.modules.qpool.QPoolSPI in project OpenOLAT by OpenOLAT.
the class QuestionPoolServiceImpl method export.
@Override
public MediaResource export(List<QuestionItemShort> items, ExportFormatOptions format, Locale locale) {
MediaResource mr = null;
if (DefaultExportFormat.ZIP_EXPORT_FORMAT.equals(format)) {
List<Long> keys = toKeys(items);
List<QuestionItemFull> fullItems = questionItemDao.loadByIds(keys);
mr = new ExportQItemsZipResource("UTF-8", locale, fullItems);
// make a zip with all items
} else {
QPoolSPI selectedSp = null;
List<QPoolSPI> sps = qpoolModule.getQuestionPoolProviders();
for (QPoolSPI sp : sps) {
if (sp.getTestExportFormats().contains(format)) {
selectedSp = sp;
break;
}
}
if (selectedSp != null) {
mr = selectedSp.exportTest(items, format, locale);
}
}
return mr;
}
Aggregations