--- loncom/interface/lonexttool.pm 2025/06/06 20:36:58 1.28 +++ loncom/interface/lonexttool.pm 2025/06/14 02:50:25 1.29 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Launch External Tool Provider (LTI) # -# $Id: lonexttool.pm,v 1.28 2025/06/06 20:36:58 raeburn Exp $ +# $Id: lonexttool.pm,v 1.29 2025/06/14 02:50:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -96,7 +96,7 @@ sub handler { my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; - my ($idx,$crstool,$is_tool,%toolhash,%toolsettings); + my ($idx,$crstool,$is_tool,%toolhash,%toolsettings,$desturl,$delay); if ($r->uri eq "/adm/$cdom/$cnum/$marker/$exttool") { %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); @@ -136,6 +136,25 @@ sub handler { } else { $toolhash{'returnurl'} = 'none'; } + if ($toolhash{'desturl'}) { + if ((ref($toolhash{'crsconf'}) eq 'HASH')) { + if ($toolhash{'crsconf'}{'desturl'}) { + if ((exists($toolsettings{'desturl'})) && + ($toolsettings{'desturl'} =~ m{^(https?\://|/)})) { + $desturl = $toolsettings{'desturl'}; + if ((exists($toolsettings{'delay'})) && + ($toolsettings{'delay'} =~ /^\d+\.?\d*$/)) { + $delay = $toolsettings{'delay'}; + } + } + } elsif ($toolhash{'defdest'} =~ m{^(https?\://|/)}) { + $desturl = $toolhash{'defdest'}; + if ($toolhash{'defdelay'} =~ /^\d+\.?\d*$/) { + $delay = $toolhash{'defdelay'}; + } + } + } + } $is_tool = 1; } } @@ -233,11 +252,31 @@ sub handler { if ($toolhash{'crsappend'} ne '') { $url .= $toolhash{'crsappend'}; } + if ($desturl ne '') { + my ($scheme,$provider,$path); + if ($url =~ m{^https?\://}) { + ($scheme,$provider,$path) = ($url =~ m{^(https?\://)([^/]+)(|/.+)$}); + if ($desturl =~ m{^/}) { + if ($path eq $desturl) { + undef($desturl); + } else { + $desturl = $scheme.$provider.$desturl; + } + } elsif ($desturl =~ m{^https?\://}) { + if ($url eq $desturl) { + undef($desturl); + } + } + } elsif ($url eq $desturl) { + undef($desturl); + } + } my %info = ( method => $toolhash{'sigmethod'}, ); $r->print(&launch_html($cdom,$cnum,$crstool,$url,$idx, - $toolhash{'cipher'},$submittext,\%lti,\%info)); + $toolhash{'cipher'},$submittext, + \%lti,\%info,$desturl,$delay)); } else { $r->print('