![]() ![]() | ![]() |
- mode <head> </headh> <</body> elimination
1: # The LearningOnline Network 2: # Pick a student from the classlist 3: # 4: # $Id: lonpickstudent.pm,v 1.11 2006/03/15 22:11:04 albertel Exp $ 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; 36: use Apache::lonlocal; 37: 38: sub handler { 39: my $r = shift; 40: &Apache::loncommon::content_type($r,'text/html'); 41: $r->send_http_header; 42: return OK if $r->header_only; 43: 44: # ------------------------------------------------------------ Print the screen 45: $r->print(&Apache::loncommon::start_page("Selecting a User")); 46: 47: 48: &Apache::loncommon::get_unprocessed_cgi 49: ($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement', 50: 'roles']); 51: # Allowed? 52: my $allowed; 53: my $scope = $env{'request.course.id'}; 54: if (!($allowed = &Apache::lonnet::allowed('srm',$scope))) { 55: $scope .= '/'.$env{'request.course.sec'}; 56: $allowed = &Apache::lonnet::allowed('srm',$scope); 57: if ($allowed) { $allowed = 'section'; } 58: } 59: 60: unless (($env{'form.roles'}) || 61: (($env{'request.course.id'}) && ($allowed))) { 62: $r->print(&mt('No context.'). 63: &Apache::loncommon::end_page()); 64: return OK; 65: } 66: 67: # See if filter present 68: 69: my $filter=$env{'form.filter'}; 70: $filter=~s/\W//g; 71: unless ($filter) { $filter='.'; } 72: 73: my $classlist=&Apache::loncoursedata::get_classlist(); 74: 75: # --------------------------------------- There is such a user, get environment 76: 77: $r->print(<<ENDSCRIPT); 78: <script> 79: function gochoose(uname,udom) { 80: opener.document.$env{'form.form'}.$env{'form.unameelement'}.value=uname; 81: var slct=opener.document.$env{'form.form'}.$env{'form.udomelement'}; 82: var i; 83: for (i=0;i<slct.length;i++) { 84: if (slct.options[i].value==udom) { slct.selectedIndex=i; } 85: } 86: self.close(); 87: } 88: </script> 89: ENDSCRIPT 90: 91: $r->print('<form>'); 92: if ($allowed && (!$env{'form.roles'})) { 93: # -------------------------------------------------------- Get course personnel 94: $r->print('<h3>'.$env{'course.'.$env{'request.course.id'}.'.description'}. 95: '</h3>'); 96: my %coursepersonnel= 97: &Apache::lonnet::get_course_adv_roles(); 98: $r->print('<table border="2">'); 99: foreach my $role (sort keys %coursepersonnel) { 100: foreach (split(/\,/,$coursepersonnel{$role})) { 101: my ($puname,$pudom)=split(/\:/,$_); 102: $r->print('<tr><td>'. 103: '<input type="button" value="Select" onClick="gochoose('. 104: "'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'. 105: &Apache::loncommon::aboutmewrapper( 106: &Apache::loncommon::plainname($puname, 107: $pudom),$puname,$pudom).'</td></tr>'); 108: } 109: } 110: $r->print('</table><p> '); 111: if ($filter ne '.') { 112: $r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />'); 113: } 114: $r->print('</p><p><table>'); 115: # ------------------------------------------------------------------ Students 116: foreach (sort keys %$classlist) { 117: # the following undefs are for 'domain', and 'username' respectively. 118: my (undef,undef,$end,$start,$id,$section,$fullname,$status)= 119: @{$classlist->{$_}}; 120: if ($allowed eq 'section' && $section ne $env{'request.course.sec'}) { 121: next; 122: } 123: if ($_=~/^(\w+)\:(\w+)$/) { 124: my ($uname,$udom)=($1,$2); 125: if (($uname=~/^$filter/) || 126: ($fullname=~/^$filter/i)) { 127: $r->print('<tr><td>'. 128: '<input type="button" value="'.&mt('Select').'" onClick="gochoose('. 129: "'".$uname."','".$udom."')".'" /></td>'. 130: '<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom. 131: '</tt></td><td>'. 132: &Apache::loncommon::aboutmewrapper( 133: $fullname, 134: $uname,$udom).'</td><td>'.$id.'</td><td>'.$section. 135: '</td></tr>'); 136: } 137: } 138: } 139: 140: $r->print('</table></p>'); 141: } else { 142: $r->print('<h3>'.&mt('Users with Roles Assigned by').' '. 143: &Apache::loncommon::plainname($env{'user.name'}, 144: $env{'user.domain'}).'</h3>'); 145: if ($filter ne '.') { 146: $r->print('<br/ >'.&mt('Name starting with').' "'.$filter.'"<br />'); 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>'.&Apache::loncommon::end_page()); 172: return OK; 173: } 174: 175: 1; 176: __END__