use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping 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.Mapping 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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping in project OpenOLAT by OpenOLAT.
the class MatchAssessmentItemBuilder method extractScoreEvaluationMode.
private void extractScoreEvaluationMode() {
boolean hasMapping = false;
if (matchInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(matchInteraction.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 DirectedPairValue) {
Identifier sourceIdentifier = ((DirectedPairValue) sValue).sourceValue();
Identifier destIdentifier = ((DirectedPairValue) sValue).destValue();
scoreMapping.put(new DirectedPairValue(sourceIdentifier, destIdentifier), entry.getMappedValue());
}
}
}
}
}
scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createTextEntryResponseDeclaration.
public static ResponseDeclaration createTextEntryResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, String response, Double score, boolean caseSensitive, List<TextEntryAlternative> alternatives) {
ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
responseDeclaration.setIdentifier(declarationId);
responseDeclaration.setCardinality(Cardinality.SINGLE);
responseDeclaration.setBaseType(BaseType.STRING);
// correct response
CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
responseDeclaration.setCorrectResponse(correctResponse);
appendStringValue(correctResponse, response);
// mapping
Mapping mapping = new Mapping(responseDeclaration);
mapping.setDefaultValue(0.0d);
responseDeclaration.setMapping(mapping);
{
// map correct response
MapEntry mapEntry = new MapEntry(mapping);
mapEntry.setMapKey(new StringValue(response));
mapEntry.setMappedValue(score);
mapEntry.setCaseSensitive(new Boolean(caseSensitive));
mapping.getMapEntries().add(mapEntry);
}
// map alternatives
if (alternatives != null && alternatives.size() > 0) {
for (TextEntryAlternative alternative : alternatives) {
if (StringHelper.containsNonWhitespace(alternative.getAlternative())) {
MapEntry mapEntry = new MapEntry(mapping);
mapEntry.setMapKey(new StringValue(alternative.getAlternative()));
mapEntry.setMappedValue(score);
mapEntry.setCaseSensitive(new Boolean(caseSensitive));
mapping.getMapEntries().add(mapEntry);
}
}
}
return responseDeclaration;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping in project OpenOLAT by OpenOLAT.
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;
}
Aggregations