Search in sources :

Example 1 with DisplayOrDownloadComponent

use of org.olat.core.gui.components.download.DisplayOrDownloadComponent in project OpenOLAT by OpenOLAT.

the class FolderRunController method activatePath.

public void activatePath(UserRequest ureq, String path) {
    if (path != null && path.length() > 0) {
        VFSItem vfsItem = folderComponent.getRootContainer().resolve(path.endsWith("/") ? path.substring(0, path.length() - 1) : path);
        if (vfsItem instanceof VFSLeaf) {
            // could be a file - create the mapper - otherwise don't create one if it's a directory
            // Create a mapper to deliver the auto-download of the file. We have to
            // create a dedicated mapper here
            // and can not reuse the standard briefcase way of file delivering, some
            // very old fancy code
            // Mapper is cleaned up automatically by basic controller
            String baseUrl = registerMapper(ureq, new VFSContainerMapper(folderComponent.getRootContainer()));
            // Trigger auto-download
            DisplayOrDownloadComponent dordc = new DisplayOrDownloadComponent("downloadcomp", baseUrl + path);
            folderContainer.put("autoDownloadComp", dordc);
            if (path.lastIndexOf("/") > 0) {
                String dirPath = path.substring(0, path.lastIndexOf("/"));
                if (StringHelper.containsNonWhitespace(dirPath)) {
                    folderComponent.setCurrentContainerPath(dirPath);
                }
            }
        } else if (vfsItem instanceof VFSContainer) {
            if (StringHelper.containsNonWhitespace(path)) {
                folderComponent.setCurrentContainerPath(path);
            }
        }
        updatePathResource(ureq);
    }
}
Also used : VFSContainerMapper(org.olat.core.util.vfs.VFSContainerMapper) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) DisplayOrDownloadComponent(org.olat.core.gui.components.download.DisplayOrDownloadComponent) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 2 with DisplayOrDownloadComponent

use of org.olat.core.gui.components.download.DisplayOrDownloadComponent in project OpenOLAT by OpenOLAT.

the class MSCourseNodeRunController method exposeUserDataToVC.

private void exposeUserDataToVC(UserRequest ureq) {
    AssessmentEntry assessmentEntry = courseNode.getUserAssessmentEntry(userCourseEnv);
    if (assessmentEntry == null) {
        myContent.contextPut("hasPassedValue", Boolean.FALSE);
        myContent.contextPut("passed", Boolean.FALSE);
        hasPassed = hasScore = hasComment = false;
    } else {
        String rawComment = assessmentEntry.getComment();
        hasPassed = assessmentEntry.getPassed() != null;
        hasScore = assessmentEntry.getScore() != null;
        hasComment = courseNode.hasCommentConfigured() && StringHelper.containsNonWhitespace(rawComment);
        boolean resultsVisible = overrideUserResultsVisiblity || assessmentEntry.getUserVisibility() == null || assessmentEntry.getUserVisibility().booleanValue();
        myContent.contextPut("resultsVisible", resultsVisible);
        myContent.contextPut("score", AssessmentHelper.getRoundedScore(assessmentEntry.getScore()));
        myContent.contextPut("hasPassedValue", (assessmentEntry.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
        myContent.contextPut("passed", assessmentEntry.getPassed());
        if (resultsVisible) {
            if (hasComment) {
                StringBuilder comment = Formatter.stripTabsAndReturns(rawComment);
                myContent.contextPut("comment", StringHelper.xssScan(comment));
                myContent.contextPut("in-comment", isPanelOpen(ureq, "comment", true));
            }
            if (courseNode.hasIndividualAsssessmentDocuments()) {
                List<File> docs = courseNode.getIndividualAssessmentDocuments(userCourseEnv);
                mapperUri = registerCacheableMapper(ureq, null, new DocumentsMapper(docs));
                myContent.contextPut("docsMapperUri", mapperUri);
                myContent.contextPut("docs", docs);
                myContent.contextPut("in-assessmentDocuments", isPanelOpen(ureq, "assessmentDocuments", true));
                if (download == null) {
                    download = new DisplayOrDownloadComponent("", null);
                    myContent.put("download", download);
                }
            }
        }
    }
    if (showLog) {
        UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
        myContent.contextPut("log", am.getUserNodeLog(courseNode, userCourseEnv.getIdentityEnvironment().getIdentity()));
    }
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) DisplayOrDownloadComponent(org.olat.core.gui.components.download.DisplayOrDownloadComponent) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File)

Example 3 with DisplayOrDownloadComponent

use of org.olat.core.gui.components.download.DisplayOrDownloadComponent in project OpenOLAT by OpenOLAT.

the class OpenMeetingsRunController method redirectToGuestRoom.

private void redirectToGuestRoom(String firstName, String lastName) {
    if (room == null && room.getRoomId() <= 0) {
        showError("room.notfound.error");
    } else {
        try {
            String securedHash = openMeetingsManager.setGuestUserToRoom(firstName, lastName, room.getRoomId());
            String url = openMeetingsManager.getURL(getIdentity(), room.getRoomId(), securedHash, getLocale());
            DisplayOrDownloadComponent cmp = new DisplayOrDownloadComponent("openCommand", url);
            mainVC.put("openCmd", cmp);
        } catch (OpenMeetingsException e) {
            showError(e.i18nKey());
        }
    }
}
Also used : DisplayOrDownloadComponent(org.olat.core.gui.components.download.DisplayOrDownloadComponent) OpenMeetingsException(org.olat.modules.openmeetings.manager.OpenMeetingsException)

Example 4 with DisplayOrDownloadComponent

use of org.olat.core.gui.components.download.DisplayOrDownloadComponent in project openolat by klemens.

the class FolderRunController method activatePath.

public void activatePath(UserRequest ureq, String path) {
    if (path != null && path.length() > 0) {
        VFSItem vfsItem = folderComponent.getRootContainer().resolve(path.endsWith("/") ? path.substring(0, path.length() - 1) : path);
        if (vfsItem instanceof VFSLeaf) {
            // could be a file - create the mapper - otherwise don't create one if it's a directory
            // Create a mapper to deliver the auto-download of the file. We have to
            // create a dedicated mapper here
            // and can not reuse the standard briefcase way of file delivering, some
            // very old fancy code
            // Mapper is cleaned up automatically by basic controller
            String baseUrl = registerMapper(ureq, new VFSContainerMapper(folderComponent.getRootContainer()));
            // Trigger auto-download
            DisplayOrDownloadComponent dordc = new DisplayOrDownloadComponent("downloadcomp", baseUrl + path);
            folderContainer.put("autoDownloadComp", dordc);
            if (path.lastIndexOf("/") > 0) {
                String dirPath = path.substring(0, path.lastIndexOf("/"));
                if (StringHelper.containsNonWhitespace(dirPath)) {
                    folderComponent.setCurrentContainerPath(dirPath);
                }
            }
        } else if (vfsItem instanceof VFSContainer) {
            if (StringHelper.containsNonWhitespace(path)) {
                folderComponent.setCurrentContainerPath(path);
            }
        }
        updatePathResource(ureq);
    }
}
Also used : VFSContainerMapper(org.olat.core.util.vfs.VFSContainerMapper) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) DisplayOrDownloadComponent(org.olat.core.gui.components.download.DisplayOrDownloadComponent) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 5 with DisplayOrDownloadComponent

use of org.olat.core.gui.components.download.DisplayOrDownloadComponent in project openolat by klemens.

the class OpenMeetingsRunController method redirectToGuestRoom.

private void redirectToGuestRoom(String firstName, String lastName) {
    if (room == null && room.getRoomId() <= 0) {
        showError("room.notfound.error");
    } else {
        try {
            String securedHash = openMeetingsManager.setGuestUserToRoom(firstName, lastName, room.getRoomId());
            String url = openMeetingsManager.getURL(getIdentity(), room.getRoomId(), securedHash, getLocale());
            DisplayOrDownloadComponent cmp = new DisplayOrDownloadComponent("openCommand", url);
            mainVC.put("openCmd", cmp);
        } catch (OpenMeetingsException e) {
            showError(e.i18nKey());
        }
    }
}
Also used : DisplayOrDownloadComponent(org.olat.core.gui.components.download.DisplayOrDownloadComponent) OpenMeetingsException(org.olat.modules.openmeetings.manager.OpenMeetingsException)

Aggregations

DisplayOrDownloadComponent (org.olat.core.gui.components.download.DisplayOrDownloadComponent)6 File (java.io.File)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSContainerMapper (org.olat.core.util.vfs.VFSContainerMapper)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)2 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)2 OpenMeetingsException (org.olat.modules.openmeetings.manager.OpenMeetingsException)2