From 3df385248abfdb899ea4be429cca6d42f0f06097 Mon Sep 17 00:00:00 2001 From: Weston Dransfield Date: Fri, 22 Apr 2022 16:56:23 -0600 Subject: [PATCH] Add support for needsAdditionalReview (#169) * Initial work for addsAdditionalSupport * Finish support for needsAdditionalReview * bump version --- ims-lti.gemspec | 2 +- lib/ims/lti/extensions/outcome_data.rb | 29 ++++++++++++++++++++------ spec/extensions/outcome_data_spec.rb | 7 +++++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/ims-lti.gemspec b/ims-lti.gemspec index 337ea3d..392584f 100644 --- a/ims-lti.gemspec +++ b/ims-lti.gemspec @@ -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' diff --git a/lib/ims/lti/extensions/outcome_data.rb b/lib/ims/lti/extensions/outcome_data.rb index 46ffe44..4418f6f 100644 --- a/lib/ims/lti/extensions/outcome_data.rb +++ b/lib/ims/lti/extensions/outcome_data.rb @@ -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? @@ -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 # @@ -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 @@ -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]) @@ -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 @@ -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 @@ -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) diff --git a/spec/extensions/outcome_data_spec.rb b/spec/extensions/outcome_data_spec.rb index 7b1e56c..c099733 100644 --- a/spec/extensions/outcome_data_spec.rb +++ b/spec/extensions/outcome_data_spec.rb @@ -107,6 +107,13 @@ @tp.post_extended_replace_result!(submitted_at: '2020-01-01') end + it 'handles needs_additional_review' do + xml = submission_xml % %{} + mock_request(xml) + + @tp.post_extended_replace_result!(needs_additional_review: true) + end + it 'handles total_score' do xml = result_xml % %{en13} mock_request(xml)