use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class ScormMainManager method getScormPackageConfig.
public ScormPackageConfig getScormPackageConfig(OLATResourceable ores) {
FileResourceManager frm = FileResourceManager.getInstance();
File reFolder = frm.getFileResourceRoot(ores);
File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
if (configXml.exists()) {
ScormPackageConfig config = (ScormPackageConfig) configXstream.fromXML(configXml);
return config;
}
return null;
}
use of org.olat.fileresource.FileResourceManager 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);
}
use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentRunController method getAssessmentTestMaxTimeLimit.
/**
* @return The maximum time limit in seconds.
*/
private Long getAssessmentTestMaxTimeLimit() {
if (overrideOptions != null && overrideOptions.getAssessmentTestMaxTimeLimit() != null) {
Long timeLimits = overrideOptions.getAssessmentTestMaxTimeLimit();
return timeLimits.longValue() > 0 ? timeLimits.longValue() : null;
}
FileResourceManager frm = FileResourceManager.getInstance();
File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
if (assessmentTest != null && assessmentTest.getTimeLimits() != null && assessmentTest.getTimeLimits().getMaximum() != null) {
return assessmentTest.getTimeLimits().getMaximum().longValue();
}
return null;
}
use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class ImsRepositoryResolver method init.
private void init(OLATResourceable fileResource) {
FileResourceManager frm = FileResourceManager.getInstance();
fUnzippedDirRoot = frm.unzipFileResource(fileResource);
sUnzippedDirRel = frm.getUnzippedDirRel(fileResource);
}
use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class QTIEditorPackageImpl method savePackageToRepository.
/**
* @return True upon success, false otherwise.
*/
public boolean savePackageToRepository() {
FileResourceManager frm = FileResourceManager.getInstance();
File tmpZipFile = new File(WebappHelper.getTmpDir(), CodeHelper.getUniqueID() + ".zip");
// first save complete ZIP package to repository
if (!savePackageTo(tmpZipFile))
return false;
// move file from temp to repository root and rename
File fRepositoryZip = frm.getFileResource(fileResource);
if (!FileUtils.moveFileToDir(tmpZipFile, frm.getFileResourceRoot(fileResource))) {
tmpZipFile.delete();
return false;
}
fRepositoryZip.delete();
new File(frm.getFileResourceRoot(fileResource), tmpZipFile.getName()).renameTo(fRepositoryZip);
// delete old unzip content. If the repository entry gets called in the meantime,
// the package will get unzipped again.
tmpZipFile.delete();
frm.deleteUnzipContent(fileResource);
// to be prepared for the next start, unzip right now.
return (frm.unzipFileResource(fileResource) != null);
}
Aggregations