use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class MatchAssessmentItemBuilder method extractCorrectResponse.
private void extractCorrectResponse() {
associations = new HashMap<>();
if (matchInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(matchInteraction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
List<FieldValue> values = correctResponse.getFieldValues();
for (FieldValue value : values) {
SingleValue sValue = value.getSingleValue();
if (sValue instanceof DirectedPairValue) {
DirectedPairValue dpValue = (DirectedPairValue) sValue;
Identifier sourceId = dpValue.sourceValue();
Identifier targetId = dpValue.destValue();
List<Identifier> targetIds = associations.get(sourceId);
if (targetIds == null) {
targetIds = new ArrayList<>();
associations.put(sourceId, targetIds);
}
targetIds.add(targetId);
}
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration 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.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class MatchAssessmentItemBuilder method buildResponseAndOutcomeDeclarations.
@Override
protected void buildResponseAndOutcomeDeclarations() {
// refresh correct response
ResponseDeclaration responseDeclaration;
if (assessmentItem.getResponseDeclaration(responseIdentifier) != null) {
responseDeclaration = assessmentItem.getResponseDeclaration(responseIdentifier);
appendAssociationMatchResponseDeclaration(responseDeclaration, associations);
} else {
responseDeclaration = createMatchResponseDeclaration(assessmentItem, responseIdentifier, associations);
assessmentItem.getResponseDeclarations().add(responseDeclaration);
}
if (scoreEvaluation == ScoreEvaluation.perAnswer) {
Map<DirectedPairValue, Double> pairMapping = new HashMap<>();
if (scoreMapping != null && scoreMapping.size() > 0) {
for (Map.Entry<DirectedPairValue, Double> entry : scoreMapping.entrySet()) {
DirectedPairValue sdKey = entry.getKey();
pairMapping.put(new DirectedPairValue(sdKey.sourceValue(), sdKey.destValue()), entry.getValue());
}
}
AssessmentItemFactory.appendPairMapping(responseDeclaration, pairMapping);
} else {
// make sure there isn't any mapping
responseDeclaration.setMapping(null);
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createKPrimResponseDeclaration.
public static ResponseDeclaration createKPrimResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, Map<Identifier, Identifier> associations, double maxScore) {
ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
responseDeclaration.setIdentifier(declarationId);
responseDeclaration.setCardinality(Cardinality.MULTIPLE);
responseDeclaration.setBaseType(BaseType.DIRECTED_PAIR);
return appendAssociationKPrimResponseDeclaration(responseDeclaration, associations, maxScore);
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createMultipleChoiceCorrectResponseDeclaration.
public static ResponseDeclaration createMultipleChoiceCorrectResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, List<Identifier> correctResponseIds) {
ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
responseDeclaration.setIdentifier(declarationId);
responseDeclaration.setCardinality(Cardinality.MULTIPLE);
responseDeclaration.setBaseType(BaseType.IDENTIFIER);
CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
responseDeclaration.setCorrectResponse(correctResponse);
for (Identifier correctResponseId : correctResponseIds) {
appendIdentifierValue(correctResponse, correctResponseId);
}
return responseDeclaration;
}
Aggregations