Search in sources :

Example 1 with QTI21ResultsExportMediaResource

use of org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource in project OpenOLAT by OpenOLAT.

the class IQIdentityListCourseNodeController method doExportResults.

private void doExportResults(UserRequest ureq) {
    List<Identity> identities = getIdentities();
    if (identities != null && !identities.isEmpty()) {
        MediaResource resource;
        CourseEnvironment courseEnv = getCourseEnvironment();
        if (isTestQTI21()) {
            resource = new QTI21ResultsExportMediaResource(courseEnv, identities, (IQTESTCourseNode) courseNode, getLocale());
        } else {
            resource = new QTI12ResultsExportMediaResource(courseEnv, getLocale(), identities, (IQTESTCourseNode) courseNode);
        }
        ureq.getDispatchResult().setResultingMediaResource(resource);
    } else {
        showWarning("error.no.assessed.users");
    }
}
Also used : IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) Identity(org.olat.core.id.Identity) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource)

Example 2 with QTI21ResultsExportMediaResource

use of org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource 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 3 with QTI21ResultsExportMediaResource

use of org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource in project openolat by klemens.

the class IQIdentityListCourseNodeController method doExportResults.

private void doExportResults(UserRequest ureq) {
    List<Identity> identities = getIdentities();
    if (identities != null && !identities.isEmpty()) {
        MediaResource resource;
        CourseEnvironment courseEnv = getCourseEnvironment();
        if (isTestQTI21()) {
            resource = new QTI21ResultsExportMediaResource(courseEnv, identities, (IQTESTCourseNode) courseNode, getLocale());
        } else {
            resource = new QTI12ResultsExportMediaResource(courseEnv, getLocale(), identities, (IQTESTCourseNode) courseNode);
        }
        ureq.getDispatchResult().setResultingMediaResource(resource);
    } else {
        showWarning("error.no.assessed.users");
    }
}
Also used : IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) Identity(org.olat.core.id.Identity) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource)

Example 4 with QTI21ResultsExportMediaResource

use of org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource in project openolat by klemens.

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)

Aggregations

CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)4 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)4 QTI12ResultsExportMediaResource (org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource)4 QTI21ResultsExportMediaResource (org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource)4 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 MediaResource (org.olat.core.gui.media.MediaResource)2 Identity (org.olat.core.id.Identity)2 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)2 QTIExportFormatter (org.olat.ims.qti.export.QTIExportFormatter)2 QTIExportFormatterCSVType1 (org.olat.ims.qti.export.QTIExportFormatterCSVType1)2 QTIExportItemFormatDelegate (org.olat.ims.qti.export.QTIExportItemFormatDelegate)2 QTIExportManager (org.olat.ims.qti.export.QTIExportManager)2 QTI21ArchiveFormat (org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat)2 QTI21StatisticSearchParams (org.olat.ims.qti21.model.QTI21StatisticSearchParams)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2