Link Name: "
+ +" Address: <\\/center><\\/td>"
+ +"<\\/tr><\\/table><\\/form><\\/center>"
+'$end_page_bookmark' );
bmquery.document.close();
}
@@ -1617,7 +1556,7 @@ sub hidden_button_check {
sub roles_selector {
my ($cdom,$cnum) = @_;
my $now = time;
- my (%courseroles,%seccount);
+ my (%courseroles,%seccount,%gotnosection);
my $is_cc;
my $role_selector;
if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) {
@@ -1632,9 +1571,35 @@ sub roles_selector {
}
}
if ($is_cc) {
- &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
+ 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));
+ }
} else {
- my %gotnosection;
foreach my $item (keys(%env)) {
if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
my $role = $1;
@@ -1692,61 +1657,6 @@ 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(
@@ -1778,9 +1688,8 @@ sub jump_to_role {
' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
}
}
- return <<"END";
+ my $output = <<"END";
END
+ return $output;
}