Search in sources :

Example 1 with FileUploadCompareWrapper

use of org.olat.modules.forms.ui.model.FileUploadCompareWrapper in project OpenOLAT by OpenOLAT.

the class CompareEvaluationsFormController method createFileUploadCompareWrapper.

private FileUploadCompareWrapper createFileUploadCompareWrapper(UserRequest ureq, FileUpload element, EvaluationFormResponse response) {
    Identity evaluator = response.getSession().getIdentity();
    String color = evaluatorToColors.get(evaluator);
    String evaluatorName = getLegend(evaluator);
    String filename = response.getStringuifiedResponse();
    String filesize = null;
    String mapperUri = null;
    String iconCss = null;
    String thumbUri = null;
    VFSLeaf leaf = evaluationFormManager.loadResponseLeaf(response);
    if (leaf != null) {
        filename = leaf.getName();
        filesize = Formatter.formatBytes((leaf).getSize());
        mapperUri = registerCacheableMapper(ureq, "file-upload-" + element.getId() + "-" + leaf.getLastModified(), new VFSMediaMapper(leaf));
        iconCss = CSSHelper.createFiletypeIconCssClassFor(leaf.getName());
        if (leaf instanceof MetaTagged) {
            MetaTagged metaTaggedLeaf = (MetaTagged) leaf;
            MetaInfo meta = metaTaggedLeaf.getMetaInfo();
            if (meta != null && meta.isThumbnailAvailable()) {
                VFSLeaf thumb = meta.getThumbnail(200, 200, false);
                if (thumb != null) {
                    thumbUri = registerCacheableMapper(ureq, "file-upload-thumb" + element.getId() + "-" + leaf.getLastModified(), new VFSMediaMapper(thumb));
                    ;
                }
            }
        }
    }
    return new FileUploadCompareWrapper(color, evaluatorName, filename, filesize, mapperUri, iconCss, thumbUri);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSMediaMapper(org.olat.core.util.vfs.VFSMediaMapper) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) FileUploadCompareWrapper(org.olat.modules.forms.ui.model.FileUploadCompareWrapper) Identity(org.olat.core.id.Identity)

Example 2 with FileUploadCompareWrapper

use of org.olat.modules.forms.ui.model.FileUploadCompareWrapper in project OpenOLAT by OpenOLAT.

the class CompareEvaluationsFormController method forgeFileUpload.

private List<EvaluationFormElementWrapper> forgeFileUpload(UserRequest ureq, FileUpload element) {
    List<EvaluationFormResponse> responses = identifierToResponses.get(element.getId());
    if (responses == null) {
        return new ArrayList<>();
    }
    List<EvaluationFormElementWrapper> fileUploadWrappers = new ArrayList<>(responses.size());
    for (EvaluationFormResponse response : responses) {
        if (response.getFileResponse() != null) {
            FileUploadCompareWrapper fileUploadWrapper = createFileUploadCompareWrapper(ureq, element, response);
            EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
            wrapper.setFileUploadCompareWrapper(fileUploadWrapper);
            fileUploadWrappers.add(wrapper);
        }
    }
    return fileUploadWrappers;
}
Also used : EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList) FileUploadCompareWrapper(org.olat.modules.forms.ui.model.FileUploadCompareWrapper) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse)

Example 3 with FileUploadCompareWrapper

use of org.olat.modules.forms.ui.model.FileUploadCompareWrapper in project openolat by klemens.

the class CompareEvaluationsFormController method createFileUploadCompareWrapper.

private FileUploadCompareWrapper createFileUploadCompareWrapper(UserRequest ureq, FileUpload element, EvaluationFormResponse response) {
    Identity evaluator = response.getSession().getIdentity();
    String color = evaluatorToColors.get(evaluator);
    String evaluatorName = getLegend(evaluator);
    String filename = response.getStringuifiedResponse();
    String filesize = null;
    String mapperUri = null;
    String iconCss = null;
    String thumbUri = null;
    VFSLeaf leaf = evaluationFormManager.loadResponseLeaf(response);
    if (leaf != null) {
        filename = leaf.getName();
        filesize = Formatter.formatBytes((leaf).getSize());
        mapperUri = registerCacheableMapper(ureq, "file-upload-" + element.getId() + "-" + leaf.getLastModified(), new VFSMediaMapper(leaf));
        iconCss = CSSHelper.createFiletypeIconCssClassFor(leaf.getName());
        if (leaf instanceof MetaTagged) {
            MetaTagged metaTaggedLeaf = (MetaTagged) leaf;
            MetaInfo meta = metaTaggedLeaf.getMetaInfo();
            if (meta != null && meta.isThumbnailAvailable()) {
                VFSLeaf thumb = meta.getThumbnail(200, 200, false);
                if (thumb != null) {
                    thumbUri = registerCacheableMapper(ureq, "file-upload-thumb" + element.getId() + "-" + leaf.getLastModified(), new VFSMediaMapper(thumb));
                    ;
                }
            }
        }
    }
    return new FileUploadCompareWrapper(color, evaluatorName, filename, filesize, mapperUri, iconCss, thumbUri);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSMediaMapper(org.olat.core.util.vfs.VFSMediaMapper) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) FileUploadCompareWrapper(org.olat.modules.forms.ui.model.FileUploadCompareWrapper) Identity(org.olat.core.id.Identity)

Example 4 with FileUploadCompareWrapper

use of org.olat.modules.forms.ui.model.FileUploadCompareWrapper in project openolat by klemens.

the class CompareEvaluationsFormController method forgeFileUpload.

private List<EvaluationFormElementWrapper> forgeFileUpload(UserRequest ureq, FileUpload element) {
    List<EvaluationFormResponse> responses = identifierToResponses.get(element.getId());
    if (responses == null) {
        return new ArrayList<>();
    }
    List<EvaluationFormElementWrapper> fileUploadWrappers = new ArrayList<>(responses.size());
    for (EvaluationFormResponse response : responses) {
        if (response.getFileResponse() != null) {
            FileUploadCompareWrapper fileUploadWrapper = createFileUploadCompareWrapper(ureq, element, response);
            EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
            wrapper.setFileUploadCompareWrapper(fileUploadWrapper);
            fileUploadWrappers.add(wrapper);
        }
    }
    return fileUploadWrappers;
}
Also used : EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList) FileUploadCompareWrapper(org.olat.modules.forms.ui.model.FileUploadCompareWrapper) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse)

Aggregations

FileUploadCompareWrapper (org.olat.modules.forms.ui.model.FileUploadCompareWrapper)4 ArrayList (java.util.ArrayList)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 Identity (org.olat.core.id.Identity)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 VFSMediaMapper (org.olat.core.util.vfs.VFSMediaMapper)2 EvaluationFormResponse (org.olat.modules.forms.EvaluationFormResponse)2 EvaluationFormElementWrapper (org.olat.modules.forms.ui.model.EvaluationFormElementWrapper)2