Search in sources :

Example 11 with QTIItemObject

use of org.olat.ims.qti.export.helper.QTIItemObject 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 12 with QTIItemObject

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

the class QTIStatisticsManagerLargeTest method getItemObjectList.

@SuppressWarnings("rawtypes")
private void getItemObjectList() {
    InputStream in = QTIStatisticsManagerLargeTest.class.getResourceAsStream("qti.xml");
    XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
    Document doc = xmlParser.parse(in, false);
    Element root = doc.getRootElement();
    List items = root.selectNodes("//item");
    itemObjects = new ArrayList<QTIItemObject>();
    for (Iterator iter = items.iterator(); iter.hasNext(); ) {
        Element el_item = (Element) iter.next();
        if (el_item.selectNodes(".//response_lid").size() > 0) {
            itemObjects.add(new ItemWithResponseLid(el_item));
        } else if (el_item.selectNodes(".//response_str").size() > 0) {
            itemObjects.add(new ItemWithResponseStr(el_item));
        }
    }
}
Also used : ItemWithResponseLid(org.olat.ims.qti.export.helper.ItemWithResponseLid) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) InputStream(java.io.InputStream) Element(org.dom4j.Element) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ItemWithResponseStr(org.olat.ims.qti.export.helper.ItemWithResponseStr) XMLParser(org.olat.core.util.xml.XMLParser) Document(org.dom4j.Document) IMSEntityResolver(org.olat.ims.resources.IMSEntityResolver)

Example 13 with QTIItemObject

use of org.olat.ims.qti.export.helper.QTIItemObject 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 14 with QTIItemObject

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

the class QTIArchiver method getQTIItemConfigs.

public static 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, 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 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, 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 : HashMap(java.util.HashMap) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 15 with QTIItemObject

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

the class QTIExportFormatterCSVType1 method openReport.

public void openReport() {
    if (qtiItemObjectList == null) {
        throw new OLATRuntimeException(null, "Can not format report when qtiItemObjectList is null", null);
    }
    if (mapWithExportItemConfigs == null) {
        // while deleting a test node the formatter has no config consiting of user input
        setDefaultQTIItemConfigs();
    }
    QTIExportItemFactory qeif = new QTIExportItemFactory(mapWithExportItemConfigs);
    // // // Preparing HeaderRow 1 and HeaderRow2
    StringBuilder hR1 = new StringBuilder();
    StringBuilder hR2 = new StringBuilder();
    int i = 1;
    for (Iterator<QTIItemObject> iter = qtiItemObjectList.iterator(); iter.hasNext(); ) {
        QTIItemObject item = iter.next();
        if (displayItem(qeif.getExportItemConfig(item))) {
            hR1.append(emb);
            hR1.append(escape(item.getItemTitle()));
            // CELFI#107
            String question = item.getQuestionText();
            // question = FilterFactory.getHtmlTagsFilter().filter(question);
            question = FilterFactory.getXSSFilter(-1).filter(question);
            question = FilterFactory.getHtmlTagsFilter().filter(question);
            if (question.length() > cut) {
                question = question.substring(0, cut) + "...";
            }
            question = StringEscapeUtils.unescapeHtml(question);
            hR1.append(": " + escape(question));
            // CELFI#107 END
            hR1.append(emb);
            if (qeif.getExportItemConfig(item).hasResponseCols()) {
                List<String> responseColumnHeaders = item.getResponseColumnHeaders();
                for (Iterator<String> iterator = responseColumnHeaders.iterator(); iterator.hasNext(); ) {
                    // HeaderRow1
                    hR1.append(sep);
                    // HeaderRow2
                    String columnHeader = iterator.next();
                    hR2.append(i);
                    hR2.append("_");
                    hR2.append(columnHeader);
                    hR2.append(sep);
                }
            }
            if (qeif.getExportItemConfig(item).hasPositionsOfResponsesCol()) {
                // HeaderRow1
                hR1.append(sep);
                // HeaderRow2
                hR2.append(i);
                hR2.append("_");
                hR2.append(translator.translate("item.positions"));
                hR2.append(sep);
            }
            if (qeif.getExportItemConfig(item).hasPointCol()) {
                // HeaderRow1
                hR1.append(sep);
                // HeaderRow2
                hR2.append(i);
                hR2.append("_");
                hR2.append(translator.translate("item.score"));
                hR2.append(sep);
            }
            if (qeif.getExportItemConfig(item).hasTimeCols()) {
                // HeaderRow1
                hR1.append(sep);
                if (!isAnonymous) {
                    hR1.append(sep);
                }
                // HeaderRow2
                if (!isAnonymous) {
                    hR2.append(i);
                    hR2.append("_");
                    hR2.append(translator.translate("item.start"));
                    hR2.append(sep);
                }
                hR2.append(i);
                hR2.append("_");
                hR2.append(translator.translate("item.duration"));
                hR2.append(sep);
            }
            i++;
        }
    }
    // // // HeaderRow1Intro
    sb.append(createHeaderRow1Intro());
    // // // HeaderRow1
    sb.append(hR1.toString());
    sb.append(car);
    // // // HeaderRow2Intro
    sb.append(createHeaderRow2Intro());
    // // // HeaderRow2
    sb.append(hR2.toString());
    sb.append(car);
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject)

Aggregations

QTIItemObject (org.olat.ims.qti.export.helper.QTIItemObject)36 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)20 HashMap (java.util.HashMap)10 QTIResult (org.olat.ims.qti.QTIResult)8 QTIObjectTreeBuilder (org.olat.ims.qti.export.helper.QTIObjectTreeBuilder)8 Test (org.junit.Test)6 QTIResultManager (org.olat.ims.qti.QTIResultManager)6 QTIExportItemFormatConfig (org.olat.ims.qti.export.QTIExportItemFormatConfig)6 QTIStatisticSearchParams (org.olat.ims.qti.statistics.QTIStatisticSearchParams)6 StatisticsItem (org.olat.ims.qti.statistics.model.StatisticsItem)6 QTIExportEssayItemFormatConfig (org.olat.ims.qti.export.QTIExportEssayItemFormatConfig)4 QTIExportFIBItemFormatConfig (org.olat.ims.qti.export.QTIExportFIBItemFormatConfig)4 QTIExportFormatter (org.olat.ims.qti.export.QTIExportFormatter)4 QTIExportFormatterCSVType1 (org.olat.ims.qti.export.QTIExportFormatterCSVType1)4 QTIExportFormatterCSVType3 (org.olat.ims.qti.export.QTIExportFormatterCSVType3)4 QTIExportKPRIMItemFormatConfig (org.olat.ims.qti.export.QTIExportKPRIMItemFormatConfig)4 QTIExportMCQItemFormatConfig (org.olat.ims.qti.export.QTIExportMCQItemFormatConfig)4 QTIExportSCQItemFormatConfig (org.olat.ims.qti.export.QTIExportSCQItemFormatConfig)4 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2