use of uk.ac.ed.ph.jqtiplus.node.content.ItemBody in project openolat by klemens.
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.content.ItemBody in project openolat by klemens.
the class AssessmentItemFactory method appendDefaultItemBody.
/**
* Append the itemBody with an empty paragraph.
*
* @param assessmentItem
* @return
*/
public static ItemBody appendDefaultItemBody(AssessmentItem assessmentItem) {
NodeGroupList nodeGroups = assessmentItem.getNodeGroups();
// the single choice interaction
ItemBodyGroup itemBodyGroup = nodeGroups.getItemBodyGroup();
ItemBody itemBody = new ItemBody(assessmentItem);
itemBodyGroup.setItemBody(itemBody);
return itemBody;
}
Aggregations