예제 #1
0
/**
 * Returns the display name of a grouping - the grouping name followed 
 * by the number of groups in the grouping in brackets.
 * @param int $groupingid The grouping ID.
 * @param int $courseid The related course.
 * @return string The display name of the grouping
 */
function groups_get_grouping_displayname($groupingid, $courseid)
{
    if ($groupingname = groups_get_grouping_name($groupingid)) {
        $count = groups_count_groups_in_grouping($groupingid, $courseid);
        return "{$groupingname} ({$count})";
    }
    return false;
}
예제 #2
0
 /**
  * outputs generated xlsx-file for userlist (forces download)
  *
  * @param int $groupid optional get only this group
  * @param int $groupingid optional get only this grouping
  * @param stdClass[] $orderby optional current order-by array
  * @param string[] $collapsed optional current array with collapsed columns
  */
 public function download_userlist_xlsx($groupid = 0, $groupingid = 0, $orderby = array(), $collapsed = array())
 {
     global $CFG;
     require_once $CFG->libdir . "/excellib.class.php";
     $coursename = $this->course->fullname;
     $grouptoolname = $this->grouptool->name;
     $workbook = new MoodleExcelWorkbook("-", 'Excel2007');
     $data = $this->userlist_table($groupingid, $groupid, $orderby, $collapsed, true);
     $this->userlist_fill_workbook($workbook, $data);
     if (!empty($groupid)) {
         $filename = clean_filename($coursename . '_' . $grouptoolname . '_' . groups_get_group_name($groupid) . '_' . get_string('userlist', 'grouptool'));
     } else {
         if (!empty($groupingid)) {
             $filename = clean_filename($coursename . '_' . $grouptoolname . '_' . groups_get_grouping_name($groupingid) . '_' . get_string('userlist', 'grouptool'));
         } else {
             $filename = clean_filename($coursename . '_' . $grouptoolname . '_' . get_string('userlist', 'grouptool'));
         }
     }
     $workbook->send($filename . '.xlsx');
     $workbook->close();
 }
예제 #3
0
    $success = false;
    print_error('invalidcourse');
}
if ($success) {
    // Make sure that the user has permissions to manage groups.
    require_login($courseid);
    $context = get_context_instance(CONTEXT_COURSE, $courseid);
    if (!has_capability('moodle/course:managegroups', $context)) {
        redirect();
    }
    //( confirm_sesskey checks that this is a POST request.)
    // Print the page and form
    $strgroups = get_string('groups');
    $strparticipants = get_string('participants');
    print_header("{$course->shortname}: {$strgroups}", $course->fullname, "<a href=\"{$CFG->wwwroot}/course/view.php?id={$courseid}\">{$course->shortname}</a> " . "-> <a href=\"{$CFG->wwwroot}/user/index.php?id={$courseid}\">{$strparticipants}</a> " . "-> <a href=\"{$CFG->wwwroot}/group/index.php?id={$courseid}\">{$strgroups}</a>" . "-> " . get_string('printerfriendly', 'group'), "", "", true, '', user_login_string($course, $USER));
    $groupingname = groups_get_grouping_name($groupingid);
    if (!$groupingname) {
        print_error('errorinvalidgrouping', 'group', groups_home_url($courseid));
    } else {
        // Print the name of the grouping
        if (!empty($CFG->enablegroupings)) {
            // NO GROUPINGS YET!
            echo "<h1>{$groupingname}</h1>\n";
        }
    }
    // Get the groups and group members for the grouping.
    if (GROUP_NOT_IN_GROUPING == $groupingid) {
        $groupids = groups_get_groups_not_in_any_grouping($courseid);
    } else {
        $groupids = groups_get_groups_in_grouping($groupingid);
    }
예제 #4
0
 public function get_full_information($modinfo = null)
 {
     $information = parent::get_full_information($modinfo);
     // Grouping conditions.
     if ($this->item->groupingid > 0) {
         $information .= get_string('requires_grouping', 'condition', groups_get_grouping_name($this->item->groupingid));
     }
     return $information;
 }