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_result_total_score?Boolean

Returns:

  • (Boolean)


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

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

#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, :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:



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/ims/lti/extensions/outcome_data.rb', line 101

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.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”, or “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:



85
86
87
88
# File 'lib/ims/lti/extensions/outcome_data.rb', line 85

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