--- loncom/interface/lonindexcourse.pm 2024/02/12 03:46:17 1.3 +++ loncom/interface/lonindexcourse.pm 2024/12/31 19:28:29 1.5 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Index Course # -# $Id: lonindexcourse.pm,v 1.3 2024/02/12 03:46:17 raeburn Exp $ +# $Id: lonindexcourse.pm,v 1.5 2024/12/31 19:28:29 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -74,8 +74,14 @@ sub course_index { last if ($c->aborted()); if ($key =~ /^src\_(.+)$/) { my $rid = $1; - if ($hash{'randomout_'.$rid} & !$env{'request.role.adv'}) { - next; + unless ($env{'request.role.adv'}) { + next if ($hash{'randomout_'.$rid} || $hash{'deeplinkout_'.$rid}); + if (!$env{'request.deeplink.login'} && $hash{'deeplinkonly_'.$rid}) { + my ($value) = map { &unescape($_); } split(/:/,$hash{'deeplinkonly_'.$rid}); + my ($state,$others,$listed) = split(/,/,$value); + next if (($state eq 'only') && + (($listed eq 'absent') || ($listed eq 'grades'))); + } } my $symb=&make_symb($rid); my %newwords=&checkonthis($r,$rid,$hash{$key},0,&Apache::lonnet::gettitle($symb), @@ -165,7 +171,26 @@ sub handler { text => "$crstype Index"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs("$crstype Index")); &Apache::lonnavdisplay::startContentScreen($r,'courseindex'); - &course_index($r); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $clientip = &Apache::lonnet::get_requestor_ip($r); + my ($blocked,$blocktext) = + &Apache::loncommon::blocking_status('index',$clientip,$cnum,$cdom); + if ($blocked) { + my $checkrole = "cm./$cdom/$cnum"; + if ($env{'request.course.sec'} ne '') { + $checkrole .= "/$env{'request.course.sec'}"; + } + if ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) && + ($env{'request.role'} !~ m{^st\./$cdom/$cnum})) { + undef($blocked); + } + } + if ($blocked) { + $r->print($blocktext); + } else { + &course_index($r); + } &Apache::lonnavdisplay::endContentScreen($r); $r->print(&Apache::loncommon::end_page()); return OK;