Search in sources :

Example 76 with VFSContainer

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

the class EditorMainController method launchSinglePagesWizard.

private void launchSinglePagesWizard(UserRequest ureq, ICourse course) {
    removeAsListenerAndDispose(multiSPChooserCtr);
    removeAsListenerAndDispose(cmc);
    VFSContainer rootContainer = course.getCourseEnvironment().getCourseFolderContainer();
    CourseEditorTreeNode selectedNode = (CourseEditorTreeNode) menuTree.getSelectedNode();
    multiSPChooserCtr = new MultiSPController(ureq, getWindowControl(), rootContainer, ores, selectedNode);
    listenTo(multiSPChooserCtr);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), multiSPChooserCtr.getInitialComponent(), true, translate("multi.sps.title"));
    listenTo(cmc);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VFSContainer(org.olat.core.util.vfs.VFSContainer) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode)

Example 77 with VFSContainer

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

the class GTAAssignedTaskController method doPreview.

private void doPreview(UserRequest ureq) {
    if (viewTaskCtrl != null)
        return;
    VFSContainer tasksContainer = gtaManager.getTasksContainer(courseEnv, gtaNode);
    viewTaskCtrl = new SinglePageController(ureq, getWindowControl(), tasksContainer, taskFile.getName(), false, null, null, TaskHelper.getStandardDeliveryOptions(), false);
    listenTo(viewTaskCtrl);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), viewTaskCtrl.getInitialComponent(), true, taskFile.getName());
    listenTo(cmc);
    cmc.activate();
}
Also used : SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 78 with VFSContainer

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

the class GTANotifications method createParticipantSolutionItems.

private boolean createParticipantSolutionItems(Task task, Identity assessedIdentity, BusinessGroup group) {
    // copy solutions
    if (gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION)) {
        RepositoryEntry re = courseEnv.getCourseGroupManager().getCourseEntry();
        DueDate dueDate = gtaManager.getSolutionDueDate(task, assessedIdentity, group, gtaNode, re, true);
        Date solutionDate = null;
        if (dueDate == null) {
            if (inStep(task, TaskProcess.solution, TaskProcess.grading, TaskProcess.graded)) {
                solutionDate = task.getSolutionDate();
            } else {
                return false;
            }
        } else if (dueDate != null && dueDate.getDueDate() != null) {
            if (task == null) {
                if (inStep(task, TaskProcess.assignment, TaskProcess.submit, TaskProcess.review, TaskProcess.correction, TaskProcess.revision) && !dueDate.isRelative() && gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION_VISIBLE_ALL, false)) {
                    solutionDate = dueDate.getDueDate();
                } else {
                    return false;
                }
            } else {
                solutionDate = dueDate.getDueDate();
            }
        } else if (task != null) {
            solutionDate = task.getSolutionDate();
        }
        if (solutionDate != null) {
            if (task.getSolutionDate() != null && task.getSolutionDate().after(solutionDate)) {
                solutionDate = task.getSolutionDate();
            }
            File solutionDirectory = gtaManager.getSolutionsDirectory(courseEnv, gtaNode);
            VFSContainer solutionContainer = gtaManager.getSolutionsContainer(courseEnv, gtaNode);
            File[] solutions = solutionDirectory.listFiles(SystemFileFilter.FILES_ONLY);
            for (File solution : solutions) {
                Date date = solutionDate;
                // check if there are new solutions too
                cal.setTimeInMillis(solution.lastModified());
                Date modificationDate = cal.getTime();
                if (date.before(modificationDate)) {
                    date = modificationDate;
                }
                if (date.after(compareDate)) {
                    String author = getAuthor(solution, solutionContainer);
                    if (task != null) {
                        String[] params = new String[] { getTaskName(task), displayName, solution.getName(), author };
                        appendSubscriptionItemForFile("notifications.solution.task", params, assessedIdentity, "[solution:0]", solution, date, false);
                    } else {
                        String[] params = new String[] { displayName, solution.getName(), author };
                        appendSubscriptionItemForFile("notifications.solution", params, assessedIdentity, "[solution:0]", solution, date, false);
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) DueDate(org.olat.course.nodes.gta.model.DueDate) File(java.io.File) Date(java.util.Date) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 79 with VFSContainer

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

the class GTANotifications method createReviewAndRevisionsItems.

private void createReviewAndRevisionsItems(Task task, Identity assessedIdentity, BusinessGroup group, boolean coach) {
    if (task == null)
        return;
    String name;
    if (group != null) {
        name = group.getName();
    } else {
        name = userManager.getUserDisplayName(assessedIdentity);
    }
    boolean sendNotificationDueDate = true;
    List<TaskRevisionDate> taskRevisions = gtaManager.getTaskRevisions(task);
    if (!coach && gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION)) {
        // check task revision 1
        if (task != null && notInStep(task, TaskProcess.assignment, TaskProcess.submit, TaskProcess.review) && checkRevisionLoop(TaskProcess.revision, 1, taskRevisions)) {
            File correctionDirectory;
            VFSContainer correctionContainer;
            if (group != null) {
                correctionDirectory = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, group);
                correctionContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, group);
            } else {
                correctionDirectory = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, assessedIdentity);
                correctionContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedIdentity);
            }
            Date correctionDate = getRevisionLoopDate(TaskProcess.revision, 1, taskRevisions);
            if (sendNotificationDueDate) {
                if (task.getRevisionsDueDate() != null) {
                    String[] params = new String[] { getTaskName(task), displayName, formatter.formatDateAndTime(task.getRevisionsDueDate()) };
                    if (group != null) {
                        appendSubscriptionItem("notifications.correction.duedate", params, group, correctionDate, coach);
                    } else {
                        appendSubscriptionItem("notifications.correction.duedate", params, assessedIdentity, correctionDate, coach);
                    }
                } else {
                    String[] params = new String[] { getTaskName(task), displayName };
                    if (group != null) {
                        appendSubscriptionItem("notifications.correction", params, group, correctionDate, coach);
                    } else {
                        appendSubscriptionItem("notifications.correction", params, assessedIdentity, correctionDate, coach);
                    }
                }
                sendNotificationDueDate = false;
            }
            File[] corrections = correctionDirectory.listFiles(SystemFileFilter.FILES_ONLY);
            for (File correction : corrections) {
                String author = getAuthor(correction, correctionContainer);
                String[] params = new String[] { getTaskName(task), displayName, correction.getName(), author };
                if (group != null) {
                    appendSubscriptionItemForFile("notifications.correction.doc", params, group, "[correction:0]", correction, correctionDate, coach);
                } else {
                    appendSubscriptionItemForFile("notifications.correction.doc", params, assessedIdentity, "[correction:0]", correction, correctionDate, coach);
                }
            }
        }
    }
    if (gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
        task = checkRevisionStep(assessedIdentity, null, task);
        if (task != null && notInStep(task, TaskProcess.assignment, TaskProcess.submit, TaskProcess.review)) {
            int currentIteration = task.getRevisionLoop();
            for (int i = 1; i <= currentIteration; i++) {
                if (coach) {
                    // revision of the students
                    if (checkRevisionLoop(TaskProcess.correction, i, taskRevisions)) {
                        File revisionDirectory;
                        VFSContainer revisionContainer;
                        if (group != null) {
                            revisionDirectory = gtaManager.getRevisedDocumentsDirectory(courseEnv, gtaNode, i, group);
                            revisionContainer = gtaManager.getRevisedDocumentsContainer(courseEnv, gtaNode, i, group);
                        } else {
                            revisionDirectory = gtaManager.getRevisedDocumentsDirectory(courseEnv, gtaNode, i, assessedIdentity);
                            revisionContainer = gtaManager.getRevisedDocumentsContainer(courseEnv, gtaNode, i, assessedIdentity);
                        }
                        Date revisionDate = getRevisionLoopDate(TaskProcess.correction, i, taskRevisions);
                        File[] revisions = revisionDirectory.listFiles(SystemFileFilter.FILES_ONLY);
                        if (revisions.length == 0) {
                            String[] params = new String[] { getTaskName(task), displayName, name };
                            if (group != null) {
                                appendSubscriptionItem("notifications.revision.group", params, group, revisionDate, coach);
                            } else {
                                appendSubscriptionItem("notifications.revision.individual", params, assessedIdentity, revisionDate, coach);
                            }
                        } else {
                            for (File revision : revisions) {
                                String author = getAuthor(revision, revisionContainer);
                                String[] params = new String[] { getTaskName(task), displayName, revision.getName(), name, author };
                                if (group != null) {
                                    appendSubscriptionItemForFile("notifications.revision.group.doc", params, group, "[revision:" + i + "]", revision, revisionDate, coach);
                                } else {
                                    appendSubscriptionItemForFile("notifications.revision.individual.doc", params, assessedIdentity, "[revision:" + i + "]", revision, revisionDate, coach);
                                }
                            }
                        }
                    }
                } else if (checkRevisionLoop(TaskProcess.revision, i, taskRevisions)) {
                    // corrections of the coach
                    File correctionDirectory;
                    VFSContainer correctionContainer;
                    if (group != null) {
                        correctionDirectory = gtaManager.getRevisedDocumentsCorrectionsDirectory(courseEnv, gtaNode, i, group);
                        correctionContainer = gtaManager.getRevisedDocumentsCorrectionsContainer(courseEnv, gtaNode, i, group);
                    } else {
                        correctionDirectory = gtaManager.getRevisedDocumentsCorrectionsDirectory(courseEnv, gtaNode, i, assessedIdentity);
                        correctionContainer = gtaManager.getRevisedDocumentsCorrectionsContainer(courseEnv, gtaNode, i, assessedIdentity);
                    }
                    Date correctionDate = getRevisionLoopDate(TaskProcess.revision, i, taskRevisions);
                    if (sendNotificationDueDate) {
                        if (task.getRevisionsDueDate() != null) {
                            String[] params = new String[] { getTaskName(task), displayName, formatter.formatDateAndTime(task.getRevisionsDueDate()) };
                            if (group != null) {
                                appendSubscriptionItem("notifications.correction.duedate", params, group, correctionDate, coach);
                            } else {
                                appendSubscriptionItem("notifications.correction.duedate", params, assessedIdentity, correctionDate, coach);
                            }
                        } else {
                            String[] params = new String[] { getTaskName(task), displayName };
                            if (group != null) {
                                appendSubscriptionItem("notifications.correction", params, group, correctionDate, coach);
                            } else {
                                appendSubscriptionItem("notifications.correction", params, assessedIdentity, correctionDate, coach);
                            }
                        }
                        sendNotificationDueDate = false;
                    }
                    File[] corrections = correctionDirectory.listFiles(SystemFileFilter.FILES_ONLY);
                    for (File correction : corrections) {
                        String author = getAuthor(correction, correctionContainer);
                        String[] params = new String[] { getTaskName(task), displayName, correction.getName(), author };
                        if (group != null) {
                            appendSubscriptionItemForFile("notifications.correction.doc", params, group, "[correction:" + i + "]", correction, correctionDate, coach);
                        } else {
                            appendSubscriptionItemForFile("notifications.correction.doc", params, assessedIdentity, "[correction:" + i + "]", correction, correctionDate, coach);
                        }
                    }
                }
            }
        }
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) Date(java.util.Date) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 80 with VFSContainer

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

the class DialogElementsEditController method doUpload.

private void doUpload(UserRequest ureq) {
    removeAsListenerAndDispose(fileUplCtr);
    VFSContainer tmpContainer = new LocalFolderImpl(new File(WebappHelper.getTmpDir(), "poster_" + UUID.randomUUID()));
    fileUplCtr = new FileUploadController(getWindowControl(), tmpContainer, ureq, FolderConfig.getLimitULKB(), Quota.UNLIMITED, null, false, false, false, false, true, false);
    listenTo(fileUplCtr);
    cmc = new CloseableModalController(getWindowControl(), "close", fileUplCtr.getInitialComponent(), true, translate("dialog.upload.file"));
    listenTo(cmc);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) FileUploadController(org.olat.core.commons.modules.bc.FileUploadController)

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