learnosity-sdk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +201 -0
  7. data/README.md +269 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/examples/lrn-sdk-rails/.gitignore +21 -0
  12. data/examples/lrn-sdk-rails/Gemfile +57 -0
  13. data/examples/lrn-sdk-rails/README.md +24 -0
  14. data/examples/lrn-sdk-rails/Rakefile +6 -0
  15. data/examples/lrn-sdk-rails/app/assets/config/manifest.js +3 -0
  16. data/examples/lrn-sdk-rails/app/assets/images/.keep +0 -0
  17. data/examples/lrn-sdk-rails/app/assets/javascripts/application.js +16 -0
  18. data/examples/lrn-sdk-rails/app/assets/javascripts/cable.js +13 -0
  19. data/examples/lrn-sdk-rails/app/assets/javascripts/channels/.keep +0 -0
  20. data/examples/lrn-sdk-rails/app/assets/javascripts/index.coffee +3 -0
  21. data/examples/lrn-sdk-rails/app/assets/stylesheets/application.css +15 -0
  22. data/examples/lrn-sdk-rails/app/assets/stylesheets/index.scss +3 -0
  23. data/examples/lrn-sdk-rails/app/channels/application_cable/channel.rb +4 -0
  24. data/examples/lrn-sdk-rails/app/channels/application_cable/connection.rb +4 -0
  25. data/examples/lrn-sdk-rails/app/controllers/application_controller.rb +3 -0
  26. data/examples/lrn-sdk-rails/app/controllers/concerns/.keep +0 -0
  27. data/examples/lrn-sdk-rails/app/controllers/index_controller.rb +105 -0
  28. data/examples/lrn-sdk-rails/app/helpers/application_helper.rb +2 -0
  29. data/examples/lrn-sdk-rails/app/helpers/index_helper.rb +2 -0
  30. data/examples/lrn-sdk-rails/app/jobs/application_job.rb +2 -0
  31. data/examples/lrn-sdk-rails/app/mailers/application_mailer.rb +4 -0
  32. data/examples/lrn-sdk-rails/app/models/application_record.rb +3 -0
  33. data/examples/lrn-sdk-rails/app/models/concerns/.keep +0 -0
  34. data/examples/lrn-sdk-rails/app/views/index/index.html.erb +24 -0
  35. data/examples/lrn-sdk-rails/app/views/layouts/application.html.erb +14 -0
  36. data/examples/lrn-sdk-rails/app/views/layouts/mailer.html.erb +13 -0
  37. data/examples/lrn-sdk-rails/app/views/layouts/mailer.text.erb +1 -0
  38. data/examples/lrn-sdk-rails/bin/bundle +3 -0
  39. data/examples/lrn-sdk-rails/bin/rails +9 -0
  40. data/examples/lrn-sdk-rails/bin/rake +9 -0
  41. data/examples/lrn-sdk-rails/bin/setup +34 -0
  42. data/examples/lrn-sdk-rails/bin/spring +17 -0
  43. data/examples/lrn-sdk-rails/bin/update +29 -0
  44. data/examples/lrn-sdk-rails/config.ru +5 -0
  45. data/examples/lrn-sdk-rails/config/application.rb +15 -0
  46. data/examples/lrn-sdk-rails/config/boot.rb +3 -0
  47. data/examples/lrn-sdk-rails/config/cable.yml +9 -0
  48. data/examples/lrn-sdk-rails/config/database.yml +25 -0
  49. data/examples/lrn-sdk-rails/config/environment.rb +5 -0
  50. data/examples/lrn-sdk-rails/config/environments/development.rb +54 -0
  51. data/examples/lrn-sdk-rails/config/environments/production.rb +86 -0
  52. data/examples/lrn-sdk-rails/config/environments/test.rb +42 -0
  53. data/examples/lrn-sdk-rails/config/initializers/application_controller_renderer.rb +6 -0
  54. data/examples/lrn-sdk-rails/config/initializers/assets.rb +11 -0
  55. data/examples/lrn-sdk-rails/config/initializers/backtrace_silencers.rb +7 -0
  56. data/examples/lrn-sdk-rails/config/initializers/cookies_serializer.rb +5 -0
  57. data/examples/lrn-sdk-rails/config/initializers/filter_parameter_logging.rb +4 -0
  58. data/examples/lrn-sdk-rails/config/initializers/inflections.rb +16 -0
  59. data/examples/lrn-sdk-rails/config/initializers/mime_types.rb +4 -0
  60. data/examples/lrn-sdk-rails/config/initializers/new_framework_defaults.rb +24 -0
  61. data/examples/lrn-sdk-rails/config/initializers/session_store.rb +3 -0
  62. data/examples/lrn-sdk-rails/config/initializers/wrap_parameters.rb +14 -0
  63. data/examples/lrn-sdk-rails/config/locales/en.yml +23 -0
  64. data/examples/lrn-sdk-rails/config/puma.rb +47 -0
  65. data/examples/lrn-sdk-rails/config/routes.rb +5 -0
  66. data/examples/lrn-sdk-rails/config/secrets.yml +22 -0
  67. data/examples/lrn-sdk-rails/config/spring.rb +6 -0
  68. data/examples/lrn-sdk-rails/db/seeds.rb +7 -0
  69. data/examples/lrn-sdk-rails/lib/assets/.keep +0 -0
  70. data/examples/lrn-sdk-rails/lib/tasks/.keep +0 -0
  71. data/examples/lrn-sdk-rails/log/.keep +0 -0
  72. data/examples/lrn-sdk-rails/public/404.html +67 -0
  73. data/examples/lrn-sdk-rails/public/422.html +67 -0
  74. data/examples/lrn-sdk-rails/public/500.html +66 -0
  75. data/examples/lrn-sdk-rails/public/apple-touch-icon-precomposed.png +0 -0
  76. data/examples/lrn-sdk-rails/public/apple-touch-icon.png +0 -0
  77. data/examples/lrn-sdk-rails/public/favicon.ico +0 -0
  78. data/examples/lrn-sdk-rails/public/robots.txt +5 -0
  79. data/examples/lrn-sdk-rails/test/controllers/.keep +0 -0
  80. data/examples/lrn-sdk-rails/test/controllers/index_controller_test.rb +9 -0
  81. data/examples/lrn-sdk-rails/test/fixtures/.keep +0 -0
  82. data/examples/lrn-sdk-rails/test/fixtures/files/.keep +0 -0
  83. data/examples/lrn-sdk-rails/test/helpers/.keep +0 -0
  84. data/examples/lrn-sdk-rails/test/integration/.keep +0 -0
  85. data/examples/lrn-sdk-rails/test/mailers/.keep +0 -0
  86. data/examples/lrn-sdk-rails/test/models/.keep +0 -0
  87. data/examples/lrn-sdk-rails/test/test_helper.rb +10 -0
  88. data/examples/lrn-sdk-rails/tmp/.keep +0 -0
  89. data/examples/lrn-sdk-rails/vendor/assets/javascripts/.keep +0 -0
  90. data/examples/lrn-sdk-rails/vendor/assets/stylesheets/.keep +0 -0
  91. data/examples/simple/init_data.rb +34 -0
  92. data/examples/simple/init_items.rb +19 -0
  93. data/learnosity-sdk.gemspec +38 -0
  94. data/lib/learnosity/sdk.rb +9 -0
  95. data/lib/learnosity/sdk/exceptions.rb +10 -0
  96. data/lib/learnosity/sdk/request.rb +9 -0
  97. data/lib/learnosity/sdk/request/init.rb +232 -0
  98. data/lib/learnosity/sdk/utils.rb +4 -0
  99. data/lib/learnosity/sdk/version.rb +5 -0
  100. metadata +187 -0
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "learnosity/sdk"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,21 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*
16
+ /tmp/*
17
+ !/log/.keep
18
+ !/tmp/.keep
19
+
20
+ # Ignore Byebug command history file.
21
+ .byebug_history
@@ -0,0 +1,57 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+
9
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
10
+ gem 'rails', '~> 5.0.2'
11
+ # Use sqlite3 as the database for Active Record
12
+ gem 'sqlite3'
13
+ # Use Puma as the app server
14
+ gem 'puma', '~> 3.0'
15
+ # Use SCSS for stylesheets
16
+ gem 'sass-rails', '~> 5.0'
17
+ # Use Uglifier as compressor for JavaScript assets
18
+ gem 'uglifier', '>= 1.3.0'
19
+ # Use CoffeeScript for .coffee assets and views
20
+ gem 'coffee-rails', '~> 4.2'
21
+ # See https://github.com/rails/execjs#readme for more supported runtimes
22
+ # gem 'therubyracer', platforms: :ruby
23
+
24
+ # Use jquery as the JavaScript library
25
+ gem 'jquery-rails'
26
+ # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
27
+ gem 'turbolinks', '~> 5'
28
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
29
+ gem 'jbuilder', '~> 2.5'
30
+ # Use Redis adapter to run Action Cable in production
31
+ # gem 'redis', '~> 3.0'
32
+ # Use ActiveModel has_secure_password
33
+ # gem 'bcrypt', '~> 3.1.7'
34
+
35
+ # Use Capistrano for deployment
36
+ # gem 'capistrano-rails', group: :development
37
+
38
+ group :development, :test do
39
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
40
+ gem 'byebug', platform: :mri
41
+ end
42
+
43
+ group :development do
44
+ # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
45
+ gem 'web-console', '>= 3.3.0'
46
+ gem 'listen', '~> 3.0.5'
47
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
48
+ gem 'spring'
49
+ gem 'spring-watcher-listen', '~> 2.0.0'
50
+ end
51
+
52
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
53
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
54
+
55
+ # The :path allows us to use the local code, you'll likely not need that in a
56
+ # normal project
57
+ gem 'learnosity-sdk', :path => '../..'
@@ -0,0 +1,24 @@
1
+ # README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the rails generate channel command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the Index controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end
@@ -0,0 +1,105 @@
1
+ require 'learnosity/sdk/request/init'
2
+ require 'securerandom'
3
+
4
+ class IndexController < ApplicationController
5
+ @@security_packet = {
6
+ 'consumer_key' => 'yis0TYCu7U9V4o7M',
7
+ 'domain' => 'localhost'
8
+ }
9
+ # XXX: The consumer secret should be in a properly secured credential store, and *NEVER* checked in in revision control
10
+ @@consumer_secret = '74c5fd430cf1242a527f6223aebd42d30464be22'
11
+ @@items_request = {
12
+ "activity_id" => "itemsassessdemo",
13
+ "assess_inline" => true,
14
+ "config" => {
15
+ "administration" => {
16
+ "options" => {"show_exit" => true, "show_extend" => true, "show_save" => true},
17
+ "pwd" => "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"
18
+ },
19
+ "configuration" => {
20
+ "fontsize" => "normal",
21
+ "idle_timeout" => {"countdown_time" => 60, "interval" => 300},
22
+ "lazyload" => false,
23
+ "ondiscard_redirect_url" => "itemsapi_assess.php",
24
+ "onsave_redirect_url" => "itemsapi_assess.php",
25
+ "onsubmit_redirect_url" => "itemsapi_assess.php",
26
+ "stylesheet" => "",
27
+ "submit_criteria" => {"type" => "attempted"}
28
+ },
29
+ "ignore_question_attributes" => [""],
30
+ "labelBundle" => {
31
+ "answerMasking" => "Answer Eliminator",
32
+ "colorScheme" => "Colour Scheme",
33
+ "item" => "Question",
34
+ "paletteInstructions" => "Instructions...colour"
35
+ },
36
+ "navigation" => {
37
+ "auto_save" => {"saveIntervalDuration" => 500, "ui" => false},
38
+ "item_count" => {"question_count_option" => false},
39
+ "scroll_to_test" => false,
40
+ "scroll_to_top" => false,
41
+ "scrolling_indicator" => false,
42
+ "show_accessibility" => {
43
+ "show_colourscheme" => true,
44
+ "show_fontsize" => true,
45
+ "show_zoom" => true
46
+ },
47
+ "show_acknowledgements" => true,
48
+ "show_answermasking" => true,
49
+ "show_calculator" => false,
50
+ "show_configuration" => false,
51
+ "show_fullscreencontrol" => true,
52
+ "show_intro" => true,
53
+ "show_itemcount" => true,
54
+ "show_next" => true,
55
+ "show_outro" => true,
56
+ "show_prev" => true,
57
+ "show_progress" => true,
58
+ "show_save" => false,
59
+ "show_submit" => true,
60
+ "show_title" => true,
61
+ "skip_submit_confirmation" => false,
62
+ "toc" => true,
63
+ "transition" => "fade",
64
+ "transition_speed" => 400,
65
+ "warning_on_change" => false
66
+ },
67
+ "subtitle" => "Walter White",
68
+ "time" => {
69
+ "limit_type" => "soft",
70
+ "max_time" => 1500,
71
+ "show_pause" => true,
72
+ "show_time" => true,
73
+ "warning_time" => 120
74
+ },
75
+ "title" => "Demo activity - showcasing question types and assess options",
76
+ "ui_style" => "main"
77
+ },
78
+ "items" => [
79
+ "Demo3",
80
+ "Demo4",
81
+ "accessibility_demo_6",
82
+ "Demo6",
83
+ "Demo7",
84
+ "Demo8",
85
+ "Demo9",
86
+ "Demo10",
87
+ "audioplayer-demo-1"
88
+ ],
89
+ "name" => "Items API demo - assess activity",
90
+ "rendering_type" => "assess",
91
+ "session_id" => SecureRandom.uuid,
92
+ "state" => "initial",
93
+ "type" => "submit_practice",
94
+ "user_id" => "demo_student"
95
+ }
96
+
97
+ def index
98
+ @init = Learnosity::Sdk::Request::Init.new(
99
+ 'items',
100
+ @@security_packet,
101
+ @@consumer_secret,
102
+ @@items_request
103
+ )
104
+ end
105
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module IndexHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,24 @@
1
+ <h1>Index#index</h1>
2
+
3
+ <div id="learnosity_assess"></div>
4
+
5
+ <script src="//items.learnosity.com"></script>
6
+ <script>
7
+ var eventOptions = {
8
+ readyListener: init
9
+ },
10
+ itemsApp = LearnosityItems.init(<%= raw @init.generate %>);
11
+
12
+ function init () {
13
+ var assessApp = itemsApp.assessApp();
14
+
15
+
16
+ assessApp.on('item:load', function () {
17
+ console.log('Active item:', getActiveItem(this.getItems()));
18
+ });
19
+
20
+ assessApp.on('test:submit:success', function () {
21
+ toggleModalClass();
22
+ });
23
+ }
24
+ </script>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>LrnSdkRails</title>
5
+ <%= csrf_meta_tags %>
6
+
7
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9
+ </head>
10
+
11
+ <body>
12
+ <%= yield %>
13
+ </body>
14
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ APP_PATH = File.expand_path('../config/application', __dir__)
8
+ require_relative '../config/boot'
9
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ require_relative '../config/boot'
8
+ require 'rake'
9
+ Rake.application.run