Search in sources :

Example 6 with StatisticAnswerOption

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

the class QTIStatisticsManagerImpl method getNumOfAnswersPerSingleChoiceAnswerOption.

/**
 * calculates how many participants selected answer option 1 and/or option 2
 * and/or option 3...
 *
 * @param aQuestion
 * @param olatResource
 * @param olatResourceDetail
 * @return
 */
@Override
public List<StatisticChoiceOption> getNumOfAnswersPerSingleChoiceAnswerOption(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
    List<Response> answerOptions = item.getQuestion().getResponses();
    List<StatisticChoiceOption> numOfAnswersPerOption = new ArrayList<>();
    for (int i = 0; i < answerOptions.size(); i++) {
        Response response = answerOptions.get(i);
        String responseIdent = response.getIdent();
        long num = 0;
        for (StatisticAnswerOption answerToNumber : answerToNumberList) {
            String answer = answerToNumber.getAnswer();
            if (answer.indexOf(responseIdent) >= 0) {
                num += answerToNumber.getCount();
            }
        }
        numOfAnswersPerOption.add(new StatisticChoiceOption(response, num));
    }
    return numOfAnswersPerOption;
}
Also used : 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) StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) StatisticChoiceOption(org.olat.ims.qti.statistics.model.StatisticChoiceOption) ArrayList(java.util.ArrayList)

Example 7 with StatisticAnswerOption

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

the class QTIStatisticsManagerImpl method getNumbersInKPrim.

@Override
public List<StatisticKPrimOption> getNumbersInKPrim(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticAnswerOption> rawDatas = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
    List<Response> responses = item.getQuestion().getResponses();
    List<StatisticKPrimOption> kprimPoints = new ArrayList<>();
    for (Response response : responses) {
        String answerIdent = response.getIdent();
        boolean isCorrect = response.isCorrect();
        String rightFlag = answerIdent + ":" + (isCorrect ? "correct" : "wrong");
        String wrongFlag = answerIdent + ":" + (isCorrect ? "wrong" : "correct");
        long numCorrect = 0;
        long numIncorrect = 0;
        long numUnanswered = 0;
        for (StatisticAnswerOption rawData : rawDatas) {
            String answer = rawData.getAnswer();
            if (answer.indexOf(rightFlag) >= 0) {
                numCorrect += rawData.getCount();
            } else if (answer.indexOf(wrongFlag) >= 0) {
                numIncorrect += rawData.getCount();
            } else {
                numUnanswered += rawData.getCount();
            }
        }
        kprimPoints.add(new StatisticKPrimOption(response, numCorrect, numIncorrect, numUnanswered));
    }
    return kprimPoints;
}
Also used : 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) StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) StatisticKPrimOption(org.olat.ims.qti.statistics.model.StatisticKPrimOption) ArrayList(java.util.ArrayList)

Example 8 with StatisticAnswerOption

use of org.olat.ims.qti.statistics.model.StatisticAnswerOption 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 9 with StatisticAnswerOption

use of org.olat.ims.qti.statistics.model.StatisticAnswerOption 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)

Example 10 with StatisticAnswerOption

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

the class QTIStatisticsManagerImpl method getNumbersInKPrim.

@Override
public List<StatisticKPrimOption> getNumbersInKPrim(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticAnswerOption> rawDatas = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
    List<Response> responses = item.getQuestion().getResponses();
    List<StatisticKPrimOption> kprimPoints = new ArrayList<>();
    for (Response response : responses) {
        String answerIdent = response.getIdent();
        boolean isCorrect = response.isCorrect();
        String rightFlag = answerIdent + ":" + (isCorrect ? "correct" : "wrong");
        String wrongFlag = answerIdent + ":" + (isCorrect ? "wrong" : "correct");
        long numCorrect = 0;
        long numIncorrect = 0;
        long numUnanswered = 0;
        for (StatisticAnswerOption rawData : rawDatas) {
            String answer = rawData.getAnswer();
            if (answer.indexOf(rightFlag) >= 0) {
                numCorrect += rawData.getCount();
            } else if (answer.indexOf(wrongFlag) >= 0) {
                numIncorrect += rawData.getCount();
            } else {
                numUnanswered += rawData.getCount();
            }
        }
        kprimPoints.add(new StatisticKPrimOption(response, numCorrect, numIncorrect, numUnanswered));
    }
    return kprimPoints;
}
Also used : 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) StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) StatisticKPrimOption(org.olat.ims.qti.statistics.model.StatisticKPrimOption) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)10 StatisticAnswerOption (org.olat.ims.qti.statistics.model.StatisticAnswerOption)10 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)8 Response (org.olat.ims.qti.editor.beecom.objects.Response)8 StatisticSurveyItemResponse (org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse)8 StatisticChoiceOption (org.olat.ims.qti.statistics.model.StatisticChoiceOption)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 StatisticFIBOption (org.olat.ims.qti.statistics.model.StatisticFIBOption)2 StatisticKPrimOption (org.olat.ims.qti.statistics.model.StatisticKPrimOption)2