From 596a04b9da39eba0f2595f8c4c025334ac84ba53 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Thu, 16 Feb 2023 10:04:36 +0100 Subject: [PATCH] Handle ReadTimeouts for LTI consumer properly --- app/controllers/concerns/lti.rb | 2 +- app/controllers/exercises_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/lti.rb b/app/controllers/concerns/lti.rb index 30fb692e..975e84eb 100644 --- a/app/controllers/concerns/lti.rb +++ b/app/controllers/concerns/lti.rb @@ -174,7 +174,7 @@ module Lti 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 + rescue IMS::LTI::XMLParseError, Net::OpenTimeout # A parsing error might happen if the LTI provider is down and doesn't return a valid XML response {status: 'error'} end diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index ef627c63..19d0b8f9 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -589,7 +589,7 @@ class ExercisesController < ApplicationController redirect_after_submit else respond_to do |format| - format.html { redirect_to(implement_exercise_path(@submission.exercise)) } + format.html { redirect_to(implement_exercise_path(@submission.exercise, alert: I18n.t('exercises.submit.failure'))) } format.json { render(json: {message: I18n.t('exercises.submit.failure')}, status: :service_unavailable) } end end