--- loncom/interface/lonpickstudent.pm 2006/06/02 13:58:31 1.19 +++ loncom/interface/lonpickstudent.pm 2006/12/06 20:54:13 1.20 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a student from the classlist # -# $Id: lonpickstudent.pm,v 1.19 2006/06/02 13:58:31 raeburn Exp $ +# $Id: lonpickstudent.pm,v 1.20 2006/12/06 20:54:13 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,6 +35,7 @@ use Apache::loncoursedata; use Apache::lonnet; use Apache::lonlocal; use Apache::longroup; +use LONCAPA; sub handler { my $r = shift; @@ -67,10 +68,14 @@ sub handler { } # See if filter present - my $filter=$env{'form.filter'}; - $filter=~s/\W//g; - unless ($filter) { $filter='.'; } + my $filtermsg; + if ($filter ne '') { + $filtermsg = '
'.&mt('Name starting with').' "'.$filter.'"
'; + $filter = quotemeta($filter); + } else { + $filter = '.' + } my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; @@ -82,7 +87,7 @@ sub handler { # --------------------------------------- There is such a user, get environment $r->print(< + ENDSCRIPT - - $r->print('
'); - if ($allowed && (!$env{'form.roles'})) { + + $r->print(''); + if ($allowed && (!$env{'form.roles'})) { # -------------------------------------------------------- Get course personnel - $r->print('

'.$env{'course.'.$env{'request.course.id'}.'.description'}. - '

'); - my %coursepersonnel= - &Apache::lonnet::get_course_adv_roles(); - $r->print(''); - foreach my $role (sort keys %coursepersonnel) { - foreach (split(/\,/,$coursepersonnel{$role})) { - my ($puname,$pudom)=split(/\:/,$_); - $role = &Apache::lonnet::plaintext($role, - &Apache::loncommon::course_type()); - $r->print(''); - } - } - $r->print('
'. - ''.$role.''. - &Apache::loncommon::aboutmewrapper( - &Apache::loncommon::plainname($puname, - $pudom),$puname,$pudom).'

 '); - if ($filter ne '.') { - $r->print('
'.&mt('Name starting with').' "'.$filter.'"
'); - } - $r->print('

'); - # ------------------------------------------------------------------ Students - foreach (sort keys %$classlist) { - # the following undefs are for 'domain', and 'username' respectively. - my (undef,undef,$end,$start,$id,$section,$fullname,$status)= - @{$classlist->{$_}}; - if ($allowed eq 'section' && $section ne $env{'request.course.sec'}) { - next; + $r->print('

'.$env{'course.'.$env{'request.course.id'}.'.description'}. + '

'); + my %coursepersonnel= + &Apache::lonnet::get_course_adv_roles(); + $r->print(&Apache::loncommon::start_data_table()); + foreach my $role (sort(keys(%coursepersonnel))) { + foreach (split(/\,/,$coursepersonnel{$role})) { + my ($puname,$pudom)=split(/\:/,$_); + $role = &Apache::lonnet::plaintext($role, + &Apache::loncommon::course_type()); + $r->print(&Apache::loncommon::start_data_table_row(). + ''. + &Apache::loncommon::end_data_table_row()); + } } - if ($_=~/^(\w+)\:(\w+)$/) { - my ($uname,$udom)=($1,$2); - if (($uname=~/^$filter/) || - ($fullname=~/^$filter/i)) { - my $grouplist = ''; - foreach my $group (sort(keys(%allgroups))) { - if (exists($grouplist{$group.':'.$uname.':'.$udom})) { - my ($end,$start) = split(/:/,$grouplist{$group.':'.$uname.':'.$udom}); - if (($end!=0) && ($end<$now)) { next; } - if (($start!=0) && ($start>$now)) {next; } - $grouplist .= " $group,"; - } - } - $grouplist =~ s/,$//; - $r->print(''. - ''); - } - } - } + $r->print(&Apache::loncommon::end_data_table().'

 '); - $r->print('

 usernamedomainNameIDsectionactive group(s)
'. + ''.$role.''. + &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($puname,$pudom),$puname,$pudom).'
'. - ''.$uname.' '.$udom. - ''. - &Apache::loncommon::aboutmewrapper( - $fullname, - $uname,$udom).''.$id.''.$section. - ''.$grouplist.'

'); - } else { - $r->print('

'.&mt('Users with Roles Assigned by').' '. - &Apache::loncommon::plainname($env{'user.name'}, - $env{'user.domain'}).'

'); - if ($filter ne '.') { - $r->print('
'.&mt('Name starting with').' "'.$filter.'"
'); - } - $r->print('

'); - my %users=&Apache::lonnet::get_my_roles(); - foreach (sort keys %users) { - if ($_=~/^(\w+)\:(\w+)\:(\w+)$/) { - my ($uname,$udom,$urole)=($1,$2,$3); - my $fullname=&Apache::loncommon::plainname($uname,$udom); - if (($uname=~/^$filter/) || - ($fullname=~/^$filter/i)) { - $r->print(''. - ''); - } - } + $r->print($filtermsg); + + $r->print('

'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + &Apache::loncommon::end_data_table_header_row(). + '

'. + ''. + ''. + ''. + ''. + ''. + ''. + &Apache::loncommon::end_data_table_header_row()); +# ------------------------------------------------------------------ Students + foreach my $user (sort(keys(%$classlist))) { + # the following undefs are for 'domain', and 'username' respectively. + my (undef,undef,$end,$start,$id,$section,$fullname,$status)= + @{$classlist->{$user}}; + if ($allowed eq 'section' && $section ne $env{'request.course.sec'}) { + next; + } + if ($user=~/^($LONCAPA::username_re)\:($LONCAPA::domain_re)$/) { + my ($uname,$udom)=($1,$2); + if (($uname=~/^$filter/) || + ($fullname=~/^$filter/i)) { + my $grouplist = ''; + foreach my $group (sort(keys(%allgroups))) { + if (exists($grouplist{$group.':'.$uname.':'.$udom})) { + my ($end,$start) = split(/:/,$grouplist{$group.':'.$uname.':'.$udom}); + if (($end!=0) && ($end<$now)) { next; } + if (($start!=0) && ($start>$now)) {next; } + $grouplist .= " $group,"; + } + } + $grouplist =~ s/,$//; + $r->print(&Apache::loncommon::start_data_table_row(). + ''. + ''. + &Apache::loncommon::end_data_table_row()); + } + } + } + + $r->print(&Apache::loncommon::end_data_table().'

'); + } else { + $r->print('

'.&mt('Users with Roles Assigned by').' '. + &Apache::loncommon::plainname($env{'user.name'}, + $env{'user.domain'}).'

'); + $r->print($filtermsg); + + $r->print('

'.&Apache::loncommon::start_data_table()); + my %users=&Apache::lonnet::get_my_roles(); + foreach my $user (sort(keys(%users))) { + if ($user =~ + /^($LONCAPA::username_re)\:($LONCAPA::domain_re)\:(\w+)$/) { + my ($uname,$udom,$urole)=($1,$2,$3); + my $fullname=&Apache::loncommon::plainname($uname,$udom); + if (($uname=~/^$filter/) || + ($fullname=~/^$filter/i)) { + $r->print(&Apache::loncommon::start_data_table_row(). + '

'. + ''. + &Apache::loncommon::end_data_table_row()); + } + } + } + $r->print(&Apache::loncommon::end_data_table().'

'); } - $r->print('
'. - ''.$uname.''.$udom. - ''. - &Apache::loncommon::aboutmewrapper( - $fullname, - $uname,$udom).''. - &Apache::lonnet::plaintext($urole). - '
 '.&mt('username').''.&mt('domain').''.&mt('Name').''.&mt('ID').''.&mt('section').''.&mt('active group(s)').''. + ''.$uname.' '.$udom. + ''. + &Apache::loncommon::aboutmewrapper($fullname, + $uname,$udom). + ''.$id.''.$section. + ''.$grouplist.''. + ''.$uname.''.$udom. + ''. + &Apache::loncommon::aboutmewrapper( + $fullname, + $uname,$udom).''. + &Apache::lonnet::plaintext($urole). + '

'); - } - $r->print('
'.&Apache::loncommon::end_page()); - return OK; + $r->print(''.&Apache::loncommon::end_page()); + return OK; } 1;