Diff for /loncom/interface/lonexttool.pm between versions 1.23 and 1.24

version 1.23, 2022/03/29 20:12:46 version 1.24, 2023/05/22 21:10:55
Line 96  sub handler { Line 96  sub handler {
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};      my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};      my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
     my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};      my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
     my ($idx,$is_tool,%toolhash,%toolsettings);      my ($idx,$crstool,$is_tool,%toolhash,%toolsettings);
   
     if ($r->uri eq "/adm/$cdom/$cnum/$marker/$exttool") {      if ($r->uri eq "/adm/$cdom/$cnum/$marker/$exttool") {
         %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);          %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
         if ($toolsettings{'id'}) {          if ($toolsettings{'id'}) {
             $idx = $toolsettings{'id'};              my %ltitools;
             my %ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer');              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');
               }
             if (ref($ltitools{$idx}) eq 'HASH') {              if (ref($ltitools{$idx}) eq 'HASH') {
                 %toolhash = %{$ltitools{$idx}};                  %toolhash = %{$ltitools{$idx}};
                 $toolhash{'display'} = {                  $toolhash{'display'} = {
Line 204  sub handler { Line 211  sub handler {
             }              }
         }          }
         my $submittext = &mt('Launch [_1]',$toolhash{'title'});          my $submittext = &mt('Launch [_1]',$toolhash{'title'});
         if (($toolhash{'key'} ne '') && ($toolhash{'secret'} ne '') &&           if (($toolhash{'url'} ne '') && ($launchok)) {
             ($toolhash{'url'} ne '') && ($launchok)) {  
             my %lti = &lti_params($r,$cnum,$cdom,$idx,$submittext,\%toolhash);              my %lti = &lti_params($r,$cnum,$cdom,$idx,$submittext,\%toolhash);
             my $url = $toolhash{'url'};              my $url = $toolhash{'url'};
             if ($toolhash{'crsappend'} ne '') {              if ($toolhash{'crsappend'} ne '') {
                 $url .= $toolhash{'crsappend'};                  $url .= $toolhash{'crsappend'};
             }              }
             $r->print(&launch_html($url,$toolhash{'key'},$toolhash{'secret'},              my %info = (
                                    $toolhash{'sigmethod'},$submittext,\%lti));                           method => $toolhash{'sigmethod'},
                          );
               $r->print(&launch_html($cdom,$cnum,$crstool,$url,$idx,
                                      $toolhash{'cipher'},$submittext,\%lti,\%info));
         } else {          } else {
             $r->print('<div>'.&mt('External Tool Unavailable').'</div>');              $r->print('<div class="LC_warning">'.&mt('External Tool Unavailable').'</div>');
         }          }
     }      }
     return OK;      return OK;
Line 434  sub lti_params { Line 443  sub lti_params {
 }  }
   
 sub launch_html {  sub launch_html {
     my ($url,$key,$secret,$sigmethod,$submittext,$paramsref) = @_;      my ($cdom,$cnum,$crstool,$url,$idx,$keynum,$submittext,$paramsref,$inforef) = @_;
     my $hashref = &LONCAPA::ltiutils::sign_params($url,$key,$secret,$paramsref,$sigmethod);      my ($status,$hashref) =
           &Apache::lonnet::sign_lti($cdom,$cnum,$crstool,$url,$idx,$keynum,
                                     '',$paramsref,$inforef);
       unless ($status eq 'ok') {
           return '<div class="LC_warning">'.&mt('External Tool Unavailable').'</div>';
       }
     my $action = &HTML::Entities::encode($url,'<>&"');      my $action = &HTML::Entities::encode($url,'<>&"');
     my $form = <<"END";      my $form = <<"END";
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Removed from v.1.23  
changed lines
  Added in v.1.24


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>