Search in sources :

Example 56 with VFSContainer

use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.

the class GTACoachRevisionAndCorrectionsController method doConfirmCollect.

private void doConfirmCollect(UserRequest ureq) {
    String toName = null;
    if (assessedGroup != null) {
        toName = assessedGroup.getName();
    } else if (assessedIdentity != null) {
        toName = userManager.getUserDisplayName(assessedIdentity);
    }
    File[] submittedDocuments;
    VFSContainer documentsContainer;
    int iteration = assignedTask.getRevisionLoop();
    if (GTAType.group.name().equals(gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_TYPE))) {
        documentsContainer = gtaManager.getRevisedDocumentsContainer(courseEnv, gtaNode, iteration, assessedGroup);
        File documentsDir = gtaManager.getRevisedDocumentsDirectory(courseEnv, gtaNode, iteration, assessedGroup);
        submittedDocuments = documentsDir.listFiles(new SystemFilenameFilter(true, false));
    } else {
        documentsContainer = gtaManager.getRevisedDocumentsContainer(courseEnv, gtaNode, iteration, getIdentity());
        File documentsDir = gtaManager.getRevisedDocumentsDirectory(courseEnv, gtaNode, iteration, getIdentity());
        submittedDocuments = documentsDir.listFiles(new SystemFilenameFilter(true, false));
    }
    FilesLocked lockedBy = TaskHelper.getDocumentsLocked(documentsContainer, submittedDocuments);
    if (lockedBy != null) {
        showWarning("warning.submit.documents.edited", new String[] { lockedBy.getLockedBy(), lockedBy.getLockedFiles() });
    } else {
        String title = translate("coach.collect.revisions.confirm.title");
        String text = translate("coach.collect.revisions.confirm.text", new String[] { toName });
        text = "<div class='o_warning'>" + text + "</div>";
        confirmCollectCtrl = activateOkCancelDialog(ureq, title, text, confirmCollectCtrl);
        listenTo(confirmCollectCtrl);
    }
}
Also used : FilesLocked(org.olat.course.nodes.gta.TaskHelper.FilesLocked) VFSContainer(org.olat.core.util.vfs.VFSContainer) SystemFilenameFilter(org.olat.core.util.io.SystemFilenameFilter) File(java.io.File)

Example 57 with VFSContainer

use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.

the class GTAParticipantController method setSubmitController.

private void setSubmitController(UserRequest ureq, Task task) {
    File documentsDir;
    VFSContainer documentsContainer;
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        documentsDir = gtaManager.getSubmitDirectory(courseEnv, gtaNode, assessedGroup);
        documentsContainer = gtaManager.getSubmitContainer(courseEnv, gtaNode, assessedGroup);
    } else {
        documentsDir = gtaManager.getSubmitDirectory(courseEnv, gtaNode, getIdentity());
        documentsContainer = gtaManager.getSubmitContainer(courseEnv, gtaNode, getIdentity());
    }
    DueDate dueDate = getSubmissionDueDate(task);
    Date deadline = dueDate == null ? null : dueDate.getDueDate();
    int maxDocs = config.getIntegerSafe(GTACourseNode.GTASK_MAX_SUBMITTED_DOCS, -1);
    submitDocCtrl = new SubmitDocumentsController(ureq, getWindowControl(), task, documentsDir, documentsContainer, maxDocs, gtaNode, courseEnv, userCourseEnv.isCourseReadOnly(), deadline, "document");
    listenTo(submitDocCtrl);
    mainVC.put("submitDocs", submitDocCtrl.getInitialComponent());
    submitButton = LinkFactory.createCustomLink("run.submit.button", "submit", "run.submit.button", Link.BUTTON, mainVC, this);
    submitButton.setElementCssClass("o_sel_course_gta_submit_docs");
    submitButton.setCustomEnabledLinkCSS(submitDocCtrl.hasUploadDocuments() ? "btn btn-primary" : "btn btn-default");
    submitButton.setIconLeftCSS("o_icon o_icon_submit");
    submitButton.setVisible(!userCourseEnv.isCourseReadOnly());
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) DueDate(org.olat.course.nodes.gta.model.DueDate) File(java.io.File) Date(java.util.Date) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 58 with VFSContainer

use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.

the class GTAParticipantController method setSolutions.

private void setSolutions(UserRequest ureq, Task assignedTask) {
    DueDate availableDate = getSolutionDueDate(assignedTask);
    boolean visible = availableDate == null || (availableDate.getDueDate() != null && availableDate.getDueDate().compareTo(new Date()) <= 0);
    if (visible) {
        File documentsDir = gtaManager.getSolutionsDirectory(courseEnv, gtaNode);
        VFSContainer documentsContainer = gtaManager.getSolutionsContainer(courseEnv, gtaNode);
        if ((availableDate != null && !availableDate.isRelative() && gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION_VISIBLE_ALL, false)) || TaskHelper.hasDocuments(documentsDir)) {
            solutionsCtrl = new DirectoryController(ureq, getWindowControl(), documentsDir, documentsContainer, "run.solutions.description", "bulk.solutions", "solutions");
            listenTo(solutionsCtrl);
            mainVC.put("solutions", solutionsCtrl.getInitialComponent());
        }
    } else {
        VelocityContainer waitVC = createVelocityContainer("wait_for_solutions");
        mainVC.put("solutions", waitVC);
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) DueDate(org.olat.course.nodes.gta.model.DueDate) File(java.io.File) Date(java.util.Date) DueDate(org.olat.course.nodes.gta.model.DueDate) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 59 with VFSContainer

use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.

the class CourseGlossaryFactory method createCourseGlossaryMainRunController.

/**
 * The glossarymaincontroller allows browsing in the glossary. A flag enables
 * the edit mode.
 *
 * @param windowControl
 * @param ureq
 * @param courseConfig use the glossary configuration from the given course
 *          configuration
 * @param hasGlossaryEditRights
 * @return
 */
public static GlossaryMainController createCourseGlossaryMainRunController(WindowControl lwControl, UserRequest lureq, CourseConfig cc, boolean hasGlossaryRights) {
    if (cc.hasGlossary()) {
        RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
        if (repoEntry == null) {
            // seems to be removed
            return null;
        }
        RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
        boolean owner = repositoryService.hasRole(lureq.getIdentity(), repoEntry, GroupRoles.owner.name());
        VFSContainer glossaryFolder = GlossaryManager.getInstance().getGlossaryRootFolder(repoEntry.getOlatResource());
        Properties glossProps = GlossaryItemManager.getInstance().getGlossaryConfig(glossaryFolder);
        boolean editUsersEnabled = "true".equals(glossProps.getProperty(GlossaryItemManager.EDIT_USERS));
        GlossarySecurityCallback secCallback;
        if (lureq.getUserSession().getRoles().isGuestOnly()) {
            secCallback = new GlossarySecurityCallbackImpl();
        } else {
            secCallback = new GlossarySecurityCallbackImpl(hasGlossaryRights, owner, editUsersEnabled, lureq.getIdentity().getKey());
        }
        return new GlossaryMainController(lwControl, lureq, glossaryFolder, repoEntry.getOlatResource(), secCallback, true);
    }
    return null;
}
Also used : GlossarySecurityCallback(org.olat.core.commons.modules.glossary.GlossarySecurityCallback) GlossaryMainController(org.olat.core.commons.modules.glossary.GlossaryMainController) GlossarySecurityCallbackImpl(org.olat.core.commons.modules.glossary.GlossarySecurityCallbackImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) Properties(java.util.Properties) RepositoryService(org.olat.repository.RepositoryService)

Example 60 with VFSContainer

use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.

the class ConvertToGTACourseNode method convertDropbox.

private void convertDropbox(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, CourseEnvironment courseEnv) {
    String dropbox = DropboxController.getDropboxPathRelToFolderRoot(courseEnv, sourceNode);
    OlatRootFolderImpl dropboxContainer = new OlatRootFolderImpl(dropbox, null);
    for (VFSItem userDropbox : dropboxContainer.getItems()) {
        if (userDropbox instanceof VFSContainer) {
            VFSContainer userDropContainer = (VFSContainer) userDropbox;
            String username = userDropContainer.getName();
            Identity assessedIdentity = securityManager.findIdentityByName(username);
            if (assessedIdentity != null) {
                VFSContainer sumbitContainer = gtaManager.getSubmitContainer(courseEnv, gtaNode, assessedIdentity);
                boolean dropped = false;
                for (VFSItem dropppedItem : userDropContainer.getItems()) {
                    if (dropppedItem instanceof VFSLeaf) {
                        VFSLeaf submittedDocument = sumbitContainer.createChildLeaf(dropppedItem.getName());
                        VFSManager.copyContent((VFSLeaf) dropppedItem, submittedDocument);
                        convertMetada(userDropContainer, sumbitContainer, dropppedItem.getName(), null, null);
                        dropped = true;
                    }
                }
                if (dropped) {
                    setTaskStatus(taskList, assessedIdentity, TaskProcess.submit, gtaNode);
                }
            }
        }
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Identity(org.olat.core.id.Identity)

Aggregations

VFSContainer (org.olat.core.util.vfs.VFSContainer)962 VFSItem (org.olat.core.util.vfs.VFSItem)364 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)338 File (java.io.File)170 Test (org.junit.Test)136 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)86 Identity (org.olat.core.id.Identity)86 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)76 RepositoryEntry (org.olat.repository.RepositoryEntry)76 IOException (java.io.IOException)74 InputStream (java.io.InputStream)64 ArrayList (java.util.ArrayList)64 Date (java.util.Date)60 URI (java.net.URI)56 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)42 OutputStream (java.io.OutputStream)40 HttpResponse (org.apache.http.HttpResponse)38 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)34 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)34 BlogFileResource (org.olat.fileresource.types.BlogFileResource)34