Search in sources :

Example 6 with QuestionType

use of org.olat.modules.qpool.QuestionType in project openolat by klemens.

the class QTIImportProcessor method processItemQuestionType.

private boolean processItemQuestionType(QuestionItemImpl poolItem, String ident, Element itemEl) {
    boolean openolatFormat = false;
    // question type: mc, sc...
    QuestionType type = null;
    // test with openolat ident
    if (ident != null && ident.startsWith(ItemParser.ITEM_PREFIX_SCQ)) {
        type = QuestionType.SC;
        openolatFormat = true;
    } else if (ident != null && ident.startsWith(ItemParser.ITEM_PREFIX_MCQ)) {
        type = QuestionType.MC;
        openolatFormat = true;
    } else if (ident != null && ident.startsWith(ItemParser.ITEM_PREFIX_FIB)) {
        type = QuestionType.FIB;
        openolatFormat = true;
    } else if (ident != null && ident.startsWith(ItemParser.ITEM_PREFIX_ESSAY)) {
        type = QuestionType.ESSAY;
        openolatFormat = true;
    } else if (ident != null && ident.startsWith(ItemParser.ITEM_PREFIX_KPRIM)) {
        type = QuestionType.KPRIM;
        openolatFormat = true;
    } else if (itemEl.selectNodes("//render_choice").size() == 1) {
        Element lidEl = (Element) itemEl.selectSingleNode("//response_lid");
        String rcardinality = getAttributeValue(lidEl, "rcardinality");
        if ("Single".equals(rcardinality)) {
            type = QuestionType.SC;
        } else if ("Multiple".equals(rcardinality)) {
            type = QuestionType.MC;
        }
    } else if (itemEl.selectNodes("//render_fib").size() == 1) {
        type = QuestionType.FIB;
    }
    if (type != null) {
        QItemType itemType = qItemTypeDao.loadByType(type.name());
        poolItem.setType(itemType);
    }
    return openolatFormat;
}
Also used : Element(org.dom4j.Element) QuestionType(org.olat.modules.qpool.QuestionType) QItemType(org.olat.modules.qpool.model.QItemType)

Aggregations

QuestionType (org.olat.modules.qpool.QuestionType)6 QItemType (org.olat.modules.qpool.model.QItemType)6 File (java.io.File)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2 HashSet (java.util.HashSet)2 Document (org.dom4j.Document)2 Element (org.dom4j.Element)2 Node (org.dom4j.Node)2 Test (org.junit.Test)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 XMLParser (org.olat.core.util.xml.XMLParser)2 IMSEntityResolver (org.olat.ims.resources.IMSEntityResolver)2 QuestionItem (org.olat.modules.qpool.QuestionItem)2 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)2