Search in sources :

Example 1 with KPrimStatistics

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

the class QTI21StatisticsManagerImpl method getKPrimStatistics.

// stringuifiedResponse: [a93247453265982 correct][b93247453265983 correct][c93247453265984 correct][d93247453265985 correct]
@Override
public List<KPrimStatistics> getKPrimStatistics(String itemRefIdent, AssessmentItem item, MatchInteraction interaction, QTI21StatisticSearchParams searchParams) {
    List<RawData> rawDatas = getRawDatas(itemRefIdent, interaction.getResponseIdentifier().toString(), searchParams);
    List<SimpleMatchSet> matchSets = interaction.getSimpleMatchSets();
    List<KPrimStatistics> kprimPoints = new ArrayList<>();
    SimpleMatchSet fourMatchSet = matchSets.get(0);
    ResponseDeclaration responseDeclaration = item.getResponseDeclaration(interaction.getResponseIdentifier());
    // readable responses
    Set<String> rightResponses = new HashSet<>();
    List<MapEntry> mapEntries = responseDeclaration.getMapping().getMapEntries();
    for (MapEntry mapEntry : mapEntries) {
        SingleValue mapKey = mapEntry.getMapKey();
        if (mapKey instanceof DirectedPairValue) {
            DirectedPairValue pairValue = (DirectedPairValue) mapKey;
            String source = pairValue.sourceValue().toString();
            String destination = pairValue.destValue().toString();
            rightResponses.add("[" + source + " " + destination + "]");
        }
    }
    for (SimpleAssociableChoice choice : fourMatchSet.getSimpleAssociableChoices()) {
        String choiceIdentifier = choice.getIdentifier().toString();
        String markerCorrect = "[" + choiceIdentifier + " correct]";
        String markerWrong = "[" + choiceIdentifier + " wrong]";
        boolean isCorrectRight = rightResponses.contains(markerCorrect);
        String rightFlag = isCorrectRight ? markerCorrect : markerWrong;
        String wrongFlag = isCorrectRight ? markerWrong : markerCorrect;
        long numCorrect = 0;
        long numIncorrect = 0;
        long numUnanswered = 0;
        for (RawData rawData : rawDatas) {
            String response = rawData.getStringuifiedResponse();
            if (response.indexOf(rightFlag) >= 0) {
                numCorrect += rawData.getCount();
            } else if (response.indexOf(wrongFlag) >= 0) {
                numIncorrect += rawData.getCount();
            } else {
                numUnanswered += rawData.getCount();
            }
        }
        kprimPoints.add(new KPrimStatistics(choice.getIdentifier(), isCorrectRight, numCorrect, numIncorrect, numUnanswered));
    }
    return kprimPoints;
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) ArrayList(java.util.ArrayList) KPrimStatistics(org.olat.ims.qti21.model.statistics.KPrimStatistics) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) HashSet(java.util.HashSet)

Example 2 with KPrimStatistics

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

the class QTI21StatisticsManagerImpl method getKPrimStatistics.

// stringuifiedResponse: [a93247453265982 correct][b93247453265983 correct][c93247453265984 correct][d93247453265985 correct]
@Override
public List<KPrimStatistics> getKPrimStatistics(String itemRefIdent, AssessmentItem item, MatchInteraction interaction, QTI21StatisticSearchParams searchParams) {
    List<RawData> rawDatas = getRawDatas(itemRefIdent, interaction.getResponseIdentifier().toString(), searchParams);
    List<SimpleMatchSet> matchSets = interaction.getSimpleMatchSets();
    List<KPrimStatistics> kprimPoints = new ArrayList<>();
    SimpleMatchSet fourMatchSet = matchSets.get(0);
    ResponseDeclaration responseDeclaration = item.getResponseDeclaration(interaction.getResponseIdentifier());
    // readable responses
    Set<String> rightResponses = new HashSet<>();
    List<MapEntry> mapEntries = responseDeclaration.getMapping().getMapEntries();
    for (MapEntry mapEntry : mapEntries) {
        SingleValue mapKey = mapEntry.getMapKey();
        if (mapKey instanceof DirectedPairValue) {
            DirectedPairValue pairValue = (DirectedPairValue) mapKey;
            String source = pairValue.sourceValue().toString();
            String destination = pairValue.destValue().toString();
            rightResponses.add("[" + source + " " + destination + "]");
        }
    }
    for (SimpleAssociableChoice choice : fourMatchSet.getSimpleAssociableChoices()) {
        String choiceIdentifier = choice.getIdentifier().toString();
        String markerCorrect = "[" + choiceIdentifier + " correct]";
        String markerWrong = "[" + choiceIdentifier + " wrong]";
        boolean isCorrectRight = rightResponses.contains(markerCorrect);
        String rightFlag = isCorrectRight ? markerCorrect : markerWrong;
        String wrongFlag = isCorrectRight ? markerWrong : markerCorrect;
        long numCorrect = 0;
        long numIncorrect = 0;
        long numUnanswered = 0;
        for (RawData rawData : rawDatas) {
            String response = rawData.getStringuifiedResponse();
            if (response.indexOf(rightFlag) >= 0) {
                numCorrect += rawData.getCount();
            } else if (response.indexOf(wrongFlag) >= 0) {
                numIncorrect += rawData.getCount();
            } else {
                numUnanswered += rawData.getCount();
            }
        }
        kprimPoints.add(new KPrimStatistics(choice.getIdentifier(), isCorrectRight, numCorrect, numIncorrect, numUnanswered));
    }
    return kprimPoints;
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) ArrayList(java.util.ArrayList) KPrimStatistics(org.olat.ims.qti21.model.statistics.KPrimStatistics) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) HashSet(java.util.HashSet)

Example 3 with KPrimStatistics

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

the class KPrimStatisticsController method getKPrim.

public Series getKPrim() {
    List<KPrimStatistics> statisticResponses = qtiStatisticsManager.getKPrimStatistics(itemRef.getIdentifier().toString(), assessmentItem, interaction, resourceResult.getSearchParams());
    // TODO String mediaBaseURL = resourceResult.getMediaBaseURL();
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    List<SimpleMatchSet> matchSets = interaction.getSimpleMatchSets();
    SimpleMatchSet fourMatchSet = matchSets.get(0);
    int i = 0;
    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"));
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (KPrimStatistics statisticResponse : statisticResponses) {
        Identifier choiceIdentifier = statisticResponse.getChoiceIdentifier();
        boolean correctRight = statisticResponse.isCorrectRight();
        double right = statisticResponse.getNumOfCorrect();
        double wrong = statisticResponse.getNumOfIncorrect();
        double notanswered = numOfParticipants - right - wrong;
        String label = Integer.toString(++i);
        d1.add(right, label);
        d2.add(wrong, label);
        d3.add(notanswered, label);
        String text = "";
        for (SimpleAssociableChoice choice : fourMatchSet.getSimpleAssociableChoices()) {
            if (choice.getIdentifier().equals(choiceIdentifier)) {
                String textFlow = assessmentHtmlBuilder.flowStaticString(choice.getFlowStatics());
                text = Formatter.formatLatexFormulas(textFlow);
            }
        }
        responseInfos.add(new ResponseInfos(label, text, null, correctRight, survey, true));
    }
    List<BarSeries> serieList = new ArrayList<>(3);
    serieList.add(d1);
    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_mi_qtikprim");
    return series;
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) KPrimStatistics(org.olat.ims.qti21.model.statistics.KPrimStatistics) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier)

Example 4 with KPrimStatistics

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

the class KPrimStatisticsController method getKPrim.

public Series getKPrim() {
    List<KPrimStatistics> statisticResponses = qtiStatisticsManager.getKPrimStatistics(itemRef.getIdentifier().toString(), assessmentItem, interaction, resourceResult.getSearchParams());
    // TODO String mediaBaseURL = resourceResult.getMediaBaseURL();
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    List<SimpleMatchSet> matchSets = interaction.getSimpleMatchSets();
    SimpleMatchSet fourMatchSet = matchSets.get(0);
    int i = 0;
    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"));
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (KPrimStatistics statisticResponse : statisticResponses) {
        Identifier choiceIdentifier = statisticResponse.getChoiceIdentifier();
        boolean correctRight = statisticResponse.isCorrectRight();
        double right = statisticResponse.getNumOfCorrect();
        double wrong = statisticResponse.getNumOfIncorrect();
        double notanswered = numOfParticipants - right - wrong;
        String label = Integer.toString(++i);
        d1.add(right, label);
        d2.add(wrong, label);
        d3.add(notanswered, label);
        String text = "";
        for (SimpleAssociableChoice choice : fourMatchSet.getSimpleAssociableChoices()) {
            if (choice.getIdentifier().equals(choiceIdentifier)) {
                String textFlow = assessmentHtmlBuilder.flowStaticString(choice.getFlowStatics());
                text = Formatter.formatLatexFormulas(textFlow);
            }
        }
        responseInfos.add(new ResponseInfos(label, text, null, correctRight, survey, true));
    }
    List<BarSeries> serieList = new ArrayList<>(3);
    serieList.add(d1);
    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_mi_qtikprim");
    return series;
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) KPrimStatistics(org.olat.ims.qti21.model.statistics.KPrimStatistics) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier)

Aggregations

ArrayList (java.util.ArrayList)4 KPrimStatistics (org.olat.ims.qti21.model.statistics.KPrimStatistics)4 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)4 SimpleMatchSet (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet)4 HashSet (java.util.HashSet)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 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 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)2 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)2