use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
the class QTI21ArchiveFormat method exportCourseElement.
public MediaResource exportCourseElement() {
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(searchParams.getTestEntry().getOlatResource());
resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
ICourse course = CourseFactory.loadCourse(searchParams.getCourseEntry());
courseNode = course.getRunStructure().getNode(searchParams.getNodeIdent());
String label = courseNode.getType() + "_" + StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".xlsx";
if ("iqself".equals(courseNode.getType())) {
anonymizerCallback = course.getCourseEnvironment().getCoursePropertyManager();
}
// content
final List<AssessmentTestSession> sessions = testSessionDao.getTestSessionsOfResponse(searchParams);
final List<AssessmentResponse> responses = responseDao.getResponse(searchParams);
return new OpenXMLWorkbookResource(label) {
@Override
protected void generate(OutputStream out) {
try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1)) {
// headers
OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
exportSheet.setHeaderRows(2);
writeHeaders_1(exportSheet, workbook);
writeHeaders_2(exportSheet, workbook);
writeData(sessions, responses, exportSheet, workbook);
} catch (Exception e) {
log.error("", e);
}
}
};
}
use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class QTI21ArchiveFormat method exportWorkbook.
public void exportWorkbook(OutputStream exportStream) {
RepositoryEntry testEntry = searchParams.getTestEntry();
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
// content
final List<AssessmentTestSession> sessions = testSessionDao.getTestSessionsOfResponse(searchParams);
final List<AssessmentResponse> responses = responseDao.getResponse(searchParams);
try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(exportStream, 1)) {
// headers
OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
exportSheet.setHeaderRows(2);
writeHeaders_1(exportSheet, workbook);
writeHeaders_2(exportSheet, workbook);
writeData(sessions, responses, exportSheet, workbook);
} catch (Exception e) {
log.error("", e);
}
}
use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class QTI21ServiceImpl method getDeliveryOptions.
@Override
public QTI21DeliveryOptions getDeliveryOptions(RepositoryEntry testEntry) {
FileResourceManager frm = FileResourceManager.getInstance();
File reFolder = frm.getFileResourceRoot(testEntry.getOlatResource());
File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
QTI21DeliveryOptions config;
if (configXml.exists()) {
config = (QTI21DeliveryOptions) configXstream.fromXML(configXml);
} else {
// set default config
config = QTI21DeliveryOptions.defaultSettings();
setDeliveryOptions(testEntry, config);
}
return config;
}
Aggregations