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



54
55
56
57
58
59
60
61
62
# File 'lib/ims/lti/extensions/outcome_data.rb', line 54

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)


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

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

#accepts_outcome_needs_grading?Boolean

check if the consumer accepts a needs_grading as outcome data

Returns:

  • (Boolean)


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

def accepts_outcome_needs_grading?
  accepted_outcome_types.member?('needs_grading')
end

#accepts_outcome_text?Boolean

check if the consumer accepts text as outcome data

Returns:

  • (Boolean)


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

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)


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

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

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

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” or “needs_grading” (needs_grading expects a true/false value)

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

Creates a new OutcomeRequest object and stores it in @outcome_requests

Returns:



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/ims/lti/extensions/outcome_data.rb', line 93

def post_replace_result_with_data!(score, data={})
  req = new_request
  if data['cdata_text']
    req.outcome_cdata_text = data['cdata_text']
  elsif data['text']
    req.outcome_text = data['text']
  end
  req.outcome_url = data['url'] if data['url']
  req.outcome_needs_grading = data['needs_grading'] if data['needs_grading']
  req.post_replace_result!(score)
end