Search in sources :

Example 1 with QTI21StatisticSearchParams

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

the class QTI21StatisticsManagerImpl method getHotspotInteractionStatistics.

@Override
public List<HotspotChoiceStatistics> getHotspotInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, HotspotInteraction hotspotInteraction, QTI21StatisticSearchParams searchParams) {
    List<RawData> results = getRawDatas(itemRefIdent, hotspotInteraction.getResponseIdentifier().toString(), searchParams);
    List<HotspotChoice> hotspotChoices = hotspotInteraction.getHotspotChoices();
    long[] counts = new long[hotspotChoices.size()];
    for (int i = counts.length; i-- > 0; ) {
        counts[i] = 0l;
    }
    for (RawData result : results) {
        Long numOfAnswers = result.getCount();
        ;
        if (numOfAnswers != null && numOfAnswers.longValue() > 0) {
            String stringuifiedResponse = result.getStringuifiedResponse();
            for (int i = hotspotChoices.size(); i-- > 0; ) {
                String identifier = hotspotChoices.get(i).getIdentifier().toString();
                if (stringuifiedResponse.contains(identifier)) {
                    counts[i] += numOfAnswers.longValue();
                }
            }
        }
    }
    List<HotspotChoiceStatistics> choicesStatistics = new ArrayList<>();
    for (int i = 0; i < hotspotChoices.size(); i++) {
        choicesStatistics.add(new HotspotChoiceStatistics(hotspotChoices.get(i), counts[i]));
    }
    return choicesStatistics;
}
Also used : HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) ArrayList(java.util.ArrayList) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)

Example 2 with QTI21StatisticSearchParams

use of org.olat.ims.qti21.model.QTI21StatisticSearchParams 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 3 with QTI21StatisticSearchParams

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

the class QTI21StatisticsManagerImpl method getChoiceInteractionStatistics.

@Override
public List<ChoiceStatistics> getChoiceInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, ChoiceInteraction choiceInteraction, QTI21StatisticSearchParams searchParams) {
    List<RawData> results = getRawDatas(itemRefIdent, choiceInteraction.getResponseIdentifier().toString(), searchParams);
    List<SimpleChoice> simpleChoices = choiceInteraction.getSimpleChoices();
    long[] counts = new long[simpleChoices.size()];
    for (int i = counts.length; i-- > 0; ) {
        counts[i] = 0l;
    }
    for (RawData result : results) {
        Long numOfAnswers = result.getCount();
        ;
        if (numOfAnswers != null && numOfAnswers.longValue() > 0) {
            String stringuifiedResponse = result.getStringuifiedResponse();
            for (int i = simpleChoices.size(); i-- > 0; ) {
                String identifier = simpleChoices.get(i).getIdentifier().toString();
                if (stringuifiedResponse.contains(identifier)) {
                    counts[i] += numOfAnswers.longValue();
                }
            }
        }
    }
    List<ChoiceStatistics> choicesStatistics = new ArrayList<>();
    for (int i = 0; i < simpleChoices.size(); i++) {
        choicesStatistics.add(new ChoiceStatistics(simpleChoices.get(i), counts[i]));
    }
    return choicesStatistics;
}
Also used : ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) ArrayList(java.util.ArrayList)

Example 4 with QTI21StatisticSearchParams

use of org.olat.ims.qti21.model.QTI21StatisticSearchParams 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 5 with QTI21StatisticSearchParams

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

the class QTIArchiver method exportQTI21.

public MediaResource exportQTI21() {
    ICourse course = CourseFactory.loadCourse(courseOres);
    RepositoryEntry testRe = courseNode.getReferencedRepositoryEntry();
    RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testRe, courseEntry, courseNode.getIdent(), allUsers, anonymUsers);
    return new QTI21ArchiveFormat(locale, searchParams).exportCourseElement();
}
Also used : QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat)

Aggregations

QTI21StatisticSearchParams (org.olat.ims.qti21.model.QTI21StatisticSearchParams)16 ArrayList (java.util.ArrayList)14 QTI21ArchiveFormat (org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 HashMap (java.util.HashMap)10 HotspotChoiceStatistics (org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)8 IOException (java.io.IOException)6 ChoiceStatistics (org.olat.ims.qti21.model.statistics.ChoiceStatistics)6 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)5 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 List (java.util.List)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 ICourse (org.olat.course.ICourse)4 QTIExportFormatterCSVType1 (org.olat.ims.qti.export.QTIExportFormatterCSVType1)4 QTIExportItemFormatDelegate (org.olat.ims.qti.export.QTIExportItemFormatDelegate)4 QTIExportManager (org.olat.ims.qti.export.QTIExportManager)4 KPrimStatistics (org.olat.ims.qti21.model.statistics.KPrimStatistics)4 MatchStatistics (org.olat.ims.qti21.model.statistics.MatchStatistics)4 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)4