Skip to content

Commit

Permalink
Add support for needsAdditionalReview (#169)
Browse files Browse the repository at this point in the history
* Initial work for addsAdditionalSupport

* Finish support for needsAdditionalReview

* bump version
  • Loading branch information
westonkd authored Apr 22, 2022
1 parent 7f176e1 commit 3df3852
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ims-lti.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = %q{ims-lti}
s.version = "1.2.4"
s.version = "1.2.5"

s.add_dependency 'builder', '>= 1.0', '< 4.0'
s.add_dependency 'oauth', '>= 0.4.5', '< 0.6'
Expand Down
29 changes: 23 additions & 6 deletions lib/ims/lti/extensions/outcome_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def accepts_outcome_url?

# check if the consumer accepts a submitted at date as outcome data
def accepts_submitted_at?
accepted_outcome_types.member?("submitted_at")
accepted_outcome_types.member?("submitted_at") ||
@ext_params["ext_outcome_submission_submitted_at_accepted"] == "true"
end

def accepts_outcome_lti_launch_url?
Expand All @@ -80,8 +81,15 @@ def accepts_outcome_result_total_score?
!!@ext_params["outcome_result_total_score_accepted"]
end

def accepts_needs_additional_review?
@ext_params["ext_outcome_submission_needs_additional_review_accepted"] == "true"
end

# POSTs the given score to the Tool Consumer with a replaceResult and
# adds the specified data. The data hash can have the keys "text", "cdata_text", "url", "submitted_at" or "lti_launch_url"
# adds the specified data.
#
# The data hash can have the keys "text", "cdata_text", "url", "submitted_at"
# "needs_additional_review", or "lti_launch_url"
#
# If both cdata_text and text are sent, cdata_text will be used
#
Expand All @@ -98,7 +106,8 @@ def post_replace_result_with_data!(score = nil, data={})

# POSTs the given score to the Tool Consumer with a replaceResult and
# adds the specified data. The options hash can have the keys
# :text, :cdata_text, :url, :submitted_at, :lti_launch_url, :score, or :total_score
# :text, :cdata_text, :url, :submitted_at, :lti_launch_url, :score,
# :needs_additional_review, or :total_score
#
# If both cdata_text and text are sent, cdata_text will be used
# If both total_score and score are sent, total_score will be used
Expand All @@ -116,6 +125,7 @@ def post_extended_replace_result!(options = {})
req.outcome_text = opts[:text]
req.outcome_url = opts[:url]
req.submitted_at = opts[:submitted_at]
req.needs_additional_review = opts[:needs_additional_review]
req.outcome_lti_launch_url = opts[:lti_launch_url]
req.total_score = opts[:total_score]
req.post_replace_result!(opts[:score])
Expand Down Expand Up @@ -156,7 +166,13 @@ module OutcomeRequest
include IMS::LTI::Extensions::ExtensionBase
include Base

attr_accessor :outcome_text, :outcome_url, :submitted_at, :outcome_lti_launch_url, :outcome_cdata_text, :total_score
attr_accessor :outcome_text,
:outcome_url,
:submitted_at,
:outcome_lti_launch_url,
:outcome_cdata_text,
:total_score,
:needs_additional_review

def result_values(node)
super
Expand Down Expand Up @@ -188,7 +204,8 @@ def details(node)
super
return unless has_details_data?

node.submittedAt submitted_at
node.submittedAt submitted_at if submitted_at
node.needsAdditionalReview if needs_additional_review
end

def score
Expand All @@ -200,7 +217,7 @@ def has_result_data?
end

def has_details_data?
!!submitted_at
!!submitted_at || !!needs_additional_review
end

def extention_process_xml(doc)
Expand Down
7 changes: 7 additions & 0 deletions spec/extensions/outcome_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@
@tp.post_extended_replace_result!(submitted_at: '2020-01-01')
end

it 'handles needs_additional_review' do
xml = submission_xml % %{<needsAdditionalReview/>}
mock_request(xml)

@tp.post_extended_replace_result!(needs_additional_review: true)
end

it 'handles total_score' do
xml = result_xml % %{<resultTotalScore><language>en</language><textString>13</textString></resultTotalScore>}
mock_request(xml)
Expand Down

0 comments on commit 3df3852

Please sign in to comment.