Search in sources :

Example 11 with QTI21ArchiveFormat

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;
}
Also used : QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat)

Example 12 with QTI21ArchiveFormat

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);
    }
}
Also used : Path(java.nio.file.Path) QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat) Date(java.util.Date)

Aggregations

QTI21ArchiveFormat (org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat)12 QTI21StatisticSearchParams (org.olat.ims.qti21.model.QTI21StatisticSearchParams)12 RepositoryEntry (org.olat.repository.RepositoryEntry)8 IOException (java.io.IOException)6 Date (java.util.Date)4 HashMap (java.util.HashMap)4 ICourse (org.olat.course.ICourse)4 QTIExportFormatterCSVType1 (org.olat.ims.qti.export.QTIExportFormatterCSVType1)4 QTIExportItemFormatDelegate (org.olat.ims.qti.export.QTIExportItemFormatDelegate)4 QTIExportManager (org.olat.ims.qti.export.QTIExportManager)4 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 Path (java.nio.file.Path)2 List (java.util.List)2 Map (java.util.Map)2 ZipOutputStream (java.util.zip.ZipOutputStream)2 ArchiveOptions (org.olat.course.nodes.ArchiveOptions)2 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)2 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)2 QTIExportEssayItemFormatConfig (org.olat.ims.qti.export.QTIExportEssayItemFormatConfig)2