Search in sources :

Example 1 with StatisticChoiceOption

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

the class SeriesFactory method getSingleChoice.

public Series getSingleChoice(Item item) {
    List<StatisticChoiceOption> statisticResponses = qtiStatisticsManager.getNumOfAnswersPerSingleChoiceAnswerOption(item, resourceResult.getSearchParams());
    String mediaBaseURL = resourceResult.getMediaBaseURL();
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    int i = 0;
    long numOfResults = 0;
    BarSeries d1 = new BarSeries();
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (StatisticChoiceOption statisticResponse : statisticResponses) {
        Response response = statisticResponse.getResponse();
        double ans_count = statisticResponse.getCount();
        numOfResults += statisticResponse.getCount();
        Float points;
        String cssColor;
        if (survey) {
            points = null;
            cssColor = "bar_default";
        } else {
            points = response.getPoints();
            cssColor = response.isCorrect() ? "bar_green" : "bar_red";
        }
        String label = Integer.toString(++i);
        d1.add(ans_count, label, cssColor);
        String text = response.getContent().renderAsHtml(mediaBaseURL);
        responseInfos.add(new ResponseInfos(label, text, points, response.isCorrect(), survey, false));
    }
    if (numOfResults != numOfParticipants) {
        long notAnswered = numOfParticipants - numOfResults;
        if (notAnswered > 0) {
            String label = Integer.toString(++i);
            String text = translate("user.not.answer");
            responseInfos.add(new ResponseInfos(label, text, null, false, survey, false));
            d1.add(notAnswered, label, "bar_grey");
        }
    }
    List<BarSeries> serieList = Collections.singletonList(d1);
    Series series = new Series(serieList, responseInfos, numOfParticipants, false);
    series.setChartType(BAR_CORRECT);
    series.setItemCss(getCssClass(item));
    return series;
}
Also used : StatisticChoiceOption(org.olat.ims.qti.statistics.model.StatisticChoiceOption) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) Response(org.olat.ims.qti.editor.beecom.objects.Response) BarSeries(org.olat.core.gui.components.chart.BarSeries)

Example 2 with StatisticChoiceOption

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

the class SeriesFactory method getSingleChoice.

public Series getSingleChoice(Item item) {
    List<StatisticChoiceOption> statisticResponses = qtiStatisticsManager.getNumOfAnswersPerSingleChoiceAnswerOption(item, resourceResult.getSearchParams());
    String mediaBaseURL = resourceResult.getMediaBaseURL();
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    int i = 0;
    long numOfResults = 0;
    BarSeries d1 = new BarSeries();
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (StatisticChoiceOption statisticResponse : statisticResponses) {
        Response response = statisticResponse.getResponse();
        double ans_count = statisticResponse.getCount();
        numOfResults += statisticResponse.getCount();
        Float points;
        String cssColor;
        if (survey) {
            points = null;
            cssColor = "bar_default";
        } else {
            points = response.getPoints();
            cssColor = response.isCorrect() ? "bar_green" : "bar_red";
        }
        String label = Integer.toString(++i);
        d1.add(ans_count, label, cssColor);
        String text = response.getContent().renderAsHtml(mediaBaseURL);
        responseInfos.add(new ResponseInfos(label, text, points, response.isCorrect(), survey, false));
    }
    if (numOfResults != numOfParticipants) {
        long notAnswered = numOfParticipants - numOfResults;
        if (notAnswered > 0) {
            String label = Integer.toString(++i);
            String text = translate("user.not.answer");
            responseInfos.add(new ResponseInfos(label, text, null, false, survey, false));
            d1.add(notAnswered, label, "bar_grey");
        }
    }
    List<BarSeries> serieList = Collections.singletonList(d1);
    Series series = new Series(serieList, responseInfos, numOfParticipants, false);
    series.setChartType(BAR_CORRECT);
    series.setItemCss(getCssClass(item));
    return series;
}
Also used : StatisticChoiceOption(org.olat.ims.qti.statistics.model.StatisticChoiceOption) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) Response(org.olat.ims.qti.editor.beecom.objects.Response) BarSeries(org.olat.core.gui.components.chart.BarSeries)

Example 3 with StatisticChoiceOption

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

the class QTIStatisticsManagerImpl method getNumOfRightAnsweredMultipleChoice.

/**
 * calculates the percentage of participants that answered a answer option
 * correctly.<br>
 * Number at index 0 = answer option 1, Number at index 1 = answer option 2,
 * etc.
 *
 * @param item
 * @param numberOfParticipants
 * @param olatResource
 * @param olatResourceDetail
 * @return
 */
@Override
public List<StatisticChoiceOption> getNumOfRightAnsweredMultipleChoice(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
    List<Response> responses = item.getQuestion().getResponses();
    List<StatisticChoiceOption> percentageRightAnswered = new ArrayList<StatisticChoiceOption>();
    for (Response response : responses) {
        String answerIdent = response.getIdent();
        long num = 0;
        for (StatisticAnswerOption answerToNumber : answerToNumberList) {
            String answer = answerToNumber.getAnswer();
            if (answer.indexOf(answerIdent) >= 0) {
                num += answerToNumber.getCount();
            }
        }
        percentageRightAnswered.add(new StatisticChoiceOption(response, num));
    }
    return percentageRightAnswered;
}
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 4 with StatisticChoiceOption

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

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 5 with StatisticChoiceOption

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

the class QTIStatisticsManagerImpl method getNumOfRightAnsweredMultipleChoice.

/**
 * calculates the percentage of participants that answered a answer option
 * correctly.<br>
 * Number at index 0 = answer option 1, Number at index 1 = answer option 2,
 * etc.
 *
 * @param item
 * @param numberOfParticipants
 * @param olatResource
 * @param olatResourceDetail
 * @return
 */
@Override
public List<StatisticChoiceOption> getNumOfRightAnsweredMultipleChoice(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
    List<Response> responses = item.getQuestion().getResponses();
    List<StatisticChoiceOption> percentageRightAnswered = new ArrayList<StatisticChoiceOption>();
    for (Response response : responses) {
        String answerIdent = response.getIdent();
        long num = 0;
        for (StatisticAnswerOption answerToNumber : answerToNumberList) {
            String answer = answerToNumber.getAnswer();
            if (answer.indexOf(answerIdent) >= 0) {
                num += answerToNumber.getCount();
            }
        }
        percentageRightAnswered.add(new StatisticChoiceOption(response, num));
    }
    return percentageRightAnswered;
}
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)

Aggregations

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