use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project openolat by klemens.
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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project openolat by klemens.
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.CorrectResponse in project openolat by klemens.
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