/** {@inheritDoc} */
  public Component getViewDeliveryUi() {
    Text question = this.uiService.newText();
    question.setText(
        null, this.uiService.newHtmlPropertyReference().setReference("question.presentation.text"));

    Attachments attachments = this.uiService.newAttachments();
    attachments.setAttachments(
        this.uiService.newPropertyReference().setReference("question.presentation.attachments"),
        null);
    attachments.setIncluded(
        this.uiService
            .newHasValueDecision()
            .setProperty(
                this.uiService
                    .newPropertyReference()
                    .setReference("question.presentation.attachments")));

    Selection selection = this.uiService.newSelection();
    selection.addSelection(
        this.uiService.newMessage().setMessage("true"),
        this.uiService.newMessage().setTemplate("true"));
    selection.addSelection(
        this.uiService.newMessage().setMessage("false"),
        this.uiService.newMessage().setTemplate("false"));
    selection.setReadOnly(this.uiService.newTrueDecision());

    Section first = this.uiService.newSection();
    first.add(question).add(attachments).add(selection);

    return this.uiService.newFragment().setMessages(this.messages).add(first);
  }
  /** {@inheritDoc} */
  public Component getDeliveryUi() {
    Text question = this.uiService.newText();
    question.setText(
        null,
        this.uiService
            .newHtmlPropertyReference()
            .setReference("answer.question.presentation.text"));

    Attachments attachments = this.uiService.newAttachments();
    attachments.setAttachments(
        this.uiService
            .newPropertyReference()
            .setReference("answer.question.presentation.attachments"),
        null);
    attachments.setIncluded(
        this.uiService
            .newHasValueDecision()
            .setProperty(
                this.uiService
                    .newPropertyReference()
                    .setReference("answer.question.presentation.attachments")));

    Selection selection = this.uiService.newSelection();
    selection.setProperty(
        this.uiService.newPropertyReference().setReference("answer.typeSpecificAnswer.answer"));
    selection.addSelection(
        this.uiService.newMessage().setMessage("true"),
        this.uiService.newMessage().setTemplate("true"));
    selection.addSelection(
        this.uiService.newMessage().setMessage("false"),
        this.uiService.newMessage().setTemplate("false"));
    selection.setOnEmptyAlert(
        this.uiService
            .newDecision()
            .setReversed()
            .setProperty(
                this.uiService
                    .newPropertyReference()
                    .setReference("answer.submission.assessment.randomAccess")),
        "linear-missing");

    Section section = this.uiService.newSection();
    section.add(question).add(attachments).add(selection);

    return this.uiService.newFragment().setMessages(this.messages).add(section);
  }
  /** {@inheritDoc} */
  public Component getAuthoringUi() {
    Selection selection = this.uiService.newSelection();
    selection.setProperty(
        this.uiService
            .newPropertyReference()
            .setReference("question.typeSpecificQuestion.correctAnswer"));
    selection.addSelection(
        this.uiService.newMessage().setMessage("true"),
        this.uiService.newMessage().setTemplate("true"));
    selection.addSelection(
        this.uiService.newMessage().setMessage("false"),
        this.uiService.newMessage().setTemplate("false"));
    selection.setTitle(
        "correct-answer",
        this.uiService.newIconPropertyReference().setIcon("/icons/answer_key.png"));
    selection.setReadOnly(
        this.uiService
            .newDecision()
            .setProperty(this.uiService.newPropertyReference().setReference("question.isSurvey")));

    Section section = this.uiService.newSection();
    section.add(selection);

    return this.uiService.newFragment().setMessages(this.messages).add(section);
  }
  /** {@inheritDoc} */
  public Component getViewQuestionUi() {
    Text question = this.uiService.newText();
    question.setText(
        null, this.uiService.newHtmlPropertyReference().setReference("question.presentation.text"));

    Attachments attachments = this.uiService.newAttachments();
    attachments.setAttachments(
        this.uiService.newPropertyReference().setReference("question.presentation.attachments"),
        null);
    attachments.setIncluded(
        this.uiService
            .newHasValueDecision()
            .setProperty(
                this.uiService
                    .newPropertyReference()
                    .setReference("question.presentation.attachments")));

    Selection selection = this.uiService.newSelection();
    selection.setProperty(
        this.uiService
            .newPropertyReference()
            .setReference("question.typeSpecificQuestion.correctAnswer"));
    selection.addSelection(
        this.uiService.newMessage().setMessage("true"),
        this.uiService.newMessage().setTemplate("true"));
    selection.addSelection(
        this.uiService.newMessage().setMessage("false"),
        this.uiService.newMessage().setTemplate("false"));
    selection.setReadOnly(this.uiService.newTrueDecision());
    selection.setCorrect(
        this.uiService
            .newPropertyReference()
            .setReference("question.typeSpecificQuestion.correctAnswer"));
    selection.setCorrectDecision(
        this.uiService
            .newDecision()
            .setProperty(
                this.uiService.newPropertyReference().setReference("question.hasCorrect")));

    Text answerKey = this.uiService.newText();
    PropertyReference[] refs = new PropertyReference[2];
    refs[0] = this.uiService.newIconPropertyReference().setIcon("/icons/answer_key.png");
    refs[1] =
        this.uiService
            .newHtmlPropertyReference()
            .setReference("question.typeSpecificQuestion.answerKey");
    answerKey.setText("answer-key", refs);

    Section first = this.uiService.newSection();
    first.add(question).add(attachments).add(selection);

    Section second = this.uiService.newSection();
    second.setIncluded(
        this.uiService
            .newDecision()
            .setProperty(
                this.uiService.newPropertyReference().setReference("question.hasCorrect")));
    second.add(answerKey);

    return this.uiService.newFragment().setMessages(this.messages).add(first).add(second);
  }
  /** {@inheritDoc} */
  public Component getReviewUi() {
    Text question = this.uiService.newText();
    question.setText(
        null,
        this.uiService
            .newHtmlPropertyReference()
            .setReference("answer.question.presentation.text"));

    Attachments attachments = this.uiService.newAttachments();
    attachments.setAttachments(
        this.uiService
            .newPropertyReference()
            .setReference("answer.question.presentation.attachments"),
        null);
    attachments.setIncluded(
        this.uiService
            .newHasValueDecision()
            .setProperty(
                this.uiService
                    .newPropertyReference()
                    .setReference("answer.question.presentation.attachments")));

    Selection selection = this.uiService.newSelection();
    selection.setProperty(
        this.uiService.newPropertyReference().setReference("answer.typeSpecificAnswer.answer"));
    selection.addSelection(
        this.uiService.newMessage().setMessage("true"),
        this.uiService.newMessage().setTemplate("true"));
    selection.addSelection(
        this.uiService.newMessage().setMessage("false"),
        this.uiService.newMessage().setTemplate("false"));
    selection.setReadOnly(this.uiService.newTrueDecision());
    selection.setCorrect(
        this.uiService
            .newPropertyReference()
            .setReference("answer.question.typeSpecificQuestion.correctAnswer"));

    // should we show correct marks?
    AndDecision mayReviewAndShowCorrect = this.uiService.newAndDecision();
    Decision[] decisionsMayReviewAndShowCorrect = new Decision[2];
    decisionsMayReviewAndShowCorrect[0] =
        this.uiService
            .newDecision()
            .setProperty(
                this.uiService.newPropertyReference().setReference("answer.submission.mayReview"));
    decisionsMayReviewAndShowCorrect[1] =
        this.uiService
            .newDecision()
            .setProperty(
                this.uiService.newPropertyReference().setReference("answer.showCorrectReview"));
    mayReviewAndShowCorrect.setRequirements(decisionsMayReviewAndShowCorrect);

    OrDecision or = this.uiService.newOrDecision();
    Decision[] decisionsOr = new Decision[2];
    decisionsOr[0] =
        this.uiService
            .newDecision()
            .setProperty(this.uiService.newPropertyReference().setReference("grading"));
    decisionsOr[1] = mayReviewAndShowCorrect;
    or.setOptions(decisionsOr);

    Decision[] decisionsShowCorrect = new Decision[2];
    decisionsShowCorrect[0] =
        this.uiService
            .newDecision()
            .setProperty(
                this.uiService.newPropertyReference().setReference("answer.question.hasCorrect"));
    decisionsShowCorrect[1] = or;
    Decision showCorrect = this.uiService.newAndDecision().setRequirements(decisionsShowCorrect);

    selection.setCorrectDecision(showCorrect);

    Text answerKey = this.uiService.newText();
    PropertyReference[] refs = new PropertyReference[2];
    refs[0] = this.uiService.newIconPropertyReference().setIcon("/icons/answer_key.png");
    refs[1] =
        this.uiService
            .newHtmlPropertyReference()
            .setReference("answer.question.typeSpecificQuestion.answerKey");
    answerKey.setText("answer-key", refs);

    Decision[] orInc = new Decision[2];
    orInc[0] =
        this.uiService
            .newDecision()
            .setProperty(this.uiService.newPropertyReference().setReference("grading"));
    orInc[1] =
        this.uiService
            .newDecision()
            .setProperty(
                this.uiService.newPropertyReference().setReference("answer.showCorrectReview"));
    Decision[] andInc = new Decision[2];
    andInc[0] =
        this.uiService
            .newDecision()
            .setProperty(
                this.uiService.newPropertyReference().setReference("answer.question.hasCorrect"));
    andInc[1] = this.uiService.newOrDecision().setOptions(orInc);
    answerKey.setIncluded(this.uiService.newAndDecision().setRequirements(andInc));

    Section first = this.uiService.newSection();
    first.add(question).add(attachments).add(selection);

    Section second = this.uiService.newSection();
    second.add(answerKey);

    return this.uiService.newFragment().setMessages(this.messages).add(first).add(second);
  }