--- loncom/auth/lonroles.pm 2010/06/02 16:26:21 1.251 +++ loncom/auth/lonroles.pm 2010/06/03 14:41:07 1.252 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.251 2010/06/02 16:26:21 raeburn Exp $ +# $Id: lonroles.pm,v 1.252 2010/06/03 14:41:07 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -223,7 +223,16 @@ sub handler { if ($env{'request.course.id'}) { # Check if user is CC trying to select a course role if ($env{'form.switchrole'}) { - if (!defined($env{'user.role.'.$env{'form.switchrole'}})) { + my $switch_is_active; + if (defined($env{'user.role.'.$env{'form.switchrole'}})) { + my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}}); + if (!$end || $end > $now) { + if (!$start || $start < $refresh) { + $switch_is_active = 1; + } + } + } + unless ($switch_is_active) { &adhoc_course_role($refresh,$then); } }