Fix XML parsing with invalid LTI response
An invalid XML response may be returned if the LTI provider is unavailable and cannot handle our request. We decided against logging in Sentry as this affects a third party functionality we cannot fix ourselves. Fixes CODEOCEAN-G2
This commit is contained in:
@ -170,8 +170,14 @@ module Lti
|
||||
# Reduce score by 100%
|
||||
normalized_lit_score *= 0.0
|
||||
end
|
||||
response = provider.post_replace_result!(normalized_lit_score)
|
||||
{code: response.response_code, message: response.post_response.body, status: response.code_major, score_sent: normalized_lit_score}
|
||||
|
||||
begin
|
||||
response = provider.post_replace_result!(normalized_lit_score)
|
||||
{code: response.response_code, message: response.post_response.body, status: response.code_major, score_sent: normalized_lit_score}
|
||||
rescue IMS::LTI::XMLParseError
|
||||
# A parsing error might happen if the LTI provider is down and doesn't return a valid XML response
|
||||
{status: 'error'}
|
||||
end
|
||||
else
|
||||
{status: 'unsupported'}
|
||||
end
|
||||
|
Reference in New Issue
Block a user