use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
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;
}
use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class DisplayPortraitManager method getPortraitResource.
/**
* Get the portrait media resource by identity name (username)
* @param identity
* @return imageResource portrait
*/
private MediaResource getPortraitResource(String username, String portraitName) {
MediaResource imageResource = null;
File imgFile = getPortraitFile(username, portraitName);
if (imgFile != null && imgFile.exists()) {
imageResource = new FileMediaResource(imgFile);
}
return imageResource;
}
use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class UserAvatarMapper method handle.
@Override
public MediaResource handle(String relPath, HttpServletRequest request) {
MediaResource rsrc = null;
if (relPath != null && relPath.endsWith(POSTFIX_LARGE) || relPath.endsWith(POSTFIX_SMALL)) {
if (relPath.startsWith("/")) {
relPath = relPath.substring(1, relPath.length());
}
int endKeyIndex = relPath.indexOf('/');
if (endKeyIndex > 0) {
String idKey = relPath.substring(0, endKeyIndex);
Long key = Long.parseLong(idKey);
String username = userManager.getUsername(key);
if (useLarge) {
rsrc = portraitManager.getBigPortraitResource(username);
} else {
rsrc = portraitManager.getSmallPortraitResource(username);
if (rsrc == null) {
rsrc = portraitManager.getBigPortraitResource(username);
}
}
}
}
return rsrc;
}
use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class TableOfContentController method doExportBinderAsPdf.
private void doExportBinderAsPdf(UserRequest ureq) {
MediaResource resource = new ExportBinderAsPDFResource(binder, ureq, getLocale());
ureq.getDispatchResult().setResultingMediaResource(resource);
}
use of org.olat.core.gui.media.MediaResource in project openolat by klemens.
the class TableOfContentController method doExportBinderAsCP.
private void doExportBinderAsCP(UserRequest ureq) {
MediaResource resource = new ExportBinderAsCPResource(binder, ureq, getLocale());
ureq.getDispatchResult().setResultingMediaResource(resource);
}
Aggregations