[LON-CAPA-cvs] cvs: loncom /interface loncoursequeueadmin.pm
raeburn
raeburn at source.lon-capa.org
Fri Dec 2 19:34:38 EST 2022
raeburn Sat Dec 3 00:34:38 2022 EDT
Modified files:
/loncom/interface loncoursequeueadmin.pm
Log:
- Listing of requests for assignment of roles to users from other domains
includes a menu to filter by date range, role type, request status, and
adjudicator. Entries only seen for users where user's domain is configured
to require approval from a DC in that domain.
-------------- next part --------------
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.64 loncom/interface/loncoursequeueadmin.pm:1.65
--- loncom/interface/loncoursequeueadmin.pm:1.64 Thu Dec 1 01:28:26 2022
+++ loncom/interface/loncoursequeueadmin.pm Sat Dec 3 00:34:38 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.64 2022/12/01 01:28:26 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.65 2022/12/03 00:34:38 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -411,7 +411,7 @@
sub display_queued_requests {
my ($context,$dom,$cnum,$secondary) = @_;
- my ($namespace,$formaction,$nextelement,%requesthash);
+ my ($namespace,$formaction,$nextelement,%requesthash,%reqstatus);
if ($context eq 'course') {
$formaction = '/adm/createuser';
$namespace = 'selfenrollrequests';
@@ -484,13 +484,15 @@
($entry) = (&unescape($item) =~ /^($match_username)_approval$/);
} elsif ($context eq 'othdomqueue') {
if (ref($requesthash{$item}) eq 'HASH') {
- next unless ($requesthash{'status&'.$item} eq 'pending');
my ($puname,$pudom,$prole,$psec) = split(/:/,$item);
$timestamp = $requesthash{$item}{'timestamp'};
my $adj = $requesthash{$item}{'adj'};
$entry = join(':',$puname,$pudom,$prole,$adj,
&escape($requesthash{$item}{'requester'}),
$psec);
+ } elsif ($item =~ /^status&/) {
+ my ($dummy,$key) = split(/&/,$item,2);
+ $reqstatus{$key} = $requesthash{$item};
}
} elsif ($context eq 'othdomaction') {
next unless ($item =~ /^pending:/);
@@ -539,13 +541,13 @@
$output .= '<h3>'.&mt('Requests for LON-CAPA accounts queued pending approval by a Domain Coordinator').'</h3>';
} elsif ($context eq 'othdomqueue') {
if ($secondary eq 'domain') {
- $output .= '<h3>'.&mt('Domain role assignments for users from another domain, queued pending approval').'</h3>';
+ $output .= '<h3>'.&mt('Domain role assignments for users from another domain which were/are queued for approval').'</h3>';
} elsif ($secondary eq 'author') {
- $output .= '<h3>'.&mt('Co-author role assignments for users from another domain, queued pending approval').'</h3>';
+ $output .= '<h3>'.&mt('Co-author role assignments for users from another domain which were/are queued for approval').'</h3>';
} elsif ($secondary eq 'course') {
- $output .= '<h3>'.&mt('Course role assignments for users from another domain, queued pending approval').'</h3>';
+ $output .= '<h3>'.&mt('Course role assignments for users from another domain which were/are queued for approval').'</h3>';
} elsif ($secondary eq 'community') {
- $output .= '<h3>'.&mt('Community role assignments for users from another domain, queued pending approval').'</h3>';
+ $output .= '<h3>'.&mt('Community role assignments for users from another domain which were/are queued for approval').'</h3>';
}
} elsif ($context eq 'othdomaction') {
if ($secondary eq 'user') {
@@ -555,9 +557,13 @@
}
} else {
$output .= '<h3>'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'</h3>';
- }
- $output .= &build_queue_display($dom,$context,\%queue_by_date,$secondary).
- '<input type="hidden" name="queue" value="approval" />';
+ }
+ if ($context eq 'othdomqueue') {
+ $output .= &queued_role_display($secondary,\%queue_by_date,\%reqstatus);
+ } else {
+ $output .= &build_queue_display($dom,$context,\%queue_by_date,$secondary).
+ '<input type="hidden" name="queue" value="approval" />';
+ }
if ($context eq 'pending') {
$output .= '<br /><input type="submit" name="validationcheck" value="'.
&mt('Validate').'" /><br />'."\n".
@@ -579,13 +585,13 @@
$output .= &mt('There are currently no requests for LON-CAPA accounts awaiting approval.');
} elsif ($context eq 'othdomqueue') {
if ($secondary eq 'domain') {
- $output .= &mt('There are currently no domain role assignment(s) for user(s) from another domain queued pending approval');
+ $output .= &mt('There are currently no domain role assignment(s) for user(s) from another domain which were/are queued for approval');
} elsif ($secondary eq 'author') {
- $output .= &mt('There are currently no co-author role assignment(s) for user(s) from another domain queued pending approval');
+ $output .= &mt('There are currently no co-author role assignment(s) for user(s) from another domain which were/are queued for approval');
} elsif ($secondary eq 'course') {
- $output .= &mt('There are currently no course role assignment(s) for user(s) from another domain queued pending approval');
+ $output .= &mt('There are currently no course role assignment(s) for user(s) from another domain which were/are queued for approval');
} elsif ($secondary eq 'community') {
- $output .= &mt('There are currently no community role assignment(s) for user(s) from another domain queued pending approval');
+ $output .= &mt('There are currently no community role assignment(s) for user(s) from another domain which were/are queued for approval');
}
} elsif ($context eq 'othdomaction') {
if ($secondary eq 'user') {
@@ -605,16 +611,13 @@
my ($dom,$context,$queue,$secondary) = @_;
return unless (ref($queue) eq 'HASH');
my (%crstypes,%roles_by_context,$output);
- if ($context eq 'othdomqueue') {
- $output = &print_filter_menu($context);
- }
$output .= &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row();
unless (($context eq 'pending') || ($context eq 'displaypending') ||
- ($context eq 'helpdesk') || ($context eq 'othdomqueue')) {
+ ($context eq 'helpdesk')) {
$output .= '<th>'.&mt('Action').'</th>';
}
- unless (($context eq 'othdomqueue') || (($context eq 'othdomaction') && ($secondary eq 'user'))) {
+ unless (($context eq 'othdomaction') && ($secondary eq 'user')) {
$output .= '<th>'.&mt('Requestor').'</th>';
}
if ($context eq 'course') {
@@ -625,14 +628,6 @@
} elsif ($context eq 'requestusername') {
$output .= '<th>'.&mt('Date requested').'</th>'.
'<th>'.&mt('Details').'</th>';
- } elsif ($context eq 'othdomqueue') {
- $output .= '<th>'.&mt('Date requested').'</th>'.
- '<th>'.&mt('Role').'</th>';
- if ($secondary eq 'course') {
- $output .= '<th>'.&mt('Section').'</th>';
- }
- $output .= '<th>'.&mt('Requested for').'</th>'.
- '<th>'.&mt('Approval needed from').'</th>';
} elsif ($context eq 'othdomaction') {
$output .= '<th>'.&mt('Date requested').'</th>'.
'<th>'.&mt('Role type').'</th>'.
@@ -698,25 +693,6 @@
"'$dom','$request','$queued'".');">'.$request.'</a>';
$namelink = $request;
}
- } elsif ($context eq 'othdomqueue') {
- my ($uname,$udom,$role,$adj,$requester,$sec) = split(/:/,$request);
- if ($adj eq 'user') {
- $adjudicator = &mt('Role Assignee');
- } elsif ($adj eq 'domain') {
- $adjudicator = &mt("[_1] in user's domain",
- &Apache::lonnet::plaintext('dc'));
- }
- my $crstype;
- $showrole = &Apache::lonnet::plaintext($role,$crstype);
- unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
- $namelink = &Apache::loncommon::plainname($uname,$udom)." ($uname:$udom)";
- }
- if ($secondary eq 'course') {
- $showsec = $sec;
- if ($showsec eq '') {
- $showsec = &mt('none');
- }
- }
} elsif ($context eq 'othdomaction') {
my ($status,$extent,$role,$crstype);
my ($info,$requester) = map { &unescape($_); } split(/:/,$request);
@@ -816,7 +792,7 @@
$ownername,$ownerdom);
}
unless (($context eq 'pending') || ($context eq 'displaypending') ||
- ($context eq 'helpdesk') || ($context eq 'othdomqueue')) {
+ ($context eq 'helpdesk')) {
$row = '<td><span class="LC_nobreak"><label>'.
'<input type="radio" value="'.$approve.'" name="'.$count.'radioreq" />'.&mt('Approve').'</label>'.
'<label>'.(' 'x2).
@@ -825,7 +801,7 @@
'<input type="radio" value="'."later:".$reject.'" name="'.$count.'radioreq" checked />'.&mt('Decide Later').
'</label></span><br /></td>';
}
- unless (($context eq 'othdomqueue') || ($context eq 'othdomaction')) {
+ unless ($context eq 'othdomaction') {
$row .= '<td>'.$namelink.'</td>'."\n";
}
if ($context eq 'course') {
@@ -836,14 +812,6 @@
} elsif ($context eq 'requestusername') {
$row .= '<td>'.$showtime.'</td>'."\n".
'<td>'.$detailslink.'</td>'."\n";
- } elsif ($context eq 'othdomqueue') {
- $row .= '<td>'.$showtime.'</td>'."\n".
- '<td>'.$showrole.'</td>'."\n";
- if ($secondary eq 'course') {
- $row .= '<td>'.$showsec.'</td>'."\n";
- }
- $row .= '<td>'.$namelink.'</td>'."\n".
- '<td>'.$adjudicator.'</td>'."\n";
} elsif ($context eq 'othdomaction') {
if ($secondary eq 'domain') {
$row .= '<td>'.$showrequester.'</td>'."\n";
@@ -874,10 +842,311 @@
return $output;
}
-sub print_filter_menu {
- my ($context) = @_;
+sub queued_role_display {
+ my ($context,$queue,$status) = @_;
+ return unless ((ref($queue) eq 'HASH') && (ref($status) eq 'HASH'));
+ my (%curr,$minshown,$maxshown,$more_records,$crstype,$viewablesec,$output);
+ my $formname = 'changequeue';
+ if ($context eq 'course') {
+ $crstype = &Apache::loncommon::course_type();
+ my ($permission,$allowed) =
+ &Apache::lonuserutils::get_permission($context,$crstype);
+ $viewablesec = &Apache::lonuserutils::viewable_section($permission);
+ my %saveable_parameters = ('show' => 'scalar',);
+ &Apache::loncommon::store_course_settings('roles_req',
+ \%saveable_parameters);
+ &Apache::loncommon::restore_course_settings('roles_req',
+ \%saveable_parameters);
+ }
+
+# Create navigation javascript
+ my $jsnav = &queued_log_js($formname);
+
+ $output = (<<ENDSCRIPT);
+<script type="text/javascript">
+// <![CDATA[
+$jsnav
+// ]]>
+</script>
+ENDSCRIPT
+
+ my $now = time();
+ my $defstart = $now - (7*24*3600); #7 days ago
+ my %defaults = (
+ page => '1',
+ show => '10',
+ role => 'any',
+ chgstatus => 'any',
+ chgadj => 'any',
+ rolereq_start_date => $defstart,
+ rolereq_end_date => $now,
+ );
+ $more_records = 0;
+ my %lt = &othdomrole_contexts();
+
+ foreach my $item ('show','page','role','chgstatus','chgadj') {
+ $curr{$item} = $env{'form.'.$item};
+ }
+ ($curr{'rolereq_start_date'},$curr{'rolereq_end_date'}) =
+ &Apache::lonuserutils::get_dates_from_form('rolereq_start_date','rolereq_end_date');
+ foreach my $key (keys(%defaults)) {
+ if ($curr{$key} eq '') {
+ $curr{$key} = $defaults{$key};
+ }
+ }
+ $minshown = 1;
+ my $count = 0;
+ if ($curr{'show'} =~ /\D/) {
+ $curr{'page'} = 1;
+ } else {
+ $maxshown = $curr{'page'} * $curr{'show'};
+ if ($curr{'page'} > 1) {
+ $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
+ }
+ }
+ $output .= &print_filter_menu($context,'changequeue',\%curr,$crstype);
+
+ my $showntableheader = 0;
+
+ # Table Header
+ my $tableheader =
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ '<th>'.&mt('Date requested').'</th>'.
+ '<th>'.&mt('Role').'</th>';
+ if ($context eq 'course') {
+ $tableheader .= '<th>'.&mt('Section').'</th>';
+ }
+ $tableheader .= '<th>'.&mt('Requested for').'</th>'.
+ '<th>'.&mt('Request status').'</th>'.
+ '<th>'.&mt('Adjudicator').'</th>'.
+ &Apache::loncommon::end_data_table_header_row();
+
+ my @sortedtimes = sort {$a <=> $b} (keys(%{$queue}));
+ my $count = 0;
+ foreach my $item (@sortedtimes) {
+ next if (($item < $curr{'rolereq_start_date'}) ||
+ ($item > $curr{'rolereq_end_date'}));
+ if (ref($queue->{$item}) eq 'ARRAY') {
+ foreach my $request (sort(@{$queue->{$item}})) {
+ if ($curr{'show'} !~ /\D/) {
+ if ($count >= $curr{'page'} * $curr{'show'}) {
+ $more_records = 1;
+ last;
+ }
+ }
+ my ($showtime,$showsec,$namelink,$showrole,$showadj,
+ $showstatus,$id);
+ $showtime = &Apache::lonlocal::locallocaltime($item);
+ my ($uname,$udom,$role,$adj,$requester,$sec) = split(/:/,$request);
+ $id = join(':',($uname,$udom,$role));
+ if ($context eq 'course') {
+ $id .= ':'.$sec;
+ }
+ if ($curr{'role'} ne 'any') {
+ if ($curr{'role'} eq 'cr') {
+ next unless ($role =~ m{^cr/});
+ } else {
+ next unless ($role eq $curr{'role'});
+ }
+ }
+ if ($curr{'chgstatus'} ne 'any') {
+ next if ($status->{$id} ne $curr{'chgstatus'});
+ }
+ if ($curr{'chgadj'} ne 'any') {
+ next if ($adj ne $curr{'chgadj'});
+ }
+ if (($context eq 'course') && ($viewablesec ne '')) {
+ next if ($sec ne $viewablesec);
+ }
+ $count ++;
+ next if ($count < $minshown);
+ unless ($showntableheader) {
+ $output .= $tableheader;
+ $showntableheader = 1;
+ }
+ $showrole = &Apache::lonnet::plaintext($role,$crstype);
+ $showstatus = $lt{$status->{$id}};
+ $showadj = $lt{$adj};
+ unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
+ $namelink = &Apache::loncommon::plainname($uname,$udom)." ($uname:$udom)";
+ }
+ if ($context eq 'course') {
+ $showsec = $sec;
+ if ($showsec eq '') {
+ $showsec = &mt('none');
+ }
+ }
+ $output .= &Apache::loncommon::start_data_table_row()."\n".
+ '<td>'.$showtime.'</td>'."\n".
+ '<td>'.$showrole.'</td>'."\n";
+ if ($context eq 'course') {
+ $output .= '<td>'.$showsec.'</td>'."\n";
+ }
+ $output .= '<td>'.$namelink.'</td>'."\n".
+ '<td>'.$showstatus.'</td>'."\n".
+ '<td>'.$showadj.'</td>'."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ }
+ }
+
+ if ($showntableheader) { # Table footer, if content displayed above
+ $output .= &Apache::loncommon::end_data_table().
+ &queued_role_navlinks(\%curr,$more_records);
+ } else { # No content displayed above
+ $output .= '<p class="LC_info">'.
+ &mt('There are no records to display.').
+ '</p>';
+ }
+ $output .= '<input type="hidden" name="page" value="'.$curr{'page'}.'" />';
+ return $output;
+}
+
+sub queued_log_js {
+ my ($formname) = @_;
+ return <<"ENDSCRIPT";
+
+function chgPage(caller) {
+ if (caller == 'previous') {
+ document.$formname.page.value --;
+ }
+ if (caller == 'next') {
+ document.$formname.page.value ++;
+ }
+ document.$formname.submit();
return;
}
+ENDSCRIPT
+}
+
+sub queued_role_navlinks {
+ my ($curr,$more_records) = @_;
+ return unless(ref($curr) eq 'HASH');
+ # Navigation Buttons
+ my $nav_links;
+ if (($curr->{'page'} > 1) || ($more_records)) {
+ $nav_links = '<p>';
+ if (($curr->{'page'} > 1) && ($curr->{'show'} !~ /\D/)) {
+ $nav_links .= '<input type="button"'
+ .' onclick="javascript:chgPage('."'previous'".');"'
+ .' value="'.&mt('Previous [_1] changes',$curr->{'show'})
+ .'" /> ';
+ }
+ if ($more_records) {
+ $nav_links .= '<input type="button"'
+ .' onclick="javascript:chgPage('."'next'".');"'
+ .' value="'.&mt('Next [_1] changes',$curr->{'show'})
+ .'" />';
+ }
+ $nav_links .= '</p>';
+ }
+ return $nav_links;
+}
+
+sub print_filter_menu {
+ my ($context,$formname,$curr,$crstype) = @_;
+
+ my $nolink = 1;
+ my $output = '<table><tr><td valign="top">'.
+ '<span class="LC_nobreak"><b>'.&mt('Changes/page:').'</b></span><br />'.
+ &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
+ (&mt('all'),5,10,20,50,100,1000,10000)).
+ '</td><td> </td>';
+ my $startform =
+ &Apache::lonhtmlcommon::date_setter($formname,'rolereq_start_date',
+ $curr->{'rolereq_start_date'},undef,
+ undef,undef,undef,undef,undef,undef,$nolink);
+ my $endform =
+ &Apache::lonhtmlcommon::date_setter($formname,'rolereq_end_date',
+ $curr->{'rolereq_end_date'},undef,
+ undef,undef,undef,undef,undef,undef,$nolink);
+ my %lt = &othdomrole_contexts();
+ $output .= '<td valign="top"><b>'.&mt('Time window in which role was requested').':</b><br />'.
+ '<table><tr><td>'.&mt('After:').
+ '</td><td>'.$startform.'</td></tr>'.
+ '<tr><td>'.&mt('Before:').'</td>'.
+ '<td>'.$endform.'</td></tr></table>'.
+ '</td>'.
+ '<td> </td>'.
+ '<td valign="top"><b>'.&mt('Requested role').':</b><br />'.
+ '<select name="role"><option value="any"';
+ if ($curr->{'role'} eq 'any') {
+ $output .= ' selected="selected"';
+ }
+ $output .= '>'.&mt('Any').'</option>'."\n";
+ my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype);
+ foreach my $role (@roles) {
+ my $plrole;
+ if ($role eq 'cr') {
+ $plrole = &mt('Custom Role');
+ } else {
+ $plrole=&Apache::lonnet::plaintext($role,$crstype);
+ }
+ my $selstr = '';
+ if ($role eq $curr->{'role'}) {
+ $selstr = ' selected="selected"';
+ }
+ $output .= ' <option value="'.$role.'"'.$selstr.'>'.$plrole.'</option>';
+ }
+ $output .= '</select></td>'.
+ '<td> </td>'.
+ '<td valign="top"><b>'.
+ &mt('Request status').':</b><br />'.
+ '<select name="chgstatus">'.
+ '<option value="any"';
+ if ($curr->{'chgstatus'} eq 'any') {
+ $output .= ' selected="selected"';
+ }
+ $output .= '>'.&mt('Any').'</option>'."\n";
+ my @possstatus = ('pending','approved','rejected');
+ foreach my $statustype (@possstatus) {
+ my $selstr = '';
+ if ($curr->{'chgstatus'} eq $statustype) {
+ $selstr = ' selected="selected"';
+ }
+ $output .= '<option value="'.$statustype.'"'.$selstr.'>'.$lt{$statustype}.'</option>'."\n";
+ }
+ $output .= '</select></td>'.
+ '<td> </td>'.
+ '<td valign="top"><b>'.
+ &mt('Adjudicator').':</b><br />'.
+ '<select name="chgadj">'.
+ '<option value="any"';
+ if ($curr->{'adj'} eq 'any') {
+ $output .= ' selected="selected"';
+ }
+ $output .= '>'.&mt('Any').'</option>'."\n";
+ my @possadj = ('domain','user');
+ foreach my $adjtype (@possadj) {
+ my $selstr = '';
+ if ($curr->{'chgadj'} eq $adjtype) {
+ $selstr = ' selected="selected"';
+ }
+ $output .= '<option value="'.$adjtype.'"'.$selstr.'>'.$lt{$adjtype}.'</option>'."\n";
+ }
+ $output .= '</select></td>'
+ .'</tr></table>';
+
+ # Update Display button
+ $output .= '<p>'.
+ '<input type="submit" value="'.&mt('Update Display').'" />'.
+ '</p>'.
+ '<hr />';
+ return $output;
+}
+
+sub othdomrole_contexts {
+ my %lt = &Apache::lonlocal::texthash(
+ pending => 'Queued',
+ approved => 'Approved',
+ rejected => 'Rejected',
+ user => 'User who acquires role',
+ );
+ $lt{'domain'} = &mt("[_1] in user's domain",
+ &Apache::lonnet::plaintext('dc'));
+ return %lt;
+}
sub update_request_queue {
my ($context,$cdom,$cnum,$coursedesc) = @_;
More information about the LON-CAPA-cvs
mailing list