use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project OpenOLAT by OpenOLAT.
the class HotspotAssessmentItemBuilder method extractCorrectAnswers.
private void extractCorrectAnswers() {
correctAnswers = new ArrayList<>(5);
if (hotspotInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hotspotInteraction.getResponseIdentifier());
if (responseDeclaration != null) {
if (responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
extractIdentifiersFromCorrectResponse(correctResponse, correctAnswers);
}
cardinality = responseDeclaration.getCardinality();
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project OpenOLAT by OpenOLAT.
the class KPrimAssessmentItemBuilder 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 destinationId = dpValue.destValue();
associations.put(sourceId, destinationId);
}
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method appendAssociationMatchResponseDeclaration.
public static ResponseDeclaration appendAssociationMatchResponseDeclaration(ResponseDeclaration responseDeclaration, Map<Identifier, List<Identifier>> associations) {
responseDeclaration.setCardinality(Cardinality.MULTIPLE);
responseDeclaration.setBaseType(BaseType.DIRECTED_PAIR);
// correct response
CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
responseDeclaration.setCorrectResponse(correctResponse);
for (Map.Entry<Identifier, List<Identifier>> association : associations.entrySet()) {
Identifier sourceChoiceId = association.getKey();
List<Identifier> targetChoiceIds = association.getValue();
for (Identifier targetChoiceId : targetChoiceIds) {
DirectedPairValue dpValue = new DirectedPairValue(sourceChoiceId, targetChoiceId);
FieldValue fValue = new FieldValue(correctResponse, dpValue);
correctResponse.getFieldValues().add(fValue);
}
}
return responseDeclaration;
}
use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createTextEntryResponseDeclaration.
/**
* For the all answers get the point
* @param assessmentItem
* @param declarationId
* @param response
* @param alternatives
* @return
*/
public static ResponseDeclaration createTextEntryResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, String response, 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);
if (alternatives != null) {
for (TextEntryAlternative alternative : alternatives) {
appendStringValue(correctResponse, alternative.getAlternative());
}
}
return responseDeclaration;
}
use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createHotspotEntryResponseDeclarationSingle.
/*
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
<correctResponse>
<value>Choice0</value>
</correctResponse>
</responseDeclaration>
*/
public static ResponseDeclaration createHotspotEntryResponseDeclarationSingle(AssessmentItem assessmentItem, Identifier responseIdentifier, Identifier correctAnswerIdentifier) {
ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
responseDeclaration.setIdentifier(responseIdentifier);
responseDeclaration.setCardinality(Cardinality.SINGLE);
responseDeclaration.setBaseType(BaseType.IDENTIFIER);
// correct response
CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
responseDeclaration.setCorrectResponse(correctResponse);
appendIdentifierValue(correctResponse, correctAnswerIdentifier);
return responseDeclaration;
}
Aggregations