Search in sources :

Example 1 with MatchStatistics

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

the class QTI21StatisticsManagerImpl method getMatchStatistics.

@Override
public List<MatchStatistics> getMatchStatistics(String itemRefIdent, AssessmentItem item, MatchInteraction interaction, QTI21StatisticSearchParams searchParams) {
    List<RawData> rawDatas = getRawDatas(itemRefIdent, interaction.getResponseIdentifier().toString(), searchParams);
    SimpleMatchSet sourceMatchSets = interaction.getSimpleMatchSets().get(0);
    SimpleMatchSet targetMatchSets = interaction.getSimpleMatchSets().get(1);
    List<MatchStatistics> matchPoints = new ArrayList<>();
    ResponseDeclaration responseDeclaration = item.getResponseDeclaration(interaction.getResponseIdentifier());
    // readable responses
    Map<Identifier, List<Identifier>> associations = new HashMap<>();
    CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
    QtiNodesExtractor.extractIdentifiersFromCorrectResponse(correctResponse, associations);
    for (SimpleAssociableChoice sourceChoice : sourceMatchSets.getSimpleAssociableChoices()) {
        for (SimpleAssociableChoice targetChoice : targetMatchSets.getSimpleAssociableChoices()) {
            DirectedPairValue dKey = new DirectedPairValue(sourceChoice.getIdentifier(), targetChoice.getIdentifier());
            String choiceIdentifier = dKey.toQtiString();
            String marker = "[" + choiceIdentifier + "]";
            boolean correct = associations.containsKey(sourceChoice.getIdentifier()) && associations.get(sourceChoice.getIdentifier()).contains(targetChoice.getIdentifier());
            long numCorrect = 0;
            long numIncorrect = 0;
            for (RawData rawData : rawDatas) {
                String response = rawData.getStringuifiedResponse();
                if (response.indexOf(marker) >= 0) {
                    if (correct) {
                        numCorrect += rawData.getCount();
                    } else {
                        numIncorrect += rawData.getCount();
                    }
                }
            }
            matchPoints.add(new MatchStatistics(sourceChoice.getIdentifier(), targetChoice.getIdentifier(), numCorrect, numIncorrect));
        }
    }
    return matchPoints;
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) MatchStatistics(org.olat.ims.qti21.model.statistics.MatchStatistics) List(java.util.List) ArrayList(java.util.ArrayList) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 2 with MatchStatistics

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

the class QTI21StatisticsManagerImpl method getMatchStatistics.

@Override
public List<MatchStatistics> getMatchStatistics(String itemRefIdent, AssessmentItem item, MatchInteraction interaction, QTI21StatisticSearchParams searchParams) {
    List<RawData> rawDatas = getRawDatas(itemRefIdent, interaction.getResponseIdentifier().toString(), searchParams);
    SimpleMatchSet sourceMatchSets = interaction.getSimpleMatchSets().get(0);
    SimpleMatchSet targetMatchSets = interaction.getSimpleMatchSets().get(1);
    List<MatchStatistics> matchPoints = new ArrayList<>();
    ResponseDeclaration responseDeclaration = item.getResponseDeclaration(interaction.getResponseIdentifier());
    // readable responses
    Map<Identifier, List<Identifier>> associations = new HashMap<>();
    CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
    QtiNodesExtractor.extractIdentifiersFromCorrectResponse(correctResponse, associations);
    for (SimpleAssociableChoice sourceChoice : sourceMatchSets.getSimpleAssociableChoices()) {
        for (SimpleAssociableChoice targetChoice : targetMatchSets.getSimpleAssociableChoices()) {
            DirectedPairValue dKey = new DirectedPairValue(sourceChoice.getIdentifier(), targetChoice.getIdentifier());
            String choiceIdentifier = dKey.toQtiString();
            String marker = "[" + choiceIdentifier + "]";
            boolean correct = associations.containsKey(sourceChoice.getIdentifier()) && associations.get(sourceChoice.getIdentifier()).contains(targetChoice.getIdentifier());
            long numCorrect = 0;
            long numIncorrect = 0;
            for (RawData rawData : rawDatas) {
                String response = rawData.getStringuifiedResponse();
                if (response.indexOf(marker) >= 0) {
                    if (correct) {
                        numCorrect += rawData.getCount();
                    } else {
                        numIncorrect += rawData.getCount();
                    }
                }
            }
            matchPoints.add(new MatchStatistics(sourceChoice.getIdentifier(), targetChoice.getIdentifier(), numCorrect, numIncorrect));
        }
    }
    return matchPoints;
}
Also used : SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) MatchStatistics(org.olat.ims.qti21.model.statistics.MatchStatistics) List(java.util.List) ArrayList(java.util.ArrayList) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 3 with MatchStatistics

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

the class MatchStatisticsController method renderMatch.

private void renderMatch() {
    List<MatchStatistics> statisticResponses = qtiStatisticsManager.getMatchStatistics(itemRef.getIdentifier().toString(), assessmentItem, interaction, resourceResult.getSearchParams());
    long max = 0;
    for (MatchStatistics statistics : statisticResponses) {
        max = Math.max(max, statistics.getNumOfCorrect() + statistics.getNumOfIncorrect());
    }
    for (MatchStatistics statistics : statisticResponses) {
        Identifier sourceIdentifier = statistics.getSourceIdentifier();
        Identifier targetIdentifier = statistics.getDestinationIdentifier();
        String key = sourceIdentifier.toString() + "-" + targetIdentifier.toString();
        StatisticsWrapper sWrapper = new StatisticsWrapper(sourceIdentifier, targetIdentifier, statistics, max);
        mainVC.contextPut(key, sWrapper);
    }
    // fill the blanks
    for (ChoiceWrapper sourceChoice : sourceWrappers) {
        for (ChoiceWrapper targetChoice : targetWrappers) {
            Identifier sourceIdentifier = sourceChoice.getChoiceIdentifier();
            Identifier targetIdentifier = targetChoice.getChoiceIdentifier();
            String key = sourceIdentifier.toString() + "-" + targetIdentifier.toString();
            if (mainVC.contextGet(key) == null) {
                mainVC.contextPut(key, new StatisticsWrapper(sourceIdentifier, targetIdentifier, null, max));
            }
        }
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) MatchStatistics(org.olat.ims.qti21.model.statistics.MatchStatistics)

Example 4 with MatchStatistics

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

the class MatchStatisticsController method renderMatch.

private void renderMatch() {
    List<MatchStatistics> statisticResponses = qtiStatisticsManager.getMatchStatistics(itemRef.getIdentifier().toString(), assessmentItem, interaction, resourceResult.getSearchParams());
    long max = 0;
    for (MatchStatistics statistics : statisticResponses) {
        max = Math.max(max, statistics.getNumOfCorrect() + statistics.getNumOfIncorrect());
    }
    for (MatchStatistics statistics : statisticResponses) {
        Identifier sourceIdentifier = statistics.getSourceIdentifier();
        Identifier targetIdentifier = statistics.getDestinationIdentifier();
        String key = sourceIdentifier.toString() + "-" + targetIdentifier.toString();
        StatisticsWrapper sWrapper = new StatisticsWrapper(sourceIdentifier, targetIdentifier, statistics, max);
        mainVC.contextPut(key, sWrapper);
    }
    // fill the blanks
    for (ChoiceWrapper sourceChoice : sourceWrappers) {
        for (ChoiceWrapper targetChoice : targetWrappers) {
            Identifier sourceIdentifier = sourceChoice.getChoiceIdentifier();
            Identifier targetIdentifier = targetChoice.getChoiceIdentifier();
            String key = sourceIdentifier.toString() + "-" + targetIdentifier.toString();
            if (mainVC.contextGet(key) == null) {
                mainVC.contextPut(key, new StatisticsWrapper(sourceIdentifier, targetIdentifier, null, max));
            }
        }
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) MatchStatistics(org.olat.ims.qti21.model.statistics.MatchStatistics)

Aggregations

MatchStatistics (org.olat.ims.qti21.model.statistics.MatchStatistics)4 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)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 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)2 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)2