Search in sources :

Example 1 with TextEntry

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

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)

Example 2 with TextEntry

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

the class TextEntryInteractionsStatisticsController method getFIB.

private Series getFIB() {
    List<AbstractTextEntryInteractionStatistics> processedAnswers = qtiStatisticsManager.getTextEntryInteractionsStatistic(itemRef.getIdentifier().toString(), assessmentItem, interactions, resourceResult.getSearchParams());
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    int i = 0;
    String cssColor = survey ? "bar_default" : "bar_green";
    String color = survey ? null : "green";
    BarSeries d1 = new BarSeries(cssColor, color, null);
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (AbstractTextEntryInteractionStatistics entry : processedAnswers) {
        String label = Integer.toString(++i);
        String answerString = entry.getCorrectResponse();
        d1.add(entry.getNumOfCorrect(), label, cssColor);
        StringBuilder text = new StringBuilder();
        text.append(answerString);
        if (entry instanceof TextEntryInteractionStatistics) {
            TextEntryInteractionStatistics textEntry = (TextEntryInteractionStatistics) entry;
            if (textEntry.getAlternatives().size() > 1) {
                text.append(" [");
                for (int j = 1; j < textEntry.getAlternatives().size(); j++) {
                    if (j > 1)
                        text.append(", ");
                    text.append(textEntry.getAlternatives().get(j));
                }
                text.append("]");
            }
        }
        Float score = entry.getPoints() == null ? null : entry.getPoints().floatValue();
        responseInfos.add(new ResponseInfos(label, text.toString(), entry.getWrongAnswers(), score, true, survey, false));
    }
    List<BarSeries> serieList = Collections.singletonList(d1);
    Series series = new Series(serieList, responseInfos, numOfParticipants, false);
    series.setChartType(SeriesFactory.BAR_ANSWERED);
    series.setItemCss("o_mi_qtifib");
    return series;
}
Also used : ArrayList(java.util.ArrayList) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) BarSeries(org.olat.core.gui.components.chart.BarSeries) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos)

Example 3 with TextEntry

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

the class FIBAssessmentItemBuilder method buildResponseAndOutcomeDeclarations.

@Override
protected void buildResponseAndOutcomeDeclarations() {
    List<ResponseDeclaration> responseDeclarations = assessmentItem.getResponseDeclarations();
    /*
		<responseDeclaration identifier="RESPONSE_1" cardinality="single" baseType="string">
			<correctResponse>
				<value>
					Gap
				</value>
			</correctResponse>
			<mapping defaultValue="0">
				<mapEntry mapKey="Gap" mappedValue="2" />
				<mapEntry mapKey="gap1" mappedValue="2" />
				<mapEntry mapKey="gap2" mappedValue="1" />
			</mapping>
		</responseDeclaration>
		*/
    for (Map.Entry<String, AbstractEntry> textEntryEntry : responseIdentifierToTextEntry.entrySet()) {
        AbstractEntry entry = textEntryEntry.getValue();
        if (entry instanceof TextEntry) {
            TextEntry textEntry = (TextEntry) entry;
            if (textEntry.getSolution() != null) {
                Double score = -1.0d;
                if (scoreEvaluation == ScoreEvaluation.perAnswer) {
                    score = textEntry.getScore();
                }
                ResponseDeclaration responseDeclaration = createTextEntryResponseDeclaration(assessmentItem, textEntry.getResponseIdentifier(), textEntry.getSolution(), score, textEntry.isCaseSensitive(), textEntry.getAlternatives());
                responseDeclarations.add(responseDeclaration);
            }
        } else if (entry instanceof NumericalEntry) {
            NumericalEntry textEntry = (NumericalEntry) entry;
            if (textEntry.getSolution() != null) {
                ResponseDeclaration responseDeclaration = createNumericalEntryResponseDeclaration(assessmentItem, textEntry.getResponseIdentifier(), textEntry.getSolution());
                responseDeclarations.add(responseDeclaration);
            }
        }
    }
}
Also used : 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) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with TextEntry

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

the class FIBAssessmentItemBuilder method buildResponseAndOutcomeDeclarations.

@Override
protected void buildResponseAndOutcomeDeclarations() {
    List<ResponseDeclaration> responseDeclarations = assessmentItem.getResponseDeclarations();
    /*
		<responseDeclaration identifier="RESPONSE_1" cardinality="single" baseType="string">
			<correctResponse>
				<value>
					Gap
				</value>
			</correctResponse>
			<mapping defaultValue="0">
				<mapEntry mapKey="Gap" mappedValue="2" />
				<mapEntry mapKey="gap1" mappedValue="2" />
				<mapEntry mapKey="gap2" mappedValue="1" />
			</mapping>
		</responseDeclaration>
		*/
    for (Map.Entry<String, AbstractEntry> textEntryEntry : responseIdentifierToTextEntry.entrySet()) {
        AbstractEntry entry = textEntryEntry.getValue();
        if (entry instanceof TextEntry) {
            TextEntry textEntry = (TextEntry) entry;
            if (textEntry.getSolution() != null) {
                Double score = -1.0d;
                if (scoreEvaluation == ScoreEvaluation.perAnswer) {
                    score = textEntry.getScore();
                }
                ResponseDeclaration responseDeclaration = createTextEntryResponseDeclaration(assessmentItem, textEntry.getResponseIdentifier(), textEntry.getSolution(), score, textEntry.isCaseSensitive(), textEntry.getAlternatives());
                responseDeclarations.add(responseDeclaration);
            }
        } else if (entry instanceof NumericalEntry) {
            NumericalEntry textEntry = (NumericalEntry) entry;
            if (textEntry.getSolution() != null) {
                ResponseDeclaration responseDeclaration = createNumericalEntryResponseDeclaration(assessmentItem, textEntry.getResponseIdentifier(), textEntry.getSolution());
                responseDeclarations.add(responseDeclaration);
            }
        }
    }
}
Also used : 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) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with TextEntry

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

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)

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