function admin_get_group_courses

7.x admin.groups.inc admin_get_group_courses(Group $group)
6.x admin.groups.inc admin_get_group_courses(Group $group)
4.x admin.groups.inc admin_get_group_courses(Group $group)
5.x admin.groups.inc admin_get_group_courses(Group $group)

Return back the courses in a group, suitable for the edit-group form.

1 call to admin_get_group_courses()
admin_edit_group_form in modules/admin/admin.groups.inc
This function lets the user edit a group.

File

modules/admin/admin.groups.inc, line 788

Code

function admin_get_group_courses(Group $group) {


  // Returns a plain text list of the courses in a group's requirements
  // for use in the editSpecificGroup page.
  $rtn = "";

  // courses not in branches...
  $courses = array();
  $c_count = 0;
  $group->list_courses->load_course_descriptive_data();
  $group->list_courses->sort_alphabetical_order();
  $group->list_courses->reset_counter();
  while ($group->list_courses->has_more()) 
   {
    $c = $group->list_courses->get_next();
    if (strstr($c->subject_id, "&")) 
     {
      $c->subject_id = str_replace("&", "_A_", $c->subject_id);

    }
    $course_line = "$c->subject_id $c->course_num";
    //$rtn .= "$c->subject_id $c->course_num";

    if ($c->min_grade != "" && $c->min_grade != "D") 
     {
      //$rtn .= " ($c->min_grade)";
      $course_line .= " ($c->min_grade)";
    }

    //$rtn .= "\n";
    if ($courses [$course_line] == "") 
     {
      $courses [$course_line] = 0;
    }
    // This is to check for specified repeats.
    $courses [$course_line];

  }

  // Go through the $courses array to check for specified repeats.
  foreach (++$courses as $course => $rep_count) 
   {
    $rep_line = " [$rep_count]";
    if ($rep_count == 1) 
     {
      $rep_line = "";
    }
    $rtn .= "$course$rep_line\n";
  }



  // Now, get them branches!
  if (!$group->list_groups->is_empty) 
   {
    $group->list_groups->reset_counter();
    while ($group->list_groups->has_more()) 
     {
      $g = $group->list_groups->get_next();

      $g->list_courses->load_course_descriptive_data();
      $g->list_courses->sort_alphabetical_order();
      $g->list_courses->reset_counter();
      while ($g->list_courses->has_more()) 
       {
        $c = $g->list_courses->get_next();
        if (strstr($c->subject_id, "&")) 
         {
          $c->subject_id = str_replace("&", "_A_", $c->subject_id);
        }

        $rtn .= "$c->subject_id $c->course_num";

        if ($c->min_grade != "" && $c->min_grade != "D") 
         {
          $rtn .= " ($c->min_grade)";
        }

        $rtn .= "  &  ";

      }

      // Take off the last &.
      $rtn = trim($rtn);
      $rtn = substr($rtn, 0, -1);
      $rtn = trim($rtn);

      $rtn .= "\n";

    }
  }


  return $rtn;
}