Search in sources :

Example 11 with FIBAssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder in project OpenOLAT by OpenOLAT.

the class AssessmentItemEditorController method initFIBEditors.

private AssessmentItemBuilder initFIBEditors(UserRequest ureq, QTI21QuestionType preferedType, AssessmentItem item) {
    FIBAssessmentItemBuilder fibItemBuilder = new FIBAssessmentItemBuilder(item, qtiService.qtiSerializer());
    itemEditor = new FIBEditorController(ureq, getWindowControl(), preferedType, fibItemBuilder, rootDirectory, rootContainer, itemFile, restrictedEdit, readOnly);
    listenTo(itemEditor);
    scoreEditor = new FIBScoreController(ureq, getWindowControl(), fibItemBuilder, itemRef, restrictedEdit, readOnly);
    listenTo(scoreEditor);
    feedbackEditor = new FeedbacksEditorController(ureq, getWindowControl(), fibItemBuilder, rootDirectory, rootContainer, itemFile, FeedbacksEnabler.standardFeedbacks(), restrictedEdit, readOnly);
    listenTo(feedbackEditor);
    tabbedPane.addTab(translate("form.fib"), itemEditor);
    tabbedPane.addTab(translate("form.score"), scoreEditor);
    tabbedPane.addTab(translate("form.feedback"), feedbackEditor);
    return fibItemBuilder;
}
Also used : FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) FIBScoreController(org.olat.ims.qti21.ui.editor.interactions.FIBScoreController) FIBEditorController(org.olat.ims.qti21.ui.editor.interactions.FIBEditorController)

Example 12 with FIBAssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder in project OpenOLAT by OpenOLAT.

the class QTI12To21Converter method convertFIB.

private AssessmentItemBuilder convertFIB(Item item) {
    FIBAssessmentItemBuilder itemBuilder = new FIBAssessmentItemBuilder("Gap text", EntryType.text, qtiSerializer);
    itemBuilder.setQuestion("");
    itemBuilder.clearTextEntries();
    convertItemBasics(item, itemBuilder);
    Question question = item.getQuestion();
    boolean singleCorrect = question.isSingleCorrect();
    if (singleCorrect) {
        itemBuilder.setScoreEvaluationMode(ScoreEvaluation.allCorrectAnswers);
    } else {
        itemBuilder.setScoreEvaluationMode(ScoreEvaluation.perAnswer);
    }
    itemBuilder.getMinScoreBuilder().setScore(new Double(question.getMinValue()));
    itemBuilder.getMaxScoreBuilder().setScore(new Double(question.getMaxValue()));
    List<Response> responses = question.getResponses();
    StringBuilder sb = new StringBuilder();
    for (Response response : responses) {
        if (response instanceof FIBResponse) {
            FIBResponse gap = (FIBResponse) response;
            if (FIBResponse.TYPE_BLANK.equals(gap.getType())) {
                String responseId = itemBuilder.generateResponseIdentifier();
                StringBuilder entryString = new StringBuilder();
                entryString.append(" <textentryinteraction responseidentifier=\"").append(responseId).append("\"");
                TextEntry entry = itemBuilder.createTextEntry(responseId);
                entry.setCaseSensitive("Yes".equals(gap.getCaseSensitive()));
                if (gap.getMaxLength() > 0) {
                    entry.setExpectedLength(gap.getMaxLength());
                    entryString.append(" expectedlength=\"").append(gap.getMaxLength()).append("\"");
                } else if (gap.getSize() > 0) {
                    entry.setExpectedLength(gap.getSize());
                    entryString.append(" expectedlength=\"").append(gap.getSize()).append("\"");
                }
                parseAlternatives(gap.getCorrectBlank(), gap.getPoints(), entry);
                entryString.append("></textentryinteraction>");
                sb.append(entryString);
            } else if (FIBResponse.TYPE_CONTENT.equals(gap.getType())) {
                Material text = gap.getContent();
                String htmltext = text.renderAsHtmlForEditor();
                htmltext = blockedHtml(htmltext);
                sb.append(htmltext);
            }
        }
    }
    String fib = "<div>" + sb.toString() + "</div>";
    itemBuilder.setQuestion(fib);
    return itemBuilder;
}
Also used : FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) ChoiceResponse(org.olat.ims.qti.editor.beecom.objects.ChoiceResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question) Material(org.olat.ims.qti.editor.beecom.objects.Material) TextEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry)

Example 13 with FIBAssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder in project OpenOLAT by OpenOLAT.

the class CSVToAssessmentItemConverter method processChoice_fib.

private void processChoice_fib(String[] parts, FIBAssessmentItemBuilder fibBuilder) {
    String firstPart = parts[0].toLowerCase();
    if ("text".equals(firstPart) || "texte".equals(firstPart)) {
        String text = parts[1];
        if (StringHelper.containsNonWhitespace(fibBuilder.getQuestion())) {
            fibBuilder.setQuestion(fibBuilder.getQuestion() + " " + text);
        } else {
            fibBuilder.setQuestion(text);
        }
    } else {
        double score = parseFloat(parts[0], 1.0f);
        String correctBlank = parts[1];
        String responseId = fibBuilder.generateResponseIdentifier();
        TextEntry textEntry = fibBuilder.createTextEntry(responseId);
        parseAlternatives(correctBlank, score, textEntry);
        if (parts.length > 2) {
            String sizes = parts[2];
            String[] sizeArr = sizes.split(",");
            if (sizeArr.length >= 2) {
                int size = Integer.parseInt(sizeArr[0]);
                textEntry.setExpectedLength(size);
            }
        }
        String entry = " <textEntryInteraction responseIdentifier=\"" + responseId + "\"/>";
        fibBuilder.setQuestion(fibBuilder.getQuestion() + " " + entry);
    }
}
Also used : TextEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry)

Example 14 with FIBAssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder 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 15 with FIBAssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder 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)

Aggregations

FIBAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder)14 EssayAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)8 KPrimAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder)8 MatchAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder)8 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)8 SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)8 AssessmentItemBuilder (org.olat.ims.qti21.model.xml.AssessmentItemBuilder)6 Translator (org.olat.core.gui.translator.Translator)4 DrawingAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)4 TextEntry (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry)4 HotspotAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder)4 SimpleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)4 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)4 HottextAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder)3 UploadAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder)3 File (java.io.File)2 Test (org.junit.Test)2 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)2 TreeDropEvent (org.olat.core.gui.components.tree.TreeDropEvent)2