private static AssessmentItem createAssessmentItem() { AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.sc, "Single choice"); // 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, "New answer", correctResponseId); // response processing ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId); assessmentItem .getNodeGroups() .getResponseProcessingGroup() .setResponseProcessing(responseProcessing); return assessmentItem; }
@Before public void before() { context = new DummyValidationContext(); recorder = new NotificationRecorder(NotificationLevel.WARNING); context.addNotificationListener(recorder); item = new AssessmentItem(); itemBody = new ItemBody(item); item.setItemBody(itemBody); paragraph = new P(itemBody); itemBody.getNodeGroups().getBlockGroup().getChildren().add(paragraph); apipAccessibility = new ApipAccessibility(item); item.setApipAccessibility(apipAccessibility); accessibilityInfo = new AccessibilityInfo(apipAccessibility); apipAccessibility.setAccessibilityInfo(accessibilityInfo); accessElement = new AccessElement(accessibilityInfo); accessibilityInfo.getAccessElements().add(accessElement); }