@Override
 protected void buildResponseAndOutcomeDeclarations() {
   ResponseDeclaration responseDeclaration =
       AssessmentItemFactory.createSingleChoiceCorrectResponseDeclaration(
           assessmentItem, responseIdentifier, correctAnswer);
   if (scoreEvaluation == ScoreEvaluation.perAnswer) {
     AssessmentItemFactory.appendMapping(responseDeclaration, scoreMapping);
   }
   assessmentItem.getResponseDeclarations().add(responseDeclaration);
 }
  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;
  }
  @Override
  protected void buildItemBody() {
    // remove current blocks
    List<Block> blocks = assessmentItem.getItemBody().getBlocks();
    blocks.clear();

    // add question
    getHtmlHelper().appendHtml(assessmentItem.getItemBody(), question);

    // add interaction
    ChoiceInteraction singleChoiceInteraction =
        AssessmentItemFactory.createSingleChoiceInteraction(
            assessmentItem, responseIdentifier, orientation, cssClass);
    singleChoiceInteraction.setShuffle(isShuffle());
    blocks.add(singleChoiceInteraction);
    List<SimpleChoice> choiceList = getSimpleChoices();
    singleChoiceInteraction.getSimpleChoices().addAll(choiceList);
  }