[LON-CAPA-cvs] cvs: loncom /interface grouproster.pm loncoursegroups.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Thu, 17 Aug 2006 23:36:11 -0000
This is a MIME encoded message
--raeburn1155857771
Content-Type: text/plain
raeburn Thu Aug 17 19:36:11 2006 EDT
Modified files:
/loncom/interface grouproster.pm loncoursegroups.pm
Log:
loncommon::start_page() does its own &mt(). Current status type should be retained when changing sorting used in roster display. Roster can be displayed in a pop-up window. Links provided to open pop-up window in table listing course groups, where membership > 0. Membership roster now available (via popup) to users with mdg or vcg privilege in cases where membership roster is not enbled in the group.
--raeburn1155857771
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060817193611.txt"
Index: loncom/interface/grouproster.pm
diff -u loncom/interface/grouproster.pm:1.3 loncom/interface/grouproster.pm:1.4
--- loncom/interface/grouproster.pm:1.3 Mon Jul 17 11:07:26 2006
+++ loncom/interface/grouproster.pm Thu Aug 17 19:36:05 2006
@@ -52,38 +52,49 @@
return HTTP_NOT_ACCEPTABLE;
}
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['group','ref']);
+ &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.<br />'));
+ $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.<br />'));
+ $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]<br />',$crstype));
+ $badinput = 1;
}
- my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
- if (!defined($curr_groups{$group})) {
- $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();
@@ -119,30 +130,43 @@
sub roster_header {
my ($cdom,$cnum,$group,$description,$gpterm,$ucgpterm) = @_;
my $refarg;
- if (exists($env{'form.ref'})) {
+ 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',
'<script type="text/javascript">'.
- $jscript.'</script>');
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/$cdom/$cnum/$group/smppg?$refarg",
- text=>"$ucgpterm: $description",
- title=>"Go to group's home page"},
- {href=>'/adm/grouproster?group='.$group.'&'.$refarg,
- text=>"Membership roster",
- title=>"Display group membership"},);
- $output .= &Apache::lonhtmlcommon::breadcrumbs(&mt('[_1] membership status - [_2]',$gpterm,$description));
+ $jscript.'</script>',$args);
+ if ($env{'form.ref'} eq 'popup') {
+ $output .= '<h3>'.&mt('Group membership status - [_1]',$description).
+ '</h3>';
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/$cdom/$cnum/$group/smppg?$refarg",
+ text=>"$ucgpterm: $description",
+ title=>"Go to group's home page"},
+ {href=>'/adm/grouproster?group='.$group.'&'.$refarg,
+ text=>"Membership roster",
+ title=>"Display group membership"},);
+ $output .= &Apache::lonhtmlcommon::breadcrumbs(&mt('[_1] membership status - [_2]',$gpterm,$description));
+ }
return $output;
}
@@ -209,9 +233,10 @@
$r->print('<input type="hidden" name="ref" value="'.$env{'form.ref'}.
'" />');
}
- $r->print('</form><br /><br />');
+ $r->print('</form><br />');
}
+ $r->print('<br />');
if (ref($numitems) eq 'HASH') {
foreach my $key (keys(%{$numitems})) {
if ($status eq $key && !$$numitems{$key}) {
@@ -225,6 +250,7 @@
<form name="grouproster" action="/adm/grouproster" method="post">
<input type="hidden" name="group" value="'.$group.'" />
<input type="hidden" name="sortby" value="'.$env{'form.sortby'}.'" />
+ <input type="hidden" name="status" value="'.$status.'" />
');
if (exists($env{'form.ref'})) {
$r->print('<input type="hidden" name="ref" value="'.$env{'form.ref'}.
@@ -312,11 +338,13 @@
my $curr_tool;
my $privlist;
foreach my $priv (@{$$userinfo{'privs'}}) {
- unless ($curr_tool eq $$tooltype{$priv}) {
- $curr_tool = $$tooltype{$priv};
- $privlist .= '<b>'.$curr_tool.'</b>: ';
+ if (defined($$tooltype{$priv})) {
+ if ($curr_tool ne $$tooltype{$priv}) {
+ $curr_tool = $$tooltype{$priv};
+ $privlist .= '<b>'.$curr_tool.'</b>: ';
+ }
+ $privlist .= $$toolprivs{$curr_tool}{$priv}.', ';
}
- $privlist .= $$toolprivs{$curr_tool}{$priv}.', ';
}
$privlist =~ s/, $//;
$output .= '<td>'.$privlist.'</td>';
Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.59 loncom/interface/loncoursegroups.pm:1.60
--- loncom/interface/loncoursegroups.pm:1.59 Fri Jul 28 20:31:58 2006
+++ loncom/interface/loncoursegroups.pm Thu Aug 17 19:36:05 2006
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: loncoursegroups.pm,v 1.59 2006/07/29 00:31:58 raeburn Exp $
+# $Id: loncoursegroups.pm,v 1.60 2006/08/17 23:36:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -127,6 +127,15 @@
function changeSort(caller) {
document.$state.sortby.value = caller;
document.$state.submit();
+}
+function openGroupRoster(group,status) {
+ var url = '/adm/grouproster?';
+ url += 'group='+group+'&status='+status+'&ref=popup';
+ var title = 'Group Membership';
+ var options = 'scrollbars=1,resizable=1,menubar=0';
+ options += ',width=700,height=600';
+ rosterbrowser = open(url,title,options,'1');
+ rosterbrowser.focus();
}\n|;
$r->print(&header('Groups',$jscript,$action,$state));
if ($env{'form.refpage'} eq 'enrl') {
@@ -1151,39 +1160,54 @@
my ($cdom,$cnum,$group,$group_info) = @_;
my %memberhash = &Apache::lonnet::get_group_membership($cdom,$cnum,$group);
my $now = time;
- my ($tmp)=keys(%memberhash);
- if ($tmp=~/^error:/) {
- $$group_info{'totalmembers'} = 'Unknown - an error occurred';
- return $tmp;
- }
+ my %lt = &Apache::lonlocal::texthash (
+ active => 'active',
+ previous => 'previous',
+ future => 'future',
+ );
+ my %membercounts = (
+ active => 0,
+ previous => 0,
+ future => 0,
+ );
my $totalmembers = 0;
- my $active = 0;
- my $previous = 0;
- my $future = 0;
foreach my $member (keys %memberhash) {
$totalmembers ++;
my ($end,$start) = split(/:/,$memberhash{$member});
unless ($start == -1) {
if (($end!=0) && ($end<$now)) {
- $previous ++;
+ $membercounts{previous} ++;
} elsif (($start!=0) && ($start>$now)) {
- $future ++;
+ $membercounts{future} ++;
} else {
- $active ++;
+ $membercounts{active} ++;
}
}
}
if ($totalmembers == 0) {
$$group_info{$group}{'totalmembers'} = 'None';
} else {
- $$group_info{$group}{'totalmembers'} = '<nobr>'.$active.
- ' - active</nobr><br /><nobr>'.$previous.
- ' - previous</nobr><br /><nobr>'.$future.
- ' - future</nobr>';
+ foreach my $type ('active','previous','future') {
+ $$group_info{$group}{'totalmembers'} .=
+ &open_list_window($group,$type,$membercounts{$type},$lt{$type});
+ }
}
return 'ok';
}
+sub open_list_window {
+ my ($group,$status,$count,$text) = @_;
+ my $entry;
+ if ($count > 0) {
+ $entry = '<nobr><a href="javascript:openGroupRoster('.
+ "'$group','$status'".')">'.$text.'</a> - '.$count.
+ '</nobr><br />';
+ } else {
+ $entry = '<nobr>'.$text.' - '.$count.'</nobr><br />';
+ }
+ return $entry;
+}
+
sub general_settings_form {
my ($r,$cdom,$cnum,$action,$formname,$page,$functions,$tools,
--raeburn1155857771--