コード例 #1
0
  public void setQuestionSizeAndTotalScore() {
    this.questionSize = 0;
    this.totalScore = 0;
    int randomPartCount = 0;

    AuthorBean author = (AuthorBean) ContextUtil.lookupBean("author");

    for (int i = 0; i < this.sections.size(); i++) {
      SectionContentsBean sectionBean = (SectionContentsBean) sections.get(i);
      ArrayList items = sectionBean.getItemContents();

      int itemsInThisSection = 0;
      if (sectionBean.getSectionAuthorType().equals(SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL)) {
        // for random draw parts, add
        randomPartCount++;
        itemsInThisSection = sectionBean.getNumberToBeDrawn().intValue();
      } else {
        itemsInThisSection = items.size();
      }

      this.questionSize += itemsInThisSection;
      for (int j = 0; j < itemsInThisSection; j++) {
        ItemContentsBean item = (ItemContentsBean) items.get(j);
        if (item.getItemData().getScore() != null) {
          this.totalScore += item.getItemData().getScore().doubleValue();
        }
      }
    }
    if (randomPartCount > 0) {
      setHasRandomDrawPart(true);
    } else {
      setHasRandomDrawPart(false);
    }
  }