Search in sources :

Example 56 with AssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder in project openolat by klemens.

the class QTI12To21Converter method appendResourceAndMetadata.

private void appendResourceAndMetadata(Item item, AssessmentItemBuilder itemBuilder, File itemFile) {
    manifest.appendAssessmentItem(itemFile.getName());
    ManifestMetadataBuilder metadata = manifest.getResourceBuilderByHref(itemFile.getName());
    metadata.setTechnicalFormat(ManifestBuilder.ASSESSMENTITEM_MIMETYPE);
    metadata.setQtiMetadataInteractionTypes(itemBuilder.getInteractionNames());
    metadata.setOpenOLATMetadataQuestionType(itemBuilder.getQuestionType().getPrefix());
    metadata.setTitle(item.getTitle(), locale.getLanguage());
    metadata.setDescription(item.getObjectives(), locale.getLanguage());
}
Also used : ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)

Example 57 with AssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder in project openolat by klemens.

the class QTI21QPoolServiceProvider method createItem.

public QuestionItem createItem(Identity identity, QTI21QuestionType type, String title, Locale locale) {
    AssessmentItemBuilder itemBuilder = null;
    Translator translator = Util.createPackageTranslator(AssessmentTestComposerController.class, locale);
    switch(type) {
        case sc:
            itemBuilder = new SingleChoiceAssessmentItemBuilder(translator.translate("new.sc"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case mc:
            itemBuilder = new MultipleChoiceAssessmentItemBuilder(translator.translate("new.mc"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case kprim:
            itemBuilder = new KPrimAssessmentItemBuilder(translator.translate("new.kprim"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case match:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_MATRIX, qtiService.qtiSerializer());
            break;
        case matchdraganddrop:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_DRAG_AND_DROP, qtiService.qtiSerializer());
            break;
        case matchtruefalse:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_TRUE_FALSE, translator.translate("match.unanswered"), translator.translate("match.true"), translator.translate("match.false"), qtiService.qtiSerializer());
            break;
        case fib:
            itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib"), EntryType.text, qtiService.qtiSerializer());
            break;
        case numerical:
            itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib.numerical"), EntryType.numerical, qtiService.qtiSerializer());
            break;
        case essay:
            itemBuilder = new EssayAssessmentItemBuilder(translator.translate("new.essay"), qtiService.qtiSerializer());
            break;
        case upload:
            itemBuilder = new UploadAssessmentItemBuilder(translator.translate("new.upload"), qtiService.qtiSerializer());
            break;
        case drawing:
            itemBuilder = new DrawingAssessmentItemBuilder(translator.translate("new.drawing"), qtiService.qtiSerializer());
            break;
        case hotspot:
            itemBuilder = new HotspotAssessmentItemBuilder(translator.translate("new.hotspot"), qtiService.qtiSerializer());
            break;
        case hottext:
            itemBuilder = new HottextAssessmentItemBuilder(translator.translate("new.hottext"), translator.translate("new.hottext.start"), translator.translate("new.hottext.text"), qtiService.qtiSerializer());
            break;
        default:
            return null;
    }
    AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
    assessmentItem.setLabel(title);
    assessmentItem.setTitle(title);
    AssessmentItemMetadata itemMetadata = new AssessmentItemMetadata();
    itemMetadata.setQuestionType(type);
    QTI21ImportProcessor processor = new QTI21ImportProcessor(identity, locale);
    QuestionItemImpl qitem = processor.processItem(assessmentItem, "", null, "OpenOLAT", Settings.getVersion(), itemMetadata);
    VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
    VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
    File itemFile = ((LocalImpl) leaf).getBasefile();
    qtiService.persistAssessmentObject(itemFile, assessmentItem);
    // create imsmanifest
    ManifestBuilder manifest = ManifestBuilder.createAssessmentItemBuilder();
    manifest.appendAssessmentItem(itemFile.getName());
    manifest.write(new File(itemFile.getParentFile(), "imsmanifest.xml"));
    return qitem;
}
Also used : HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ManifestBuilder(org.olat.ims.qti21.model.xml.ManifestBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) 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) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) Translator(org.olat.core.gui.translator.Translator) AssessmentItemMetadata(org.olat.ims.qti21.model.xml.AssessmentItemMetadata) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) LocalImpl(org.olat.core.util.vfs.LocalImpl) File(java.io.File) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)

Example 58 with AssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder in project openolat by klemens.

the class CSVToAssessmentItemConverter method processHint.

private void processHint(String[] parts) {
    if (currentItem == null || parts.length < 2)
        return;
    String feedback = parts[1];
    if (StringHelper.containsNonWhitespace(feedback)) {
        AssessmentItemBuilder itemBuilder = currentItem.getItemBuilder();
        itemBuilder.createHint().setText(feedback);
    }
}
Also used : SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) 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)

Example 59 with AssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder in project openolat by klemens.

the class CSVToAssessmentItemConverter method processPoints.

private void processPoints(String[] parts) {
    if (currentItem == null)
        return;
    double points = parseFloat(parts[1], 1.0f);
    AssessmentItemBuilder itemBuilder = currentItem.getItemBuilder();
    if (itemBuilder instanceof SimpleChoiceAssessmentItemBuilder) {
        itemBuilder.setMinScore(0.0d);
        itemBuilder.setMaxScore(points);
    } else if (itemBuilder instanceof FIBAssessmentItemBuilder) {
        itemBuilder.setMinScore(0.0d);
        itemBuilder.setMaxScore(points);
    } else if (itemBuilder instanceof KPrimAssessmentItemBuilder) {
        itemBuilder.setMinScore(0.0d);
        itemBuilder.setMaxScore(points);
    } else if (itemBuilder instanceof MatchAssessmentItemBuilder) {
        itemBuilder.setMinScore(0.0d);
        itemBuilder.setMaxScore(points);
    }
}
Also used : SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) 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) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder)

Example 60 with AssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder in project openolat by klemens.

the class CSVToAssessmentItemConverter method processQuestion.

private void processQuestion(String[] parts) {
    if (currentItem == null)
        return;
    String content = parts[1];
    if (StringHelper.containsNonWhitespace(content)) {
        AssessmentItemBuilder itemBuilder = currentItem.getItemBuilder();
        itemBuilder.setQuestion("<p>" + content + "</p>");
    }
}
Also used : SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) 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)

Aggregations

EssayAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)28 FIBAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder)28 KPrimAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder)28 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)28 SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)28 MatchAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder)26 AssessmentItemBuilder (org.olat.ims.qti21.model.xml.AssessmentItemBuilder)24 SimpleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder)18 EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)14 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)12 EssayResponse (org.olat.ims.qti.editor.beecom.objects.EssayResponse)12 Question (org.olat.ims.qti.editor.beecom.objects.Question)12 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)12 ChoiceResponse (org.olat.ims.qti.editor.beecom.objects.ChoiceResponse)10 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)10 Response (org.olat.ims.qti.editor.beecom.objects.Response)10 File (java.io.File)8 HashMap (java.util.HashMap)8 DrawingAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)8 HotspotAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder)8