Module: IMS::LTI::Extensions::Content::ToolProvider
- Includes:
- Base, ExtensionBase
- Defined in:
- lib/ims/lti/extensions/content.rb
Instance Method Summary collapse
-
#accepted_content_types ⇒ Object
a list of the supported outcome data types.
- #accepted_file_extensions ⇒ Object
-
#accepts_content? ⇒ Boolean
check if the content extension is supported.
-
#accepts_content_type?(content_type) ⇒ Boolean
check if the consumer accepts a given type of content.
- #accepts_file?(file_name = nil) ⇒ Boolean
- #accepts_iframe? ⇒ Boolean
- #accepts_image_url? ⇒ Boolean
- #accepts_lti_launch_url? ⇒ Boolean
- #accepts_oembed? ⇒ Boolean
- #accepts_url? ⇒ Boolean
- #content_intended_use ⇒ Object
- #content_return_url ⇒ Object
-
#file_content_return_url(url, text, content_type = nil) ⇒ Object
generates the return url for file submissions.
-
#iframe_content_return_url(url, width, height, title = nil) ⇒ Object
generates the return url for iframe submissions.
-
#image_content_return_url(url, width, height, alt = '') ⇒ Object
generates the return url for image submissions.
-
#is_content_for?(intended_use) ⇒ Boolean
check the use of the content.
-
#lti_launch_content_return_url(url, text = 'link', title = nil) ⇒ Object
generates the return url for lti launch submissions.
-
#oembed_content_return_url(url, endpoint) ⇒ Object
generates the return url for oembed submissions.
-
#url_content_return_url(url, title = nil, text = 'link', target = '_blank') ⇒ Object
generates the return url for url submissions.
Methods included from Base
#extend_outcome_request, #extend_outcome_response, #outcome_request_extensions, #outcome_response_extensions
Methods included from ExtensionBase
#outcome_request_extensions, #outcome_response_extensions
Instance Method Details
#accepted_content_types ⇒ Object
a list of the supported outcome data types
27 28 29 30 31 32 33 34 35 |
# File 'lib/ims/lti/extensions/content.rb', line 27 def accepted_content_types return @content_types if @content_types @content_types = [] if val = @ext_params["content_return_types"] @content_types = val.split(',').map {|i| i.to_sym} end @content_types end |
#accepted_file_extensions ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/ims/lti/extensions/content.rb', line 37 def accepted_file_extensions return @file_extensions if @file_extensions @file_extensions = [] if val = @ext_params["content_file_extensions"] @file_extensions = val.split(',').map {|i| i.downcase.strip} end @file_extensions end |
#accepts_content? ⇒ Boolean
check if the content extension is supported
79 80 81 |
# File 'lib/ims/lti/extensions/content.rb', line 79 def accepts_content? !!@ext_params["content_return_types"] end |
#accepts_content_type?(content_type) ⇒ Boolean
check if the consumer accepts a given type of content
84 85 86 |
# File 'lib/ims/lti/extensions/content.rb', line 84 def accepts_content_type?(content_type) accepted_content_types.include? content_type.to_sym end |
#accepts_file?(file_name = nil) ⇒ Boolean
47 48 49 50 51 52 |
# File 'lib/ims/lti/extensions/content.rb', line 47 def accepts_file?(file_name = nil) accepted_content_types.include?(:file) && ( file_name.nil? || accepted_file_extensions.empty? || accepted_file_extensions.any?{|ext| file_name.downcase[/#{ext}$/]} ) end |
#accepts_iframe? ⇒ Boolean
66 67 68 |
# File 'lib/ims/lti/extensions/content.rb', line 66 def accepts_iframe? accepted_content_types.include?(:iframe) end |
#accepts_image_url? ⇒ Boolean
62 63 64 |
# File 'lib/ims/lti/extensions/content.rb', line 62 def accepts_image_url? accepted_content_types.include?(:image_url) end |
#accepts_lti_launch_url? ⇒ Boolean
58 59 60 |
# File 'lib/ims/lti/extensions/content.rb', line 58 def accepts_lti_launch_url? accepted_content_types.include?(:lti_launch_url) end |
#accepts_oembed? ⇒ Boolean
70 71 72 |
# File 'lib/ims/lti/extensions/content.rb', line 70 def accepted_content_types.include?(:oembed) end |
#accepts_url? ⇒ Boolean
54 55 56 |
# File 'lib/ims/lti/extensions/content.rb', line 54 def accepts_url? accepted_content_types.include?(:url) end |
#content_intended_use ⇒ Object
74 75 76 |
# File 'lib/ims/lti/extensions/content.rb', line 74 def content_intended_use @ext_params["content_intended_use"].to_sym if @ext_params["content_intended_use"] end |
#content_return_url ⇒ Object
93 94 95 |
# File 'lib/ims/lti/extensions/content.rb', line 93 def content_return_url @ext_params["content_return_url"] end |
#file_content_return_url(url, text, content_type = nil) ⇒ Object
generates the return url for file submissions
98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ims/lti/extensions/content.rb', line 98 def file_content_return_url(url, text, content_type = nil) url = CGI::escape(url) text = CGI::escape(text) content_type = CGI::escape(content_type) if content_type return_url = "#{content_return_url}?return_type=file&url=#{url}&text=#{text}" return_url = "#{return_url}&content_type=#{content_type}" if content_type return return_url end |
#iframe_content_return_url(url, width, height, title = nil) ⇒ Object
generates the return url for iframe submissions
143 144 145 146 147 148 149 150 151 152 |
# File 'lib/ims/lti/extensions/content.rb', line 143 def iframe_content_return_url(url, width, height, title = nil) url = CGI::escape(url) width = CGI::escape(width.to_s) height = CGI::escape(height.to_s) return_url = "#{content_return_url}?return_type=iframe&url=#{url}&width=#{width}&height=#{height}" return_url = "#{return_url}&title=#{CGI::escape(title)}" if title return return_url end |
#image_content_return_url(url, width, height, alt = '') ⇒ Object
generates the return url for image submissions
133 134 135 136 137 138 139 140 |
# File 'lib/ims/lti/extensions/content.rb', line 133 def image_content_return_url(url, width, height, alt = '') url = CGI::escape(url) width = CGI::escape(width.to_s) height = CGI::escape(height.to_s) alt = CGI::escape(alt) "#{content_return_url}?return_type=image_url&url=#{url}&width=#{width}&height=#{height}&alt=#{alt}" end |
#is_content_for?(intended_use) ⇒ Boolean
check the use of the content
89 90 91 |
# File 'lib/ims/lti/extensions/content.rb', line 89 def is_content_for? (intended_use) content_intended_use == intended_use end |
#lti_launch_content_return_url(url, text = 'link', title = nil) ⇒ Object
generates the return url for lti launch submissions
122 123 124 125 126 127 128 129 130 |
# File 'lib/ims/lti/extensions/content.rb', line 122 def lti_launch_content_return_url(url, text='link', title=nil) url = CGI::escape(url) text = CGI::escape(text) return_url = "#{content_return_url}?return_type=lti_launch_url&url=#{url}&text=#{text}" return_url = "#{return_url}&title=#{CGI::escape(title)}" if title return return_url end |
#oembed_content_return_url(url, endpoint) ⇒ Object
generates the return url for oembed submissions
155 156 157 158 159 160 |
# File 'lib/ims/lti/extensions/content.rb', line 155 def (url, endpoint) url = CGI::escape(url) endpoint = CGI::escape(endpoint) "#{content_return_url}?return_type=oembed&url=#{url}&endpoint=#{endpoint}" end |
#url_content_return_url(url, title = nil, text = 'link', target = '_blank') ⇒ Object
generates the return url for url submissions
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ims/lti/extensions/content.rb', line 110 def url_content_return_url(url, title = nil, text = 'link', target = '_blank') url = CGI::escape(url) text = CGI::escape(text) target = CGI::escape(target) return_url = "#{content_return_url}?return_type=url&url=#{url}&text=#{text}&target=#{target}" return_url = "#{return_url}&title=#{CGI::escape(title)}" if title return return_url end |