Annotation of loncom/interface/loncoursegroups.pm, revision 1.1

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 ($cdom,$cnum) = split/_/,$env{'request.course.id'};
        !           108:     my @menu =
        !           109:         (
        !           110:           { text => 'Create a new group',
        !           111:             help => 'Course_Create_Group',
        !           112:             action => 'create',
        !           113:             permission => $manage_permission,
        !           114:             },
        !           115:           { text => 'Modify an existing group',
        !           116:             help => 'Course_Modify_Group',
        !           117:             action => 'modify',
        !           118:             permission => $manage_permission,
        !           119:             },
        !           120:           { text => 'Delete an existing group',
        !           121:             help => 'Course_Delete_Group',
        !           122:             action => 'delete',
        !           123:             permission => $manage_permission,
        !           124:             },
        !           125:           { text => 'Enter an existing group',
        !           126:             help => 'Course_Display_Group',
        !           127:             action => 'display',
        !           128:             permission => $view_permission,
        !           129:             },
        !           130:           );
        !           131:     my $menu_html = '';
        !           132:     foreach my $menu_item (@menu) {
        !           133:         next if (! $menu_item->{'permission'});
        !           134:         $menu_html.='<p>';
        !           135:         $menu_html.='<font size="+1">';
        !           136:         if (exists($menu_item->{'url'})) {
        !           137:             $menu_html.=qq{<a href="$menu_item->{'url'}">};
        !           138:         } else {
        !           139:             $menu_html.=
        !           140:                 qq{<a href="/adm/coursegroups?action=$menu_item->{'action'}">};
        !           141:         }
        !           142:         $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
        !           143:         if (exists($menu_item->{'help'})) {
        !           144:             $menu_html.=
        !           145:                 &Apache::loncommon::help_open_topic($menu_item->{'help'});
        !           146:         }
        !           147:         $menu_html.='</p>'.$/;
        !           148:     }
        !           149:     $r->print($menu_html);
        !           150:     return;
        !           151: }
        !           152: 
        !           153: sub footer {
        !           154:        return(<<ENDFOOT);
        !           155:   </form>
        !           156:  </body>
        !           157: </html>
        !           158: ENDFOOT
        !           159:  
        !           160: }
        !           161: 
        !           162: sub first_creation_form {
        !           163:     my ($r) = @_;
        !           164:     my %lt = &Apache::lonlocal::texthash(
        !           165:         'gmem' => 'Group membership options',
        !           166:         'picr' => 'Pick the criteria to use to build a list of course users from which you will select members of the new group',   
        !           167:         'gdat' => 'Group open and close dates',
        !           168:         'sten' => 'Set a start date/time and end date/time for the group',
        !           169:         'acst' => 'Active/Inactive status',
        !           170:         'coro' => 'Course roles',
        !           171:         'cose' => 'Course sections',
        !           172:         'gfun' => 'Group functionality',
        !           173:     );
        !           174: 
        !           175:     my %status_types = (
        !           176:                    active => &mt('Currently has access'),
        !           177:                    previous => &mt('Previously had access'),
        !           178:                    future => &mt('Will have future access'),
        !           179:                    );
        !           180: 
        !           181:     my @roles = ('st','cc','in','ta','ep','cr');
        !           182: 
        !           183:     my %sectioncount = ();
        !           184:     my @sections = ();
        !           185:     my $section_sel = '';
        !           186:     my $numvisible;
        !           187:     my $numsections = &Apache::loncommon::get_sections($env{'course.'.$env{'request.course.id'}.'.domain'},$env{'course.'.$env{'request.course.id'}.'.num'},\%sectioncount);
        !           188: 
        !           189:     @sections = sort {$a cmp $b} keys(%sectioncount);
        !           190:     unshift(@sections,'all'); # Put 'all' at the front of the list
        !           191:     if ($numsections < 4) {
        !           192:         $numvisible = $numsections + 1;
        !           193:     }
        !           194: 
        !           195:     $r->print(<<"END");
        !           196: <b>$lt{'gmem'}</b><br/> $lt{'picr'}
        !           197: <br /><br />
        !           198: <table border="0">
        !           199:  <tr>
        !           200:  <td><b>$lt{'acst'}</b></td>
        !           201:   <td>&nbsp;</td>
        !           202:   <td><b>$lt{'coro'}</b></td>
        !           203:   <td>&nbsp;</td>
        !           204:   <td><b>$lt{'cose'}</b></td>
        !           205:   <td>&nbsp;</td>
        !           206:  </tr>
        !           207:  <tr>
        !           208:  <tr>
        !           209: END
        !           210:     $r->print(&Apache::lonhtmlcommon::status_select_row(\%status_types));
        !           211:     $r->print('<td>&nbsp;</td>');
        !           212:     $r->print(&Apache::lonhtmlcommon::role_select_row(\@roles));
        !           213:     $r->print(<<"END");
        !           214:   <td>&nbsp;</td>
        !           215:   <td align="center">
        !           216:    <select name="sectionpick" multiple="true" size="$numvisible">
        !           217:     $section_sel
        !           218:    </select>
        !           219:   </td>
        !           220:  </tr>
        !           221: </table>
        !           222: END
        !           223:     return;
        !           224: }
        !           225: 
        !           226: sub second_creation_form {
        !           227:     my ($r) = @_;
        !           228: }
        !           229: 
        !           230: sub completed_creation {
        !           231:     my ($r) = @_;
        !           232: }
        !           233: 
        !           234: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>