# # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # package Apache::loncoursegroups; use strict; use Apache::lonnet; use Apache::loncommon; use Apache::lonhtmlcommon; use Apache::lonlocal; use Apache::Constants qw(:common :http); sub handler { my ($r) = @_; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; if ($r->header_only) { return OK; } &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['action','state']); $r->print(&header()); &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/groups", text=>"Group Management", faq=>9,bug=>'Instructor Interface',}); # Needs to be in a course if (! ($env{'request.course.fn'})) { # Not in a course $env{'user.error.msg'}= "/adm/groups:mdg:0:0:Cannot create, modify or delete course groups"; return HTTP_NOT_ACCEPTABLE; } my $view_permission = &Apache::lonnet::allowed('vcg',$env{'request.course.id'}); my $manage_permission = &Apache::lonnet::allowed('mdg',$env{'request.course.id'}); if (! exists($env{'form.action'})) { $r->print(&Apache::lonhtmlcommon::breadcrumbs (undef,'Course Group Manager')); &print_main_menu($r,$manage_permission,$view_permission); } elsif ($env{'form.action'} eq 'create' && $manage_permission) { &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/coursegroups?action=create&state=', text=>"Create Group"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs (undef,'Create Group','Course_Create_Group')); if (! exists($env{'form.state'})) { &first_creation_form($r); } elsif ($env{'form.state'} eq 'pick_members') { &second_creation_form($r); } elsif ($env{'form.state'} eq 'complete') { &completed_creation($r); } else { &first_creation_form($r); } } $r->print(&footer()); return OK; } sub header { my $html=&Apache::lonxml::xmlbegin(); my $bodytag=&Apache::loncommon::bodytag('Course Groups Manager'); my $title = &mt('LON-CAPA Groups Manager'); return(< $title $bodytag
ENDHEAD } sub print_main_menu { my ($r,$manage_permission,$view_permission)=@_; my @menu = ( { text => 'Create a new group', help => 'Course_Create_Group', action => 'create', permission => $manage_permission, }, { text => 'Modify an existing group', help => 'Course_Modify_Group', action => 'modify', permission => $manage_permission, }, { text => 'Delete an existing group', help => 'Course_Delete_Group', action => 'delete', permission => $manage_permission, }, { text => 'Enter an existing group', help => 'Course_Display_Group', action => 'display', permission => $view_permission, }, ); my $menu_html = ''; foreach my $menu_item (@menu) { next if (! $menu_item->{'permission'}); $menu_html.='

'; $menu_html.=''; if (exists($menu_item->{'url'})) { $menu_html.=qq{}; } else { $menu_html.= qq{}; } $menu_html.= &mt($menu_item->{'text'}).''; if (exists($menu_item->{'help'})) { $menu_html.= &Apache::loncommon::help_open_topic($menu_item->{'help'}); } $menu_html.='

'.$/; } $r->print($menu_html); return; } sub footer { return(< ENDFOOT } sub first_creation_form { my ($r) = @_; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my %lt = &Apache::lonlocal::texthash( 'gmem' => 'Group membership options', 'picr' => 'Pick the criteria to use to build a list of course users from which you will select members of the new group', 'gdat' => 'Group open and close dates', 'sten' => 'Set a start date/time and end date/time for the group', 'acst' => 'Active/Inactive status', 'coro' => 'Course roles', 'cose' => 'Course sections', 'gfun' => 'Group functionality', ); my %status_types = ( active => &mt('Currently has access'), previous => &mt('Previously had access'), future => &mt('Will have future access'), ); my @roles = ('st','cc','in','ta','ep','cr'); my %sectioncount = (); my @sections = (); my $section_sel = ''; my $numvisible; my $numsections = &Apache::loncommon::get_sections($cdom,$cnum, \%sectioncount); @sections = sort {$a cmp $b} keys(%sectioncount); unshift(@sections,'all'); # Put 'all' at the front of the list if ($numsections < 4) { $numvisible = $numsections + 1; } $r->print(<<"END"); $lt{'gmem'}
$lt{'picr'}

END $r->print(&Apache::lonhtmlcommon::status_select_row(\%status_types)); $r->print(''); $r->print(&Apache::lonhtmlcommon::role_select_row(\@roles)); $r->print(<<"END");
$lt{'acst'}   $lt{'coro'}   $lt{'cose'}  
  
END return; } sub second_creation_form { my ($r) = @_; } sub completed_creation { my ($r) = @_; } 1;