use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
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 klemens.
the class ScormMainManager method setScormPackageConfig.
public void setScormPackageConfig(OLATResourceable ores, ScormPackageConfig config) {
FileResourceManager frm = FileResourceManager.getInstance();
File reFolder = frm.getFileResourceRoot(ores);
File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
if (config == null) {
if (configXml.exists()) {
configXml.delete();
}
} else {
OutputStream out = null;
try {
out = new FileOutputStream(configXml);
configXstream.toXML(config, out);
} catch (IOException e) {
log.error("", e);
} finally {
IOUtils.closeQuietly(out);
}
}
}
use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
the class QTI21EditForm method update.
protected void update(RepositoryEntry testEntry) {
Double minValue = null;
Double maxValue = null;
Double cutValue = null;
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
if (assessmentTest != null) {
AssessmentTestBuilder testBuilder = new AssessmentTestBuilder(assessmentTest);
maxValue = testBuilder.getMaxScore();
cutValue = testBuilder.getCutValue();
if (maxValue != null && "OpenOLAT".equals(assessmentTest.getToolName())) {
minValue = 0d;
}
}
// 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);
update();
}
use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
the class QTI21EditLayoutForm method getMaxTimeLimit.
/**
* @return The time limit of the assessment test in seconds or -1 if not configured
*/
private long getMaxTimeLimit() {
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
long timeLimit = -1;
if (assessmentTest != null && assessmentTest.getTimeLimits() != null && assessmentTest.getTimeLimits().getMaximum() != null) {
timeLimit = assessmentTest.getTimeLimits().getMaximum().longValue();
}
return timeLimit;
}
use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
the class CPManagerImpl method setCPPackageConfig.
@Override
public void setCPPackageConfig(OLATResourceable ores, CPPackageConfig config) {
FileResourceManager frm = FileResourceManager.getInstance();
File reFolder = frm.getFileResourceRoot(ores);
File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
if (config == null) {
if (configXml.exists()) {
configXml.delete();
}
} else {
OutputStream out = null;
try {
out = new FileOutputStream(configXml);
configXstream.toXML(config, out);
} catch (IOException e) {
log.error("", e);
} finally {
IOUtils.closeQuietly(out);
}
}
}
Aggregations