learnosity-sdk 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +5 -5
  2. data/.github/PULL_REQUEST_TEMPLATE.md +13 -0
  3. data/.gitignore +1 -0
  4. data/.travis.yml +15 -5
  5. data/CONTRIBUTING.md +14 -0
  6. data/ChangeLog.md +14 -0
  7. data/LICENSE.md +141 -0
  8. data/Makefile +69 -0
  9. data/README.md +230 -186
  10. data/REFERENCE.md +249 -0
  11. data/Rakefile +9 -0
  12. data/docs/images/apache-license.svg +20 -0
  13. data/docs/images/downloads.svg +20 -0
  14. data/docs/images/image-assessment-retrieval.png +0 -0
  15. data/docs/images/image-concept-overview.png +0 -0
  16. data/docs/images/image-logo-graphic.png +0 -0
  17. data/docs/images/image-quickstart-examples-assessment.png +0 -0
  18. data/docs/images/image-quickstart-index.png +0 -0
  19. data/docs/images/image-signed-request-creation.png +0 -0
  20. data/docs/quickstart/css/style.css +113 -0
  21. data/{examples → docs/quickstart}/lrn-sdk-rails/Gemfile +2 -2
  22. data/docs/quickstart/lrn-sdk-rails/app/controllers/author_controller.rb +179 -0
  23. data/docs/quickstart/lrn-sdk-rails/app/controllers/index_controller.rb +9 -0
  24. data/docs/quickstart/lrn-sdk-rails/app/controllers/items_controller.rb +33 -0
  25. data/docs/quickstart/lrn-sdk-rails/app/controllers/questions_controller.rb +44 -0
  26. data/docs/quickstart/lrn-sdk-rails/app/controllers/reports_controller.rb +32 -0
  27. data/docs/quickstart/lrn-sdk-rails/app/views/author/index.html.erb +14 -0
  28. data/docs/quickstart/lrn-sdk-rails/app/views/index/index.html.erb +34 -0
  29. data/{examples/lrn-sdk-rails/app/views/index → docs/quickstart/lrn-sdk-rails/app/views/items}/index.html.erb +2 -5
  30. data/docs/quickstart/lrn-sdk-rails/app/views/questions/index.html.erb +6 -0
  31. data/docs/quickstart/lrn-sdk-rails/app/views/reports/index.html.erb +14 -0
  32. data/docs/quickstart/lrn-sdk-rails/config/application.rb +24 -0
  33. data/docs/quickstart/lrn-sdk-rails/config/routes.rb +11 -0
  34. data/examples/simple/init_data.rb +6 -4
  35. data/examples/simple/init_items.rb +6 -4
  36. data/learnosity-sdk.gemspec +14 -14
  37. data/lib/learnosity/sdk/request/init.rb +10 -9
  38. data/lib/learnosity/sdk/version.rb +1 -1
  39. metadata +116 -97
  40. data/LICENSE +0 -201
  41. data/examples/lrn-sdk-rails/README.md +0 -24
  42. data/examples/lrn-sdk-rails/app/controllers/index_controller.rb +0 -106
  43. data/examples/lrn-sdk-rails/config/application.rb +0 -15
  44. data/examples/lrn-sdk-rails/config/routes.rb +0 -5
  45. /data/{examples → docs/quickstart}/lrn-sdk-rails/.gitignore +0 -0
  46. /data/{examples → docs/quickstart}/lrn-sdk-rails/Rakefile +0 -0
  47. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/config/manifest.js +0 -0
  48. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/images/.keep +0 -0
  49. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/javascripts/application.js +0 -0
  50. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/javascripts/cable.js +0 -0
  51. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/javascripts/channels/.keep +0 -0
  52. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/javascripts/index.coffee +0 -0
  53. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/stylesheets/application.css +0 -0
  54. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/stylesheets/index.scss +0 -0
  55. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/channels/application_cable/channel.rb +0 -0
  56. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/channels/application_cable/connection.rb +0 -0
  57. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/controllers/application_controller.rb +0 -0
  58. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/controllers/concerns/.keep +0 -0
  59. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/helpers/application_helper.rb +0 -0
  60. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/helpers/index_helper.rb +0 -0
  61. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/jobs/application_job.rb +0 -0
  62. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/mailers/application_mailer.rb +0 -0
  63. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/models/application_record.rb +0 -0
  64. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/models/concerns/.keep +0 -0
  65. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/views/layouts/application.html.erb +0 -0
  66. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/views/layouts/mailer.html.erb +0 -0
  67. /data/{examples → docs/quickstart}/lrn-sdk-rails/app/views/layouts/mailer.text.erb +0 -0
  68. /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/bundle +0 -0
  69. /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/rails +0 -0
  70. /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/rake +0 -0
  71. /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/setup +0 -0
  72. /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/spring +0 -0
  73. /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/update +0 -0
  74. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/boot.rb +0 -0
  75. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/cable.yml +0 -0
  76. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/database.yml +0 -0
  77. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/environment.rb +0 -0
  78. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/environments/development.rb +0 -0
  79. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/environments/production.rb +0 -0
  80. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/environments/test.rb +0 -0
  81. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/application_controller_renderer.rb +0 -0
  82. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/assets.rb +0 -0
  83. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/backtrace_silencers.rb +0 -0
  84. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/cookies_serializer.rb +0 -0
  85. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/filter_parameter_logging.rb +0 -0
  86. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/inflections.rb +0 -0
  87. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/mime_types.rb +0 -0
  88. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/new_framework_defaults.rb +0 -0
  89. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/session_store.rb +0 -0
  90. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/wrap_parameters.rb +0 -0
  91. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/locales/en.yml +0 -0
  92. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/puma.rb +0 -0
  93. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/secrets.yml +0 -0
  94. /data/{examples → docs/quickstart}/lrn-sdk-rails/config/spring.rb +0 -0
  95. /data/{examples → docs/quickstart}/lrn-sdk-rails/config.ru +0 -0
  96. /data/{examples → docs/quickstart}/lrn-sdk-rails/db/seeds.rb +0 -0
  97. /data/{examples → docs/quickstart}/lrn-sdk-rails/lib/assets/.keep +0 -0
  98. /data/{examples → docs/quickstart}/lrn-sdk-rails/lib/tasks/.keep +0 -0
  99. /data/{examples → docs/quickstart}/lrn-sdk-rails/log/.keep +0 -0
  100. /data/{examples → docs/quickstart}/lrn-sdk-rails/public/404.html +0 -0
  101. /data/{examples → docs/quickstart}/lrn-sdk-rails/public/422.html +0 -0
  102. /data/{examples → docs/quickstart}/lrn-sdk-rails/public/500.html +0 -0
  103. /data/{examples → docs/quickstart}/lrn-sdk-rails/public/apple-touch-icon-precomposed.png +0 -0
  104. /data/{examples → docs/quickstart}/lrn-sdk-rails/public/apple-touch-icon.png +0 -0
  105. /data/{examples → docs/quickstart}/lrn-sdk-rails/public/favicon.ico +0 -0
  106. /data/{examples → docs/quickstart}/lrn-sdk-rails/public/robots.txt +0 -0
  107. /data/{examples → docs/quickstart}/lrn-sdk-rails/test/controllers/.keep +0 -0
  108. /data/{examples → docs/quickstart}/lrn-sdk-rails/test/controllers/index_controller_test.rb +0 -0
  109. /data/{examples → docs/quickstart}/lrn-sdk-rails/test/fixtures/.keep +0 -0
  110. /data/{examples → docs/quickstart}/lrn-sdk-rails/test/fixtures/files/.keep +0 -0
  111. /data/{examples → docs/quickstart}/lrn-sdk-rails/test/helpers/.keep +0 -0
  112. /data/{examples → docs/quickstart}/lrn-sdk-rails/test/integration/.keep +0 -0
  113. /data/{examples → docs/quickstart}/lrn-sdk-rails/test/mailers/.keep +0 -0
  114. /data/{examples → docs/quickstart}/lrn-sdk-rails/test/models/.keep +0 -0
  115. /data/{examples → docs/quickstart}/lrn-sdk-rails/test/test_helper.rb +0 -0
  116. /data/{examples → docs/quickstart}/lrn-sdk-rails/tmp/.keep +0 -0
  117. /data/{examples → docs/quickstart}/lrn-sdk-rails/vendor/assets/javascripts/.keep +0 -0
  118. /data/{examples → docs/quickstart}/lrn-sdk-rails/vendor/assets/stylesheets/.keep +0 -0
data/REFERENCE.md ADDED
@@ -0,0 +1,249 @@
1
+ # Learnosity Ruby-SDK: Reference Guide
2
+
3
+ ## Usage
4
+
5
+ Some usage examples can be found in the `examples/simple` subdirectory. A working Rails project can be found under `docs/quickstart/lrn-sdk-rails/`.
6
+
7
+ ### Init
8
+
9
+ This class generates and signs init options for all supported APIs. Its
10
+ constructor takes four mandatory arguments, and one optional argument.
11
+
12
+ - `service`: the name of the API to sign initialisation options for,
13
+ - `security_packet`: a hash with at least the `consumer_key`, optionally the
14
+ `domain` and `timestamp`; `user_id` is also mandatory for Questions API,
15
+ - `consumer_secret`
16
+ - `request`: the request you want to get a signature for
17
+ - `action` [Data API only]: the action of your request, either `get` or `post`
18
+
19
+ The `Init#generate` method can then be used to generate the options. By default,
20
+ it will generate a JSON string. It however takes one parameter, `encode` which,
21
+ if false, will simply return a native Ruby Hash with the signed options.
22
+
23
+ Given your consumer key and secret, and the request you want to run against,
24
+ say, the `items` API, you just need to instantiate the
25
+ `Learnosity::Sdk::Request::Init`, and call its `generate` method.
26
+
27
+ ```ruby
28
+ require "learnosity/sdk/request/init"
29
+
30
+ security_packet = {
31
+ # XXX: This is a Learnosity Demos consumer; replace it with your own consumer key.
32
+ # Add the demo consumer key and secret to application.rb in your Rails project: docs/quickstart/lrn-sdk-rails/config/
33
+ # application.rb -- this path shows a file from the quick start example project, which is explained in README.md.
34
+ 'consumer_key' => Rails.configuration.consumer_key,
35
+ 'domain' => 'localhost'
36
+ }
37
+ # XXX: The consumer secret should be in a properly secured credential store, and *NEVER* checked into version control.
38
+ # Add the demo consumer key and secret to application.rb in your Rails project: docs/quickstart/lrn-sdk-rails/config/
39
+ # application.rb -- this path shows a file from the quick start example project, which is explained in README.md.
40
+ consumer_secret = Rails.configuration.consumer_secret
41
+
42
+ items_request = { 'limit' => 50 }
43
+
44
+ init = Learnosity::Sdk::Request::Init.new(
45
+ 'items',
46
+ security_packet,
47
+ consumer_secret,
48
+ items_request
49
+ )
50
+
51
+ puts init.generate
52
+ ```
53
+
54
+ This will return a string of signed options suitable for initialisation of
55
+ the API.
56
+
57
+ ```html
58
+ <html>
59
+ <head>
60
+ </head>
61
+ <body>
62
+ <script src="//items.learnosity.com/"></script>
63
+ <script>
64
+ var itemsApp = LearnosityItems.init(INSERT OPTIONS HERE);
65
+ </script>
66
+ </body>
67
+ </html>
68
+ ```
69
+
70
+ ### Data API
71
+
72
+ When the `service` parameter is `data`, the `action` parameter is mandatory.
73
+ Moreover, `Init#generate`'s `encode` parameter is ignored, and a native Ruby Hash
74
+ with the signed options is unconditionally returned, for use with your favourite
75
+ HTTP library (note that, regardless of the `action` parameter, you should always
76
+ send `POST` requests).
77
+
78
+ ```ruby
79
+ require 'net/http'
80
+ require "learnosity/sdk/request/init"
81
+
82
+ security_packet = {
83
+ # XXX: This is a Learnosity Demos consumer; replace it with your own consumer key.
84
+ # Add the demo consumer key and secret to application.rb in your Rails project: docs/quickstart/lrn-sdk-rails/config/
85
+ # application.rb -- this path shows a file from the quick start example project, which is explained in README.md.
86
+ 'consumer_key' => Rails.configuration.consumer_key,
87
+ 'domain' => 'localhost'
88
+ }
89
+ # XXX: The consumer secret should be in a properly secured credential store, and *NEVER* checked into version control.
90
+ # Add the demo consumer key and secret to application.rb in your Rails project: docs/quickstart/lrn-sdk-rails/config/
91
+ # application.rb -- this path shows a file from the quick start example project, which is explained in README.md.
92
+ consumer_secret = Rails.configuration.consumer_secret
93
+
94
+ data_request = { 'limit' => 50 }
95
+
96
+ init = Learnosity::Sdk::Request::Init.new(
97
+ 'data',
98
+ security_packet,
99
+ consumer_secret,
100
+ data_request,
101
+ 'get'
102
+ )
103
+
104
+ request = init.generate
105
+
106
+ Net::HTTP.post_form URI('https://data.learnosity.com/v1/itembank/items'), request
107
+ ```
108
+
109
+ ### Recursive Queries
110
+
111
+ tl;dr: not currently implemented
112
+
113
+ Some requests are paginated to the `limit` passed in the request, or some
114
+ server-side default. Responses to those requests contain a `next` parameter in
115
+ their `meta` property, which can be placed in the next request to access another
116
+ page of data.
117
+
118
+ For the time being, you can iterate through pages by looping over the
119
+ `Init#new`/`Init#generate`/`Net::HTTP#post_form`, updating the `next` attribute
120
+ in the request.
121
+
122
+ ```ruby
123
+ response = JSON.parse(res.body)
124
+ if ( !response['meta']['next'].nil? \
125
+ and !response['meta']['records'].nil? and response['meta']['records'] > 0)
126
+ data_request['next'] = response['meta']['next']
127
+ end
128
+ ```
129
+
130
+ This will `require 'json'` to be able to parse the response.
131
+
132
+ See `examples/simple/init_data.rb` for an example.
133
+
134
+ ### Generating UUIDs
135
+
136
+ You will need to generate UUIDs. You can use the Ruby `securerandom`
137
+ module for this purpose.
138
+
139
+ ```ruby
140
+ require 'securerandom'
141
+
142
+ p SecureRandom.uuid
143
+ ```
144
+
145
+ ### Rails
146
+
147
+ You can bootstrap a Ruby-on-Rails project using this SDK by doing the
148
+ following.
149
+
150
+ Note, this is a quick 0 to 100 in 10s examples of how to use this
151
+ SDK with Rails. As such, it takes many unwise shortcuts in the architecture of
152
+ the app; do not take this as the example of a good Rails app.
153
+
154
+ First, generate a skeleton project
155
+
156
+ rails new lrn-sdk-rails
157
+ cd lrn-sdk-rails
158
+
159
+ Add the `learnosity-sdk` as a dependency to this project
160
+
161
+ echo "gem 'learnosity-sdk' >> Gemfile
162
+ bundle install
163
+
164
+ Create a default controller
165
+
166
+ rails generate controller Index index
167
+
168
+ Add the `require` for the SDK at the top of the newly created controller,
169
+ `app/controllers/index_controller.rb`, and insert the assessment configuration
170
+ there (taken from [items-api-demo](examples/simple/init_items.rb), and truncated for legibility). Add the demo
171
+ consumer key and secret to [[application.rb](docs/quickstart/lrn-sdk-rails/config/application.rb) (link shows the file from the quick start example, which is referenced in [README.md](README.md)).
172
+
173
+ ```ruby
174
+ require 'learnosity/sdk/request/init'
175
+
176
+ class IndexController < ApplicationController
177
+ @@security_packet = {
178
+ # XXX: This is a Learnosity Demos consumer; replace it with your own consumer key.
179
+ # Add the demo consumer key and secret to application.rb in your Rails project: docs/quickstart/lrn-sdk-rails/config/
180
+ # application.rb -- this path shows a file from the quick start example project, which is explained in README.md.
181
+ 'consumer_key' => Rails.configuration.consumer_key,
182
+ 'domain' => 'localhost'
183
+ }
184
+ # XXX: The consumer secret should be in a properly secured credential store, and *NEVER* checked into version control.
185
+ # Add the demo consumer key and secret to application.rb in your Rails project: docs/quickstart/lrn-sdk-rails/config/
186
+ # application.rb -- this path shows a file from the quick start example project, which is explained in README.md.
187
+ consumer_secret = Rails.configuration.consumer_secret
188
+ @@items_request = {
189
+ [...]
190
+ }
191
+
192
+ def index
193
+ init = Learnosity::Sdk::Request::Init.new(
194
+ 'items',
195
+ @@security_packet,
196
+ @@consumer_secret,
197
+ @@items_request
198
+ )
199
+ end
200
+ end
201
+ ```
202
+
203
+ Add the HTML/Javascript boilerplate to the view, `app/views/index/index.html.erb`
204
+
205
+ ```erb
206
+ <h1>Index#index</h1>
207
+
208
+ <div id="learnosity_assess"></div>
209
+
210
+ <script src="//items.learnosity.com"></script>
211
+ <script>
212
+ var eventOptions = {
213
+ readyListener: init
214
+ },
215
+ itemsApp = LearnosityItems.init(<%= raw(@init.generate) %>);
216
+
217
+ function init () {
218
+ var assessApp = itemsApp.assessApp();
219
+
220
+ assessApp.on('item:load', function () {
221
+ console.log('Active item:', getActiveItem(this.getItems()));
222
+ });
223
+
224
+ assessApp.on('test:submit:success', function () {
225
+ toggleModalClass();
226
+ });
227
+ }
228
+ </script>
229
+ ```
230
+
231
+ Finally, you can serve the project with
232
+
233
+ rails server
234
+
235
+
236
+ It will become available at http://localhost:3000/index/index
237
+
238
+ For reference you can find the result of these steps in
239
+ `docs/quickstart/lrn-sdk-rails/`.
240
+
241
+ ## Further reading
242
+ Thanks for reading to the end! Find more information about developing an app with Learnosity on our documentation sites:
243
+ <ul>
244
+ <li><a href="http://help.learnosity.com">help.learnosity.com</a> -- general help portal and tutorials,
245
+ <li><a href="http://reference.learnosity.com">reference.learnosity.com</a> -- developer reference site, and
246
+ <li><a href="http://authorguide.learnosity.com">authorguide.learnosity.com</a> -- authoring documentation for content creators.
247
+ </ul>
248
+
249
+ Back to [README.md](README.md)
data/Rakefile CHANGED
@@ -1,6 +1,15 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "./lib/learnosity/sdk/version"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
7
  task :default => :spec
8
+
9
+ task :version do
10
+ puts Learnosity::Sdk::VERSION
11
+ end
12
+
13
+ task :clean do
14
+ ["Gemfile.lock", ".rspec_status"].each {|f| File.delete(f) rescue nil}
15
+ end
@@ -0,0 +1,20 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="122" height="20">
2
+ <linearGradient id="b" x2="0" y2="100%">
3
+ <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
4
+ <stop offset="1" stop-opacity=".1"/>
5
+ </linearGradient>
6
+ <mask id="a">
7
+ <rect width="122" height="20" rx="3" fill="#fff"/>
8
+ </mask>
9
+ <g mask="url(#a)">
10
+ <rect width="48" height="20" fill="#555"/>
11
+ <rect x="48" width="74" height="20" fill="#428F7E"/>
12
+ <rect width="122" height="20" fill="url(#b)"/>
13
+ </g>
14
+ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
15
+ <text x="25" y="15" fill="#010101" fill-opacity=".3">license</text>
16
+ <text x="25" y="14">license</text>
17
+ <text x="84" y="15" fill="#010101" fill-opacity=".3">Apache-2.0</text>
18
+ <text x="84" y="14">Apache-2.0</text>
19
+ </g>
20
+ </svg>
@@ -0,0 +1,20 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="132" height="20">
2
+ <linearGradient id="b" x2="0" y2="100%">
3
+ <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
4
+ <stop offset="1" stop-opacity=".1"/>
5
+ </linearGradient>
6
+ <mask id="a">
7
+ <rect width="132" height="20" rx="3" fill="#fff"/>
8
+ </mask>
9
+ <g mask="url(#a)">
10
+ <rect width="70" height="20" fill="#555"/>
11
+ <rect x="70" width="62" height="20" fill="#007ec6"/>
12
+ <rect width="132" height="20" fill="url(#b)"/>
13
+ </g>
14
+ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
15
+ <text x="36" y="15" fill="#010101" fill-opacity=".3">downloads</text>
16
+ <text x="36" y="14">downloads</text>
17
+ <text x="100" y="15" fill="#010101" fill-opacity=".3">102.49 k </text>
18
+ <text x="100" y="14">102.49 k </text>
19
+ </g>
20
+ </svg>
Binary file
@@ -0,0 +1,113 @@
1
+ html,
2
+ body,
3
+ .main {
4
+ padding: 0;
5
+ margin: 0;
6
+ color: #333;
7
+ }
8
+ body {
9
+ height: auto;
10
+ margin: 20px;
11
+ font-family: Helvetica, Arial, sans-serif;
12
+ }
13
+ h1, h2, h3, h4, h5, h6 {
14
+ font-weight: normal;
15
+ margin: 2em 0 .3em 0;
16
+ padding: 0;
17
+ }
18
+ h1 { font-size: 2.0em; margin: .3em 0 .3em; }
19
+ h2 { font-size: 1.6em; }
20
+ h3 { font-size: 1.4em; }
21
+ h4 { font-size: 1.2em; }
22
+ h5 { font-size: 1.1em; }
23
+ h6 { font-size: 1.0em; }
24
+ ul {
25
+ margin-top: 0;
26
+ margin-bottom: 1em;
27
+ }
28
+ a { color: #3498DB; }
29
+ a:visited { color: #3498DB; }
30
+ a:hover { color: #2979AF; }
31
+ .quickstart-index {
32
+ margin: 0;
33
+ background-color: #efefef;
34
+ }
35
+ .quickstart-index h1 {
36
+ padding-bottom: 1em;
37
+ margin-bottom: 1em;
38
+ border-bottom: 1px dashed rgba(0, 0, 0, .3);
39
+ }
40
+ .container {
41
+ padding: 20px;
42
+ }
43
+ .lrn-logo {
44
+ width: 150px;
45
+ }
46
+ .header-nav,
47
+ .footer-nav {
48
+ position: fixed;
49
+ width: 100%;
50
+ }
51
+ .header-nav {
52
+ top: 0;
53
+ background-color: #ffffff;
54
+ border-bottom: 2px solid #222;
55
+ height: 80px;
56
+ }
57
+ .footer-nav {
58
+ color: #f3f3f3;
59
+ background-color: #222;
60
+ padding: 1em 0;
61
+ text-align: center;
62
+ bottom: 0em;
63
+ }
64
+ .footer-nav a {
65
+ color: #fff;
66
+ padding: 0 0.5em;
67
+ text-decoration: none;
68
+ }
69
+ .footer-nav a:hover {
70
+ color: #ccc;
71
+ text-decoration: underline;
72
+ }
73
+ .module-block {
74
+ background: #ffffff;
75
+ max-width: 800px;
76
+ margin: 80px auto 40px;
77
+ padding: 20px;
78
+ }
79
+ .api-list li {
80
+ margin-top: 1em;
81
+ }
82
+ .api-list p {
83
+ margin: 3px 0 6px 6px;
84
+ }
85
+ .hero-icon {
86
+ position: relative;
87
+ top: 7px;
88
+ height: 42px;
89
+ width: 42px;
90
+ background-repeat: no-repeat;
91
+ background-position: center;
92
+ background-size: 80%;
93
+ }
94
+ .li-authorapi {
95
+ background-image: url(https://docs.learnosity.com/static/img/icons/authorapi.svg);
96
+ }
97
+ .li-itemsapi {
98
+ background-image: url(https://docs.learnosity.com/static/img/icons/itemsapi.svg);
99
+ }
100
+ .li-reportsapi {
101
+ background-image: url(https://docs.learnosity.com/static/img/icons/reports.svg);
102
+ }
103
+ .li-dataapi {
104
+ background-image: url(https://docs.learnosity.com/static/img/icons/dataapi.svg);
105
+ }
106
+ [class^="li-"], [class*=" li-"] {
107
+ background-color: #0d5786;
108
+ color: #ffffff;
109
+ width: 36px;
110
+ height: 36px;
111
+ border-radius: 50%;
112
+ display: inline-block;
113
+ }
@@ -11,7 +11,7 @@ gem 'rails', '~> 5.0.2'
11
11
  # Use sqlite3 as the database for Active Record
12
12
  gem 'sqlite3', '~> 1.3.6'
13
13
  # Use Puma as the app server
14
- gem 'puma', '~> 3.0'
14
+ gem 'puma', '~> 4.3.8'
15
15
  # Use SCSS for stylesheets
16
16
  gem 'sass-rails', '~> 5.0'
17
17
  # Use Uglifier as compressor for JavaScript assets
@@ -54,4 +54,4 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
54
54
 
55
55
  # The :path allows us to use the local code, you'll likely not need that in a
56
56
  # normal project
57
- gem 'learnosity-sdk', :path => '../..'
57
+ gem 'learnosity-sdk', :path => '../../..'
@@ -0,0 +1,179 @@
1
+ require 'learnosity/sdk/request/init' # Learnosity helper.
2
+ require 'securerandom'
3
+
4
+ class AuthorController < ApplicationController
5
+
6
+ @@security_packet = {
7
+ # XXX: This is a Learnosity Demos consumer; replace it with your own consumer key. Set values in application.rb.
8
+ 'consumer_key' => Rails.configuration.consumer_key,
9
+ 'domain' => 'localhost',
10
+ 'user_id' => SecureRandom.uuid
11
+ }
12
+
13
+ # XXX: The consumer secret should be in a properly secured credential store, and *NEVER* checked into version control
14
+ @@consumer_secret = Rails.configuration.consumer_secret
15
+
16
+ @@author_request = {
17
+ "mode"=> "item_edit",
18
+ "reference"=> "a15ac409-f6d5-42de-a491-a1e4ab03c826",
19
+ "user"=> {
20
+ "id" => "brianmoser",
21
+ "firstname" => "Test",
22
+ "lastname" => "Test",
23
+ "email" => "test@test.com"
24
+ },
25
+ "config"=> {
26
+ "global"=> {
27
+ "disable_onbeforeunload"=> true,
28
+ "hide_tags"=>
29
+ [
30
+ {
31
+ "type"=> "internal_category_uuid"
32
+ }
33
+ ]
34
+ },
35
+ "item_edit"=> {
36
+ "item"=> {
37
+ "back"=> true,
38
+ "columns"=> true,
39
+ "answers"=> true,
40
+ "scoring"=> true,
41
+ "reference"=> {
42
+ "edit"=> false,
43
+ "show"=> false,
44
+ "prefix"=> "LEAR_"
45
+ },
46
+ "save"=> true,
47
+ "status"=> false,
48
+ "dynamic_content"=> true,
49
+ "shared_passage"=> true
50
+ },
51
+ "widget"=> {
52
+ "delete"=> false,
53
+ "edit"=> true
54
+ }
55
+ },
56
+ "item_list"=> {
57
+ "item"=> {
58
+ "status"=> true,
59
+ "url"=> "http://myApp.com/items/:reference/edit"
60
+ },
61
+ "toolbar"=> {
62
+ "add"=> true,
63
+ "browse"=> {
64
+ "controls"=> [
65
+ {
66
+ "type"=> "hierarchy",
67
+ "hierarchies"=> [
68
+ {
69
+ "reference"=> "CCSS_Math_Hierarchy",
70
+ "label"=> "CCSS Math"
71
+ },
72
+ {
73
+ "reference"=> "CCSS_ELA_Hierarchy",
74
+ "label"=> "CCSS ELA"
75
+ },
76
+ {
77
+ "reference"=> "Demo_Items_Hierarchy",
78
+ "label"=> "Demo Items"
79
+ }
80
+ ]
81
+ },
82
+ {
83
+ "type"=> "tag",
84
+ "tag"=> {
85
+ "type"=> "Alignment",
86
+ "label"=> "def456"
87
+ }
88
+ },
89
+ {
90
+ "type"=> "tag",
91
+ "tag"=> {
92
+ "type"=> "Course",
93
+ "label"=> "commoncore"
94
+ }
95
+ }
96
+ ]
97
+ }
98
+ },
99
+ "filter"=> {
100
+ "restricted"=> {
101
+ "current_user"=> true,
102
+ "tags"=> {
103
+ "all"=> [
104
+ {
105
+ "type"=> "Alignment",
106
+ "name"=> ["def456", "abc123"]
107
+ },
108
+ {
109
+ "type"=> "Course"
110
+ }
111
+ ],
112
+ "either"=> [
113
+ {
114
+ "type"=> "Grade",
115
+ "name"=> "4"
116
+ },
117
+ {
118
+ "type"=> "Grade",
119
+ "name"=> "5"
120
+ },
121
+ {
122
+ "type"=> "Subject",
123
+ "name"=> ["Math", "Science"]
124
+ }
125
+ ],
126
+ "none"=> [
127
+ {
128
+ "type"=> "Grade",
129
+ "name"=> "6"
130
+ }
131
+ ]
132
+ }
133
+ }
134
+ }
135
+ },
136
+ "dependencies"=> {
137
+ "question_editor_api"=> {
138
+ "init_options"=> {}
139
+ },
140
+ "questions_api"=> {
141
+ "init_options"=> {}
142
+ }
143
+ },
144
+ "widget_templates"=> {
145
+ "back"=> true,
146
+ "save"=> true,
147
+ "widget_types"=> {
148
+ "default"=> "questions",
149
+ "show"=> true
150
+ }
151
+ },
152
+ "container"=> {
153
+ "height"=> "auto",
154
+ "fixed_footer_height"=> 0,
155
+ "scroll_into_view_selector"=> "body"
156
+ },
157
+ "label_bundle"=> {
158
+ "backButton"=> "Zurück",
159
+ "loadingText"=> "Wird geladen",
160
+ "modalClose"=> "Schließen",
161
+ "saveButton"=> "Speichern",
162
+ "duplicateButton"=> "Duplikat",
163
+ "dateTimeLocale"=> "en-us",
164
+ "toolTipDateTimeSeparator"=> "um",
165
+ "toolTipDateFormat"=> "DD-MM-YYYY",
166
+ "toolTipTimeFormat"=> "HH:MM:SS",
167
+ }
168
+ },
169
+ }
170
+
171
+ def index
172
+ @init = Learnosity::Sdk::Request::Init.new(
173
+ 'author',
174
+ @@security_packet,
175
+ @@consumer_secret,
176
+ @@author_request
177
+ )
178
+ end
179
+ end
@@ -0,0 +1,9 @@
1
+ require 'learnosity/sdk/request/init' # Learnosity helper.
2
+ require 'securerandom' # Library for generating UUIDs.
3
+
4
+ class IndexController < ApplicationController
5
+
6
+ def index
7
+
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ require 'learnosity/sdk/request/init' # Learnosity helper.
2
+ require 'securerandom' # Library for generating UUIDs.
3
+
4
+ class ItemsController < ApplicationController
5
+ @@security_packet = {
6
+ # XXX: This is a Learnosity Demos consumer; replace it with your own consumer key. Set values in application.rb.
7
+ 'consumer_key' => Rails.configuration.consumer_key,
8
+ 'domain' => 'localhost'
9
+ }
10
+
11
+ # XXX: The consumer secret should be in a properly secured credential store, and *NEVER* checked into version control
12
+ @@consumer_secret = Rails.configuration.consumer_secret
13
+
14
+ @@items_request = {
15
+ "user_id" => SecureRandom.uuid,
16
+ "activity_template_id" => "quickstart_examples_activity_template_001",
17
+ "session_id" => SecureRandom.uuid,
18
+ "activity_id" => "quickstart_examples_activity_001",
19
+ "rendering_type" => "assess",
20
+ "type" => "submit_practice",
21
+ "name" => "Items API Quickstart",
22
+ "state" => "initial"
23
+ }
24
+
25
+ def index
26
+ @init = Learnosity::Sdk::Request::Init.new(
27
+ 'items',
28
+ @@security_packet,
29
+ @@consumer_secret,
30
+ @@items_request
31
+ )
32
+ end
33
+ end