use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
the class AssessmentTestPreWarm method run.
@Override
public void run() {
long start = System.nanoTime();
FileResourceManager frm = FileResourceManager.getInstance();
List<RepositoryEntry> entries = repositoryEntryDao.getLastUsedRepositoryEntries(ImsQTI21Resource.TYPE_NAME, 0, 20);
for (RepositoryEntry entry : entries) {
try {
File fUnzippedDirRoot = frm.unzipFileResource(entry.getOlatResource());
qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
} catch (RuntimeException e) {
log.error("Loading the AssessmentTest of repository entry: " + entry.getKey() + " (" + entry.getDisplayname() + ")", e);
}
}
log.info(entries.size() + " AssessmentTest preloaded in (ms): " + CodeHelper.nanoToMilliTime(start));
}
use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
the class QTI21RuntimeController method getAssessableElement.
private AssessableResource getAssessableElement(RepositoryEntry testEntry) {
FileResourceManager frm = FileResourceManager.getInstance();
File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentTest);
Double minScore = QtiNodesExtractor.extractMinScore(assessmentTest);
boolean hasScore = assessmentTest.getOutcomeDeclaration(QTI21Constants.SCORE_IDENTIFIER) != null;
boolean hasPassed = assessmentTest.getOutcomeDeclaration(QTI21Constants.PASS_IDENTIFIER) != null;
return new QTI21AssessableResource(hasScore, hasPassed, true, true, minScore, maxScore, null);
}
use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
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 klemens.
the class QTI21AssessmentRunController method doShowResults.
private void doShowResults(UserRequest ureq) {
removeAsListenerAndDispose(resultCtrl);
AssessmentTestSession session = null;
if (courseNode instanceof SelfAssessableCourseNode) {
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
session = qtiService.getLastAssessmentTestSessions(courseEntry, courseNode.getIdent(), testEntry, getIdentity());
} else {
AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
AssessmentEntry assessmentEntry = am.getAssessmentEntry(courseNode, getIdentity());
if (assessmentEntry.getAssessmentId() != null) {
session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
} else {
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
session = qtiService.getLastAssessmentTestSessions(courseEntry, courseNode.getIdent(), testEntry, getIdentity());
}
}
if (session == null) {
mainVC.contextPut("showResults", Boolean.FALSE);
} else {
FileResourceManager frm = FileResourceManager.getInstance();
File fUnzippedDirRoot = frm.unzipFileResource(session.getTestEntry().getOlatResource());
URI assessmentObjectUri = qtiService.createAssessmentTestUri(fUnzippedDirRoot);
File submissionDir = qtiService.getAssessmentResultFile(session);
String mapperUri = registerCacheableMapper(ureq, "QTI21CNResults::" + session.getTestEntry().getKey(), new ResourcesMapper(assessmentObjectUri, submissionDir));
resultCtrl = new AssessmentResultController(ureq, getWindowControl(), getIdentity(), true, session, fUnzippedDirRoot, mapperUri, null, getDeliveryOptions().getAssessmentResultsOptions(), false, false, true);
listenTo(resultCtrl);
mainVC.put("resultReport", resultCtrl.getInitialComponent());
mainVC.contextPut("showResults", Boolean.TRUE);
}
saveOpenPanel(ureq, "results", Boolean.TRUE);
}
use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
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;
}
Aggregations