Annotation of loncom/interface/loncoursegroups.pm, revision 1.2
1.1 raeburn 1: #
2: # Copyright Michigan State University Board of Trustees
3: #
4: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
5: #
6: # LON-CAPA is free software; you can redistribute it and/or modify
7: # it under the terms of the GNU General Public License as published by
8: # the Free Software Foundation; either version 2 of the License, or
9: # (at your option) any later version.
10: #
11: # LON-CAPA is distributed in the hope that it will be useful,
12: # but WITHOUT ANY WARRANTY; without even the implied warranty of
13: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: # GNU General Public License for more details.
15: #
16: # You should have received a copy of the GNU General Public License
17: # along with LON-CAPA; if not, write to the Free Software
18: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: #
20: # /home/httpd/html/adm/gpl.txt
21: #
22: # http://www.lon-capa.org/
23: #
24:
25: package Apache::loncoursegroups;
26:
27: use strict;
28: use Apache::lonnet;
29: use Apache::loncommon;
30: use Apache::lonhtmlcommon;
31: use Apache::lonlocal;
32: use Apache::Constants qw(:common :http);
33:
34: sub handler {
35: my ($r) = @_;
36: &Apache::loncommon::content_type($r,'text/html');
37: $r->send_http_header;
38:
39: if ($r->header_only) {
40: return OK;
41: }
42:
43: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
44: ['action','state']);
45:
46: $r->print(&header());
47:
48: &Apache::lonhtmlcommon::clear_breadcrumbs();
49: &Apache::lonhtmlcommon::add_breadcrumb
50: ({href=>"/adm/groups",
51: text=>"Group Management",
52: faq=>9,bug=>'Instructor Interface',});
53: # Needs to be in a course
54: if (! ($env{'request.course.fn'})) {
55: # Not in a course
56: $env{'user.error.msg'}=
57: "/adm/groups:mdg:0:0:Cannot create, modify or delete course groups";
58: return HTTP_NOT_ACCEPTABLE;
59: }
60:
61: my $view_permission =
62: &Apache::lonnet::allowed('vcg',$env{'request.course.id'});
63: my $manage_permission =
64: &Apache::lonnet::allowed('mdg',$env{'request.course.id'});
65:
66: if (! exists($env{'form.action'})) {
67: $r->print(&Apache::lonhtmlcommon::breadcrumbs
68: (undef,'Course Group Manager'));
69: &print_main_menu($r,$manage_permission,$view_permission);
70: } elsif ($env{'form.action'} eq 'create' && $manage_permission) {
71: &Apache::lonhtmlcommon::add_breadcrumb
72: ({href=>'/adm/coursegroups?action=create&state=',
73: text=>"Create Group"});
74: $r->print(&Apache::lonhtmlcommon::breadcrumbs
75: (undef,'Create Group','Course_Create_Group'));
76: if (! exists($env{'form.state'})) {
77: &first_creation_form($r);
78: } elsif ($env{'form.state'} eq 'pick_members') {
79: &second_creation_form($r);
80: } elsif ($env{'form.state'} eq 'complete') {
81: &completed_creation($r);
82: } else {
83: &first_creation_form($r);
84: }
85: }
86: $r->print(&footer());
87: return OK;
88: }
89:
90: sub header {
91: my $html=&Apache::lonxml::xmlbegin();
92: my $bodytag=&Apache::loncommon::bodytag('Course Groups Manager');
93: my $title = &mt('LON-CAPA Groups Manager');
94: return(<<ENDHEAD);
95: $html
96: <head>
97: <title>$title</title>
98: </head>
99: $bodytag
100: <form method="post"
101: action="/adm/coursegroup" name="form">
102: ENDHEAD
103: }
104:
105: sub print_main_menu {
106: my ($r,$manage_permission,$view_permission)=@_;
107: my @menu =
108: (
109: { text => 'Create a new group',
110: help => 'Course_Create_Group',
111: action => 'create',
112: permission => $manage_permission,
113: },
114: { text => 'Modify an existing group',
115: help => 'Course_Modify_Group',
116: action => 'modify',
117: permission => $manage_permission,
118: },
119: { text => 'Delete an existing group',
120: help => 'Course_Delete_Group',
121: action => 'delete',
122: permission => $manage_permission,
123: },
124: { text => 'Enter an existing group',
125: help => 'Course_Display_Group',
126: action => 'display',
127: permission => $view_permission,
128: },
129: );
130: my $menu_html = '';
131: foreach my $menu_item (@menu) {
132: next if (! $menu_item->{'permission'});
133: $menu_html.='<p>';
134: $menu_html.='<font size="+1">';
135: if (exists($menu_item->{'url'})) {
136: $menu_html.=qq{<a href="$menu_item->{'url'}">};
137: } else {
138: $menu_html.=
139: qq{<a href="/adm/coursegroups?action=$menu_item->{'action'}">};
140: }
141: $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
142: if (exists($menu_item->{'help'})) {
143: $menu_html.=
144: &Apache::loncommon::help_open_topic($menu_item->{'help'});
145: }
146: $menu_html.='</p>'.$/;
147: }
148: $r->print($menu_html);
149: return;
150: }
151:
152: sub footer {
153: return(<<ENDFOOT);
154: </form>
155: </body>
156: </html>
157: ENDFOOT
158:
159: }
160:
161: sub first_creation_form {
162: my ($r) = @_;
1.2 ! raeburn 163: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
! 164: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.1 raeburn 165: my %lt = &Apache::lonlocal::texthash(
166: 'gmem' => 'Group membership options',
167: 'picr' => 'Pick the criteria to use to build a list of course users from which you will select members of the new group',
168: 'gdat' => 'Group open and close dates',
169: 'sten' => 'Set a start date/time and end date/time for the group',
170: 'acst' => 'Active/Inactive status',
171: 'coro' => 'Course roles',
172: 'cose' => 'Course sections',
173: 'gfun' => 'Group functionality',
174: );
175:
176: my %status_types = (
177: active => &mt('Currently has access'),
178: previous => &mt('Previously had access'),
179: future => &mt('Will have future access'),
180: );
181:
182: my @roles = ('st','cc','in','ta','ep','cr');
183:
184: my %sectioncount = ();
185: my @sections = ();
186: my $section_sel = '';
187: my $numvisible;
1.2 ! raeburn 188: my $numsections = &Apache::loncommon::get_sections($cdom,$cnum,
! 189: \%sectioncount);
1.1 raeburn 190:
191: @sections = sort {$a cmp $b} keys(%sectioncount);
192: unshift(@sections,'all'); # Put 'all' at the front of the list
193: if ($numsections < 4) {
194: $numvisible = $numsections + 1;
195: }
196:
197: $r->print(<<"END");
198: <b>$lt{'gmem'}</b><br/> $lt{'picr'}
199: <br /><br />
200: <table border="0">
201: <tr>
202: <td><b>$lt{'acst'}</b></td>
203: <td> </td>
204: <td><b>$lt{'coro'}</b></td>
205: <td> </td>
206: <td><b>$lt{'cose'}</b></td>
207: <td> </td>
208: </tr>
209: <tr>
210: <tr>
211: END
212: $r->print(&Apache::lonhtmlcommon::status_select_row(\%status_types));
213: $r->print('<td> </td>');
214: $r->print(&Apache::lonhtmlcommon::role_select_row(\@roles));
215: $r->print(<<"END");
216: <td> </td>
217: <td align="center">
218: <select name="sectionpick" multiple="true" size="$numvisible">
219: $section_sel
220: </select>
221: </td>
222: </tr>
223: </table>
224: END
225: return;
226: }
227:
228: sub second_creation_form {
229: my ($r) = @_;
230: }
231:
232: sub completed_creation {
233: my ($r) = @_;
234: }
235:
236: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>