[LON-CAPA-cvs] cvs: loncom /interface lonuserutils.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Tue, 06 Nov 2007 18:23:18 -0000
This is a MIME encoded message
--raeburn1194373398
Content-Type: text/plain
raeburn Tue Nov 6 13:23:18 2007 EDT
Modified files:
/loncom/interface lonuserutils.pm
Log:
- Move creation of course selection interface so all selection buttons and "Update Display" button are generated in all cases before data retrieval
- Flush display (includes "Searching ..." message) before user data are retrieved and processed for display.
- Move block to check for keys in %userlist so user display occurs in course context
- Check for sortable columns updated
- Typo - missing $ from $env{
--raeburn1194373398
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20071106132318.txt"
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.2 loncom/interface/lonuserutils.pm:1.3
--- loncom/interface/lonuserutils.pm:1.2 Mon Nov 5 23:39:19 2007
+++ loncom/interface/lonuserutils.pm Tue Nov 6 13:23:14 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.2 2007/11/06 04:39:19 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.3 2007/11/06 18:23:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1130,23 +1130,36 @@
}
my ($indexhash,$keylist) = &make_keylist_array();
my (%userlist,%userinfo);
+ if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
+ my $courseform =
+ &Apache::lonhtmlcommon::course_selection($formname,$totcodes,
+ $codetitles,$idlist,$idlist_titles);
+ $r->print('<p>'.&Apache::lonhtmlcommon::start_pick_box()."\n".
+ &Apache::lonhtmlcommon::start_pick_box()."\n".
+ &Apache::lonhtmlcommon::row_title(&mt('Select Course(s)'),
+ 'LC_oddrow_value')."\n".
+ $courseform."\n".
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::end_pick_box().'</p>'.
+ '<p>'.&list_submit_button(&mt('Update Display')).
+ "\n</p>\n");
+ }
+ $r->print('<hr />'.&mt('Searching').' ...<br /> <br />');
+ $r->rflush();
if ($context eq 'course') {
- #
- # Print the userlist
- $r->print('<h2>'.&mt('Current User List').'</h2>');
- (my $classlist,$keylist)=&Apache::loncoursedata::get_classlist();
-
- if (exists($permission->{'view_section'})) {
- my $sec = &Apache::loncoursedata::CL_SECTION();
- foreach my $student (keys(%{$classlist})) {
- if ($userlist{$student}[$sec] ne $permission->{'view_section'}) {
- delete($userlist{$student});
+ my $classlist = &Apache::loncoursedata::get_classlist();
+ my $secidx = &Apache::loncoursedata::CL_SECTION();
+ foreach my $student (keys(%{$classlist})) {
+ if (exists($permission->{'view_section'})) {
+ if ($classlist->{$student}[$secidx] ne $permission->{'view_section'}) {
+ next;
+ } else {
+ $userlist{$student} = $classlist->{$student};
}
+ } else {
+ $userlist{$student} = $classlist->{$student};
}
}
- foreach my $item (keys(%{$classlist})) {
- $userlist{$item} = $classlist->{$item};
- }
my $cid =$env{'request.course.id'};
my $cdom=$env{'course.'.$cid.'.domain'};
my $cnum=$env{'course.'.$cid.'.num'};
@@ -1206,19 +1219,6 @@
}
}
} elsif ($env{'form.roletype'} eq 'course') {
- my $courseform =
- &Apache::lonhtmlcommon::course_selection($formname,$totcodes,
- $codetitles,$idlist,$idlist_titles);
- my $output='<p>'.&Apache::lonhtmlcommon::start_pick_box()."\n".
- &Apache::lonhtmlcommon::start_pick_box()."\n".
- &Apache::lonhtmlcommon::row_title(&mt('Select Course(s)'),
- 'LC_oddrow_value')."\n".
- $courseform."\n".
- &Apache::lonhtmlcommon::row_closure(1).
- &Apache::lonhtmlcommon::end_pick_box().'</p>';
- $r->print($output);
- $r->print('<p>'.&list_submit_button(&mt('Update Display')).
- "\n</p>\n");
if ($env{'form.coursepick'}) {
my %courses = &process_coursepick();
my %allusers;
@@ -1264,29 +1264,29 @@
}
}
}
- if (keys(%userlist) == 0) {
- if ($context eq 'construction_space') {
- $r->print(&mt('There are no co-authors to display.')."\n");
- } elsif ($context eq 'domain') {
- if ($env{'form.roletype'} eq 'domain') {
- $r->print(&mt('There are no users with domain roles to display.')."\n");
- } elsif ($env{'form.roletype'} eq 'construction_space') {
- $r->print(&mt('There are no authors or co-authors to display.')."\n");
- } elsif ($env{'form.roletype'} eq 'course') {
- $r->print(&mt('There are no course users to display')."\n");
- }
- } elsif ($context eq 'course') {
- $r->print(&mt('There are no course users to display.')."\n");
+ }
+ if (keys(%userlist) == 0) {
+ if ($context eq 'construction_space') {
+ $r->print(&mt('There are no co-authors to display.')."\n");
+ } elsif ($context eq 'domain') {
+ if ($env{'form.roletype'} eq 'domain') {
+ $r->print(&mt('There are no users with domain roles to display.')."\n");
+ } elsif ($env{'form.roletype'} eq 'construction_space') {
+ $r->print(&mt('There are no authors or co-authors to display.')."\n");
+ } elsif ($env{'form.roletype'} eq 'course') {
+ $r->print(&mt('There are no course users to display')."\n");
}
+ } elsif ($context eq 'course') {
+ $r->print(&mt('There are no course users to display.')."\n");
+ }
+ } else {
+ # Print out the available choices
+ if ($env{'form.action'} eq 'modifystudent') {
+ &show_users_list($r,$context,'view','modify',
+ $env{'form.Status'},\%userlist,$keylist);
} else {
- # Print out the available choices
- if ($env{'form.action'} eq 'modifystudent') {
- &show_users_list($r,$context,'view','modify',
- $env{'form.Status'},\%userlist,$keylist);
- } else {
- &show_users_list($r,$context,$env{'form.output'},'aboutme',
- $env{'form.Status'},\%userlist,$keylist);
- }
+ &show_users_list($r,$context,$env{'form.output'},'aboutme',
+ $env{'form.Status'},\%userlist,$keylist);
}
}
$r->print('</form>');
@@ -1603,14 +1603,14 @@
my ($CSVfile,$CSVfilename);
#
my $sortby = $env{'form.sortby'};
+ my @sortable = ('username','domain','id','fullname','start','end','email','role');
if ($context eq 'course') {
- if ($sortby !~ /^(username|domain|section|groups|fullname|id|start|end|type)$/) {
- $sortby = 'username';
- }
+ push(@sortable,('section','groups','type'));
} else {
- if ($sortby !~ /^(username|domain|id|fullname|start|end|role|email|extent)$/) {
- $sortby = 'username';
- }
+ push(@sortable,'extent');
+ }
+ if (!grep(/^\Q$sortby\E$/,@sortable)) {
+ $sortby = 'username';
}
my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers);
if ($context eq 'course') {
@@ -1683,7 +1683,7 @@
if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) {
push(@cols,('start','end'));
}
- if ($env{'form.showrole'} eq 'Any') {
+ if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {
push(@cols,'role');
}
if ($context eq 'domain' && ($env{'form.roletype'} eq 'construction_space' ||
@@ -1705,11 +1705,8 @@
}
my $results_description = &results_header_row($rolefilter,$statusmode,
$context);
-
+ $r->print('<b>'.$results_description.'</b><br />');
if ($mode eq 'html' || $mode eq 'view') {
- $r->print('<hr />'.&mt('Searching').' ...<br /> <br />');
- $r->rflush();
- $r->print('<b>'.$results_description.'</b><br />');
if ($linkto eq 'aboutme') {
$r->print(&mt("Select a user name to view the user's personal page."));
} elsif ($linkto eq 'modify') {
@@ -1988,7 +1985,7 @@
my ($rolefilter,$statusmode,$context) = @_;
my $description;
if ($context eq 'course') {
- $description = &mt('Course - ').$env{'course.'.env{'request.course.id'}.'.description'}.': ';
+ $description = &mt('Course - ').$env{'course.'.$env{'request.course.id'}.'.description'}.': ';
if ($statusmode eq 'Expired') {
$description .= &mt('Users in course with expired [_1] roles',$rolefilter);
}
--raeburn1194373398--