Class: LtiPublicResources::ApiController
Instance Method Summary
collapse
#cors_preflight_check, #cors_set_access_control_headers, #ga_domain, #ga_tracking_code, #set_default_headers
Instance Method Details
#browse ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/lti_public_resources/api_controller.rb', line 41
def browse
tool_id = params[:tool_id].to_sym
lti_app = @apps[tool_id]
driver = LtiPublicResources.drivers[tool_id]
folder = params[:folder]
criteria = APR::RequestCriteria.new(folder: folder)
results = driver.perform_request(criteria)
render json: { driver_response: results }
end
|
#embed ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/lti_public_resources/api_controller.rb', line 51
def embed
tp = tool_provider(params)
return_type = params[:return_type]
redirect_url = build_url(tp, return_type)
ret = return_type.to_json
if redirect_url.present?
ret = { redirectUrl: redirect_url }.to_json
end
render json: ret
end
|
#lti_app ⇒ Object
11
12
13
14
15
|
# File 'app/controllers/lti_public_resources/api_controller.rb', line 11
def lti_app
tool_id = params[:id].to_sym
lti_app = @apps[tool_id]
render json: { lti_app: lti_app }
end
|
#lti_apps ⇒ Object
7
8
9
|
# File 'app/controllers/lti_public_resources/api_controller.rb', line 7
def lti_apps
render json: { lti_apps: @apps }
end
|
#search ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/lti_public_resources/api_controller.rb', line 17
def search
tool_id = params[:tool_id].to_sym
lti_app = @apps[tool_id]
driver = LtiPublicResources.drivers[tool_id]
case lti_app[:tool_type]
when 'search'
q = {
query: params[:query],
page: (params[:page] ? params[:page].to_i : 1),
content_filter: APR::RequestCriteria::CONTENT_FILTER_NONE,
sort: APR::RequestCriteria::SORT_RELEVANCE
}
criteria = APR::RequestCriteria.new(q)
when 'browse'
criteria = APR::RequestCriteria.new(folder: params[:folder])
else
raise StandardError.new("Unknown tool type!")
end
results = driver.perform_request(criteria)
render json: { driver_response: results }
end
|
#xml_config ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'app/controllers/lti_public_resources/api_controller.rb', line 62
def xml_config
script_name = request.env['SCRIPT_NAME']
host = request.scheme + "://" + request.host_with_port
tool_id = 'public_resources'
if params[:id]
tool_id = params[:id]
lti_app = @apps[tool_id.to_sym]
name = lti_app[:name]
description = lti_app[:description]
icon = "#{host}/assets/lti_public_resources/#{lti_app[:icon_path]}"
text = lti_app[:name]
url = "#{host}#{script_name}/?tool_id=#{tool_id}"
else
name = "Public Resources"
description = "Collection of public resources"
icon = "#{host}/assets/lti_public_resources/public_resources_icon.png"
text = "Public Resources"
url = "#{host}#{script_name}"
end
tc = IMS::LTI::ToolConfig.new(:title => name, :launch_url => url)
tc.description = description
tc.extend IMS::LTI::Extensions::Canvas::ToolConfig
tc.canvas_privacy_anonymous!
tc.canvas_domain! request.host_with_port
tc.canvas_text! text
tc.canvas_icon_url! icon
tc.canvas_selector_dimensions! 560, 600
tc.canvas_editor_button!(enabled: true)
tc.canvas_resource_selection!(enabled: true)
tc.set_ext_param('canvas.instructure.com', :tool_id, tool_id)
render xml: tc.to_xml(:indent => 2)
end
|