--- loncom/interface/lonexttool.pm 2016/06/06 17:40:48 1.4 +++ loncom/interface/lonexttool.pm 2017/11/30 01:52:14 1.5 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Launch External Tool Provider (LTI) # -# $Id: lonexttool.pm,v 1.4 2016/06/06 17:40:48 raeburn Exp $ +# $Id: lonexttool.pm,v 1.5 2017/11/30 01:52:14 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -104,6 +104,7 @@ sub handler { }; $toolhash{'crslabel'} = $toolsettings{'crslabel'}; $toolhash{'crstitle'} = $toolsettings{'crstitle'}; + $toolhash{'crsappend'} = $toolsettings{'crsappend'}; $is_tool = 1; if ($target eq 'tex') { $r->print(&mt('External Tool')); @@ -111,8 +112,12 @@ sub handler { my $submittext = &mt('Launch [_1]',$toolhash{'title'}); if (($toolhash{'key'} ne '') && ($toolhash{'secret'} ne '') && ($toolhash{'url'} ne '')) { my %lti = <i_params($r,$cnum,$cdom,$submittext,\%toolhash); - $r->print(&launch_html($toolhash{'url'},$toolhash{'key'}, - $toolhash{'secret'},$submittext,\%lti)); + my $url = $toolhash{'url'}; + if ($toolhash{'crsappend'} ne '') { + $url .= $toolhash{'crsappend'}; + } + $r->print(&launch_html($url,$toolhash{'key'},$toolhash{'secret'}, + $submittext,\%lti)); } else { $r->print('
'.&mt('External Tool Unavailable').'
'); } @@ -245,14 +250,14 @@ sub lti_params { } if ($passback) { if ($ltirole eq 'Learner') { - $ltiparams{'lis_outcome_service_url'} = $crsprotocol.'//'.$crshostname.'/adm/ltipassback'; + $ltiparams{'lis_outcome_service_url'} = $crsprotocol.'//'.$crshostname.'/adm/service/passback'; $ltiparams{'ext_ims_lis_basic_outcome_url'} = $ltiparams{'lis_outcome_service_url'}; $ltiparams{'lis_result_sourcedid'} = ''; #FIXME } } if ($roster) { if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) { - $ltiparams{'ext_ims_lis_memberships_url'} = $crsprotocol.'//'.$crshostname.'/adm/ltiroster'; + $ltiparams{'ext_ims_lis_memberships_url'} = $crsprotocol.'//'.$crshostname.'/adm/service/roster'; $ltiparams{'ext_ims_lis_memberships_id'} = ''; #FIXME } } @@ -291,7 +296,14 @@ sub lti_params { } if (keys(%custom)) { foreach my $key (keys(%custom)) { - $ltiparams{'custom_'.$key} = $custom{$key}; + my $value = $custom{$key}; + $value =~ s/^\s+|\s+\$//g; + if ($value =~ /^\QLONCAPA::env{\E([^\}]+)\}$/) { + if (exists($env{$1})) { + $value = $env{$1}; + } + } + $ltiparams{'custom_'.$key} = $value; } } foreach my $key (keys(%ltiparams)) { @@ -304,12 +316,13 @@ sub lti_params { sub launch_html { my ($url,$key,$secret,$submittext,$paramsref) = @_; my $hashref = &sign_params($url,$key,$secret,$paramsref); + my $action = &HTML::Entities::encode($url,'<>&"'); my $form = <<"END";
-
+ END if (ref($hashref) eq 'HASH') { foreach my $item (keys(%{$hashref})) {