Search in sources :

Example 1 with MapEntry

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry in project OpenOLAT by OpenOLAT.

the class QTI21StatisticsManagerImpl method getTextEntryInteractionSettings.

private TextEntryInteractionStatistics getTextEntryInteractionSettings(Identifier responseIdentifier, ResponseDeclaration responseDeclaration) {
    String correctResponse = null;
    boolean caseSensitive = true;
    double points = Double.NaN;
    List<String> alternatives = new ArrayList<>();
    List<MapEntry> mapEntries = responseDeclaration.getMapping().getMapEntries();
    for (MapEntry mapEntry : mapEntries) {
        SingleValue mapKey = mapEntry.getMapKey();
        if (mapKey instanceof StringValue) {
            String value = ((StringValue) mapKey).stringValue();
            if (correctResponse == null) {
                correctResponse = value;
                points = mapEntry.getMappedValue();
            } else {
                alternatives.add(value);
            }
        }
        caseSensitive &= mapEntry.getCaseSensitive();
    }
    if (points == -1.0d) {
        // all score
        points = 0.0d;
    }
    return new TextEntryInteractionStatistics(responseIdentifier, caseSensitive, correctResponse, alternatives, points);
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) ArrayList(java.util.ArrayList) StringValue(uk.ac.ed.ph.jqtiplus.value.StringValue) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics)

Example 2 with MapEntry

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry 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 3 with MapEntry

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry in project OpenOLAT by OpenOLAT.

the class SimpleChoiceAssessmentItemBuilder method extractScoreEvaluationMode.

private void extractScoreEvaluationMode() {
    boolean hasMapping = false;
    if (choiceInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(choiceInteraction.getResponseIdentifier());
        if (responseDeclaration != null) {
            Mapping mapping = responseDeclaration.getMapping();
            hasMapping = (mapping != null && mapping.getMapEntries() != null && mapping.getMapEntries().size() > 0);
            if (hasMapping) {
                scoreMapping = new HashMap<>();
                for (MapEntry entry : mapping.getMapEntries()) {
                    SingleValue sValue = entry.getMapKey();
                    if (sValue instanceof IdentifierValue) {
                        Identifier identifier = ((IdentifierValue) sValue).identifierValue();
                        scoreMapping.put(identifier, entry.getMappedValue());
                    }
                }
            }
        }
    }
    scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 4 with MapEntry

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method appendMapping.

/*
	<mapping defaultValue="0">
		<mapEntry mapKey="idd072fa37-f4c3-4532-a2fb-4458fa23e919" mappedValue="2.0" />
		<mapEntry mapKey="ide18af420-393e-43dc-b194-7af94663b576" mappedValue="-0.5" />
		<mapEntry mapKey="id72eb2dda-4053-45ba-a9f8-cc101f3e3987" mappedValue="2.0" />
	</mapping>
	 */
public static Mapping appendMapping(ResponseDeclaration responseDeclaration, Map<Identifier, Double> map) {
    Mapping mapping = new Mapping(responseDeclaration);
    mapping.setDefaultValue(0d);
    responseDeclaration.setMapping(mapping);
    for (Map.Entry<Identifier, Double> entry : map.entrySet()) {
        MapEntry mapEntry = new MapEntry(mapping);
        mapEntry.setMapKey(new IdentifierValue(entry.getKey()));
        mapEntry.setMappedValue(entry.getValue());
        mapping.getMapEntries().add(mapEntry);
    }
    return mapping;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) Map(java.util.Map)

Example 5 with MapEntry

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry in project OpenOLAT by OpenOLAT.

the class HottextAssessmentItemBuilder method extractScoreEvaluationMode.

private void extractScoreEvaluationMode() {
    boolean hasMapping = false;
    if (hottextInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hottextInteraction.getResponseIdentifier());
        if (responseDeclaration != null) {
            Mapping mapping = responseDeclaration.getMapping();
            hasMapping = (mapping != null && mapping.getMapEntries() != null && mapping.getMapEntries().size() > 0);
            if (hasMapping) {
                scoreMapping = new HashMap<>();
                for (MapEntry entry : mapping.getMapEntries()) {
                    SingleValue sValue = entry.getMapKey();
                    if (sValue instanceof IdentifierValue) {
                        Identifier identifier = ((IdentifierValue) sValue).identifierValue();
                        scoreMapping.put(identifier, entry.getMappedValue());
                    }
                }
            }
        }
    }
    scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createHottextCorrectResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)

Aggregations

MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)22 Mapping (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping)18 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)14 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)12 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)12 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)10 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)8 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)8 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)6 StringValue (uk.ac.ed.ph.jqtiplus.value.StringValue)6 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)4 HashSet (java.util.HashSet)2 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 AssessmentItemFactory.appendAssociationMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationMatchResponseDeclaration)2 AssessmentItemFactory.createHottextCorrectResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)2 AssessmentItemFactory.createMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMatchResponseDeclaration)2