--- loncom/interface/grouproster.pm 2006/07/02 18:01:47 1.1
+++ loncom/interface/grouproster.pm 2019/08/05 18:02:17 1.10.2.1
@@ -1,5 +1,7 @@
# The LearningOnline Network with CAPA
#
+# $Id: grouproster.pm,v 1.10.2.1 2019/08/05 18:02:17 raeburn Exp $
+#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -31,6 +33,8 @@ use Apache::loncommon;
use Apache::lonhtmlcommon;
use Apache::lonlocal;
use Apache::longroup;
+use Apache::lonnavmaps;
+use LONCAPA;
use Apache::Constants qw(:common :http);
use lib '/home/httpd/lib/perl/';
@@ -51,38 +55,49 @@ sub handler {
return HTTP_NOT_ACCEPTABLE;
}
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['group']);
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['group','ref','status']);
my $gpterm = &Apache::loncommon::group_term();
my $ucgpterm = $gpterm;
$ucgpterm =~ s/^(\w)/uc($1)/e;
my $crstype = &Apache::loncommon::course_type();
my $group;
+ my %curr_groups;
+ # Validating group input.
+ my $badinput;
if ((!defined($env{'form.group'})) || ($env{'form.group'} eq '')) {
- $r->print(&mt('No [_1] name provided',$gpterm));
-
+ $r->print(&mt('No group name provided.').'
');
+ $badinput = 1;
} else {
$group = $env{'form.group'};
$group =~ s/\W//g;
}
- if ($group eq '') {
- $r->print(&mt('Invalid [_1] name provided',$gpterm));
+ if (!$badinput && $group eq '') {
+ $r->print(&mt('Invalid group name provided.').'
');
+ $badinput = 1;
}
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
if ($cdom eq '' || $cnum eq '') {
- $r->print(&mt('Invalid [_1]',$crstype));
+ $r->print(&mt('Invalid [_1]',$crstype).'
');
+ $badinput = 1;
}
- my @coursegroups = split(/:/,$env{'request.course.groups'});
- if ((@coursegroups == 0) || ((@coursegroups > 0) &&
- (!(grep/^\Q$group\E$/,@coursegroups)))) {
- $r->print(&mt('[_1] is not the name of a valid [_2] in this [_3].',
- $group,$gpterm,lc($crstype)));
- }
+ if (!$badinput) {
+ %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
+ if (!defined($curr_groups{$group})) {
+ $r->print(&mt('"[_1]" is not the name of a valid group in this [_2].',
+ $group,lc($crstype)));
+ $badinput = 1;
+ }
+ }
+ if ($badinput) {
+ return OK;
+ }
&Apache::lonhtmlcommon::clear_breadcrumbs();
@@ -90,15 +105,14 @@ sub handler {
'/'.$group);
my $view_details = &Apache::lonnet::allowed('vmd',$env{'request.course.id'}.'/'.$group);
- my $viewgrps = &Apache::lonnet::allowed('vcg',$env{'request.course.id'});
+ my $viewgrps = &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
my $editgrps = &Apache::lonnet::allowed('mdg',$env{'request.course.id'});
if ((!$can_view) && (!$view_details) && (!$viewgrps) && (!$editgrps)) {
- $r->print(&mt('You do not have privileges to view the membership roster in this [_1]',$gpterm));
+ $r->print(&mt('You do not have privileges to view the membership roster in this '.$gpterm.'.'));
return OK;
}
- my %coursegroups = &Apache::longroup::coursegroups($cdom,$cnum,$group);
- my %content = &Apache::longroup::get_group_settings($coursegroups{$group});
+ my %content = &Apache::longroup::get_group_settings($curr_groups{$group});
my $description = &unescape($content{'description'});
$r->print(&roster_header($cdom,$cnum,$group,$description,$gpterm,$ucgpterm));
@@ -118,23 +132,54 @@ sub handler {
sub roster_header {
my ($cdom,$cnum,$group,$description,$gpterm,$ucgpterm) = @_;
+ my $refarg;
+ if (exists($env{'form.ref'}) && $env{'form.ref'} ne 'popup') {
+ $refarg = 'ref='.$env{'form.ref'};
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/coursegroups",
+ text=>"Groups",
+ title=>"View course groups"});
+ }
+ my $args;
+ if ($env{'form.ref'} eq 'popup') {
+ $args = {
+ 'no_nav_bar' => 1,
+ 'no_inline_link' => 1,
+ };
+ }
my $jscript = qq|
function changeSort(caller) {
document.grouproster.sortby.value = caller;
document.grouproster.submit();
}\n|;
+ my $itemtitle = &mt('Group membership status - [_1]',$description);
my $output =
- &Apache::loncommon::start_page(&mt('[_1] Membership ',$ucgpterm),
+ &Apache::loncommon::start_page('Group Membership',
'');
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/$cdom/$cnum/$group/grppg",
- text=>"$ucgpterm: $description",
- title=>"Go to group's home page"},
- {href=>"/adm/grouproster?group=$group",
- text=>"Membership roster",
- title=>"Display group membership"},);
- $output .= &Apache::lonhtmlcommon::breadcrumbs(&mt('[_1] membership status - [_2]',$gpterm,$description));
+ $jscript.'',$args);
+ if ($env{'form.ref'} eq 'popup') {
+ $output .= '