Search in sources :

Example 1 with QTIExportItemFormatConfig

use of org.olat.ims.qti.export.QTIExportItemFormatConfig in project OpenOLAT by OpenOLAT.

the class IQEditReplaceWizard method doStep2.

private void doStep2(UserRequest ureq) {
    String nodeTitle = courseNode.getShortTitle();
    if (results != null && !results.isEmpty()) {
        exportDir = CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), course.getCourseTitle());
        UserManager um = UserManager.getInstance();
        String charset = um.getUserCharset(ureq.getIdentity());
        QTIExportManager qem = QTIExportManager.getInstance();
        Long repositoryRef = results.get(0).getResultSet().getRepositoryRef();
        List<QTIItemObject> qtiItemObjectList = new QTIObjectTreeBuilder().getQTIItemObjectList(repositoryRef);
        QTIExportFormatter formatter;
        if (courseNode instanceof IQTESTCourseNode) {
            formatter = new QTIExportFormatterCSVType1(ureq.getLocale(), "\t", "\"", "\r\n", false);
        } else if (courseNode instanceof IQSELFCourseNode) {
            formatter = new QTIExportFormatterCSVType1(ureq.getLocale(), "\t", "\"", "\r\n", false);
            ((QTIExportFormatterCSVType1) formatter).setAnonymous(true);
        } else {
            formatter = new QTIExportFormatterCSVType3(ureq.getLocale(), null, "\t", "\"", "\r\n", false);
        }
        Map<Class<?>, QTIExportItemFormatConfig> qtiItemConfigs = getQTIItemConfigs(qtiItemObjectList);
        formatter.setMapWithExportItemConfigs(qtiItemConfigs);
        resultExportFile = qem.exportResults(formatter, results, qtiItemObjectList, courseNode.getShortTitle(), exportDir, charset, ".xls");
        vcStep2 = createVelocityContainer("replacewizard_step2");
        String[] args1 = new String[] { Integer.toString(learners.size()) };
        vcStep2.contextPut("information", translate("replace.wizard.information.paragraph1", args1));
        String[] args2 = new String[] { exportDir.getName(), resultExportFile };
        vcStep2.contextPut("information_par2", translate("replace.wizard.information.paragraph2", args2));
        vcStep2.contextPut("nodetitle", nodeTitle);
        showFileButton = LinkFactory.createButton("replace.wizard.showfile", vcStep2, this);
    } else {
        // it exists no result
        String[] args = new String[] { Integer.toString(numberOfQtiSerEntries) };
        vcStep2 = createVelocityContainer("replacewizard_step2");
        vcStep2.contextPut("information", translate("replace.wizard.information.empty.results", args));
        vcStep2.contextPut("nodetitle", nodeTitle);
    }
    nextBtn = LinkFactory.createButton("replace.wizard.next", vcStep2, this);
    setNextWizardStep(translate("replace.wizard.title.step2"), vcStep2);
}
Also used : QTIExportFormatterCSVType1(org.olat.ims.qti.export.QTIExportFormatterCSVType1) QTIExportFormatterCSVType3(org.olat.ims.qti.export.QTIExportFormatterCSVType3) QTIExportFormatter(org.olat.ims.qti.export.QTIExportFormatter) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) UserManager(org.olat.user.UserManager) QTIExportManager(org.olat.ims.qti.export.QTIExportManager) QTIObjectTreeBuilder(org.olat.ims.qti.export.helper.QTIObjectTreeBuilder) IQSELFCourseNode(org.olat.course.nodes.IQSELFCourseNode) QTIExportItemFormatConfig(org.olat.ims.qti.export.QTIExportItemFormatConfig)

Example 2 with QTIExportItemFormatConfig

use of org.olat.ims.qti.export.QTIExportItemFormatConfig 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 3 with QTIExportItemFormatConfig

use of org.olat.ims.qti.export.QTIExportItemFormatConfig in project openolat by klemens.

the class QTIStatisticsResource method getQTIItemConfigs.

/**
 * Copy of QTIArchiveWizardController.getQTIItemConfigs but with all options set
 * to true except for the time column.
 *
 * @param itemList
 * @return
 */
private static final Map<Class<?>, QTIExportItemFormatConfig> getQTIItemConfigs(List<QTIItemObject> itemList) {
    Map<Class<?>, QTIExportItemFormatConfig> itConfigs = new HashMap<>();
    for (Iterator<QTIItemObject> iter = itemList.iterator(); iter.hasNext(); ) {
        QTIItemObject item = iter.next();
        if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_SCQ)) {
            if (itConfigs.get(QTIExportSCQItemFormatConfig.class) == null) {
                QTIExportSCQItemFormatConfig confSCQ = new QTIExportSCQItemFormatConfig(true, true, true, false);
                itConfigs.put(QTIExportSCQItemFormatConfig.class, confSCQ);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_MCQ)) {
            if (itConfigs.get(QTIExportMCQItemFormatConfig.class) == null) {
                QTIExportMCQItemFormatConfig confMCQ = new QTIExportMCQItemFormatConfig(true, true, true, false);
                itConfigs.put(QTIExportMCQItemFormatConfig.class, confMCQ);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_KPRIM)) {
            if (itConfigs.get(QTIExportKPRIMItemFormatConfig.class) == null) {
                QTIExportKPRIMItemFormatConfig confKPRIM = new QTIExportKPRIMItemFormatConfig(true, true, true, false);
                itConfigs.put(QTIExportKPRIMItemFormatConfig.class, confKPRIM);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_ESSAY)) {
            if (itConfigs.get(QTIExportEssayItemFormatConfig.class) == null) {
                QTIExportEssayItemFormatConfig confEssay = new QTIExportEssayItemFormatConfig(true, false);
                itConfigs.put(QTIExportEssayItemFormatConfig.class, confEssay);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_FIB)) {
            if (itConfigs.get(QTIExportFIBItemFormatConfig.class) == null) {
                QTIExportFIBItemFormatConfig confFIB = new QTIExportFIBItemFormatConfig(true, true, false);
                itConfigs.put(QTIExportFIBItemFormatConfig.class, confFIB);
            }
        } else // if cannot find the type via the ItemParser, look for the QTIItemObject type
        if (item.getItemType().equals(QTIItemObject.TYPE.A)) {
            QTIExportEssayItemFormatConfig confEssay = new QTIExportEssayItemFormatConfig(true, false);
            itConfigs.put(QTIExportEssayItemFormatConfig.class, confEssay);
        } else if (item.getItemType().equals(QTIItemObject.TYPE.R)) {
            QTIExportSCQItemFormatConfig confSCQ = new QTIExportSCQItemFormatConfig(true, true, true, false);
            itConfigs.put(QTIExportSCQItemFormatConfig.class, confSCQ);
        } else if (item.getItemType().equals(QTIItemObject.TYPE.C)) {
            QTIExportMCQItemFormatConfig confMCQ = new QTIExportMCQItemFormatConfig(true, true, true, false);
            itConfigs.put(QTIExportMCQItemFormatConfig.class, confMCQ);
        } else if (item.getItemType().equals(QTIItemObject.TYPE.B)) {
            QTIExportFIBItemFormatConfig confFIB = new QTIExportFIBItemFormatConfig(true, true, false);
            itConfigs.put(QTIExportFIBItemFormatConfig.class, confFIB);
        } else {
            throw new OLATRuntimeException(null, "Can not resolve QTIItem type", null);
        }
    }
    return itConfigs;
}
Also used : QTIExportEssayItemFormatConfig(org.olat.ims.qti.export.QTIExportEssayItemFormatConfig) QTIExportMCQItemFormatConfig(org.olat.ims.qti.export.QTIExportMCQItemFormatConfig) HashMap(java.util.HashMap) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) QTIExportSCQItemFormatConfig(org.olat.ims.qti.export.QTIExportSCQItemFormatConfig) QTIExportKPRIMItemFormatConfig(org.olat.ims.qti.export.QTIExportKPRIMItemFormatConfig) QTIExportItemFormatConfig(org.olat.ims.qti.export.QTIExportItemFormatConfig) QTIExportFIBItemFormatConfig(org.olat.ims.qti.export.QTIExportFIBItemFormatConfig)

Example 4 with QTIExportItemFormatConfig

use of org.olat.ims.qti.export.QTIExportItemFormatConfig in project openolat by klemens.

the class IQEditReplaceWizard method getQTIItemConfigs.

private Map<Class<?>, QTIExportItemFormatConfig> getQTIItemConfigs(List<QTIItemObject> qtiItemObjectList) {
    Map<Class<?>, QTIExportItemFormatConfig> itConfigs = new HashMap<>();
    for (Iterator<QTIItemObject> iter = qtiItemObjectList.iterator(); iter.hasNext(); ) {
        QTIItemObject item = iter.next();
        if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_SCQ)) {
            if (itConfigs.get(QTIExportSCQItemFormatConfig.class) == null) {
                QTIExportSCQItemFormatConfig confSCQ = new QTIExportSCQItemFormatConfig(true, false, false, false);
                itConfigs.put(QTIExportSCQItemFormatConfig.class, confSCQ);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_MCQ)) {
            if (itConfigs.get(QTIExportMCQItemFormatConfig.class) == null) {
                QTIExportMCQItemFormatConfig confMCQ = new QTIExportMCQItemFormatConfig(true, false, false, false);
                itConfigs.put(QTIExportMCQItemFormatConfig.class, confMCQ);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_KPRIM)) {
            if (itConfigs.get(QTIExportKPRIMItemFormatConfig.class) == null) {
                QTIExportKPRIMItemFormatConfig confKPRIM = new QTIExportKPRIMItemFormatConfig(true, false, false, false);
                itConfigs.put(QTIExportKPRIMItemFormatConfig.class, confKPRIM);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_ESSAY)) {
            if (itConfigs.get(QTIExportEssayItemFormatConfig.class) == null) {
                QTIExportEssayItemFormatConfig confEssay = new QTIExportEssayItemFormatConfig(true, false);
                itConfigs.put(QTIExportEssayItemFormatConfig.class, confEssay);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_FIB)) {
            if (itConfigs.get(QTIExportFIBItemFormatConfig.class) == null) {
                QTIExportFIBItemFormatConfig confFIB = new QTIExportFIBItemFormatConfig(true, false, false);
                itConfigs.put(QTIExportFIBItemFormatConfig.class, confFIB);
            }
        } else if (item.getItemType().equals(QTIItemObject.TYPE.A)) {
            QTIExportEssayItemFormatConfig confEssay = new QTIExportEssayItemFormatConfig(true, false);
            itConfigs.put(QTIExportEssayItemFormatConfig.class, confEssay);
        } else if (item.getItemType().equals(QTIItemObject.TYPE.R)) {
            QTIExportSCQItemFormatConfig confSCQ = new QTIExportSCQItemFormatConfig(true, false, false, false);
            itConfigs.put(QTIExportSCQItemFormatConfig.class, confSCQ);
        } else if (item.getItemType().equals(QTIItemObject.TYPE.C)) {
            QTIExportMCQItemFormatConfig confMCQ = new QTIExportMCQItemFormatConfig(true, false, false, false);
            itConfigs.put(QTIExportMCQItemFormatConfig.class, confMCQ);
        } else if (item.getItemType().equals(QTIItemObject.TYPE.B)) {
            QTIExportFIBItemFormatConfig confFIB = new QTIExportFIBItemFormatConfig(true, false, false);
            itConfigs.put(QTIExportFIBItemFormatConfig.class, confFIB);
        } else {
            throw new OLATRuntimeException(null, "Can not resolve QTIItem type", null);
        }
    }
    return itConfigs;
}
Also used : QTIExportEssayItemFormatConfig(org.olat.ims.qti.export.QTIExportEssayItemFormatConfig) QTIExportMCQItemFormatConfig(org.olat.ims.qti.export.QTIExportMCQItemFormatConfig) HashMap(java.util.HashMap) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) QTIExportSCQItemFormatConfig(org.olat.ims.qti.export.QTIExportSCQItemFormatConfig) QTIExportKPRIMItemFormatConfig(org.olat.ims.qti.export.QTIExportKPRIMItemFormatConfig) QTIExportItemFormatConfig(org.olat.ims.qti.export.QTIExportItemFormatConfig) QTIExportFIBItemFormatConfig(org.olat.ims.qti.export.QTIExportFIBItemFormatConfig)

Example 5 with QTIExportItemFormatConfig

use of org.olat.ims.qti.export.QTIExportItemFormatConfig in project OpenOLAT by OpenOLAT.

the class QTIStatisticsResource method getQTIItemConfigs.

/**
 * Copy of QTIArchiveWizardController.getQTIItemConfigs but with all options set
 * to true except for the time column.
 *
 * @param itemList
 * @return
 */
private static final Map<Class<?>, QTIExportItemFormatConfig> getQTIItemConfigs(List<QTIItemObject> itemList) {
    Map<Class<?>, QTIExportItemFormatConfig> itConfigs = new HashMap<>();
    for (Iterator<QTIItemObject> iter = itemList.iterator(); iter.hasNext(); ) {
        QTIItemObject item = iter.next();
        if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_SCQ)) {
            if (itConfigs.get(QTIExportSCQItemFormatConfig.class) == null) {
                QTIExportSCQItemFormatConfig confSCQ = new QTIExportSCQItemFormatConfig(true, true, true, false);
                itConfigs.put(QTIExportSCQItemFormatConfig.class, confSCQ);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_MCQ)) {
            if (itConfigs.get(QTIExportMCQItemFormatConfig.class) == null) {
                QTIExportMCQItemFormatConfig confMCQ = new QTIExportMCQItemFormatConfig(true, true, true, false);
                itConfigs.put(QTIExportMCQItemFormatConfig.class, confMCQ);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_KPRIM)) {
            if (itConfigs.get(QTIExportKPRIMItemFormatConfig.class) == null) {
                QTIExportKPRIMItemFormatConfig confKPRIM = new QTIExportKPRIMItemFormatConfig(true, true, true, false);
                itConfigs.put(QTIExportKPRIMItemFormatConfig.class, confKPRIM);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_ESSAY)) {
            if (itConfigs.get(QTIExportEssayItemFormatConfig.class) == null) {
                QTIExportEssayItemFormatConfig confEssay = new QTIExportEssayItemFormatConfig(true, false);
                itConfigs.put(QTIExportEssayItemFormatConfig.class, confEssay);
            }
        } else if (item.getItemIdent().startsWith(ItemParser.ITEM_PREFIX_FIB)) {
            if (itConfigs.get(QTIExportFIBItemFormatConfig.class) == null) {
                QTIExportFIBItemFormatConfig confFIB = new QTIExportFIBItemFormatConfig(true, true, false);
                itConfigs.put(QTIExportFIBItemFormatConfig.class, confFIB);
            }
        } else // if cannot find the type via the ItemParser, look for the QTIItemObject type
        if (item.getItemType().equals(QTIItemObject.TYPE.A)) {
            QTIExportEssayItemFormatConfig confEssay = new QTIExportEssayItemFormatConfig(true, false);
            itConfigs.put(QTIExportEssayItemFormatConfig.class, confEssay);
        } else if (item.getItemType().equals(QTIItemObject.TYPE.R)) {
            QTIExportSCQItemFormatConfig confSCQ = new QTIExportSCQItemFormatConfig(true, true, true, false);
            itConfigs.put(QTIExportSCQItemFormatConfig.class, confSCQ);
        } else if (item.getItemType().equals(QTIItemObject.TYPE.C)) {
            QTIExportMCQItemFormatConfig confMCQ = new QTIExportMCQItemFormatConfig(true, true, true, false);
            itConfigs.put(QTIExportMCQItemFormatConfig.class, confMCQ);
        } else if (item.getItemType().equals(QTIItemObject.TYPE.B)) {
            QTIExportFIBItemFormatConfig confFIB = new QTIExportFIBItemFormatConfig(true, true, false);
            itConfigs.put(QTIExportFIBItemFormatConfig.class, confFIB);
        } else {
            throw new OLATRuntimeException(null, "Can not resolve QTIItem type", null);
        }
    }
    return itConfigs;
}
Also used : QTIExportEssayItemFormatConfig(org.olat.ims.qti.export.QTIExportEssayItemFormatConfig) QTIExportMCQItemFormatConfig(org.olat.ims.qti.export.QTIExportMCQItemFormatConfig) HashMap(java.util.HashMap) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) QTIExportSCQItemFormatConfig(org.olat.ims.qti.export.QTIExportSCQItemFormatConfig) QTIExportKPRIMItemFormatConfig(org.olat.ims.qti.export.QTIExportKPRIMItemFormatConfig) QTIExportItemFormatConfig(org.olat.ims.qti.export.QTIExportItemFormatConfig) QTIExportFIBItemFormatConfig(org.olat.ims.qti.export.QTIExportFIBItemFormatConfig)

Aggregations

QTIExportItemFormatConfig (org.olat.ims.qti.export.QTIExportItemFormatConfig)8 HashMap (java.util.HashMap)6 QTIExportEssayItemFormatConfig (org.olat.ims.qti.export.QTIExportEssayItemFormatConfig)6 QTIExportFIBItemFormatConfig (org.olat.ims.qti.export.QTIExportFIBItemFormatConfig)6 QTIExportKPRIMItemFormatConfig (org.olat.ims.qti.export.QTIExportKPRIMItemFormatConfig)6 QTIExportMCQItemFormatConfig (org.olat.ims.qti.export.QTIExportMCQItemFormatConfig)6 QTIExportSCQItemFormatConfig (org.olat.ims.qti.export.QTIExportSCQItemFormatConfig)6 QTIItemObject (org.olat.ims.qti.export.helper.QTIItemObject)6 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)4 QTIExportFormatterCSVType1 (org.olat.ims.qti.export.QTIExportFormatterCSVType1)4 QTIExportManager (org.olat.ims.qti.export.QTIExportManager)4 IOException (java.io.IOException)2 IQSELFCourseNode (org.olat.course.nodes.IQSELFCourseNode)2 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)2 QTIExportFormatter (org.olat.ims.qti.export.QTIExportFormatter)2 QTIExportFormatterCSVType3 (org.olat.ims.qti.export.QTIExportFormatterCSVType3)2 QTIExportItemFormatDelegate (org.olat.ims.qti.export.QTIExportItemFormatDelegate)2 QTIObjectTreeBuilder (org.olat.ims.qti.export.helper.QTIObjectTreeBuilder)2 QTI21ArchiveFormat (org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat)2 QTI21StatisticSearchParams (org.olat.ims.qti21.model.QTI21StatisticSearchParams)2