Class: LtiBoxEngine::LtiController
Instance Method Summary
collapse
#cors_preflight_check, #cors_set_access_control_headers, #set_default_headers
Instance Method Details
#embed ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/controllers/lti_box_engine/lti_controller.rb', line 30
def embed
item = params[:item]
lti_launch = LtiLaunch.where(id: params[:lti_launch_id]).first
launch_params = lti_launch.payload
tp = IMS::LTI::ToolProvider.new(nil, nil, launch_params)
tp.extend IMS::LTI::Extensions::Content::ToolProvider
if tp.accepts_content?
if tp.accepts_file?(item['name']) && item['type'] != 'folder'
redirect_url = tp.file_content_return_url(item['url'], item['name'])
render json: { redirect_url: redirect_url } and return
elsif tp.accepts_url?
redirect_url = tp.url_content_return_url(Client.box_url_to_box_embed_url(item['url']), item['name'], item['name'])
render json: { redirect_url: redirect_url } and return
else
render text: 'Unsupported content type', status: 500
end
else
render text: 'Unable to embed content', status: 500
end
end
|
#health_check ⇒ Object
76
77
78
|
# File 'app/controllers/lti_box_engine/lti_controller.rb', line 76
def health_check
head 200
end
|
#index ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/lti_box_engine/lti_controller.rb', line 8
def index
@client = Client.new
@tp = @client.authorize!(request, params)
if @tp
if @tp.accepts_content?
@lti_launch = LtiLaunch.create_from_tp(@tp)
if @tp.accepts_file?
@link_type = "direct"
else
@link_type = "shared"
end
else
redirect_to "https://www.box.com/embed_widget/files/0/f/0"
end
else
@message = @client.error_message
render :error
end
end
|
#xml_config ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'app/controllers/lti_box_engine/lti_controller.rb', line 54
def xml_config
host = "#{request.protocol}#{request.host_with_port}"
url = "#{host}#{root_path}"
title = "Box"
tool_id = "lti_box_engine"
tc = IMS::LTI::ToolConfig.new(:title => title, :launch_url => url)
tc.extend IMS::LTI::Extensions::Canvas::ToolConfig
tc.description = "Embed files from Box.net"
tc.canvas_privacy_anonymous!
tc.canvas_domain!(request.host)
tc.canvas_icon_url!("#{host}/assets/lti_box_engine/icon.png")
tc.canvas_text!(title)
tc.set_ext_param('canvas.instructure.com', :tool_id, tool_id)
tc.canvas_homework_submission!(enabled: true)
tc.canvas_editor_button!(enabled: true)
tc.canvas_resource_selection!(enabled: true)
tc.canvas_course_navigation!(enabled: true)
tc.canvas_user_navigation!(enabled: true)
tc.canvas_selector_dimensions!(430, 200)
render xml: tc.to_xml
end
|