--- loncom/lti/ltiutils.pm 2024/02/27 04:04:06 1.21 +++ loncom/lti/ltiutils.pm 2024/11/21 07:26:04 1.22 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA LTI interactions # -# $Id: ltiutils.pm,v 1.21 2024/02/27 04:04:06 raeburn Exp $ +# $Id: ltiutils.pm,v 1.22 2024/11/21 07:26:04 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 Apache::lonnet; use Apache::loncommon; use Apache::loncoursedata; @@ -758,7 +759,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 = ( @@ -785,7 +786,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. @@ -842,11 +843,16 @@ END ], $gradexml, ); - my $response = &LONCAPA::LWPReq::makerequest('',$request,'','',10); - my $message=$response->status_line; -#FIXME Handle case where pass back of score to LTI Consumer failed. + $sendit = 1; } } + if ($sendit) { + my $response = &LONCAPA::LWPReq::makerequest('',$request,'','',10); + my $message=$response->status_line; + $respcode = $response->code; + $result = HTTP::Status::status_message($respcode); + } + return ($sendit,$score,$respcode,$result); } sub setup_logout_callback {