Annotation of loncom/interface/lonpickstudent.pm, revision 1.8

1.1       www         1: # The LearningOnline Network
                      2: # Pick a student from the classlist
                      3: #
1.8     ! albertel    4: # $Id: lonpickstudent.pm,v 1.7 2003/09/22 00:48:32 www Exp $
1.1       www         5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: package Apache::lonpickstudent;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
                     33: use Apache::loncommon;
                     34: use Apache::loncoursedata;
                     35: use Apache::lonnet;
1.7       www        36: use Apache::lonlocal;
1.1       www        37: 
                     38: sub handler {
                     39:     my $r = shift;
1.7       www        40:     &Apache::loncommon::content_type($r,'text/html');
1.1       www        41:     $r->send_http_header;
                     42:     return OK if $r->header_only;
                     43: 
                     44: # ------------------------------------------------------------ Print the screen
1.8     ! albertel   45:     my $html=&Apache::lonxml::xmlbegin();
1.1       www        46:     $r->print(<<ENDDOCUMENT);
1.8     ! albertel   47: $html
1.1       www        48: <head>
                     49: <title>The LearningOnline Network with CAPA</title>
                     50: </head>
                     51: ENDDOCUMENT
                     52: 
1.6       www        53: 
                     54: 
                     55: 
                     56:     &Apache::loncommon::get_unprocessed_cgi
                     57:         ($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement',
                     58: 			       'roles']);
                     59: # Allowed?
                     60: 
                     61:     unless (($ENV{'form.roles'}) ||
                     62:             (($ENV{'request.course.id'}) && 
                     63:              (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})))) {
                     64: 	$r->print('<body>No context.</body>');
1.1       www        65:         return OK;
                     66:     }
1.2       www        67: 
1.6       www        68: # See if filter present
1.1       www        69: 
1.2       www        70:     my $filter=$ENV{'form.filter'};
                     71:     $filter=~s/\W//g;
                     72:     unless ($filter) { $filter='.'; }
1.1       www        73: 
1.3       www        74:     my $classlist=&Apache::loncoursedata::get_classlist();
1.1       www        75:        
                     76: # --------------------------------------- There is such a user, get environment
                     77: 
                     78:     $r->print(&Apache::loncommon::bodytag("Selecting a User"));
1.2       www        79:     $r->print(<<ENDSCRIPT);
                     80: <script>
                     81: function gochoose(uname,udom) {
                     82:     opener.document.$ENV{'form.form'}.$ENV{'form.unameelement'}.value=uname;
                     83:     var slct=opener.document.$ENV{'form.form'}.$ENV{'form.udomelement'};
                     84:     var i;
                     85:     for (i=0;i<slct.length;i++) {
1.4       www        86:         if (slct.options[i].value==udom) { slct.selectedIndex=i; }
1.2       www        87:     }
                     88:     self.close();
                     89: }
                     90: </script>
                     91: ENDSCRIPT
                     92:     
1.6       www        93:   $r->print('<form>');
                     94:   if ((&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) &&
                     95:       (!$ENV{'form.roles'})) {
                     96: # -------------------------------------------------------- Get course personnel
1.2       www        97:     $r->print('<h3>'.$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
1.6       www        98:               '</h3>');
1.4       www        99:     my %coursepersonnel=
                    100:        &Apache::lonnet::get_course_adv_roles();
                    101:     $r->print('<table border="2">');
1.5       www       102:     foreach my $role (sort keys %coursepersonnel) {
1.4       www       103:        foreach (split(/\,/,$coursepersonnel{$role})) {
                    104: 	   my ($puname,$pudom)=split(/\:/,$_);
                    105: 	   $r->print('<tr><td>'.
                    106:              '<input type="button" value="Select" onClick="gochoose('.
                    107:              "'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'.
                    108: 		     &Apache::loncommon::aboutmewrapper(
                    109:                           &Apache::loncommon::plainname($puname,
                    110:                           $pudom),$puname,$pudom).'</td></tr>');
                    111: 	}
                    112:     }
                    113:     $r->print('</table><p>&nbsp;');
1.2       www       114:     if ($filter ne '.') {
1.7       www       115:        $r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />');
1.2       www       116:     }
1.6       www       117:     $r->print('</p><p><table>');
1.4       www       118:   # ------------------------------------------------------------------ Students
1.1       www       119:     foreach (sort keys %$classlist) {
1.3       www       120:         # the following undefs are for 'domain', and 'username' respectively.
                    121: 	my (undef,undef,$end,$start,$id,$section,$fullname,$status)=
                    122:             @{$classlist->{$_}};
                    123:         if ($_=~/^(\w+)\:(\w+)$/) {
1.1       www       124: 	    my ($uname,$udom)=($1,$2);
1.2       www       125: 	    if (($uname=~/^$filter/) || 
1.3       www       126:                 ($fullname=~/^$filter/i)) {
1.2       www       127: 	       $r->print('<tr><td>'.
1.7       www       128:                       '<input type="button" value="'.&mt('Select').'" onClick="gochoose('.
1.2       www       129:                       "'".$uname."','".$udom."')".'" /></td>'.
1.6       www       130:                          '<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom.
1.2       www       131:                          '</tt></td><td>'.
                    132:                          &Apache::loncommon::aboutmewrapper(
1.3       www       133:                          $fullname,
                    134:                          $uname,$udom).'</td><td>'.$id.'</td><td>'.$section.
                    135:                                        '</td></tr>');
1.2       www       136: 	   }
1.1       www       137:         }
                    138:     }
                    139: 
1.6       www       140:     $r->print('</table></p>');
                    141:   } else {
1.7       www       142:     $r->print('<h3>'.&mt('Users with Roles Assigned by').' '.
1.6       www       143: 	      &Apache::loncommon::plainname($ENV{'user.name'},
                    144: 					    $ENV{'user.domain'}).'</h3>');
                    145:     if ($filter ne '.') {
1.7       www       146:        $r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />');
1.6       www       147:     }
                    148:     $r->print('<p><table>');
                    149:     my %users=&Apache::lonnet::get_my_roles();
                    150:     foreach (sort keys %users) {
                    151:         if ($_=~/^(\w+)\:(\w+)\:(\w+)$/) {
                    152: 	    my ($uname,$udom,$urole)=($1,$2,$3);
                    153: 	    my $fullname=&Apache::loncommon::plainname($uname,$udom);
                    154: 	    if (($uname=~/^$filter/) || 
                    155:                 ($fullname=~/^$filter/i)) {
                    156: 	       $r->print('<tr><td>'.
                    157:                       '<input type="button" value="Select" onClick="gochoose('.
                    158:                       "'".$uname."','".$udom."')".'" /></td>'.
                    159:                          '<td><tt>'.$uname.'</tt></td><td><tt>'.$udom.
                    160:                          '</tt></td><td>'.
                    161:                          &Apache::loncommon::aboutmewrapper(
                    162:                          $fullname,
                    163:                          $uname,$udom).'</td><td><td>'.
                    164: 			 &Apache::lonnet::plaintext($urole).
                    165:                                        '</td></tr>');
                    166: 	   }
                    167:         }
                    168:     }
                    169:     $r->print('</table></p>');
                    170:   }
                    171:   $r->print('</form></body></html>');
                    172:   return OK;
1.1       www       173: } 
                    174: 
                    175: 1;
                    176: __END__

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