Search in sources :

Example 1 with TextEntryInteractionStatistics

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

the class QTI21StatisticsManagerImpl method getTextEntryInteractionSettings.

private TextEntryInteractionStatistics getTextEntryInteractionSettings(Identifier responseIdentifier, ResponseDeclaration responseDeclaration) {
    String correctResponse = null;
    boolean caseSensitive = true;
    double points = Double.NaN;
    List<String> alternatives = new ArrayList<>();
    List<MapEntry> mapEntries = responseDeclaration.getMapping().getMapEntries();
    for (MapEntry mapEntry : mapEntries) {
        SingleValue mapKey = mapEntry.getMapKey();
        if (mapKey instanceof StringValue) {
            String value = ((StringValue) mapKey).stringValue();
            if (correctResponse == null) {
                correctResponse = value;
                points = mapEntry.getMappedValue();
            } else {
                alternatives.add(value);
            }
        }
        caseSensitive &= mapEntry.getCaseSensitive();
    }
    if (points == -1.0d) {
        // all score
        points = 0.0d;
    }
    return new TextEntryInteractionStatistics(responseIdentifier, caseSensitive, correctResponse, alternatives, points);
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) ArrayList(java.util.ArrayList) StringValue(uk.ac.ed.ph.jqtiplus.value.StringValue) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics)

Example 2 with TextEntryInteractionStatistics

use of org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics 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 TextEntryInteractionStatistics

use of org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics 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 4 with TextEntryInteractionStatistics

use of org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics 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 5 with TextEntryInteractionStatistics

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

the class QTI21StatisticsManagerImpl method getTextEntryInteractionSettings.

private TextEntryInteractionStatistics getTextEntryInteractionSettings(Identifier responseIdentifier, ResponseDeclaration responseDeclaration) {
    String correctResponse = null;
    boolean caseSensitive = true;
    double points = Double.NaN;
    List<String> alternatives = new ArrayList<>();
    List<MapEntry> mapEntries = responseDeclaration.getMapping().getMapEntries();
    for (MapEntry mapEntry : mapEntries) {
        SingleValue mapKey = mapEntry.getMapKey();
        if (mapKey instanceof StringValue) {
            String value = ((StringValue) mapKey).stringValue();
            if (correctResponse == null) {
                correctResponse = value;
                points = mapEntry.getMappedValue();
            } else {
                alternatives.add(value);
            }
        }
        caseSensitive &= mapEntry.getCaseSensitive();
    }
    if (points == -1.0d) {
        // all score
        points = 0.0d;
    }
    return new TextEntryInteractionStatistics(responseIdentifier, caseSensitive, correctResponse, alternatives, points);
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) ArrayList(java.util.ArrayList) StringValue(uk.ac.ed.ph.jqtiplus.value.StringValue) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics)

Aggregations

ArrayList (java.util.ArrayList)6 AbstractTextEntryInteractionStatistics (org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics)6 TextEntryInteractionStatistics (org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics)6 HashMap (java.util.HashMap)2 BarSeries (org.olat.core.gui.components.chart.BarSeries)2 ResponseInfos (org.olat.ims.qti.statistics.ui.ResponseInfos)2 Series (org.olat.ims.qti.statistics.ui.Series)2 NumericalInputInteractionStatistics (org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics)2 TextEntryInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction)2 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)2 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)2 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)2 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)2 StringValue (uk.ac.ed.ph.jqtiplus.value.StringValue)2