--- loncom/interface/lonexttool.pm 2023/07/05 18:42:48 1.22.2.3 +++ loncom/interface/lonexttool.pm 2022/03/29 20:12:46 1.23 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Launch External Tool Provider (LTI) # -# $Id: lonexttool.pm,v 1.22.2.3 2023/07/05 18:42:48 raeburn Exp $ +# $Id: lonexttool.pm,v 1.23 2022/03/29 20:12:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -96,20 +96,13 @@ 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,$is_tool,%toolhash,%toolsettings); if ($r->uri eq "/adm/$cdom/$cnum/$marker/$exttool") { %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); if ($toolsettings{'id'}) { - my %ltitools; - if ($toolsettings{'id'} =~ /^c(\d+)$/) { - $idx = $1; - $crstool = 1; - %ltitools = &Apache::lonnet::get_course_lti($cnum,$cdom,'consumer'); - } else { - $idx = $toolsettings{'id'}; - %ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer'); - } + $idx = $toolsettings{'id'}; + my %ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer'); if (ref($ltitools{$idx}) eq 'HASH') { %toolhash = %{$ltitools{$idx}}; $toolhash{'display'} = { @@ -211,19 +204,17 @@ sub handler { } } my $submittext = &mt('Launch [_1]',$toolhash{'title'}); - if (($toolhash{'url'} ne '') && ($launchok)) { + if (($toolhash{'key'} ne '') && ($toolhash{'secret'} ne '') && + ($toolhash{'url'} ne '') && ($launchok)) { my %lti = <i_params($r,$cnum,$cdom,$idx,$submittext,\%toolhash); my $url = $toolhash{'url'}; if ($toolhash{'crsappend'} ne '') { $url .= $toolhash{'crsappend'}; } - my %info = ( - method => $toolhash{'sigmethod'}, - ); - $r->print(&launch_html($cdom,$cnum,$crstool,$url,$idx, - $toolhash{'cipher'},$submittext,\%lti,\%info)); + $r->print(&launch_html($url,$toolhash{'key'},$toolhash{'secret'}, + $toolhash{'sigmethod'},$submittext,\%lti)); } else { - $r->print('
'.&mt('External Tool Unavailable').'
'); + $r->print('
'.&mt('External Tool Unavailable').'
'); } } return OK; @@ -443,13 +434,8 @@ sub lti_params { } sub launch_html { - my ($cdom,$cnum,$crstool,$url,$idx,$keynum,$submittext,$paramsref,$inforef) = @_; - my ($status,$hashref) = - &Apache::lonnet::sign_lti($cdom,$cnum,$crstool,'tools','launch',$url,$idx,$keynum, - $paramsref,$inforef); - unless ($status eq 'ok') { - return '
'.&mt('External Tool Unavailable').'
'; - } + my ($url,$key,$secret,$sigmethod,$submittext,$paramsref) = @_; + my $hashref = &LONCAPA::ltiutils::sign_params($url,$key,$secret,$paramsref,$sigmethod); my $action = &HTML::Entities::encode($url,'<>&"'); my $form = <<"END";