Diff for /loncom/interface/lonexttool.pm between versions 1.3 and 1.4

version 1.3, 2016/01/26 14:30:25 version 1.4, 2016/06/06 17:40:48
Line 102  sub handler { Line 102  sub handler {
                                            width  => $toolsettings{'width'},                                             width  => $toolsettings{'width'},
                                            height => $toolsettings{'height'},                                             height => $toolsettings{'height'},
                                        };                                         };
                   $toolhash{'crslabel'} = $toolsettings{'crslabel'};
                   $toolhash{'crstitle'} = $toolsettings{'crstitle'};
                 $is_tool = 1;                  $is_tool = 1;
                 if ($target eq 'tex') {                  if ($target eq 'tex') {
                     $r->print(&mt('External Tool'));                      $r->print(&mt('External Tool'));
                 } else {                  } else {
                     my $submittext = &mt('Launch [_1]',$toolhash{'title'});                      my $submittext = &mt('Launch [_1]',$toolhash{'title'});
                     if (($toolhash{'key'} ne '') && ($toolhash{'secret'} ne '') && ($toolhash{'url'} ne '')) {                      if (($toolhash{'key'} ne '') && ($toolhash{'secret'} ne '') && ($toolhash{'url'} ne '')) {
                         my %lti = &lti_params($r,$submittext,\%toolhash);                          my %lti = &lti_params($r,$cnum,$cdom,$submittext,\%toolhash);
                         $r->print(&launch_html($toolhash{'url'},$toolhash{'key'},                          $r->print(&launch_html($toolhash{'url'},$toolhash{'key'},
                                                $toolhash{'secret'},$submittext,\%lti));                                                 $toolhash{'secret'},$submittext,\%lti));
                     } else {                      } else {
Line 129  sub handler { Line 131  sub handler {
 }  }
   
 sub lti_params {  sub lti_params {
     my ($r,$submittext,$toolsref) = @_;      my ($r,$cnum,$cdom,$submittext,$toolsref) = @_;
     my ($version,$context_type,$msgtype,$toolname,$passback,$roster,$locale,      my ($version,$context_type,$msgtype,$toolname,$passback,$roster,$locale,
         %fields,%rolesmap,%display,%custom,@userlangs);          $crslabel,$crstitle,%fields,%rolesmap,%display,%custom,@userlangs);
     if (ref($toolsref) eq 'HASH') {      if (ref($toolsref) eq 'HASH') {
         $version = $toolsref->{'version'};          $version = $toolsref->{'version'};
         $toolname = $toolsref->{'title'};          $toolname = $toolsref->{'title'};
Line 150  sub lti_params { Line 152  sub lti_params {
         if (ref($toolsref->{'custom'}) eq 'HASH') {          if (ref($toolsref->{'custom'}) eq 'HASH') {
             %custom = %{$toolsref->{'custom'}};              %custom = %{$toolsref->{'custom'}};
         }          }
           $crslabel = $toolsref->{'crslabel'};
           $crstitle = $toolsref->{'crstitle'};
     }      }
     if ($version eq '') {      if ($version eq '') {
         $version = 'LTI-1p0';          $version = 'LTI-1p0';
Line 160  sub lti_params { Line 164  sub lti_params {
     if ($msgtype eq '') {      if ($msgtype eq '') {
         $msgtype = 'basic-lti-launch-request';          $msgtype = 'basic-lti-launch-request';
     }      }
       if ($crslabel eq '') {
           $crslabel = $env{'course.'.$env{'request.course.id'}.'.internal.coursecode'},
       }
       if ($crstitle eq '') {
           $crstitle = $env{'course.'.$env{'request.course.id'}.'.description'},;
       }
     my $lonhost = $r->dir_config('lonHostID');      my $lonhost = $r->dir_config('lonHostID');
     my $loncaparev = $r->dir_config('lonVersion');      my $loncaparev = $r->dir_config('lonVersion');
     my $uname = $env{'user.name'};      my $uname = $env{'user.name'};
Line 202  sub lti_params { Line 212  sub lti_params {
             }              }
         }          }
     }      }
       my $domdesc = &Apache::lonnet::domain($cdom);
       my $primary_id = &Apache::lonnet::domain($cdom,'primary');
       my $int_dom = &Apache::lonnet::internet_dom($primary_id);
       my $portal_url = &Apache::lonnet::course_portal_url($cnum,$cdom);
   
     my %ltiparams = (      my %ltiparams = (
         lti_version                            => $version,          lti_version                            => $version,
         lti_message_type                       => $msgtype,          lti_message_type                       => $msgtype,
         resource_link_title                    => $title,          resource_link_title                    => $title,
         resource_link_id                       => $digest_symb,          resource_link_id                       => $digest_symb,
         tool_consumer_instance_guid            => $lonhost,          tool_consumer_instance_guid            => $lonhost,
           tool_consumer_instance_description     => $domdesc,
         tool_consumer_info_product_family_code => 'loncapa',          tool_consumer_info_product_family_code => 'loncapa',
           tool_consumer_instance_name            => $int_dom,  
           tool_consumer_instance_url             => $portal_url,
         tool_consumer_info_version             => $loncaparev,          tool_consumer_info_version             => $loncaparev,
         user_id                                => $digest_user,          user_id                                => $digest_user,
         lis_person_sourcedid                   => $uname.':'.$udom,  
         roles                                  => $ltirole,          roles                                  => $ltirole,
         context_id                             => $env{'request.course.id'},          context_id                             => $env{'request.course.id'},
         context_type                           => $context_type,          context_type                           => $context_type,
         context_label                          => $env{'course.'.$env{'request.course.id'}.'.internal.coursecode'},          context_label                          => $crslabel,
         context_title                          => $env{'course.'.$env{'request.course.id'}.'.description'},          context_title                          => $crstitle,
         launch_presentation_locale             => $locale,          launch_presentation_locale             => $locale,
     );      );
     my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'};      my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'};
Line 269  sub lti_params { Line 286  sub lti_params {
         }          }
         $ltiparams{'lis_person_contact_email_primary'} = $contact_email;          $ltiparams{'lis_person_contact_email_primary'} = $contact_email;
     }      }
       if ($fields{'user'}) {
           $ltiparams{'lis_person_sourcedid'} = $uname.':'.$udom; 
       }
     if (keys(%custom)) {      if (keys(%custom)) {
         foreach my $key (keys(%custom)) {          foreach my $key (keys(%custom)) {
             $ltiparams{'custom_'.$key} = $custom{$key};              $ltiparams{'custom_'.$key} = $custom{$key};

Removed from v.1.3  
changed lines
  Added in v.1.4


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