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);
}
}
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;
}
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;
}
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);
}
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);
}
Aggregations