Link Name: "
- +" Address: <\\/center><\\/td>"
- +"<\\/tr><\\/table><\\/form><\\/center>"
+ +' '
+'$end_page_bookmark' );
bmquery.document.close();
}
@@ -1537,7 +1629,7 @@ sub hidden_button_check {
sub roles_selector {
my ($cdom,$cnum) = @_;
my $now = time;
- my (%courseroles,%seccount,%gotnosection);
+ my (%courseroles,%seccount);
my $is_cc;
my $role_selector;
if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) {
@@ -1552,35 +1644,9 @@ sub roles_selector {
}
}
if ($is_cc) {
- my %adv_roles =
- &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
- foreach my $role (keys(%adv_roles)) {
- my ($urole,$usec) = split(/:/,$role);
- if (!$gotnosection{$urole}) {
- $seccount{$urole} ++;
- $gotnosection{$urole} = 1;
- }
- if (ref($courseroles{$urole}) eq 'ARRAY') {
- if ($usec ne '') {
- if (!grep(/^Q$usec\E$/,@{$courseroles{$urole}})) {
- push(@{$courseroles{$urole}},$usec);
- $seccount{$urole} ++;
- }
- }
- } else {
- @{$courseroles{$urole}} = ();
- if ($usec ne '') {
- $seccount{$urole} ++;
- push(@{$courseroles{$urole}},$usec);
- }
- }
- }
- my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
- @{$courseroles{'st'}} = ();
- if (keys(%sections_count) > 0) {
- push(@{$courseroles{'st'}},keys(%sections_count));
- }
+ &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
} else {
+ my %gotnosection;
foreach my $item (keys(%env)) {
if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
my $role = $1;
@@ -1638,6 +1704,61 @@ sub roles_selector {
return $role_selector;
}
+sub get_all_courseroles {
+ my ($cdom,$cnum,$courseroles,$seccount) = @_;
+ unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
+ return;
+ }
+ my ($result,$cached) =
+ &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
+ if (defined($cached)) {
+ if (ref($result) eq 'HASH') {
+ if ((ref($result->{'roles'}) eq 'HASH') &&
+ (ref($result->{'seccount'}) eq 'HASH')) {
+ %{$courseroles} = %{$result->{'roles'}};
+ %{$seccount} = %{$result->{'seccount'}};
+ return;
+ }
+ }
+ }
+ my %gotnosection;
+ my %adv_roles =
+ &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
+ foreach my $role (keys(%adv_roles)) {
+ my ($urole,$usec) = split(/:/,$role);
+ if (!$gotnosection{$urole}) {
+ $seccount->{$urole} ++;
+ $gotnosection{$urole} = 1;
+ }
+ if (ref($courseroles->{$urole}) eq 'ARRAY') {
+ if ($usec ne '') {
+ if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
+ push(@{$courseroles->{$urole}},$usec);
+ $seccount->{$urole} ++;
+ }
+ }
+ } else {
+ @{$courseroles->{$urole}} = ();
+ if ($usec ne '') {
+ $seccount->{$urole} ++;
+ push(@{$courseroles->{$urole}},$usec);
+ }
+ }
+ }
+ my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
+ @{$courseroles->{'st'}} = ();
+ if (keys(%sections_count) > 0) {
+ push(@{$courseroles->{'st'}},keys(%sections_count));
+ $seccount->{'st'} = scalar(keys(%sections_count));
+ }
+ my $rolehash = {
+ 'roles' => $courseroles,
+ 'seccount' => $seccount,
+ };
+ &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
+ return;
+}
+
sub jump_to_role {
my ($cdom,$cnum,$seccount,$courseroles) = @_;
my %lt = &Apache::lonlocal::texthash(