use of org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat in project openolat by klemens.
the class QTIArchiver method hasResults.
public boolean hasResults() {
if (results != null)
return results.booleanValue();
ICourse course = CourseFactory.loadCourse(courseOres);
RepositoryEntry testRe = courseNode.getReferencedRepositoryEntry();
boolean success = false;
if (ImsQTI21Resource.TYPE_NAME.equals(testRe.getOlatResource().getResourceableTypeName())) {
type = Type.qti21;
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testRe, courseEntry, courseNode.getIdent(), allUsers, anonymUsers);
success = new QTI21ArchiveFormat(locale, searchParams).hasResults();
} else {
type = Type.qti12;
success = qrm.hasResultSets(courseOres.getResourceableId(), courseNode.getIdent(), testRe.getKey());
}
results = Boolean.valueOf(success);
return success;
}
use of org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat in project openolat by klemens.
the class QTI21ResetDataController method archiveData.
private void archiveData(RepositoryEntry testEntry) {
// backup
String archiveName = "qti21test_" + StringHelper.transformDisplayNameToFileSystemName(testEntry.getDisplayname()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".zip";
Path exportPath = Paths.get(FolderConfig.getCanonicalRoot(), FolderConfig.getUserHomes(), getIdentity().getName(), "private", "archive", StringHelper.transformDisplayNameToFileSystemName(testEntry.getDisplayname()), archiveName);
File exportFile = exportPath.toFile();
exportFile.getParentFile().mkdirs();
try (FileOutputStream fileStream = new FileOutputStream(exportFile);
ZipOutputStream exportStream = new ZipOutputStream(fileStream)) {
// author can do this, also they can archive all users and anonyme users
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testEntry, null, null, true, true);
new QTI21ArchiveFormat(getLocale(), searchParams).exportResource(exportStream);
} catch (IOException e) {
logError("", e);
}
}
Aggregations