/** @inheritDoc */
  public List getUnassignedMembersInRole(final String siteContext, final Role role) {
    List siteMembers = getSiteMembersInRole(siteContext, role);

    // Get all userUids of all users in sections
    List<String> sectionedUserUids = new ArrayList<String>();
    List sections = getSections(siteContext);
    for (Iterator sectionIter = sections.iterator(); sectionIter.hasNext(); ) {
      CourseSection section = (CourseSection) sectionIter.next();
      List sectionUsers = securityService.unlockUsers(getLock(role), section.getUuid());
      for (Iterator userIter = sectionUsers.iterator(); userIter.hasNext(); ) {
        org.sakaiproject.user.api.User user = (org.sakaiproject.user.api.User) userIter.next();
        sectionedUserUids.add(user.getId());
      }
    }

    // Now generate the list of unsectioned enrollments by subtracting the two collections
    // Since the APIs return different kinds of objects, we need to iterate
    List<ParticipationRecord> unsectionedMembers = new ArrayList<ParticipationRecord>();
    for (Iterator iter = siteMembers.iterator(); iter.hasNext(); ) {
      ParticipationRecord record = (ParticipationRecord) iter.next();
      if (!sectionedUserUids.contains(record.getUser().getUserUid())) {
        unsectionedMembers.add(record);
      }
    }
    return unsectionedMembers;
  }
 public String getSelectedSectionUid() {
   int filterValue = selectedSectionFilterValue.intValue();
   if (filterValue == ALL_SECTIONS_SELECT_VALUE) {
     return null;
   } else {
     if (availableSections == null) availableSections = getViewableSections();
     CourseSection section = (CourseSection) availableSections.get(filterValue);
     return section.getUuid();
   }
 }
  protected void init() {
    graderIdToNameMap = new HashMap();

    defaultSearchString = getLocalizedString("search_default_student_search_string");
    if (searchString == null) {
      searchString = defaultSearchString;
    }

    // Section filtering.
    availableSections = getViewableSections();
    sectionFilterSelectItems = new ArrayList();

    // The first choice is always "All available enrollments"
    sectionFilterSelectItems.add(
        new SelectItem(
            new Integer(ALL_SECTIONS_SELECT_VALUE),
            FacesUtil.getLocalizedString("search_sections_all")));

    // TODO If there are unassigned students and the current user is allowed to see them, add them
    // next.

    // Add the available sections.
    for (int i = 0; i < availableSections.size(); i++) {
      CourseSection section = (CourseSection) availableSections.get(i);
      sectionFilterSelectItems.add(new SelectItem(new Integer(i), section.getTitle()));
    }

    // If the selected value now falls out of legal range due to sections
    // being deleted, throw it back to the default value (meaning everyone).
    int selectedSectionVal = selectedSectionFilterValue.intValue();
    if ((selectedSectionVal >= 0) && (selectedSectionVal >= availableSections.size())) {
      if (log.isInfoEnabled())
        log.info(
            "selectedSectionFilterValue="
                + selectedSectionFilterValue.intValue()
                + " but available sections="
                + availableSections.size());
      selectedSectionFilterValue = new Integer(ALL_SECTIONS_SELECT_VALUE);
    }

    // Category filtering
    availableCategories = getViewableCategories();
    categoryFilterSelectItems = new ArrayList();

    // The first choice is always "All Categories"
    categoryFilterSelectItems.add(
        new SelectItem(
            new Integer(ALL_CATEGORIES_SELECT_VALUE),
            FacesUtil.getLocalizedString("search_categories_all")));

    // Add available categories
    for (int i = 0; i < availableCategories.size(); i++) {
      Category cat = (Category) availableCategories.get(i);
      categoryFilterSelectItems.add(
          new SelectItem(new Integer(cat.getId().intValue()), cat.getName()));
    }

    // If the selected value now falls out of legal range due to categories
    // being deleted, throw it back to the default value (meaning all categories)
    int selectedCategoryVal = selectedCategoryFilterValue.intValue();
  }
 /** @inheritDoc */
 public String getSectionCategory(final String sectionUuid) {
   CourseSection section = getSection(sectionUuid);
   return section.getCategory();
 }
 /** @inheritDoc */
 public String getSectionName(final String sectionUuid) {
   CourseSection section = getSection(sectionUuid);
   return section.getTitle();
 }