use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry in project openolat by klemens.
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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry in project openolat by klemens.
the class AssessmentItemFactory method appendAssociationKPrimResponseDeclaration.
public static ResponseDeclaration appendAssociationKPrimResponseDeclaration(ResponseDeclaration responseDeclaration, Map<Identifier, Identifier> associations, double maxScore) {
responseDeclaration.setCardinality(Cardinality.MULTIPLE);
responseDeclaration.setBaseType(BaseType.DIRECTED_PAIR);
// correct response
CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
responseDeclaration.setCorrectResponse(correctResponse);
for (Map.Entry<Identifier, Identifier> association : associations.entrySet()) {
Identifier choiceId = association.getKey();
Identifier correctwrongId = association.getValue();
DirectedPairValue dpValue = new DirectedPairValue(choiceId, correctwrongId);
FieldValue fValue = new FieldValue(correctResponse, dpValue);
correctResponse.getFieldValues().add(fValue);
}
double mappedValue = maxScore;
if (associations.size() > 0) {
mappedValue = maxScore / associations.size();
}
// mapping
Mapping mapping = new Mapping(responseDeclaration);
mapping.setDefaultValue(-mappedValue);
responseDeclaration.setMapping(mapping);
for (Map.Entry<Identifier, Identifier> association : associations.entrySet()) {
Identifier choiceId = association.getKey();
Identifier correctwrongId = association.getValue();
MapEntry mapEntry = new MapEntry(mapping);
mapEntry.setMapKey(new DirectedPairValue(choiceId, correctwrongId));
mapEntry.setMappedValue(mappedValue);
mapping.getMapEntries().add(mapEntry);
}
return responseDeclaration;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry in project openolat by klemens.
the class AssessmentItemFactory method appendPairMapping.
public static Mapping appendPairMapping(ResponseDeclaration responseDeclaration, Map<DirectedPairValue, Double> map) {
Mapping mapping = new Mapping(responseDeclaration);
mapping.setDefaultValue(0d);
responseDeclaration.setMapping(mapping);
for (Map.Entry<DirectedPairValue, Double> entry : map.entrySet()) {
MapEntry mapEntry = new MapEntry(mapping);
mapEntry.setMapKey(entry.getKey());
mapEntry.setMappedValue(entry.getValue());
mapping.getMapEntries().add(mapEntry);
}
return mapping;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry 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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry in project OpenOLAT by OpenOLAT.
the class HotspotAssessmentItemBuilder method extractScoreEvaluationMode.
private void extractScoreEvaluationMode() {
boolean hasMapping = false;
if (hotspotInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hotspotInteraction.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;
}
Aggregations