Skip to content

Commit

Permalink
Set bonus points for survey via LTI parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kiragrammel committed Oct 13, 2023
1 parent a258e2a commit 5f764f0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 75 in app/controllers/sessions_controller.rb

View workflow job for this annotation

GitHub Actions / lint

[rubocop] reported by reviewdog 🐶 Extra empty line detected at method body beginning. Raw Output: app/controllers/sessions_controller.rb:75:1: C: Layout/EmptyLinesAroundMethodBody: Extra empty line detected at method body beginning.
if params[:custom_bonus_points]

Check warning on line 76 in app/controllers/sessions_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/sessions_controller.rb#L76

Added line #L76 was not covered by tests
# 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[:custom_bonus_points])

Check warning on line 82 in app/controllers/sessions_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/sessions_controller.rb#L80-L82

Added lines #L80 - L82 were not covered by tests
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.
Expand Down

0 comments on commit 5f764f0

Please sign in to comment.