Search in sources :

Example 6 with ResponseInfos

use of org.olat.ims.qti.statistics.ui.ResponseInfos in project OpenOLAT by OpenOLAT.

the class ChoiceInteractionStatisticsController method getMultipleChoice.

private Series getMultipleChoice(StatisticsItem itemStats) {
    List<ChoiceStatistics> statisticResponses = getChoiceInteractionStatistics();
    BarSeries d1 = new BarSeries("bar_green", "green", translate("answer.correct"));
    BarSeries d2 = new BarSeries("bar_red", "red", translate("answer.false"));
    BarSeries d3 = new BarSeries("bar_grey", "grey", translate("answer.noanswer"));
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    int notAnswered = numOfParticipants - (itemStats == null ? 0 : itemStats.getNumOfResults());
    List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(assessmentItem, interaction);
    int i = 0;
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (ChoiceStatistics statisticResponse : statisticResponses) {
        Choice choice = statisticResponse.getChoice();
        String text = getAnswerText(choice);
        boolean correct = correctAnswers.contains(choice.getIdentifier());
        double answersPerAnswerOption = statisticResponse.getCount();
        double rightA;
        double wrongA;
        if (survey) {
            rightA = answersPerAnswerOption;
            wrongA = 0d;
        } else if (correct) {
            rightA = answersPerAnswerOption;
            wrongA = numOfParticipants - notAnswered - answersPerAnswerOption;
        } else {
            // minus negative points are not answered right?
            rightA = numOfParticipants - notAnswered - answersPerAnswerOption;
            wrongA = answersPerAnswerOption;
        }
        String label = Integer.toString(++i);
        d1.add(rightA, label);
        d2.add(wrongA, label);
        d3.add(notAnswered, label);
        Float pointsObj;
        if (survey) {
            pointsObj = null;
        } else {
            Double mappedValue = CorrectResponsesUtil.getMappedValue(assessmentItem, interaction, choice);
            if (mappedValue != null) {
                pointsObj = mappedValue.floatValue();
            } else {
                pointsObj = correct ? 1.0f : 0.0f;
            }
        }
        responseInfos.add(new ResponseInfos(label, text, pointsObj, correct, survey, false));
    }
    List<BarSeries> serieList = new ArrayList<>(3);
    serieList.add(d1);
    if (!survey) {
        serieList.add(d2);
        serieList.add(d3);
    }
    Series series = new Series(serieList, responseInfos, numOfParticipants, !survey);
    series.setChartType(survey ? SeriesFactory.BAR_ANSWERED : SeriesFactory.BAR_CORRECT_WRONG_NOT);
    series.setItemCss("o_qti_scitem");
    return series;
}
Also used : Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos)

Example 7 with ResponseInfos

use of org.olat.ims.qti.statistics.ui.ResponseInfos in project openolat by klemens.

the class ChoiceInteractionStatisticsController method getMultipleChoice.

private Series getMultipleChoice(StatisticsItem itemStats) {
    List<ChoiceStatistics> statisticResponses = getChoiceInteractionStatistics();
    BarSeries d1 = new BarSeries("bar_green", "green", translate("answer.correct"));
    BarSeries d2 = new BarSeries("bar_red", "red", translate("answer.false"));
    BarSeries d3 = new BarSeries("bar_grey", "grey", translate("answer.noanswer"));
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    int notAnswered = numOfParticipants - (itemStats == null ? 0 : itemStats.getNumOfResults());
    List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(assessmentItem, interaction);
    int i = 0;
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (ChoiceStatistics statisticResponse : statisticResponses) {
        Choice choice = statisticResponse.getChoice();
        String text = getAnswerText(choice);
        boolean correct = correctAnswers.contains(choice.getIdentifier());
        double answersPerAnswerOption = statisticResponse.getCount();
        double rightA;
        double wrongA;
        if (survey) {
            rightA = answersPerAnswerOption;
            wrongA = 0d;
        } else if (correct) {
            rightA = answersPerAnswerOption;
            wrongA = numOfParticipants - notAnswered - answersPerAnswerOption;
        } else {
            // minus negative points are not answered right?
            rightA = numOfParticipants - notAnswered - answersPerAnswerOption;
            wrongA = answersPerAnswerOption;
        }
        String label = Integer.toString(++i);
        d1.add(rightA, label);
        d2.add(wrongA, label);
        d3.add(notAnswered, label);
        Float pointsObj;
        if (survey) {
            pointsObj = null;
        } else {
            Double mappedValue = CorrectResponsesUtil.getMappedValue(assessmentItem, interaction, choice);
            if (mappedValue != null) {
                pointsObj = mappedValue.floatValue();
            } else {
                pointsObj = correct ? 1.0f : 0.0f;
            }
        }
        responseInfos.add(new ResponseInfos(label, text, pointsObj, correct, survey, false));
    }
    List<BarSeries> serieList = new ArrayList<>(3);
    serieList.add(d1);
    if (!survey) {
        serieList.add(d2);
        serieList.add(d3);
    }
    Series series = new Series(serieList, responseInfos, numOfParticipants, !survey);
    series.setChartType(survey ? SeriesFactory.BAR_ANSWERED : SeriesFactory.BAR_CORRECT_WRONG_NOT);
    series.setItemCss("o_qti_scitem");
    return series;
}
Also used : Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos)

Example 8 with ResponseInfos

use of org.olat.ims.qti.statistics.ui.ResponseInfos in project openolat by klemens.

the class ChoiceInteractionStatisticsController method getSingleChoice.

private Series getSingleChoice() {
    List<ChoiceStatistics> statisticResponses = getChoiceInteractionStatistics();
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(assessmentItem, interaction);
    int i = 0;
    long numOfResults = 0;
    BarSeries d1 = new BarSeries();
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (ChoiceStatistics statisticResponse : statisticResponses) {
        Choice choice = statisticResponse.getChoice();
        String text = getAnswerText(choice);
        double ans_count = statisticResponse.getCount();
        numOfResults += statisticResponse.getCount();
        boolean correct = correctAnswers.contains(choice.getIdentifier());
        Float points;
        String cssColor;
        if (survey) {
            points = null;
            cssColor = "bar_default";
        } else {
            Double mappedValue = CorrectResponsesUtil.getMappedValue(assessmentItem, interaction, choice);
            if (mappedValue != null) {
                points = mappedValue.floatValue();
            } else {
                // response.getPoints();
                points = correct ? 1.0f : 0.0f;
            }
            cssColor = correct ? "bar_green" : "bar_red";
        }
        String label = Integer.toString(++i);
        d1.add(ans_count, label, cssColor);
        responseInfos.add(new ResponseInfos(label, text, points, correct, 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(SeriesFactory.BAR_CORRECT);
    series.setItemCss("o_qti_scitem");
    return series;
}
Also used : Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos)

Example 9 with ResponseInfos

use of org.olat.ims.qti.statistics.ui.ResponseInfos in project openolat by klemens.

the class HotspotInteractionStatisticsController method getSingleChoice.

private Series getSingleChoice(List<HotspotChoiceStatistics> statisticResponses) {
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    List<Identifier> correctAnswers = getCorrectResponses();
    int i = 0;
    long numOfResults = 0;
    BarSeries d1 = new BarSeries();
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (HotspotChoiceStatistics statisticResponse : statisticResponses) {
        HotspotChoice choice = statisticResponse.getChoice();
        String text = getAnswerText(choice);
        double ans_count = statisticResponse.getCount();
        numOfResults += statisticResponse.getCount();
        boolean correct = correctAnswers.contains(choice.getIdentifier());
        Float points;
        String cssColor;
        if (survey) {
            points = null;
            cssColor = "bar_default";
        } else {
            Double mappedValue = CorrectResponsesUtil.getMappedValue(assessmentItem, interaction, choice);
            if (mappedValue != null) {
                points = mappedValue.floatValue();
            } else {
                points = correct ? 1.0f : 0.0f;
            }
            cssColor = correct ? "bar_green" : "bar_red";
        }
        String label = Integer.toString(++i);
        d1.add(ans_count, label, cssColor);
        responseInfos.add(new ResponseInfos(label, text, points, correct, 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(SeriesFactory.BAR_CORRECT);
    series.setItemCss("o_qti_scitem");
    return series;
}
Also used : ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)

Example 10 with ResponseInfos

use of org.olat.ims.qti.statistics.ui.ResponseInfos in project openolat by klemens.

the class HotspotInteractionStatisticsController method getMultipleChoice.

private Series getMultipleChoice(StatisticsItem itemStats, List<HotspotChoiceStatistics> statisticResponses) {
    BarSeries d1 = new BarSeries("bar_green", "green", translate("answer.correct"));
    BarSeries d2 = new BarSeries("bar_red", "red", translate("answer.false"));
    BarSeries d3 = new BarSeries("bar_grey", "grey", translate("answer.noanswer"));
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    int notAnswered = numOfParticipants - (itemStats == null ? 0 : itemStats.getNumOfResults());
    List<Identifier> correctAnswers = getCorrectResponses();
    int i = 0;
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (HotspotChoiceStatistics statisticResponse : statisticResponses) {
        HotspotChoice choice = statisticResponse.getChoice();
        String text = getAnswerText(choice);
        boolean correct = correctAnswers.contains(choice.getIdentifier());
        double answersPerAnswerOption = statisticResponse.getCount();
        double rightA;
        double wrongA;
        if (survey) {
            rightA = answersPerAnswerOption;
            wrongA = 0d;
        } else if (correct) {
            rightA = answersPerAnswerOption;
            wrongA = numOfParticipants - notAnswered - answersPerAnswerOption;
        } else {
            // minus negative points are not answered right?
            rightA = numOfParticipants - notAnswered - answersPerAnswerOption;
            wrongA = answersPerAnswerOption;
        }
        String label = Integer.toString(++i);
        d1.add(rightA, label);
        d2.add(wrongA, label);
        d3.add(notAnswered, label);
        Float pointsObj = survey ? null : (correct ? 1.0f : 0.0f);
        responseInfos.add(new ResponseInfos(label, text, pointsObj, correct, survey, false));
    }
    List<BarSeries> serieList = new ArrayList<>(3);
    serieList.add(d1);
    if (!survey) {
        serieList.add(d2);
        serieList.add(d3);
    }
    Series series = new Series(serieList, responseInfos, numOfParticipants, !survey);
    series.setChartType(survey ? SeriesFactory.BAR_ANSWERED : SeriesFactory.BAR_CORRECT_WRONG_NOT);
    series.setItemCss("o_qti_scitem");
    return series;
}
Also used : ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)

Aggregations

ArrayList (java.util.ArrayList)12 BarSeries (org.olat.core.gui.components.chart.BarSeries)12 ResponseInfos (org.olat.ims.qti.statistics.ui.ResponseInfos)12 Series (org.olat.ims.qti.statistics.ui.Series)12 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)10 ChoiceStatistics (org.olat.ims.qti21.model.statistics.ChoiceStatistics)4 HotspotChoiceStatistics (org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)4 Choice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice)4 HotspotChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)4 AbstractTextEntryInteractionStatistics (org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics)2 KPrimStatistics (org.olat.ims.qti21.model.statistics.KPrimStatistics)2 TextEntryInteractionStatistics (org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics)2 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)2 SimpleMatchSet (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet)2