Search in sources :

Example 16 with LocalFolderImpl

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

the class PFCourseNode method createPeekViewRunController.

@Override
public Controller createPeekViewRunController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne) {
    VFSContainer rootFolder = null;
    CourseEnvironment courseEnv = userCourseEnv.getCourseEnvironment();
    Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
    Path folderRelPath = null;
    OlatRootFolderImpl baseContainer = courseEnv.getCourseBaseContainer();
    PFManager pfManager = CoreSpringFactory.getImpl(PFManager.class);
    if (userCourseEnv.isCoach() || userCourseEnv.isAdmin()) {
        folderRelPath = Paths.get(baseContainer.getBasefile().toPath().toString(), PFManager.FILENAME_PARTICIPANTFOLDER, getIdent());
        rootFolder = new LocalFolderImpl(folderRelPath.toFile());
    } else if (userCourseEnv.isParticipant()) {
        folderRelPath = Paths.get(baseContainer.getBasefile().toPath().toString(), PFManager.FILENAME_PARTICIPANTFOLDER, getIdent(), pfManager.getIdFolderName(identity));
        rootFolder = new LocalFolderImpl(folderRelPath.toFile());
    }
    if (rootFolder == null) {
        return super.createPeekViewRunController(ureq, wControl, userCourseEnv, ne);
    } else {
        return new PFPeekviewController(ureq, wControl, rootFolder, getIdent(), 4);
    }
}
Also used : Path(java.nio.file.Path) PFManager(org.olat.course.nodes.pf.manager.PFManager) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) PFPeekviewController(org.olat.course.nodes.pf.ui.PFPeekviewController) Identity(org.olat.core.id.Identity) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 17 with LocalFolderImpl

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

the class CheckboxEditController method getFileContainer.

private VFSContainer getFileContainer() {
    VFSContainer container;
    if (courseNode == null) {
        File tmp = new File(FolderConfig.getCanonicalTmpDir(), checkbox.getCheckboxId());
        container = new LocalFolderImpl(tmp);
    } else {
        ICourse course = CourseFactory.loadCourse(courseOres);
        CourseEnvironment courseEnv = course.getCourseEnvironment();
        container = checkboxManager.getFileContainer(courseEnv, courseNode);
    }
    return container;
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) ICourse(org.olat.course.ICourse) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 18 with LocalFolderImpl

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

the class ScormDirectoryHelper method getScormRootFolder.

/**
 * Return the SCORM Root folder
 */
public static VFSContainer getScormRootFolder() {
    VFSContainer canonicalRoot = new LocalFolderImpl(new File(FolderConfig.getCanonicalRoot()));
    VFSContainer scormContainer = (VFSContainer) canonicalRoot.resolve("scorm");
    if (scormContainer == null) {
        scormContainer = canonicalRoot.createChildContainer("scorm");
    }
    return scormContainer;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 19 with LocalFolderImpl

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

the class DialogCourseNode method doArchiveElement.

/**
 * Archive a single dialog element with files and forum
 * @param element
 * @param exportDirectory
 */
public void doArchiveElement(DialogElement element, File exportDirectory, Locale locale) {
    DialogElementsManager depm = CoreSpringFactory.getImpl(DialogElementsManager.class);
    VFSContainer dialogContainer = depm.getDialogContainer(element);
    // there is only one file (leave) in the top forum container
    VFSItem dialogFile = dialogContainer.getItems(new VFSLeafFilter()).get(0);
    VFSContainer exportContainer = new LocalFolderImpl(exportDirectory);
    // append export timestamp to avoid overwriting previous export
    String exportDirName = Formatter.makeStringFilesystemSave(getShortTitle()) + "_" + element.getForum().getKey() + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
    VFSContainer diaNodeElemExportContainer = exportContainer.createChildContainer(exportDirName);
    // don't check quota
    diaNodeElemExportContainer.setLocalSecurityCallback(new FullAccessCallback());
    diaNodeElemExportContainer.copyFrom(dialogFile);
    ForumArchiveManager fam = ForumArchiveManager.getInstance();
    ForumFormatter ff = new ForumRTFFormatter(diaNodeElemExportContainer, false, locale);
    fam.applyFormatter(ff, element.getForum().getKey(), null);
}
Also used : ForumFormatter(org.olat.modules.fo.archiver.formatters.ForumFormatter) FullAccessCallback(org.olat.core.util.vfs.callbacks.FullAccessCallback) ForumArchiveManager(org.olat.modules.fo.archiver.ForumArchiveManager) ForumRTFFormatter(org.olat.modules.fo.archiver.formatters.ForumRTFFormatter) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) DialogElementsManager(org.olat.course.nodes.dialog.DialogElementsManager) Date(java.util.Date) VFSLeafFilter(org.olat.core.util.vfs.filters.VFSLeafFilter) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 20 with LocalFolderImpl

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

the class IQ12EditForm method update.

/**
 * Update the module configuration from the qti file: read min/max/cut values
 * @param res
 */
protected void update(OLATResource res) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedRoot = frm.unzipFileResource(res);
    // with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
    VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedRoot);
    VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
    if (vfsQTI == null) {
        throw new AssertException("qti file did not exist even it should be guaranteed by repositor check-in ");
    }
    // ensures that InputStream is closed in every case.
    Document doc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
    if (doc == null) {
        // error reading qti file (existence check was made before)
        throw new AssertException("qti file could not be read " + ((LocalFileImpl) vfsQTI).getBasefile().getAbsolutePath());
    }
    // Extract min, max and cut value
    Float minValue = null, maxValue = null, cutValue = null;
    Element decvar = (Element) doc.selectSingleNode("questestinterop/assessment/outcomes_processing/outcomes/decvar");
    if (decvar != null) {
        Attribute minval = decvar.attribute("minvalue");
        if (minval != null) {
            String mv = minval.getValue();
            try {
                minValue = new Float(Float.parseFloat(mv));
            } catch (NumberFormatException e1) {
            // if not correct in qti file -> ignore
            }
        }
        Attribute maxval = decvar.attribute("maxvalue");
        if (maxval != null) {
            String mv = maxval.getValue();
            try {
                maxValue = new Float(Float.parseFloat(mv));
            } catch (NumberFormatException e1) {
            // if not correct in qti file -> ignore
            }
        }
        Attribute cutval = decvar.attribute("cutvalue");
        if (cutval != null) {
            String cv = cutval.getValue();
            try {
                cutValue = new Float(Float.parseFloat(cv));
            } catch (NumberFormatException e1) {
            // if not correct in qti file -> ignore
            }
        }
    }
    // Put values to module configuration
    minScoreEl.setValue(minValue == null ? "" : AssessmentHelper.getRoundedScore(minValue));
    minScoreEl.setVisible(minValue != null);
    maxScoreEl.setValue(maxValue == null ? "" : AssessmentHelper.getRoundedScore(maxValue));
    maxScoreEl.setVisible(maxValue != null);
    cutValueEl.setValue(cutValue == null ? "" : AssessmentHelper.getRoundedScore(cutValue));
    cutValueEl.setVisible(cutValue != null);
}
Also used : AssertException(org.olat.core.logging.AssertException) FileResourceManager(org.olat.fileresource.FileResourceManager) Attribute(org.dom4j.Attribute) VFSContainer(org.olat.core.util.vfs.VFSContainer) SelectionElement(org.olat.core.gui.components.form.flexible.elements.SelectionElement) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) Element(org.dom4j.Element) VFSItem(org.olat.core.util.vfs.VFSItem) Document(org.dom4j.Document) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Aggregations

LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)122 File (java.io.File)82 VFSContainer (org.olat.core.util.vfs.VFSContainer)76 VFSItem (org.olat.core.util.vfs.VFSItem)38 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)30 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)10 Document (org.dom4j.Document)10 RepositoryEntry (org.olat.repository.RepositoryEntry)10 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)8 OLATResource (org.olat.resource.OLATResource)8 Date (java.util.Date)6 Document (org.apache.lucene.document.Document)6 Element (org.dom4j.Element)6 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)6 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)6 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)6 CPPackageConfig (org.olat.ims.cp.ui.CPPackageConfig)6 SearchResourceContext (org.olat.search.service.SearchResourceContext)6