--- loncom/lti/ltiutils.pm 2024/02/27 04:13:34 1.17.2.5 +++ loncom/lti/ltiutils.pm 2025/01/16 21:52:05 1.17.2.6 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA LTI interactions # -# $Id: ltiutils.pm,v 1.17.2.5 2024/02/27 04:13:34 raeburn Exp $ +# $Id: ltiutils.pm,v 1.17.2.6 2025/01/16 21:52:05 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -34,6 +34,7 @@ use Digest::SHA; use Digest::MD5 qw(md5_hex); use Encode; use UUID::Tiny ':std'; +use HTTP::Status; use LWP::UserAgent(); use Apache::lonnet; use Apache::loncommon; @@ -761,7 +762,7 @@ sub send_grade { if ($sigmethod eq '') { $sigmethod = 'HMAC-SHA1'; } - my $request; + my ($request,$sendit,$respcode,$result); if ($msgformat eq '1.0') { my $date = &Apache::loncommon::utc_string(time); my %ltiparams = ( @@ -788,7 +789,7 @@ sub send_grade { ? join("&$name=", map {escape($_) } @{$hashref->{$_}}) : &escape($hashref->{$_}) ); } keys(%{$hashref}))); -#FIXME Need to handle case where passback failed. + $sendit = 1; } } else { srand( time() ^ ($$ + ($$ << 15)) ); # Seed rand. @@ -845,13 +846,18 @@ END ], $gradexml, ); - my $ua=new LWP::UserAgent; - $ua->timeout(10); - my $response=$ua->request($request); - my $message=$response->status_line; -#FIXME Handle case where pass back of score to LTI Consumer failed. + $sendit = 1; } } + if ($sendit) { + my $ua=new LWP::UserAgent; + $ua->timeout(10); + my $response=$ua->request($request); + my $message=$response->status_line; + $respcode = $response->code; + $result = HTTP::Status::status_message($respcode); + } + return ($sendit,$score,$respcode,$result); } sub setup_logout_callback {