Search in sources :

Example 1 with QTI21ArchiveFormat

use of org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat in project OpenOLAT by OpenOLAT.

the class QTIArchiver method exportQTI21.

public MediaResource exportQTI21() {
    ICourse course = CourseFactory.loadCourse(courseOres);
    RepositoryEntry testRe = courseNode.getReferencedRepositoryEntry();
    RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testRe, courseEntry, courseNode.getIdent(), allUsers, anonymUsers);
    return new QTI21ArchiveFormat(locale, searchParams).exportCourseElement();
}
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 2 with QTI21ArchiveFormat

use of org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat in project OpenOLAT by OpenOLAT.

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 3 with QTI21ArchiveFormat

use of org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat in project OpenOLAT by OpenOLAT.

the class IQSELFCourseNode method archiveNodeData.

@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
    String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
    try {
        if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
            RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, re, courseEntry, getIdent());
            QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(locale, searchParams);
            qaf.exportCourseElement(exportStream);
            return true;
        } else {
            QTIExportManager qem = QTIExportManager.getInstance();
            QTIExportFormatterCSVType1 qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
            qef.setAnonymous(true);
            if (options != null && options.getExportFormat() != null) {
                Map<Class<?>, QTIExportItemFormatConfig> itemConfigs = new HashMap<>();
                Class<?>[] itemTypes = new Class<?>[] { QTIExportSCQItemFormatConfig.class, QTIExportMCQItemFormatConfig.class, QTIExportKPRIMItemFormatConfig.class, QTIExportFIBItemFormatConfig.class, QTIExportEssayItemFormatConfig.class };
                for (Class<?> itemClass : itemTypes) {
                    itemConfigs.put(itemClass, new QTIExportItemFormatDelegate(options.getExportFormat()));
                }
                qef.setMapWithExportItemConfigs(itemConfigs);
            }
            return qem.selectAndExportResults(qef, course.getResourceableId(), getShortTitle(), getIdent(), re, exportStream, locale, ".xls");
        }
    } catch (IOException e) {
        log.error("", e);
        return false;
    }
}
Also used : QTIExportMCQItemFormatConfig(org.olat.ims.qti.export.QTIExportMCQItemFormatConfig) QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) HashMap(java.util.HashMap) QTIExportFormatterCSVType1(org.olat.ims.qti.export.QTIExportFormatterCSVType1) RepositoryEntry(org.olat.repository.RepositoryEntry) QTIExportItemFormatDelegate(org.olat.ims.qti.export.QTIExportItemFormatDelegate) IOException(java.io.IOException) QTIExportFIBItemFormatConfig(org.olat.ims.qti.export.QTIExportFIBItemFormatConfig) QTIExportEssayItemFormatConfig(org.olat.ims.qti.export.QTIExportEssayItemFormatConfig) QTIExportManager(org.olat.ims.qti.export.QTIExportManager) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat) QTIExportSCQItemFormatConfig(org.olat.ims.qti.export.QTIExportSCQItemFormatConfig) QTIExportKPRIMItemFormatConfig(org.olat.ims.qti.export.QTIExportKPRIMItemFormatConfig) QTIExportItemFormatConfig(org.olat.ims.qti.export.QTIExportItemFormatConfig)

Example 4 with QTI21ArchiveFormat

use of org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat in project OpenOLAT by OpenOLAT.

the class IQTESTCourseNode method archiveNodeData.

@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
    String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
    Long courseResourceableId = course.getResourceableId();
    // 1) prepare result export
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    try {
        RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
        boolean onyx = OnyxModule.isOnyxTest(re.getOlatResource());
        if (onyx) {
            return true;
        } else if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
            // 2a) create export resource
            List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
            new QTI21ResultsExportMediaResource(courseEnv, identities, this, locale).exportTestResults(exportStream);
            // excel results
            RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, re, courseEntry, getIdent());
            QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(locale, searchParams);
            qaf.exportCourseElement(exportStream);
            return true;
        } else {
            // 2b) create export resource
            List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
            new QTI12ResultsExportMediaResource(courseEnv, locale, identities, this).exportTestResults(exportStream);
            // excel results
            String shortTitle = getShortTitle();
            QTIExportManager qem = QTIExportManager.getInstance();
            QTIExportFormatter qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
            if (options != null && options.getExportFormat() != null) {
                Map<Class<?>, QTIExportItemFormatConfig> itemConfigs = new HashMap<>();
                Class<?>[] itemTypes = new Class<?>[] { QTIExportSCQItemFormatConfig.class, QTIExportMCQItemFormatConfig.class, QTIExportKPRIMItemFormatConfig.class, QTIExportFIBItemFormatConfig.class, QTIExportEssayItemFormatConfig.class };
                for (Class<?> itemClass : itemTypes) {
                    itemConfigs.put(itemClass, new QTIExportItemFormatDelegate(options.getExportFormat()));
                }
                qef.setMapWithExportItemConfigs(itemConfigs);
            }
            return qem.selectAndExportResults(qef, courseResourceableId, shortTitle, getIdent(), re, exportStream, locale, ".xls");
        }
    } catch (IOException e) {
        log.error("", e);
        return false;
    }
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) QTIExportFormatterCSVType1(org.olat.ims.qti.export.QTIExportFormatterCSVType1) RepositoryEntry(org.olat.repository.RepositoryEntry) QTIExportItemFormatDelegate(org.olat.ims.qti.export.QTIExportItemFormatDelegate) IOException(java.io.IOException) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource) QTIExportFormatter(org.olat.ims.qti.export.QTIExportFormatter) QTIExportManager(org.olat.ims.qti.export.QTIExportManager) List(java.util.List) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with QTI21ArchiveFormat

use of org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat in project openolat by klemens.

the class QTI21ResultsExportMediaResource method exportExcelResults.

private void exportExcelResults(RepositoryEntry testEntry, ZipOutputStream zout) {
    ArchiveOptions options = new ArchiveOptions();
    options.setIdentities(identities);
    QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, testEntry, entry, courseNode.getIdent());
    searchParams.setLimitToIdentities(identities);
    QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(translator.getLocale(), searchParams);
    String label = StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName() + "_" + testEntry.getDisplayname()) + "_" + Formatter.formatDatetimeWithMinutes(new Date()) + ".xlsx";
    qaf.exportCourseElement(exportFolderName + "/" + label, zout);
}
Also used : QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) ArchiveOptions(org.olat.course.nodes.ArchiveOptions) 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