learnosity-sdk 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/PULL_REQUEST_TEMPLATE.md +13 -0
- data/.gitignore +1 -0
- data/.travis.yml +15 -5
- data/CONTRIBUTING.md +14 -0
- data/ChangeLog.md +18 -0
- data/LICENSE.md +141 -0
- data/Makefile +69 -0
- data/README.md +230 -186
- data/REFERENCE.md +249 -0
- data/Rakefile +9 -0
- data/docs/images/apache-license.svg +20 -0
- data/docs/images/downloads.svg +20 -0
- data/docs/images/image-assessment-retrieval.png +0 -0
- data/docs/images/image-concept-overview.png +0 -0
- data/docs/images/image-logo-graphic.png +0 -0
- data/docs/images/image-quickstart-examples-assessment.png +0 -0
- data/docs/images/image-quickstart-index.png +0 -0
- data/docs/images/image-signed-request-creation.png +0 -0
- data/docs/quickstart/css/style.css +113 -0
- data/{examples → docs/quickstart}/lrn-sdk-rails/Gemfile +2 -2
- data/docs/quickstart/lrn-sdk-rails/app/controllers/author_controller.rb +179 -0
- data/docs/quickstart/lrn-sdk-rails/app/controllers/authoraide_controller.rb +32 -0
- data/docs/quickstart/lrn-sdk-rails/app/controllers/index_controller.rb +9 -0
- data/docs/quickstart/lrn-sdk-rails/app/controllers/items_controller.rb +33 -0
- data/docs/quickstart/lrn-sdk-rails/app/controllers/questions_controller.rb +44 -0
- data/docs/quickstart/lrn-sdk-rails/app/controllers/reports_controller.rb +32 -0
- data/docs/quickstart/lrn-sdk-rails/app/views/author/index.html.erb +14 -0
- data/docs/quickstart/lrn-sdk-rails/app/views/authoraide/index.html.erb +6 -0
- data/docs/quickstart/lrn-sdk-rails/app/views/index/index.html.erb +38 -0
- data/{examples/lrn-sdk-rails/app/views/index → docs/quickstart/lrn-sdk-rails/app/views/items}/index.html.erb +2 -5
- data/docs/quickstart/lrn-sdk-rails/app/views/questions/index.html.erb +6 -0
- data/docs/quickstart/lrn-sdk-rails/app/views/reports/index.html.erb +14 -0
- data/docs/quickstart/lrn-sdk-rails/config/application.rb +24 -0
- data/docs/quickstart/lrn-sdk-rails/config/routes.rb +12 -0
- data/examples/simple/init_data.rb +6 -4
- data/examples/simple/init_items.rb +6 -4
- data/learnosity-sdk.gemspec +14 -14
- data/lib/learnosity/sdk/request/init.rb +13 -12
- data/lib/learnosity/sdk/version.rb +1 -1
- metadata +122 -101
- data/LICENSE +0 -201
- data/examples/lrn-sdk-rails/README.md +0 -24
- data/examples/lrn-sdk-rails/app/controllers/index_controller.rb +0 -106
- data/examples/lrn-sdk-rails/config/application.rb +0 -15
- data/examples/lrn-sdk-rails/config/routes.rb +0 -5
- /data/{examples → docs/quickstart}/lrn-sdk-rails/.gitignore +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/Rakefile +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/config/manifest.js +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/images/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/javascripts/application.js +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/javascripts/cable.js +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/javascripts/channels/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/javascripts/index.coffee +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/stylesheets/application.css +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/assets/stylesheets/index.scss +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/channels/application_cable/channel.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/channels/application_cable/connection.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/controllers/application_controller.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/controllers/concerns/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/helpers/application_helper.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/helpers/index_helper.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/jobs/application_job.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/mailers/application_mailer.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/models/application_record.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/models/concerns/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/views/layouts/application.html.erb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/views/layouts/mailer.html.erb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/app/views/layouts/mailer.text.erb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/bundle +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/rails +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/rake +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/setup +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/spring +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/bin/update +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/boot.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/cable.yml +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/database.yml +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/environment.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/environments/development.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/environments/production.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/environments/test.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/application_controller_renderer.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/assets.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/backtrace_silencers.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/cookies_serializer.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/filter_parameter_logging.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/inflections.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/mime_types.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/new_framework_defaults.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/session_store.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/initializers/wrap_parameters.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/locales/en.yml +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/puma.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/secrets.yml +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config/spring.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/config.ru +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/db/seeds.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/lib/assets/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/lib/tasks/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/log/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/public/404.html +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/public/422.html +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/public/500.html +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/public/apple-touch-icon-precomposed.png +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/public/apple-touch-icon.png +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/public/favicon.ico +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/public/robots.txt +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/test/controllers/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/test/controllers/index_controller_test.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/test/fixtures/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/test/fixtures/files/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/test/helpers/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/test/integration/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/test/mailers/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/test/models/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/test/test_helper.rb +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/tmp/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/vendor/assets/javascripts/.keep +0 -0
- /data/{examples → docs/quickstart}/lrn-sdk-rails/vendor/assets/stylesheets/.keep +0 -0
@@ -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
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'learnosity/sdk/request/init' # Learnosity helper.
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
class QuestionsController < 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
|
+
@@questions_request = {
|
17
|
+
"id"=> "f0001",
|
18
|
+
"name"=> "Intro Activity - French 101",
|
19
|
+
"questions"=>[
|
20
|
+
{
|
21
|
+
"response_id"=> "60005",
|
22
|
+
"type"=> "association",
|
23
|
+
"stimulus"=> "Match the cities to the parent nation.",
|
24
|
+
"stimulus_list"=>["London", "Dublin", "Paris", "Sydney"],
|
25
|
+
"possible_responses"=>["Australia", "France", "Ireland", "England"
|
26
|
+
],
|
27
|
+
"validation"=> {
|
28
|
+
"valid_responses"=> [
|
29
|
+
["England"],["Ireland"],["France"],["Australia"]
|
30
|
+
]
|
31
|
+
},
|
32
|
+
"instant_feedback" => true
|
33
|
+
}
|
34
|
+
],
|
35
|
+
}
|
36
|
+
def index
|
37
|
+
@init = Learnosity::Sdk::Request::Init.new(
|
38
|
+
'questions',
|
39
|
+
@@security_packet,
|
40
|
+
@@consumer_secret,
|
41
|
+
@@questions_request
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'learnosity/sdk/request/init' # Learnosity helper.
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
class ReportsController < 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
|
+
@@reports_request = {
|
17
|
+
"reports" => [{
|
18
|
+
"id"=> "session-detail",
|
19
|
+
"type"=> "session-detail-by-item",
|
20
|
+
"user_id"=> "906d564c-39d4-44ba-8ddc-2d44066e2ba9",
|
21
|
+
"session_id"=> "906d564c-39d4-44ba-8ddc-2d44066e2ba9"
|
22
|
+
}]
|
23
|
+
}
|
24
|
+
def index
|
25
|
+
@init = Learnosity::Sdk::Request::Init.new(
|
26
|
+
'reports',
|
27
|
+
@@security_packet,
|
28
|
+
@@consumer_secret,
|
29
|
+
@@reports_request
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h1>Standalone Author Example</h1>
|
2
|
+
<div id="learnosity-author"></div>
|
3
|
+
<script src="https://authorapi.learnosity.com?latest-lts"></script>
|
4
|
+
<script>
|
5
|
+
var callbacks = {
|
6
|
+
readyListener: function () {
|
7
|
+
console.log("Author API has successfully initialized.");
|
8
|
+
},
|
9
|
+
errorListener: function (err) {
|
10
|
+
console.log(err);
|
11
|
+
}
|
12
|
+
};
|
13
|
+
var authorApp = LearnosityAuthor.init( <%= raw @init.generate %>);
|
14
|
+
</script>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<style>
|
4
|
+
.tb { border-collapse: collapse; }
|
5
|
+
.tb th, .tb td { padding: 5px; border: solid 1px #777; text-align: center;}
|
6
|
+
.tb th { background-color: lightblue; }
|
7
|
+
</style>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<h1>Standalone Example APIs</title></h1>
|
11
|
+
<table class="tb" style="width:300px;">
|
12
|
+
<tr>
|
13
|
+
<th>APIs</th>
|
14
|
+
<th>Links</th>
|
15
|
+
</tr>
|
16
|
+
<tr>
|
17
|
+
<td>Author API</td>
|
18
|
+
<td><%=link_to("Here", author_index_path, target: '_blank') %> </td>
|
19
|
+
</tr>
|
20
|
+
<tr>
|
21
|
+
<td>Questions API</td>
|
22
|
+
<td><%=link_to("Here", questions_index_path, target: '_blank') %></td>
|
23
|
+
</tr>
|
24
|
+
<tr>
|
25
|
+
<td>Items API</td>
|
26
|
+
<td><%=link_to("Here", items_index_path, target: '_blank') %></td>
|
27
|
+
</tr>
|
28
|
+
<tr>
|
29
|
+
<td>Reports API</td>
|
30
|
+
<td><%=link_to("Here", reports_index_path, target: '_blank') %></td>
|
31
|
+
</tr>
|
32
|
+
<tr>
|
33
|
+
<td>Authoraide API</td>
|
34
|
+
<td><%=link_to("Here", authoraide_index_path, target: '_blank') %> </td>
|
35
|
+
</tr>
|
36
|
+
</table>
|
37
|
+
</body>
|
38
|
+
</html>
|
@@ -1,8 +1,6 @@
|
|
1
|
-
<h1>
|
2
|
-
|
1
|
+
<h1>Standalone Assessment Example</h1>
|
3
2
|
<div id="learnosity_assess"></div>
|
4
|
-
|
5
|
-
<script src="//items.learnosity.com"></script>
|
3
|
+
<script src="https://items.learnosity.com?latest-lts"></script>
|
6
4
|
<script>
|
7
5
|
var eventOptions = {
|
8
6
|
readyListener: init
|
@@ -12,7 +10,6 @@
|
|
12
10
|
function init () {
|
13
11
|
var assessApp = itemsApp.assessApp();
|
14
12
|
|
15
|
-
|
16
13
|
assessApp.on('item:load', function () {
|
17
14
|
console.log('Active item:', getActiveItem(this.getItems()));
|
18
15
|
});
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h1>Standalone Reports Example</h1>
|
2
|
+
<span class="learnosity-report" id="session-detail"></span>
|
3
|
+
<script src="https://reports.learnosity.com?latest-lts"></script>
|
4
|
+
<script>
|
5
|
+
var callbacks = {
|
6
|
+
readyListener: function () {
|
7
|
+
console.log("Learnosity Reports has successfully initialized.");
|
8
|
+
},
|
9
|
+
errorListener: function (err) {
|
10
|
+
console.log(err);
|
11
|
+
}
|
12
|
+
};
|
13
|
+
reportsApp = LearnosityReports.init( <%= raw @init.generate %>);
|
14
|
+
</script>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'boot'
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require(*Rails.groups)
|
8
|
+
|
9
|
+
module LrnSdkRails
|
10
|
+
class Application < Rails::Application
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
12
|
+
# Application configuration should go into files in config/initializers
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
14
|
+
|
15
|
+
# The consumerKey and consumerSecret are the public & private
|
16
|
+
# security keys required to access Learnosity APIs and
|
17
|
+
# data. Learnosity will provide keys for your own private account.
|
18
|
+
# Note: The consumer secret should be in a properly secured credential store,
|
19
|
+
# and *NEVER* checked into version control.
|
20
|
+
# The keys listed here grant access to Learnosity's public demos account.
|
21
|
+
config.consumer_key = 'yis0TYCu7U9V4o7M'
|
22
|
+
config.consumer_secret = '74c5fd430cf1242a527f6223aebd42d30464be22'
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
root 'index#index'
|
3
|
+
get 'index/index'
|
4
|
+
get 'questions/index', as: 'questions_index'
|
5
|
+
get 'author/index' , as: 'author_index'
|
6
|
+
get 'authoraide/index' , as: 'authoraide_index'
|
7
|
+
get 'reports/index', as: 'reports_index'
|
8
|
+
get 'items/index', as: 'items_index'
|
9
|
+
# get 'abc' , to: "index#index"
|
10
|
+
|
11
|
+
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
12
|
+
end
|
@@ -7,12 +7,14 @@ require 'learnosity/sdk/request/init'
|
|
7
7
|
itembank_uri = URI('https://data.learnosity.com/v1/itembank/items')
|
8
8
|
|
9
9
|
security_packet = {
|
10
|
-
|
11
|
-
|
10
|
+
# XXX: This is a Learnosity Demos consumer; replace it with your own consumer key. Set values in application.rb.
|
11
|
+
'consumer_key' => Rails.configuration.consumer_key,
|
12
12
|
'domain' => 'localhost'
|
13
13
|
}
|
14
|
-
# XXX: The consumer secret should be in a properly secured credential store, and *NEVER* checked
|
15
|
-
|
14
|
+
# XXX: The consumer secret should be in a properly secured credential store, and *NEVER* checked into version control.
|
15
|
+
# Set values in application.rb.
|
16
|
+
consumer_secret = Rails.configuration.consumer_secret
|
17
|
+
|
16
18
|
data_request = { 'limit' => 1 }
|
17
19
|
|
18
20
|
# Do 5 subsequent requests using the `next` pointer
|
@@ -2,12 +2,14 @@
|
|
2
2
|
require 'learnosity/sdk/request/init'
|
3
3
|
|
4
4
|
security_packet = {
|
5
|
-
|
6
|
-
|
5
|
+
# XXX: This is a Learnosity Demos consumer; replace it with your own consumer key. Set values in application.rb.
|
6
|
+
'consumer_key' => Rails.configuration.consumer_key,
|
7
7
|
'domain' => 'localhost'
|
8
8
|
}
|
9
|
-
# XXX: The consumer secret should be in a properly secured credential store, and *NEVER* checked
|
10
|
-
|
9
|
+
# XXX: The consumer secret should be in a properly secured credential store, and *NEVER* checked into version control.
|
10
|
+
# Set values in application.rb.
|
11
|
+
consumer_secret = Rails.configuration.consumer_secret
|
12
|
+
|
11
13
|
items_request = { 'limit' => 50 }
|
12
14
|
|
13
15
|
init = Learnosity::Sdk::Request::Init.new(
|
data/learnosity-sdk.gemspec
CHANGED
@@ -4,37 +4,37 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'learnosity/sdk/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'learnosity-sdk'
|
8
8
|
spec.version = Learnosity::Sdk::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = [ 'Olivier Mehani', 'learnosity' ]
|
10
|
+
spec.email = [ 'olivier.mehani@learnosity.com', 'licenses@learnosity.com' ]
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
12
|
+
spec.summary = 'SDK to interact with Learnosity APIs'
|
13
|
+
spec.homepage = 'https://github.com/Learnosity/learnosity-sdk-ruby/'
|
14
14
|
|
15
|
-
spec.license =
|
15
|
+
spec.license = 'Apache-2.0'
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
19
|
if spec.respond_to?(:metadata)
|
20
|
-
spec.metadata['allowed_push_host'] =
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
21
|
else
|
22
|
-
raise
|
23
|
-
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
'public gem pushes.'
|
24
24
|
end
|
25
25
|
|
26
26
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
27
|
f.match(%r{^(test|spec|features)/})
|
28
28
|
end
|
29
|
-
spec.bindir =
|
29
|
+
spec.bindir = 'exe'
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
-
spec.require_paths = [
|
31
|
+
spec.require_paths = ['lib']
|
32
32
|
|
33
33
|
spec.add_runtime_dependency 'sys-uname', '>= 1.0'
|
34
34
|
|
35
|
-
spec.add_development_dependency 'bundler', '
|
36
|
-
spec.add_development_dependency 'rake', '
|
37
|
-
spec.add_development_dependency 'rspec', '
|
35
|
+
spec.add_development_dependency 'bundler', '>= 2.2.10'
|
36
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
37
|
+
spec.add_development_dependency 'rspec', '>= 3.0'
|
38
38
|
end
|
39
39
|
|
40
40
|
# vim: sw=2
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'digest'
|
2
2
|
require 'json'
|
3
|
-
|
3
|
+
require 'openssl'
|
4
4
|
require 'learnosity/sdk/exceptions'
|
5
5
|
require 'learnosity/sdk/utils'
|
6
6
|
require 'learnosity/sdk/version'
|
@@ -19,11 +19,13 @@ module Learnosity
|
|
19
19
|
@@valid_security_keys = ['consumer_key', 'domain', 'timestamp', 'expires', 'user_id'];
|
20
20
|
|
21
21
|
# Service names that are valid for `$service`
|
22
|
-
@@valid_services = ['assess', 'author', 'data', 'events', 'items', 'questions', 'reports'];
|
22
|
+
@@valid_services = ['assess', 'author', 'data', 'events', 'items', 'questions', 'reports', 'authoraide'];
|
23
23
|
|
24
24
|
# Determines if telemetry is enabled
|
25
25
|
@@telemetry_enabled = true
|
26
26
|
|
27
|
+
@@signaturePrefix = '$02$'
|
28
|
+
|
27
29
|
def self.enable_telemetry
|
28
30
|
@@telemetry_enabled = true
|
29
31
|
end
|
@@ -60,8 +62,6 @@ module Learnosity
|
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
63
|
-
signature_array << @secret
|
64
|
-
|
65
65
|
if @sign_request_data and ! @request_string.nil?
|
66
66
|
signature_array << @request_string
|
67
67
|
end
|
@@ -70,14 +70,14 @@ module Learnosity
|
|
70
70
|
signature_array << @action
|
71
71
|
end
|
72
72
|
|
73
|
-
hash_signature(signature_array)
|
73
|
+
hash_signature(signature_array, @secret)
|
74
74
|
end
|
75
75
|
|
76
76
|
def generate(encode = true)
|
77
77
|
output = {}
|
78
78
|
|
79
79
|
case @service
|
80
|
-
when 'assess', 'author', 'data', 'items', 'reports'
|
80
|
+
when 'assess', 'author', 'data', 'items', 'reports', 'authoraide'
|
81
81
|
output['security'] = @security_packet
|
82
82
|
|
83
83
|
unless @request_packet.nil?
|
@@ -255,10 +255,10 @@ module Learnosity
|
|
255
255
|
when 'events'
|
256
256
|
hashed_users = {}
|
257
257
|
@request_packet['users'].each do |k, v|
|
258
|
-
hashed_users[k] = hash_value(k
|
258
|
+
hashed_users[k] = hash_value(k , @secret)
|
259
259
|
end
|
260
260
|
@request_packet['users'] = hashed_users
|
261
|
-
when 'author', 'data'
|
261
|
+
when 'author', 'data', 'authoraide'
|
262
262
|
@sign_request_data = true
|
263
263
|
else
|
264
264
|
raise Exception, "set_service_options() for #{@service} not implemented"
|
@@ -269,12 +269,13 @@ module Learnosity
|
|
269
269
|
JSON.generate @request_packet unless request_packet.nil?
|
270
270
|
end
|
271
271
|
|
272
|
-
def hash_value(value)
|
273
|
-
|
272
|
+
def hash_value(value, secret)
|
273
|
+
|
274
|
+
@@signaturePrefix + OpenSSL::HMAC.hexdigest("SHA256", secret, value)
|
274
275
|
end
|
275
276
|
|
276
|
-
def hash_signature(signature_array)
|
277
|
-
hash_value(signature_array.join('_'))
|
277
|
+
def hash_signature(signature_array, secret)
|
278
|
+
hash_value(signature_array.join('_'), secret)
|
278
279
|
end
|
279
280
|
end
|
280
281
|
|