Search in sources :

Example 11 with TextEntry

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

the class FIBEditorController method doGapEntry.

private void doGapEntry(UserRequest ureq, String responseIdentifier, String selectedText, String emptySolution, String type, boolean newEntry) {
    if (textEntrySettingsCtrl != null || numericalEntrySettingsCtrl != null)
        return;
    AbstractEntry interaction = itemBuilder.getEntry(responseIdentifier);
    if (interaction == null) {
        interaction = createEntry(responseIdentifier, selectedText, type, newEntry);
    } else if (StringHelper.containsNonWhitespace(selectedText)) {
        updateSolution(interaction, selectedText, emptySolution);
    }
    if (interaction instanceof TextEntry) {
        textEntrySettingsCtrl = new FIBTextEntrySettingsController(ureq, getWindowControl(), (TextEntry) interaction, restrictedEdit, readOnly);
        listenTo(textEntrySettingsCtrl);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), textEntrySettingsCtrl.getInitialComponent(), true, translate("title.add"));
        cmc.activate();
        listenTo(cmc);
    } else if (interaction instanceof NumericalEntry) {
        numericalEntrySettingsCtrl = new FIBNumericalEntrySettingsController(ureq, getWindowControl(), (NumericalEntry) interaction, restrictedEdit, readOnly);
        listenTo(numericalEntrySettingsCtrl);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), numericalEntrySettingsCtrl.getInitialComponent(), true, translate("title.add"));
        cmc.activate();
        listenTo(cmc);
    }
}
Also used : AbstractEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TextEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry) NumericalEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry)

Example 12 with TextEntry

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

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

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

the class FIBAssessmentItemBuilder method extractEntriesSettingsFromResponseDeclaration.

/**
 * We loop around the textEntryInteraction, search the responseDeclaration. responseDeclaration
 * of type string are gap text, of type float are numerical.
 */
public void extractEntriesSettingsFromResponseDeclaration() {
    DoubleAdder mappedScore = new DoubleAdder();
    AtomicInteger countAlternatives = new AtomicInteger(0);
    responseIdentifierToTextEntry = new HashMap<>();
    List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
    for (Interaction interaction : interactions) {
        if (interaction instanceof TextEntryInteraction && interaction.getResponseIdentifier() != null) {
            AbstractEntry entry = null;
            TextEntryInteraction textInteraction = (TextEntryInteraction) interaction;
            ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(interaction.getResponseIdentifier());
            if (responseDeclaration != null) {
                if (responseDeclaration.hasBaseType(BaseType.STRING) && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
                    TextEntry textEntry = new TextEntry(textInteraction);
                    extractTextEntrySettingsFromResponseDeclaration(textEntry, responseDeclaration, countAlternatives, mappedScore);
                    String marker = "responseIdentifier=\"" + interaction.getResponseIdentifier().toString() + "\"";
                    question = question.replace(marker, marker + " openolatType=\"string\"");
                    if (StringHelper.containsNonWhitespace(textEntry.getSolution())) {
                        question = question.replace(marker, marker + " data-qti-solution=\"" + escapeForDataQtiSolution(textEntry.getSolution()) + "\"");
                    }
                    entry = textEntry;
                } else if (responseDeclaration.hasBaseType(BaseType.FLOAT) && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
                    NumericalEntry numericalEntry = new NumericalEntry(textInteraction);
                    entry = numericalEntry;
                    extractNumericalEntrySettings(assessmentItem, numericalEntry, responseDeclaration, countAlternatives, mappedScore);
                    String marker = "responseIdentifier=\"" + interaction.getResponseIdentifier().toString() + "\"";
                    question = question.replace(marker, marker + " openolatType=\"float\"");
                    if (numericalEntry.getSolution() != null) {
                        question = question.replace(marker, marker + " data-qti-solution=\"" + Double.toString(numericalEntry.getSolution()) + "\"");
                    }
                }
            }
            if (entry != null) {
                responseIdentifierToTextEntry.put(interaction.getResponseIdentifier().toString(), entry);
            }
        }
    }
    boolean hasMapping = Math.abs(mappedScore.doubleValue() - (-1.0 * countAlternatives.get())) > 0.0001;
    scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
Also used : DoubleAdder(java.util.concurrent.atomic.DoubleAdder) AssessmentItemFactory.appendTextEntryInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendTextEntryInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AssessmentItemFactory.appendTextEntryInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendTextEntryInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) AssessmentItemFactory.createNumericalEntryResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createNumericalEntryResponseDeclaration) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createTextEntryResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createTextEntryResponseDeclaration)

Example 15 with TextEntry

use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry in project openolat by klemens.

the class CorrectResponsesUtil method getCorrectTextResponses.

public static final AbstractEntry getCorrectTextResponses(AssessmentItem assessmentItem, TextEntryInteraction interaction) {
    ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(interaction.getResponseIdentifier());
    if (responseDeclaration.hasBaseType(BaseType.STRING) && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
        TextEntry textEntry = new TextEntry(interaction);
        FIBAssessmentItemBuilder.extractTextEntrySettingsFromResponseDeclaration(textEntry, responseDeclaration, new AtomicInteger(), new DoubleAdder());
        return textEntry;
    } else if (responseDeclaration.hasBaseType(BaseType.FLOAT) && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
        NumericalEntry numericalEntry = new NumericalEntry(interaction);
        FIBAssessmentItemBuilder.extractNumericalEntrySettings(assessmentItem, numericalEntry, responseDeclaration, new AtomicInteger(), new DoubleAdder());
        return numericalEntry;
    }
    return null;
}
Also used : DoubleAdder(java.util.concurrent.atomic.DoubleAdder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TextEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) NumericalEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry)

Aggregations

TextEntry (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntry)10 NumericalEntry (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry)6 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 DoubleAdder (java.util.concurrent.atomic.DoubleAdder)4 AssessmentItemFactory.createNumericalEntryResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createNumericalEntryResponseDeclaration)4 AssessmentItemFactory.createTextEntryResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createTextEntryResponseDeclaration)4 AbstractEntry (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 BarSeries (org.olat.core.gui.components.chart.BarSeries)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)2 ChoiceResponse (org.olat.ims.qti.editor.beecom.objects.ChoiceResponse)2 EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)2 EssayResponse (org.olat.ims.qti.editor.beecom.objects.EssayResponse)2 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)2 Material (org.olat.ims.qti.editor.beecom.objects.Material)2 Question (org.olat.ims.qti.editor.beecom.objects.Question)2