--- loncom/auth/lonroles.pm 2005/11/14 20:03:52 1.135 +++ loncom/auth/lonroles.pm 2005/12/22 03:39:36 1.142 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.135 2005/11/14 20:03:52 albertel Exp $ +# $Id: lonroles.pm,v 1.142 2005/12/22 03:39:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,7 +51,7 @@ sub redirect_user { my $navwindow; if ($launch_nav eq 'on') { $navwindow.=&Apache::lonnavmaps::launch_win('now',undef,undef, - ($url eq '/adm/whatsnew')); + ($url =~ m-^/adm/whatsnew-)); } else { $navwindow.=&Apache::lonnavmaps::close(); } @@ -126,6 +126,11 @@ sub handler { if ($tstatus eq 'is') { $where=~s/^\///; my ($cdom,$cnum,$csec)=split(/\//,$where); +# check for course groups + my %coursegroups = &Apache::lonnet::get_active_groups( + $env{'user.domain'},$env{'user.name'},$cdom, $cnum); + my $cgrps = join(':',keys(%coursegroups)); + # store role if recent_role list being kept if ($env{'environment.recentroles'}) { &Apache::lonhtmlcommon::store_recent('roles', @@ -227,7 +232,8 @@ ENDENTERKEY &Apache::lonnet::appenv( 'request.role' => $trolecode, 'request.role.domain' => $cdom, - 'request.course.sec' => $csec); + 'request.course.sec' => $csec, + 'request.course.groups' => $cgrps); my $tadv=0; my $msg=&mt('Entering course ...'); @@ -265,13 +271,18 @@ ENDENTERKEY '.course.helper.not.run'}) { $furl = "/adm/helper/course.initialization.helper"; # Send the user to the course they selected - } elsif (($env{'request.course.fn'}) - && ($role eq 'cc' && ($env{'environment.course_init_display'} ne 'firstres'))) { - $msg = &mt('Entering course ....'); - &redirect_user($r,&mt('New in course'), - '/adm/whatsnew',$msg, - $env{'environment.remotenavmap'}); - return OK; + } elsif ($env{'request.course.id'}) { + if (&Apache::lonnet::allowed('whn', + $env{'request.course.id'})) { + my $startpage = &courseloadpage($courseid); + unless ($startpage eq 'firstres') { + $msg = &mt('Entering course ....'); + &redirect_user($r,&mt('New in course'), + '/adm/whatsnew?refpage=start',$msg, + $env{'environment.remotenavmap'}); + return OK; + } + } } &redirect_user($r,&mt('Entering Course'), $furl,$msg, @@ -436,7 +447,7 @@ ENDHEADER if ($envkey=~/^user\.role\./) { my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont); &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend); - next if (!defined($role) || $role eq ''); + next if (!defined($role) || $role eq '' || $role =~ /^gr/); $tremark=''; $tpstart=' '; $tpend=' '; @@ -630,7 +641,7 @@ ENDHEADER if (defined($roletext{'user.role.'.$_})) { $output.=$roletext{'user.role.'.$_}; if ($_ =~ m-dc\./(\w+)/- && $dcroles{$1}) { - $output .= &allcourses_row($1); + $output .= &allcourses_row($1,'recent'); } } elsif ($numdc > 0) { unless ($_ =~/^error\:/) { @@ -658,7 +669,7 @@ ENDHEADER $output.=$roletext{$sortrole{$which}}; if ($sortrole{$which} =~ m-dc\./(\w+)/-) { if ($dcroles{$1}) { - $output .= &allcourses_row($1); + $output .= &allcourses_row($1,''); } } } @@ -870,13 +881,13 @@ sub check_fordc { } sub courselink { - my ($dcdom) = @_; + my ($dcdom,$rowtype) = @_; my $courseform=&Apache::loncommon::selectcourse_link - ('rolechoice','dccourse_'.$dcdom,'dcdomain_'.$dcdom,'coursedesc_'.$dcdom,$dcdom); - my $hiddenitems = ''. - ''. - ''. - ''; + ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.$dcdom,$dcdom); + my $hiddenitems = ''. + ''. + ''. + ''; return $courseform.$hiddenitems; } @@ -917,34 +928,26 @@ END } sub processpick { - my $dcdom = shift; my $process_pick = <<"END"; END return $process_pick; @@ -981,12 +984,10 @@ sub display_cc_role { } sub allcourses_row { - my $dcdom = shift; + my ($dcdom,$rowtype) = @_; my $ccrole = Apache::lonnet::plaintext('cc'); - my $selectlink = &courselink($dcdom); + my $selectlink = &courselink($dcdom,$rowtype); my $output = '