Search in sources :

Example 1 with NumericalInputInteractionStatistics

use of org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics in project OpenOLAT by OpenOLAT.

the class QTI21StatisticsManagerImpl method getNumericalInputInteractionSettings.

private NumericalInputInteractionStatistics getNumericalInputInteractionSettings(Identifier responseIdentifier, ResponseDeclaration responseDeclaration, AssessmentItem item) {
    NumericalEntry numericalEntry = new NumericalEntry(responseIdentifier);
    FIBAssessmentItemBuilder.extractNumericalEntrySettings(item, numericalEntry, responseDeclaration, new AtomicInteger(), new DoubleAdder());
    String correctResponse = "";
    Double solution = numericalEntry.getSolution();
    if (numericalEntry.getSolution() != null) {
        correctResponse = solution.toString();
    }
    double points = Double.NaN;
    if (numericalEntry.getScore() == null) {
        // all score
        points = 0.0d;
    } else {
        points = numericalEntry.getScore().doubleValue();
    }
    return new NumericalInputInteractionStatistics(responseIdentifier, correctResponse, solution, numericalEntry.getToleranceMode(), numericalEntry.getLowerTolerance(), numericalEntry.getUpperTolerance(), points);
}
Also used : DoubleAdder(java.util.concurrent.atomic.DoubleAdder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NumericalEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry) NumericalInputInteractionStatistics(org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics)

Example 2 with NumericalInputInteractionStatistics

use of org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics in project openolat by klemens.

the class QTI21StatisticsManagerImpl method getTextEntryInteractionsStatistic.

@Override
public List<AbstractTextEntryInteractionStatistics> getTextEntryInteractionsStatistic(String itemRefIdent, AssessmentItem item, List<TextEntryInteraction> interactions, QTI21StatisticSearchParams searchParams) {
    List<AbstractTextEntryInteractionStatistics> options = new ArrayList<>();
    Map<String, AbstractTextEntryInteractionStatistics> optionMap = new HashMap<>();
    for (TextEntryInteraction interaction : interactions) {
        Identifier responseIdentifier = interaction.getResponseIdentifier();
        ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
        if (responseDeclaration.hasBaseType(BaseType.STRING)) {
            TextEntryInteractionStatistics stats = getTextEntryInteractionSettings(responseIdentifier, responseDeclaration);
            optionMap.put(responseIdentifier.toString(), stats);
            options.add(stats);
        } else if (responseDeclaration.hasBaseType(BaseType.FLOAT)) {
            NumericalInputInteractionStatistics stats = getNumericalInputInteractionSettings(responseIdentifier, responseDeclaration, item);
            optionMap.put(responseIdentifier.toString(), stats);
            options.add(stats);
        }
    }
    for (TextEntryInteraction interaction : interactions) {
        String responseIdentifier = interaction.getResponseIdentifier().toString();
        List<RawData> datas = getRawDatas(itemRefIdent, responseIdentifier, searchParams);
        for (RawData data : datas) {
            Long count = data.getCount();
            if (count != null && count.longValue() > 0) {
                AbstractTextEntryInteractionStatistics stats = optionMap.get(responseIdentifier);
                String response = data.getStringuifiedResponse();
                if (response != null && response.length() >= 2 && response.startsWith("[") && response.endsWith("]")) {
                    response = response.substring(1, response.length() - 1);
                }
                if (stats.matchResponse(response)) {
                    stats.addCorrect(count.longValue());
                } else {
                    stats.addIncorrect(count.longValue());
                    stats.addWrongResponses(response);
                }
            }
        }
    }
    return options;
}
Also used : TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) NumericalInputInteractionStatistics(org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 3 with NumericalInputInteractionStatistics

use of org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics in project OpenOLAT by OpenOLAT.

the class QTI21StatisticsManagerImpl method getTextEntryInteractionsStatistic.

@Override
public List<AbstractTextEntryInteractionStatistics> getTextEntryInteractionsStatistic(String itemRefIdent, AssessmentItem item, List<TextEntryInteraction> interactions, QTI21StatisticSearchParams searchParams) {
    List<AbstractTextEntryInteractionStatistics> options = new ArrayList<>();
    Map<String, AbstractTextEntryInteractionStatistics> optionMap = new HashMap<>();
    for (TextEntryInteraction interaction : interactions) {
        Identifier responseIdentifier = interaction.getResponseIdentifier();
        ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
        if (responseDeclaration.hasBaseType(BaseType.STRING)) {
            TextEntryInteractionStatistics stats = getTextEntryInteractionSettings(responseIdentifier, responseDeclaration);
            optionMap.put(responseIdentifier.toString(), stats);
            options.add(stats);
        } else if (responseDeclaration.hasBaseType(BaseType.FLOAT)) {
            NumericalInputInteractionStatistics stats = getNumericalInputInteractionSettings(responseIdentifier, responseDeclaration, item);
            optionMap.put(responseIdentifier.toString(), stats);
            options.add(stats);
        }
    }
    for (TextEntryInteraction interaction : interactions) {
        String responseIdentifier = interaction.getResponseIdentifier().toString();
        List<RawData> datas = getRawDatas(itemRefIdent, responseIdentifier, searchParams);
        for (RawData data : datas) {
            Long count = data.getCount();
            if (count != null && count.longValue() > 0) {
                AbstractTextEntryInteractionStatistics stats = optionMap.get(responseIdentifier);
                String response = data.getStringuifiedResponse();
                if (response != null && response.length() >= 2 && response.startsWith("[") && response.endsWith("]")) {
                    response = response.substring(1, response.length() - 1);
                }
                if (stats.matchResponse(response)) {
                    stats.addCorrect(count.longValue());
                } else {
                    stats.addIncorrect(count.longValue());
                    stats.addWrongResponses(response);
                }
            }
        }
    }
    return options;
}
Also used : TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) NumericalInputInteractionStatistics(org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 4 with NumericalInputInteractionStatistics

use of org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics in project openolat by klemens.

the class QTI21StatisticsManagerImpl method getNumericalInputInteractionSettings.

private NumericalInputInteractionStatistics getNumericalInputInteractionSettings(Identifier responseIdentifier, ResponseDeclaration responseDeclaration, AssessmentItem item) {
    NumericalEntry numericalEntry = new NumericalEntry(responseIdentifier);
    FIBAssessmentItemBuilder.extractNumericalEntrySettings(item, numericalEntry, responseDeclaration, new AtomicInteger(), new DoubleAdder());
    String correctResponse = "";
    Double solution = numericalEntry.getSolution();
    if (numericalEntry.getSolution() != null) {
        correctResponse = solution.toString();
    }
    double points = Double.NaN;
    if (numericalEntry.getScore() == null) {
        // all score
        points = 0.0d;
    } else {
        points = numericalEntry.getScore().doubleValue();
    }
    return new NumericalInputInteractionStatistics(responseIdentifier, correctResponse, solution, numericalEntry.getToleranceMode(), numericalEntry.getLowerTolerance(), numericalEntry.getUpperTolerance(), points);
}
Also used : DoubleAdder(java.util.concurrent.atomic.DoubleAdder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NumericalEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry) NumericalInputInteractionStatistics(org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics)

Aggregations

NumericalInputInteractionStatistics (org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 DoubleAdder (java.util.concurrent.atomic.DoubleAdder)2 AbstractTextEntryInteractionStatistics (org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics)2 TextEntryInteractionStatistics (org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics)2 NumericalEntry (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry)2 TextEntryInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction)2 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)2 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)2