Module: IMS::LTI::Extensions::OutcomeData::ToolProvider

Includes:
ExtensionBase, Base
Defined in:
lib/ims/lti/extensions/outcome_data.rb

Instance Method Summary collapse

Methods included from Base

#outcome_request_extensions

Methods included from ExtensionBase

#outcome_request_extensions, #outcome_response_extensions

Instance Method Details

#accepted_outcome_typesObject

a list of the supported outcome data types



45
46
47
48
49
50
51
52
53
# File 'lib/ims/lti/extensions/outcome_data.rb', line 45

def accepted_outcome_types
  return @outcome_types if @outcome_types
  @outcome_types = []
  if val = @ext_params["outcome_data_values_accepted"]
    @outcome_types = val.split(',')
  end

  @outcome_types
end

#accepts_outcome_data?Boolean

check if the outcome data extension is supported

Returns:

  • (Boolean)


56
57
58
# File 'lib/ims/lti/extensions/outcome_data.rb', line 56

def accepts_outcome_data?
  !!@ext_params["outcome_data_values_accepted"]
end

#accepts_outcome_lti_launch_url?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/ims/lti/extensions/outcome_data.rb', line 75

def accepts_outcome_lti_launch_url?
  accepted_outcome_types.member?("lti_launch_url")
end

#accepts_outcome_result_total_score?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/ims/lti/extensions/outcome_data.rb', line 79

def accepts_outcome_result_total_score?
  !!@ext_params["outcome_result_total_score_accepted"]
end

#accepts_outcome_text?Boolean

check if the consumer accepts text as outcome data

Returns:

  • (Boolean)


61
62
63
# File 'lib/ims/lti/extensions/outcome_data.rb', line 61

def accepts_outcome_text?
  accepted_outcome_types.member?("text")
end

#accepts_outcome_url?Boolean

check if the consumer accepts a url as outcome data

Returns:

  • (Boolean)


66
67
68
# File 'lib/ims/lti/extensions/outcome_data.rb', line 66

def accepts_outcome_url?
  accepted_outcome_types.member?("url")
end

#accepts_submitted_at?Boolean

check if the consumer accepts a submitted at date as outcome data

Returns:

  • (Boolean)


71
72
73
# File 'lib/ims/lti/extensions/outcome_data.rb', line 71

def 
  accepted_outcome_types.member?("submitted_at")
end

#post_extended_replace_result!(options = {}) ⇒ OutcomeResponse

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

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 If score is nil, the replace result XML will not contain a resultScore node

Creates a new OutcomeRequest object and stores it in @outcome_requests

Returns:



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/ims/lti/extensions/outcome_data.rb', line 110

def post_extended_replace_result!(options = {})
  opts = {}
  options.each {|k,v| opts[k.to_sym] = v}

  req = new_request
  req.outcome_cdata_text = opts[:cdata_text]
  req.outcome_text = opts[:text]
  req.outcome_url = opts[:url]
  req. = opts[:submitted_at]
  req.outcome_lti_launch_url = opts[:lti_launch_url]
  req.total_score = opts[:total_score]
  req.post_replace_result!(opts[:score])
end

#post_replace_result_with_data!(score = nil, data = {}) ⇒ OutcomeResponse

Deprecated.

Use #post_extended_replace_result! instead

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”

If both cdata_text and text are sent, cdata_text will be used

If score is nil, the replace result XML will not contain a resultScore node

Creates a new OutcomeRequest object and stores it in @outcome_requests

Returns:



94
95
96
97
# File 'lib/ims/lti/extensions/outcome_data.rb', line 94

def post_replace_result_with_data!(score = nil, data={})
  data[:score] = score if score
  post_extended_replace_result!(data)
end