Search in sources :

Example 1 with StatisticFIBOption

use of org.olat.ims.qti.statistics.model.StatisticFIBOption in project OpenOLAT by OpenOLAT.

the class SeriesFactory method getFIB.

public Series getFIB(Item item) {
    List<StatisticFIBOption> processedAnswers = qtiStatisticsManager.getStatisticAnswerOptionsFIB(item, resourceResult.getSearchParams());
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    boolean singleCorrectScore = item.getQuestion().getSingleCorrectScore() > 0.0f;
    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 (StatisticFIBOption entry : processedAnswers) {
        String label = Integer.toString(++i);
        String answerString = entry.getCorrectBlank();
        d1.add(entry.getNumOfCorrect(), label, cssColor);
        StringBuilder text = new StringBuilder();
        text.append(answerString);
        if (entry.getAlternatives().size() > 1) {
            text.append(" [");
            for (int j = 1; j < entry.getAlternatives().size(); j++) {
                if (j > 1)
                    text.append(", ");
                text.append(entry.getAlternatives().get(j));
            }
            text.append("]");
        }
        Float score = singleCorrectScore ? null : entry.getPoints();
        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(BAR_ANSWERED);
    series.setItemCss(getCssClass(item));
    return series;
}
Also used : ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) BarSeries(org.olat.core.gui.components.chart.BarSeries) StatisticFIBOption(org.olat.ims.qti.statistics.model.StatisticFIBOption)

Example 2 with StatisticFIBOption

use of org.olat.ims.qti.statistics.model.StatisticFIBOption in project openolat by klemens.

the class SeriesFactory method getFIB.

public Series getFIB(Item item) {
    List<StatisticFIBOption> processedAnswers = qtiStatisticsManager.getStatisticAnswerOptionsFIB(item, resourceResult.getSearchParams());
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    boolean singleCorrectScore = item.getQuestion().getSingleCorrectScore() > 0.0f;
    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 (StatisticFIBOption entry : processedAnswers) {
        String label = Integer.toString(++i);
        String answerString = entry.getCorrectBlank();
        d1.add(entry.getNumOfCorrect(), label, cssColor);
        StringBuilder text = new StringBuilder();
        text.append(answerString);
        if (entry.getAlternatives().size() > 1) {
            text.append(" [");
            for (int j = 1; j < entry.getAlternatives().size(); j++) {
                if (j > 1)
                    text.append(", ");
                text.append(entry.getAlternatives().get(j));
            }
            text.append("]");
        }
        Float score = singleCorrectScore ? null : entry.getPoints();
        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(BAR_ANSWERED);
    series.setItemCss(getCssClass(item));
    return series;
}
Also used : ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) BarSeries(org.olat.core.gui.components.chart.BarSeries) StatisticFIBOption(org.olat.ims.qti.statistics.model.StatisticFIBOption)

Example 3 with StatisticFIBOption

use of org.olat.ims.qti.statistics.model.StatisticFIBOption in project OpenOLAT by OpenOLAT.

the class QTIStatisticsManagerImpl method getStatisticAnswerOptionsFIB.

@Override
public List<StatisticFIBOption> getStatisticAnswerOptionsFIB(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticFIBOption> options = new ArrayList<>();
    Map<String, StatisticFIBOption> optionMap = new HashMap<>();
    boolean groupBy = true;
    List<Response> responses = item.getQuestion().getResponses();
    for (Response response : responses) {
        if (response instanceof FIBResponse) {
            FIBResponse fibResponse = (FIBResponse) response;
            if (FIBResponse.TYPE_BLANK.equals(fibResponse.getType())) {
                String ident = fibResponse.getIdent();
                String[] correctFIBs = fibResponse.getCorrectBlank().split(";");
                if (correctFIBs == null || correctFIBs.length == 0) {
                    continue;
                }
                StatisticFIBOption option = new StatisticFIBOption();
                option.setCorrectBlank(correctFIBs[0]);
                option.setAlternatives(Arrays.asList(correctFIBs));
                boolean caseSensitive = "Yes".equals(fibResponse.getCaseSensitive());
                groupBy &= !caseSensitive;
                option.setCaseSensitive(caseSensitive);
                option.setPoints(fibResponse.getPoints());
                options.add(option);
                optionMap.put(ident, option);
            }
        }
    }
    List<StatisticAnswerOption> answerOptions = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams, groupBy);
    for (StatisticAnswerOption answerOption : answerOptions) {
        long count = answerOption.getCount();
        String concatenedAnswer = answerOption.getAnswer();
        Map<String, String> parsedAnswerMap = QTIResultManager.parseResponseStrAnswers(concatenedAnswer);
        for (Map.Entry<String, String> parsedAnswerEntry : parsedAnswerMap.entrySet()) {
            String ident = parsedAnswerEntry.getKey();
            StatisticFIBOption option = optionMap.get(ident);
            if (option == null) {
                continue;
            }
            String text = parsedAnswerEntry.getValue();
            boolean correct;
            if (option.isCaseSensitive()) {
                correct = option.getAlternatives().contains(text);
            } else {
                correct = false;
                for (String alt : option.getAlternatives()) {
                    if (alt.equalsIgnoreCase(text)) {
                        correct = true;
                    }
                }
            }
            if (correct) {
                option.setNumOfCorrect(option.getNumOfCorrect() + count);
            } else {
                option.setNumOfIncorrect(option.getNumOfIncorrect() + count);
                option.getWrongAnswers().add(text);
            }
        }
    }
    return options;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) StatisticFIBOption(org.olat.ims.qti.statistics.model.StatisticFIBOption) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with StatisticFIBOption

use of org.olat.ims.qti.statistics.model.StatisticFIBOption in project openolat by klemens.

the class QTIStatisticsManagerImpl method getStatisticAnswerOptionsFIB.

@Override
public List<StatisticFIBOption> getStatisticAnswerOptionsFIB(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticFIBOption> options = new ArrayList<>();
    Map<String, StatisticFIBOption> optionMap = new HashMap<>();
    boolean groupBy = true;
    List<Response> responses = item.getQuestion().getResponses();
    for (Response response : responses) {
        if (response instanceof FIBResponse) {
            FIBResponse fibResponse = (FIBResponse) response;
            if (FIBResponse.TYPE_BLANK.equals(fibResponse.getType())) {
                String ident = fibResponse.getIdent();
                String[] correctFIBs = fibResponse.getCorrectBlank().split(";");
                if (correctFIBs == null || correctFIBs.length == 0) {
                    continue;
                }
                StatisticFIBOption option = new StatisticFIBOption();
                option.setCorrectBlank(correctFIBs[0]);
                option.setAlternatives(Arrays.asList(correctFIBs));
                boolean caseSensitive = "Yes".equals(fibResponse.getCaseSensitive());
                groupBy &= !caseSensitive;
                option.setCaseSensitive(caseSensitive);
                option.setPoints(fibResponse.getPoints());
                options.add(option);
                optionMap.put(ident, option);
            }
        }
    }
    List<StatisticAnswerOption> answerOptions = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams, groupBy);
    for (StatisticAnswerOption answerOption : answerOptions) {
        long count = answerOption.getCount();
        String concatenedAnswer = answerOption.getAnswer();
        Map<String, String> parsedAnswerMap = QTIResultManager.parseResponseStrAnswers(concatenedAnswer);
        for (Map.Entry<String, String> parsedAnswerEntry : parsedAnswerMap.entrySet()) {
            String ident = parsedAnswerEntry.getKey();
            StatisticFIBOption option = optionMap.get(ident);
            if (option == null) {
                continue;
            }
            String text = parsedAnswerEntry.getValue();
            boolean correct;
            if (option.isCaseSensitive()) {
                correct = option.getAlternatives().contains(text);
            } else {
                correct = false;
                for (String alt : option.getAlternatives()) {
                    if (alt.equalsIgnoreCase(text)) {
                        correct = true;
                    }
                }
            }
            if (correct) {
                option.setNumOfCorrect(option.getNumOfCorrect() + count);
            } else {
                option.setNumOfIncorrect(option.getNumOfIncorrect() + count);
                option.getWrongAnswers().add(text);
            }
        }
    }
    return options;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) StatisticFIBOption(org.olat.ims.qti.statistics.model.StatisticFIBOption) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)4 StatisticFIBOption (org.olat.ims.qti.statistics.model.StatisticFIBOption)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 BarSeries (org.olat.core.gui.components.chart.BarSeries)2 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)2 Response (org.olat.ims.qti.editor.beecom.objects.Response)2 StatisticAnswerOption (org.olat.ims.qti.statistics.model.StatisticAnswerOption)2 StatisticSurveyItemResponse (org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse)2