public int updateRandomPoolQuestions(String sectionId) {
   for (int i = 0; i < this.sections.size(); i++) {
     SectionContentsBean sectionBean = (SectionContentsBean) sections.get(i);
     if (sectionBean.getSectionId().equals(sectionId)) {
       AssessmentService assessmentService = new AssessmentService();
       int success =
           assessmentService.updateRandomPoolQuestions(assessmentService.getSection(sectionId));
       if (success == AssessmentService.UPDATE_SUCCESS) {
         // need to update section since it has changed
         sections.set(
             i, new SectionContentsBean(assessmentService.getSection(sectionBean.getSectionId())));
       } else {
         return success;
       }
     }
   }
   return AssessmentService.UPDATE_SUCCESS;
 }
Beispiel #2
0
  /**
   * Returns a generic Map of section options (for use by helpers that won't be in the same class
   * loader and would thus get class cast issues from using SelectItem)
   */
  public Map getSectionList() {
    Map items = new Hashtable();

    ResourceLoader rb =
        new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages");
    AssessmentBean assessbean = (AssessmentBean) ContextUtil.lookupBean("assessmentBean");
    List<SectionContentsBean> sectionSet = assessbean.getSections();
    Iterator<SectionContentsBean> iter = sectionSet.iterator();
    int i = 0;
    while (iter.hasNext()) {
      i = i + 1;
      SectionContentsBean part = iter.next();

      // need to filter out all the random draw parts
      if (part.getSectionAuthorType().equals(SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL)) {
        // skip random draw parts, cannot add items to this part
        // manually
      } else {
        if ("".equals(part.getTitle())) {
          items.put(rb.getString("p") + " " + i, part.getSectionId());
        } else {
          items.put(rb.getString("p") + " " + i + " - " + part.getTitle(), part.getSectionId());
        }
      }
    }

    // create a new part if there are no non-randomDraw parts available
    if (items.size() < 1) {
      i = i + 1;
      items.put(rb.getString("p") + " " + i, "-1"); // use -1 to
      // indicate this is
      // a temporary part.
      // if the user
      // decides to cancel
      // the operation,
      // this part will
      // not be created
    }

    return items;
  }
Beispiel #3
0
  public ArrayList getSectionSelectList() {
    ArrayList list = new ArrayList();

    ResourceLoader rb =
        new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages");
    AssessmentBean assessbean = (AssessmentBean) ContextUtil.lookupBean("assessmentBean");
    List<SectionContentsBean> sectionSet = assessbean.getSections();
    Iterator<SectionContentsBean> iter = sectionSet.iterator();
    int i = 0;
    while (iter.hasNext()) {
      i = i + 1;
      SectionContentsBean part = iter.next();
      SelectItem selection = new SelectItem();

      // need to filter out all the random draw parts
      if (part.getSectionAuthorType().equals(SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL)) {
        // skip random draw parts, cannot add items to this part manually
      } else {
        if ("".equals(part.getTitle())) {
          selection.setLabel(rb.getString("p") + " " + i);
        } else {
          selection.setLabel(
              rb.getString("p")
                  + " "
                  + i
                  + " - "
                  + FormattedText.convertFormattedTextToPlaintext(part.getTitle()));
        }
        selection.setValue(part.getSectionId());
        list.add(selection);
      }
    }

    Collections.reverse(list);
    // create a new part if there are no non-randomDraw parts available
    if (list.size() < 1) {
      i = i + 1;
      SelectItem temppart = new SelectItem();
      temppart.setLabel(rb.getString("p") + " " + i);
      temppart.setValue(
          "-1"); // use -1 to indicate this is a temporary part. if the user decides to cancel the
                 // operation, this part will not be created
      list.add(temppart);
    }

    return list;
  }