use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping 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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping 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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping 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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping 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.Mapping 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;
}
Aggregations