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

1.1       www         1: # The LearningOnline Network
                      2: # Pick a student from the classlist
                      3: #
1.7     ! www         4: # $Id: lonpickstudent.pm,v 1.6 2003/08/13 20:40:31 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
                     45:     $r->print(<<ENDDOCUMENT);
                     46: <html>
                     47: <head>
                     48: <title>The LearningOnline Network with CAPA</title>
                     49: </head>
                     50: ENDDOCUMENT
                     51: 
1.6       www        52: 
                     53: 
                     54: 
                     55:     &Apache::loncommon::get_unprocessed_cgi
                     56:         ($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement',
                     57: 			       'roles']);
                     58: # Allowed?
                     59: 
                     60:     unless (($ENV{'form.roles'}) ||
                     61:             (($ENV{'request.course.id'}) && 
                     62:              (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})))) {
                     63: 	$r->print('<body>No context.</body>');
1.1       www        64:         return OK;
                     65:     }
1.2       www        66: 
1.6       www        67: # See if filter present
1.1       www        68: 
1.2       www        69:     my $filter=$ENV{'form.filter'};
                     70:     $filter=~s/\W//g;
                     71:     unless ($filter) { $filter='.'; }
1.1       www        72: 
1.3       www        73:     my $classlist=&Apache::loncoursedata::get_classlist();
1.1       www        74:        
                     75: # --------------------------------------- There is such a user, get environment
                     76: 
                     77:     $r->print(&Apache::loncommon::bodytag("Selecting a User"));
1.2       www        78:     $r->print(<<ENDSCRIPT);
                     79: <script>
                     80: function gochoose(uname,udom) {
                     81:     opener.document.$ENV{'form.form'}.$ENV{'form.unameelement'}.value=uname;
                     82:     var slct=opener.document.$ENV{'form.form'}.$ENV{'form.udomelement'};
                     83:     var i;
                     84:     for (i=0;i<slct.length;i++) {
1.4       www        85:         if (slct.options[i].value==udom) { slct.selectedIndex=i; }
1.2       www        86:     }
                     87:     self.close();
                     88: }
                     89: </script>
                     90: ENDSCRIPT
                     91:     
1.6       www        92:   $r->print('<form>');
                     93:   if ((&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) &&
                     94:       (!$ENV{'form.roles'})) {
                     95: # -------------------------------------------------------- Get course personnel
1.2       www        96:     $r->print('<h3>'.$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
1.6       www        97:               '</h3>');
1.4       www        98:     my %coursepersonnel=
                     99:        &Apache::lonnet::get_course_adv_roles();
                    100:     $r->print('<table border="2">');
1.5       www       101:     foreach my $role (sort keys %coursepersonnel) {
1.4       www       102:        foreach (split(/\,/,$coursepersonnel{$role})) {
                    103: 	   my ($puname,$pudom)=split(/\:/,$_);
                    104: 	   $r->print('<tr><td>'.
                    105:              '<input type="button" value="Select" onClick="gochoose('.
                    106:              "'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'.
                    107: 		     &Apache::loncommon::aboutmewrapper(
                    108:                           &Apache::loncommon::plainname($puname,
                    109:                           $pudom),$puname,$pudom).'</td></tr>');
                    110: 	}
                    111:     }
                    112:     $r->print('</table><p>&nbsp;');
1.2       www       113:     if ($filter ne '.') {
1.7     ! www       114:        $r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />');
1.2       www       115:     }
1.6       www       116:     $r->print('</p><p><table>');
1.4       www       117:   # ------------------------------------------------------------------ Students
1.1       www       118:     foreach (sort keys %$classlist) {
1.3       www       119:         # the following undefs are for 'domain', and 'username' respectively.
                    120: 	my (undef,undef,$end,$start,$id,$section,$fullname,$status)=
                    121:             @{$classlist->{$_}};
                    122:         if ($_=~/^(\w+)\:(\w+)$/) {
1.1       www       123: 	    my ($uname,$udom)=($1,$2);
1.2       www       124: 	    if (($uname=~/^$filter/) || 
1.3       www       125:                 ($fullname=~/^$filter/i)) {
1.2       www       126: 	       $r->print('<tr><td>'.
1.7     ! www       127:                       '<input type="button" value="'.&mt('Select').'" onClick="gochoose('.
1.2       www       128:                       "'".$uname."','".$udom."')".'" /></td>'.
1.6       www       129:                          '<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom.
1.2       www       130:                          '</tt></td><td>'.
                    131:                          &Apache::loncommon::aboutmewrapper(
1.3       www       132:                          $fullname,
                    133:                          $uname,$udom).'</td><td>'.$id.'</td><td>'.$section.
                    134:                                        '</td></tr>');
1.2       www       135: 	   }
1.1       www       136:         }
                    137:     }
                    138: 
1.6       www       139:     $r->print('</table></p>');
                    140:   } else {
1.7     ! www       141:     $r->print('<h3>'.&mt('Users with Roles Assigned by').' '.
1.6       www       142: 	      &Apache::loncommon::plainname($ENV{'user.name'},
                    143: 					    $ENV{'user.domain'}).'</h3>');
                    144:     if ($filter ne '.') {
1.7     ! www       145:        $r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />');
1.6       www       146:     }
                    147:     $r->print('<p><table>');
                    148:     my %users=&Apache::lonnet::get_my_roles();
                    149:     foreach (sort keys %users) {
                    150:         if ($_=~/^(\w+)\:(\w+)\:(\w+)$/) {
                    151: 	    my ($uname,$udom,$urole)=($1,$2,$3);
                    152: 	    my $fullname=&Apache::loncommon::plainname($uname,$udom);
                    153: 	    if (($uname=~/^$filter/) || 
                    154:                 ($fullname=~/^$filter/i)) {
                    155: 	       $r->print('<tr><td>'.
                    156:                       '<input type="button" value="Select" onClick="gochoose('.
                    157:                       "'".$uname."','".$udom."')".'" /></td>'.
                    158:                          '<td><tt>'.$uname.'</tt></td><td><tt>'.$udom.
                    159:                          '</tt></td><td>'.
                    160:                          &Apache::loncommon::aboutmewrapper(
                    161:                          $fullname,
                    162:                          $uname,$udom).'</td><td><td>'.
                    163: 			 &Apache::lonnet::plaintext($urole).
                    164:                                        '</td></tr>');
                    165: 	   }
                    166:         }
                    167:     }
                    168:     $r->print('</table></p>');
                    169:   }
                    170:   $r->print('</form></body></html>');
                    171:   return OK;
1.1       www       172: } 
                    173: 
                    174: 1;
                    175: __END__

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