From 206f4051c6772555da793183023bc0af0f0e95c5 Mon Sep 17 00:00:00 2001 From: kiragrammel Date: Fri, 13 Oct 2023 14:16:44 +0200 Subject: [PATCH] Set bonus points for survey via LTI parameter --- app/controllers/sessions_controller.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index d4cbef7dd..b4750366d 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -72,14 +72,17 @@ def destroy private def redirect_to_survey - # The following code is taken from store_lti_session_data(params) & send_score_for(submission, user) - # It gives a bonus point to users who opened the survey - begin - lti_parameters = params.slice(*Lti::SESSION_PARAMETERS).permit!.to_h - provider = build_tool_provider(consumer: current_user.consumer, parameters: lti_parameters) - provider.post_replace_result!(1.0) - rescue IMS::LTI::XMLParseError, Net::OpenTimeout, Net::ReadTimeout, Errno::ECONNRESET, SocketError, EOFError - # We don't do anything here because it is only a bonus point and we want the users to do the survey + + if params[:bonus_points] + # The following code is taken from store_lti_session_data(params) & send_score_for(submission, user) + # It gives a bonus point to users who opened the survey + begin + lti_parameters = params.slice(*Lti::SESSION_PARAMETERS).permit!.to_h + provider = build_tool_provider(consumer: current_user.consumer, parameters: lti_parameters) + provider.post_replace_result!(params[:bonus_points]) + rescue IMS::LTI::XMLParseError, Net::OpenTimeout, Net::ReadTimeout, Errno::ECONNRESET, SocketError, EOFError + # We don't do anything here because it is only a bonus point and we want the users to do the survey + end end # This method is taken from Xikolo and slightly adapted.