Exemplo n.º 1
0
  /** {@inheritDoc} */
  public Component getViewAnswerUi() {
    EntityList entityList = this.uiService.newEntityList();
    entityList.setStyle(EntityList.Style.form);
    entityList.setIterator(
        this.uiService
            .newPropertyReference()
            .setReference("answer.question.typeSpecificQuestion.choices"),
        "choice");
    entityList.setEmptyTitle("no-answer");

    // include each choice only if the choice has been selected by the user
    PropertyReference entityIncludedProperty =
        this.uiService.newPropertyReference().setReference("choice.id");
    PropertyReference entityIncludedComparison =
        this.uiService.newPropertyReference().setReference("answer.typeSpecificAnswer.answer");
    CompareDecision entityIncludedDecision = this.uiService.newCompareDecision();
    entityIncludedDecision.setProperty(entityIncludedProperty);
    entityIncludedDecision.setEqualsProperty(entityIncludedComparison);
    entityList.setEntityIncluded(entityIncludedDecision);

    SelectionColumn selCol = this.uiService.newSelectionColumn();
    selCol.setSingle();
    selCol.setValueProperty(this.uiService.newTextPropertyReference().setReference("choice.id"));
    selCol.setProperty(
        this.uiService.newPropertyReference().setReference("answer.typeSpecificAnswer.answer"));
    selCol.setReadOnly(this.uiService.newTrueDecision());
    selCol.setCorrect(
        this.uiService
            .newPropertyReference()
            .setReference("answer.question.typeSpecificQuestion.correctAnswer"));
    selCol.setCorrectDecision(
        this.uiService
            .newDecision()
            .setProperty(
                this.uiService.newPropertyReference().setReference("answer.question.hasCorrect")));
    entityList.addColumn(selCol);

    PropertyColumn propCol = this.uiService.newPropertyColumn();
    propCol.setProperty(this.uiService.newHtmlPropertyReference().setReference("choice.text"));
    entityList.addColumn(propCol);

    return this.uiService.newFragment().setMessages(this.messages).add(entityList);
  }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  public Component getViewStatsUi() {
    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")));

    EntityList entityList = this.uiService.newEntityList();
    entityList.setStyle(EntityList.Style.form);
    entityList.setIterator(
        this.uiService.newPropertyReference().setReference("question.typeSpecificQuestion.choices"),
        "choice");
    entityList.setEmptyTitle("no-answer");

    SelectionColumn selCol = this.uiService.newSelectionColumn();
    selCol.setSingle();
    selCol.setValueProperty(this.uiService.newTextPropertyReference().setReference("choice.id"));
    selCol.setProperty(
        this.uiService
            .newPropertyReference()
            .setReference("question.typeSpecificQuestion.correctAnswer"));
    selCol.setReadOnly(this.uiService.newTrueDecision());
    selCol.setCorrect(
        this.uiService
            .newPropertyReference()
            .setReference("question.typeSpecificQuestion.correctAnswer"));
    selCol.setCorrectDecision(
        this.uiService
            .newDecision()
            .setProperty(
                this.uiService.newPropertyReference().setReference("question.hasCorrect")));
    entityList.addColumn(selCol);

    PropertyColumn propCol = this.uiService.newPropertyColumn();
    propCol.setProperty(this.uiService.newHtmlPropertyReference().setReference("choice.text"));
    entityList.addColumn(propCol);

    propCol = this.uiService.newPropertyColumn();
    propCol.setRight();
    propCol.setProperty(
        this.uiService
            .newHtmlPropertyReference()
            .setReference("choice.id")
            .setFormatDelegate(this.uiService.getFormatDelegate("FormatPercent", "sakai.mneme")));
    entityList.addColumn(propCol);

    propCol = this.uiService.newPropertyColumn();
    propCol.setRight();
    propCol.setProperty(
        this.uiService
            .newHtmlPropertyReference()
            .setReference("choice.id")
            .setFormatDelegate(this.uiService.getFormatDelegate("FormatCount", "sakai.mneme")));
    entityList.addColumn(propCol);

    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);

    Text unanswered =
        this.uiService
            .newText()
            .setText(
                null,
                this.uiService
                    .newHtmlPropertyReference()
                    .setFormatDelegate(
                        this.uiService.getFormatDelegate(
                            "FormatUnansweredPercent", "sakai.mneme")));

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

    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);
  }