forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
groupings.php
84 lines (68 loc) · 3.08 KB
/
groupings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php // $Id$
// Allows a creator to edit groupings
require_once '../config.php';
require_once $CFG->dirroot.'/group/lib.php';
$courseid = required_param('id', PARAM_INT);
if (!$course = get_record('course', 'id', $courseid)) {
print_error('nocourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:managegroups', $context);
$strgrouping = get_string('grouping', 'group');
$strgroups = get_string('groups');
$strname = get_string('name');
$strdelete = get_string('delete');
$stredit = get_string('edit');
$srtnewgrouping = get_string('creategrouping', 'group');
$strgroups = get_string('groups');
$strgroupings = get_string('groupings', 'group');
$struses = get_string('activities');
$strparticipants = get_string('participants');
$strmanagegrping = get_String('showgroupsingrouping', 'group');
$navlinks = array(array('name'=>$strparticipants, 'link'=>$CFG->wwwroot.'/user/index.php?id='.$courseid, 'type'=>'misc'),
array('name'=>$strgroupings, 'link'=>'', 'type'=>'misc'));
$navigation = build_navigation($navlinks);
/// Print header
print_header_simple($strgroupings, ': '.$strgroupings, $navigation, '', '', true, '', navmenu($course));
// Add tabs
$currenttab = 'groupings';
require('tabs.php');
print_heading($strgroupings);
$data = array();
if ($groupings = get_records('groupings', 'courseid', $course->id, 'name')) {
foreach($groupings as $grouping) {
$line = array();
$line[0] = format_string($grouping->name);
if ($groups = groups_get_all_groups($courseid, 0, $grouping->id)) {
$groupnames = array();
foreach ($groups as $group) {
$groupnames[] = format_string($group->name);
}
$line[1] = implode(', ', $groupnames);
} else {
$line[1] = get_string('none');
}
$line[2] = (int)count_records('course_modules', 'course', $course->id, 'groupingid', $grouping->id);
$buttons = "<a title=\"$stredit\" href=\"grouping.php?id=$grouping->id\"><img".
" src=\"$CFG->pixpath/t/edit.gif\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
$buttons .= "<a title=\"$strdelete\" href=\"grouping.php?id=$grouping->id&delete=1\"><img".
" src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
$buttons .= "<a title=\"$strmanagegrping\" href=\"assign.php?id=$grouping->id\"><img".
" src=\"$CFG->pixpath/i/group.gif\" class=\"icon\" alt=\"$strmanagegrping\" /></a> ";
$line[3] = $buttons;
$data[] = $line;
}
}
$table = new object();
$table->head = array($strgrouping, $strgroups, $struses, $stredit);
$table->size = array('30%', '50%', '10%', '10%');
$table->align = array('left', 'left', 'center', 'center');
$table->width = '90%';
$table->data = $data;
print_table($table);
echo '<div class="buttons">';
print_single_button('grouping.php', array('courseid'=>$courseid), $srtnewgrouping);
echo '</div>';
print_footer($course);
?>