version 1.21, 2007/07/21 00:48:55
|
version 1.29, 2011/01/23 01:04:26
|
Line 50 sub handler {
|
Line 50 sub handler {
|
|
|
&Apache::loncommon::get_unprocessed_cgi |
&Apache::loncommon::get_unprocessed_cgi |
($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement', |
($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement', |
'roles']); |
'roles','courseadvonly','clicker']); |
# Allowed? |
# Allowed? |
my $allowed; |
my $allowed; |
my $scope = $env{'request.course.id'}; |
my $scope = $env{'request.course.id'}; |
Line 70 sub handler {
|
Line 70 sub handler {
|
# See if filter present |
# See if filter present |
my $filter=$env{'form.filter'}; |
my $filter=$env{'form.filter'}; |
my $filtermsg; |
my $filtermsg; |
if ($filter eq '') { |
my $encoded_filter = &HTML::Entities::encode($filter,'<>&"'); |
$filter = '.' |
$filter = quotemeta($filter); |
} else { |
my $change = &mt('Change'); |
my $encoded_filter = &HTML::Entities::encode($filter,'<>&"'); |
my $filterbutton =<<FILTER; |
$filter = quotemeta($filter); |
|
my $change = &mt('Change'); |
|
my $filterbutton =<<FILTER; |
|
<input type="text" name="filter" value="$encoded_filter" /> |
<input type="text" name="filter" value="$encoded_filter" /> |
<input type="submit" name="Change" value="$change" /> |
<input type="submit" name="Change" value="$change" /> |
FILTER |
FILTER |
foreach my $name ('form','unameelement','udomelement','roles') { |
foreach my $name ('form','unameelement','udomelement','roles') { |
my $value = &HTML::Entities::encode($env{"form.$name"},'<>&"'); |
my $value = &HTML::Entities::encode($env{"form.$name"},'<>&"'); |
$filterbutton .= <<HIDDEN; |
$filterbutton .= <<HIDDEN; |
<input type="hidden" name="$name" value="$value" /> |
<input type="hidden" name="$name" value="$value" /> |
HIDDEN |
HIDDEN |
} |
} |
|
unless ($env{'form.courseadvonly'}) { |
$filtermsg = '<br />'. |
$filtermsg = '<br />'. |
&mt('Showing users with a name starting with [_1]', |
&mt('Showing users with a name starting with [_1]', |
$filterbutton).'<br />'; |
$filterbutton).'<br />'; |
|
} |
|
if ($filter eq '') { |
|
$filter = '.' |
} |
} |
|
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $classlist=&Apache::loncoursedata::get_classlist(); |
|
my %grouplist=&Apache::lonnet::get_group_membership($cdom,$cnum); |
|
my $now = time; |
|
my %allgroups = &Apache::longroup::coursegroups($cdom,$cnum); |
|
|
|
# --------------------------------------- There is such a user, get environment |
# --------------------------------------- There is such a user, get environment |
|
|
$r->print(<<ENDSCRIPT); |
$r->print(<<ENDSCRIPT); |
<script type="text/javascript"> |
<script type="text/javascript"> |
function gochoose(uname,udom) { |
function gochoose(uname,udom) { |
opener.document.$env{'form.form'}.$env{'form.unameelement'}.value=uname; |
opener.document.$env{'form.form'}.elements['$env{'form.unameelement'}'].value=uname; |
var slct=opener.document.$env{'form.form'}.$env{'form.udomelement'}; |
var slct=opener.document.$env{'form.form'}.elements['$env{'form.udomelement'}']; |
var i; |
var i; |
for (i=0;i<slct.length;i++) { |
for (i=0;i<slct.length;i++) { |
if (slct.options[i].value==udom) { slct.selectedIndex=i; } |
if (slct.options[i].value==udom) { slct.selectedIndex=i; } |
Line 123 ENDSCRIPT
|
Line 117 ENDSCRIPT
|
&Apache::lonnet::get_course_adv_roles(); |
&Apache::lonnet::get_course_adv_roles(); |
$r->print(&Apache::loncommon::start_data_table()); |
$r->print(&Apache::loncommon::start_data_table()); |
foreach my $role (sort(keys(%coursepersonnel))) { |
foreach my $role (sort(keys(%coursepersonnel))) { |
foreach (split(/\,/,$coursepersonnel{$role})) { |
foreach my $user (split(/\,/,$coursepersonnel{$role})) { |
my ($puname,$pudom)=split(/\:/,$_); |
my ($puname,$pudom)=split(/\:/,$user); |
$role = &Apache::lonnet::plaintext($role, |
|
&Apache::loncommon::course_type()); |
|
$r->print(&Apache::loncommon::start_data_table_row(). |
$r->print(&Apache::loncommon::start_data_table_row(). |
'<td>'. |
'<td>'. |
'<input type="button" value="Select" onClick="gochoose('. |
'<input type="button" value="'.&mt('Select').'" onClick="gochoose('. |
"'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'. |
"'".$puname."','".$pudom."')".'" /></td><td>'.$role.'</td><td>'. |
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($puname,$pudom),$puname,$pudom).'</td>'. |
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($puname,$pudom),$puname,$pudom).'</td>'. |
&Apache::loncommon::end_data_table_row()); |
&Apache::loncommon::end_data_table_row()); |
Line 139 ENDSCRIPT
|
Line 131 ENDSCRIPT
|
|
|
$r->print($filtermsg); |
$r->print($filtermsg); |
|
|
$r->print('</p><p>'. |
$r->print('</p>'); |
&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(). |
unless ($env{'form.courseadvonly'}) { |
&Apache::loncommon::end_data_table_header_row(). |
|
'<th> </th>'. |
|
'<th>'.&mt('username').'</th>'. |
|
'<th>'.&mt('domain').'</th>'. |
|
'<th>'.&mt('Name').'</th>'. |
|
'<th>'.&mt('ID').'</th>'. |
|
'<th>'.&mt('section').'</th>'. |
|
'<th>'.&mt('active group(s)').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row()); |
|
# ------------------------------------------------------------------ Students |
# ------------------------------------------------------------------ Students |
foreach my $user (sort(keys(%$classlist))) { |
|
# the following undefs are for 'domain', and 'username' respectively. |
# Do we have a clicker? |
my (undef,undef,$end,$start,$id,$section,$fullname,$status)= |
|
@{$classlist->{$user}}; |
my $clicker=$env{'form.clicker'}; |
if ($allowed eq 'section' && $section ne $env{'request.course.sec'}) { |
my @fragments=(); |
next; |
if ($clicker) { |
} |
$r->print('<h1>'.&mt('Clicker: [_1]',$clicker).'</h1>'); |
if ($user=~/^($LONCAPA::username_re)\:($LONCAPA::domain_re)$/) { |
my $clicklength=length($clicker); |
my ($uname,$udom)=($1,$2); |
my $maxlength=$clicklength-1; |
if (($uname=~/^$filter/) || |
if ($maxlength>2) { |
($fullname=~/^$filter/i)) { |
my $minlength=$maxlength-2; |
my $grouplist = ''; |
if ($minlength<2) { $minlength=2; } |
foreach my $group (sort(keys(%allgroups))) { |
for (my $length=$maxlength;$length>=$minlength;$length--) { |
if (exists($grouplist{$group.':'.$uname.':'.$udom})) { |
for (my $startidx=0; $startidx<=$clicklength-$length; $startidx++) { |
my ($end,$start) = split(/:/,$grouplist{$group.':'.$uname.':'.$udom}); |
push(@fragments,substr($clicker,$startidx,$length)); |
if (($end!=0) && ($end<$now)) { next; } |
} |
if (($start!=0) && ($start>$now)) {next; } |
} |
$grouplist .= " $group,"; |
} |
} |
} |
|
|
|
my $result; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $classlist=&Apache::loncoursedata::get_classlist(); |
|
my %grouplist=&Apache::lonnet::get_group_membership($cdom,$cnum); |
|
my $now = time; |
|
my %allgroups = &Apache::longroup::coursegroups($cdom,$cnum); |
|
|
|
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/,$//; |
|
my $markedupclicker; |
|
if ($clicker) { |
|
$markedupclicker=(&Apache::lonnet::userenvironment($udom,$uname,'clickers'))[1]; |
|
if ($markedupclicker!~/\w/) { |
|
$markedupclicker='-'; |
|
} else { |
|
foreach my $frag (@fragments) { |
|
if ($markedupclicker=~/\Q$frag\E/is) { |
|
$markedupclicker=~s/(\Q$frag\E)/<font color=\"green\" size=\"\+1\"><b>$1<\/b><\/font>/gis; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
$result .=&Apache::loncommon::start_data_table_row(). |
|
'<td>'. |
|
'<input type="button" value="'.&mt('Select').'" onClick="gochoose('. |
|
"'".$uname."','".$udom."')".'" /></td>'. |
|
'<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom. |
|
'</tt></td><td>'. |
|
&Apache::loncommon::aboutmewrapper($fullname, |
|
$uname,$udom). |
|
'</td><td>'.$id.'</td><td>'.$section. |
|
'</td><td>'.$grouplist.'</td>'. |
|
($clicker?'<td>'.$markedupclicker.'</td>':''). |
|
&Apache::loncommon::end_data_table_row(); |
} |
} |
$grouplist =~ s/,$//; |
} |
$r->print(&Apache::loncommon::start_data_table_row(). |
|
'<td>'. |
|
'<input type="button" value="'.&mt('Select').'" onClick="gochoose('. |
|
"'".$uname."','".$udom."')".'" /></td>'. |
|
'<td><tt>'.$uname.'</tt></td><td> <tt>'.$udom. |
|
'</tt></td><td>'. |
|
&Apache::loncommon::aboutmewrapper($fullname, |
|
$uname,$udom). |
|
'</td><td>'.$id.'</td><td>'.$section. |
|
'</td><td>'.$grouplist.'</td>'. |
|
&Apache::loncommon::end_data_table_row()); |
|
} |
|
} |
} |
} |
if (!$result) { |
|
$r->print('<p>'.&mt('No students found.').'</p>'); |
$r->print(&Apache::loncommon::end_data_table().'</p>'); |
} else { |
|
$r->print(&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(). |
|
&Apache::loncommon::end_data_table_header_row(). |
|
'<th> </th>'. |
|
'<th>'.&mt('username').'</th>'. |
|
'<th>'.&mt('domain').'</th>'. |
|
'<th>'.&mt('Name').'</th>'. |
|
'<th>'.&mt('ID').'</th>'. |
|
'<th>'.&mt('section').'</th>'. |
|
'<th>'.&mt('active group(s)').'</th>'. |
|
($clicker?'<th>'.&mt('clicker').'</th>':''). |
|
&Apache::loncommon::end_data_table_header_row(). |
|
$result. |
|
&Apache::loncommon::end_data_table()); |
|
} |
|
} |
} else { |
} else { |
$r->print('<h3>'.&mt('Users with Roles Assigned by').' '. |
$r->print('<h3>'.&mt('Users with Roles Assigned by').' '. |
&Apache::loncommon::plainname($env{'user.name'}, |
&Apache::loncommon::plainname($env{'user.name'}, |
Line 196 ENDSCRIPT
|
Line 239 ENDSCRIPT
|
$r->print($filtermsg); |
$r->print($filtermsg); |
|
|
$r->print('<p>'.&Apache::loncommon::start_data_table()); |
$r->print('<p>'.&Apache::loncommon::start_data_table()); |
my %users=&Apache::lonnet::get_my_roles(); |
my %user_role=&Apache::lonnet::get_my_roles(); |
foreach my $user (sort(keys(%users))) { |
my %users; |
if ($user =~ |
foreach my $user_role (keys(%user_role)) { |
/^($LONCAPA::username_re)\:($LONCAPA::domain_re)\:(\w+)$/) { |
next if ($user_role !~ |
my ($uname,$udom,$urole)=($1,$2,$3); |
/^($LONCAPA::username_re):($LONCAPA::domain_re):(\w+)$/); |
my $fullname=&Apache::loncommon::plainname($uname,$udom); |
my ($uname,$udom,$urole)=($1,$2,$3); |
if (($uname=~/^$filter/) || |
my $fullname=&Apache::loncommon::plainname($uname,$udom); |
($fullname=~/^$filter/i)) { |
next if (($uname!~/^$filter/i) && ($fullname !~/^$filter/i)); |
$r->print(&Apache::loncommon::start_data_table_row(). |
|
'<td>'. |
if (!exists($users{"$uname:$udom"})) { |
'<input type="button" value="Select" onClick="gochoose('. |
$users{"$uname:$udom"} = {'fullname' => $fullname }; |
"'".$uname."','".$udom."')".'" /></td>'. |
|
'<td><tt>'.$uname.'</tt></td><td><tt>'.$udom. |
|
'</tt></td><td>'. |
|
&Apache::loncommon::aboutmewrapper( |
|
$fullname, |
|
$uname,$udom).'</td><td><td>'. |
|
&Apache::lonnet::plaintext($urole). |
|
'</td>'. |
|
&Apache::loncommon::end_data_table_row()); |
|
} |
|
} |
} |
|
push(@{$users{"$uname:$udom"}{'roles'}},$urole); |
|
} |
|
foreach my $user (sort {lc($a) cmp lc($b)} (keys(%users))) { |
|
my ($uname,$udom) = split(':',$user); |
|
$r->print(&Apache::loncommon::start_data_table_row(). |
|
'<td>'. |
|
'<input type="button" value="'.&mt('Select').'" onClick="gochoose('. |
|
"'".$uname."','".$udom."')".'" /></td>'. |
|
'<td><tt>'.$uname.'</tt></td>'. |
|
'<td><tt>'.$udom.'</tt></td><td>'. |
|
&Apache::loncommon::aboutmewrapper($users{$user}{'fullname'}, |
|
$uname,$udom).'</td>'. |
|
'<td>'. |
|
join(', ',sort(map {&Apache::lonnet::plaintext($_)} |
|
(@{$users{$user}{'roles'}}))). |
|
'</td>'. |
|
&Apache::loncommon::end_data_table_row()); |
} |
} |
$r->print(&Apache::loncommon::end_data_table().'</p>'); |
$r->print(&Apache::loncommon::end_data_table().'</p>'); |
} |
} |