Search in sources :

Example 1 with QItemTypeDAO

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

the class QTI12To21Converter method convertItem.

/**
 * @param item
 * @return The name of the assesssmentItem file
 */
private boolean convertItem(QuestionItemImpl convertedQuestion, Item item) {
    QItemTypeDAO qItemTypeDao = CoreSpringFactory.getImpl(QItemTypeDAO.class);
    AssessmentItemBuilder itemBuilder = null;
    int questionType = item.getQuestion().getType();
    switch(questionType) {
        case Question.TYPE_SC:
            itemBuilder = convertSingleChoice(item);
            convertedQuestion.setType(qItemTypeDao.loadByType(QuestionType.SC.name()));
            break;
        case Question.TYPE_MC:
            itemBuilder = convertMultipleChoice(item);
            convertedQuestion.setType(qItemTypeDao.loadByType(QuestionType.MC.name()));
            break;
        case Question.TYPE_KPRIM:
            itemBuilder = convertKPrim(item);
            convertedQuestion.setType(qItemTypeDao.loadByType(QuestionType.KPRIM.name()));
            break;
        case Question.TYPE_FIB:
            itemBuilder = convertFIB(item);
            convertedQuestion.setType(qItemTypeDao.loadByType(QuestionType.FIB.name()));
            break;
        case Question.TYPE_ESSAY:
            itemBuilder = convertEssay(item);
            convertedQuestion.setType(qItemTypeDao.loadByType(QuestionType.ESSAY.name()));
            break;
    }
    if (itemBuilder != null) {
        itemBuilder.build();
        AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
        String itemId = IdentifierGenerator.newAsString(itemBuilder.getQuestionType().getPrefix());
        File itemFile = new File(unzippedDirRoot, itemId + ".xml");
        persistAssessmentObject(itemFile, assessmentItem);
        appendResourceAndMetadata(item, itemBuilder, itemFile);
        convertedQuestion.setRootFilename(itemFile.getName());
        return true;
    }
    return false;
}
Also used : QItemTypeDAO(org.olat.modules.qpool.manager.QItemTypeDAO) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) AssessmentItemBuilder(org.olat.ims.qti21.model.xml.AssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) File(java.io.File)

Example 2 with QItemTypeDAO

use of org.olat.modules.qpool.manager.QItemTypeDAO in project OpenOLAT by OpenOLAT.

the class QTI12To21Converter method convertItem.

/**
 * @param item
 * @return The name of the assesssmentItem file
 */
private boolean convertItem(QuestionItemImpl convertedQuestion, Item item) {
    QItemTypeDAO qItemTypeDao = CoreSpringFactory.getImpl(QItemTypeDAO.class);
    AssessmentItemBuilder itemBuilder = null;
    int questionType = item.getQuestion().getType();
    switch(questionType) {
        case Question.TYPE_SC:
            itemBuilder = convertSingleChoice(item);
            convertedQuestion.setType(qItemTypeDao.loadByType(QuestionType.SC.name()));
            break;
        case Question.TYPE_MC:
            itemBuilder = convertMultipleChoice(item);
            convertedQuestion.setType(qItemTypeDao.loadByType(QuestionType.MC.name()));
            break;
        case Question.TYPE_KPRIM:
            itemBuilder = convertKPrim(item);
            convertedQuestion.setType(qItemTypeDao.loadByType(QuestionType.KPRIM.name()));
            break;
        case Question.TYPE_FIB:
            itemBuilder = convertFIB(item);
            convertedQuestion.setType(qItemTypeDao.loadByType(QuestionType.FIB.name()));
            break;
        case Question.TYPE_ESSAY:
            itemBuilder = convertEssay(item);
            convertedQuestion.setType(qItemTypeDao.loadByType(QuestionType.ESSAY.name()));
            break;
    }
    if (itemBuilder != null) {
        itemBuilder.build();
        AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
        String itemId = IdentifierGenerator.newAsString(itemBuilder.getQuestionType().getPrefix());
        File itemFile = new File(unzippedDirRoot, itemId + ".xml");
        persistAssessmentObject(itemFile, assessmentItem);
        appendResourceAndMetadata(item, itemBuilder, itemFile);
        convertedQuestion.setRootFilename(itemFile.getName());
        return true;
    }
    return false;
}
Also used : QItemTypeDAO(org.olat.modules.qpool.manager.QItemTypeDAO) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) AssessmentItemBuilder(org.olat.ims.qti21.model.xml.AssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) File(java.io.File)

Aggregations

File (java.io.File)2 AssessmentItemBuilder (org.olat.ims.qti21.model.xml.AssessmentItemBuilder)2 EssayAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)2 FIBAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder)2 KPrimAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder)2 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)2 SimpleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder)2 SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)2 QItemTypeDAO (org.olat.modules.qpool.manager.QItemTypeDAO)2 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)2