use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration 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.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createHotspotCorrectResponseDeclaration.
public static ResponseDeclaration createHotspotCorrectResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, List<Identifier> correctResponseIds, Cardinality cardinality) {
ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
responseDeclaration.setIdentifier(declarationId);
if (cardinality != null && (cardinality == Cardinality.SINGLE || cardinality == Cardinality.MULTIPLE)) {
responseDeclaration.setCardinality(cardinality);
} else if (correctResponseIds == null || correctResponseIds.size() == 0 || correctResponseIds.size() > 1) {
responseDeclaration.setCardinality(Cardinality.MULTIPLE);
} else {
responseDeclaration.setCardinality(Cardinality.SINGLE);
}
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.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createMatchResponseDeclaration.
/**
* Add the response declaration with correct answers (but without score mapping)
*
* @param assessmentItem
* @param declarationId
* @param associations
* @return
*/
public static ResponseDeclaration createMatchResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, Map<Identifier, List<Identifier>> associations) {
ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
responseDeclaration.setIdentifier(declarationId);
responseDeclaration.setCardinality(Cardinality.MULTIPLE);
responseDeclaration.setBaseType(BaseType.DIRECTED_PAIR);
return appendAssociationMatchResponseDeclaration(responseDeclaration, associations);
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createSingleChoice.
public static AssessmentItem createSingleChoice(String title, String defaultAnswer) {
AssessmentItem assessmentItem = createAssessmentItem(QTI21QuestionType.sc, title);
// define correct answer
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
Identifier correctResponseId = IdentifierGenerator.newAsIdentifier("sc");
ResponseDeclaration responseDeclaration = createSingleChoiceCorrectResponseDeclaration(assessmentItem, responseDeclarationId, correctResponseId);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
// the single choice interaction
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
ChoiceInteraction choiceInteraction = appendChoiceInteraction(itemBody, responseDeclarationId, 1, true);
appendSimpleChoice(choiceInteraction, defaultAnswer, correctResponseId);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createHottextCorrectResponseDeclaration.
public static ResponseDeclaration createHottextCorrectResponseDeclaration(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