rails-xapi 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +152 -0
- data/Rakefile +8 -0
- data/app/controllers/rails_xapi/application_controller.rb +7 -0
- data/app/helpers/rails_xapi/application_helper.rb +26 -0
- data/app/jobs/rails_xapi/application_job.rb +4 -0
- data/app/jobs/rails_xapi/create_statement_job.rb +11 -0
- data/app/mailers/rails_xapi/application_mailer.rb +6 -0
- data/app/models/concerns/serializable.rb +14 -0
- data/app/models/rails_xapi/account.rb +27 -0
- data/app/models/rails_xapi/activity_definition.rb +143 -0
- data/app/models/rails_xapi/actor.rb +227 -0
- data/app/models/rails_xapi/application_record.rb +5 -0
- data/app/models/rails_xapi/context.rb +163 -0
- data/app/models/rails_xapi/context_activity.rb +37 -0
- data/app/models/rails_xapi/errors/xapi_error.rb +4 -0
- data/app/models/rails_xapi/extension.rb +29 -0
- data/app/models/rails_xapi/group_member.rb +21 -0
- data/app/models/rails_xapi/interaction_activity.rb +103 -0
- data/app/models/rails_xapi/interaction_component.rb +34 -0
- data/app/models/rails_xapi/object.rb +150 -0
- data/app/models/rails_xapi/result.rb +174 -0
- data/app/models/rails_xapi/statement.rb +62 -0
- data/app/models/rails_xapi/validators/language_map_validator.rb +64 -0
- data/app/models/rails_xapi/verb.rb +260 -0
- data/app/services/application_service.rb +16 -0
- data/app/services/rails_xapi/query.rb +217 -0
- data/app/services/rails_xapi/statement_creator.rb +53 -0
- data/app/views/layouts/rails_xapi/application.html.erb +12 -0
- data/config/locales/rails_xapi.en.yml +43 -0
- data/config/locales/rails_xapi.fr.yml +233 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20240716144226_create_rails_xapi_actors.rb +16 -0
- data/db/migrate/20240716144227_create_rails_xapi_accounts.rb +15 -0
- data/db/migrate/20240716144228_create_rails_xapi_verbs.rb +14 -0
- data/db/migrate/20240716144229_create_rails_xapi_objects.rb +16 -0
- data/db/migrate/20240716144230_create_rails_xapi_activity_definitions.rb +17 -0
- data/db/migrate/20240716144231_create_rails_xapi_extensions.rb +13 -0
- data/db/migrate/20240716144232_create_rails_xapi_statements.rb +19 -0
- data/db/migrate/20240716144233_create_rails_xapi_results.rb +21 -0
- data/db/migrate/20240716144234_create_rails_xapi_contexts.rb +23 -0
- data/db/migrate/20240716144235_create_rails_xapi_context_activities.rb +16 -0
- data/db/migrate/20240716144236_create_rails_xapi_group_members.rb +16 -0
- data/db/migrate/20250522093846_create_rails_xapi_interaction_activities.rb +15 -0
- data/db/migrate/20250522122830_create_rails_xapi_interaction_component.rb +16 -0
- data/lib/rails-xapi/configuration.rb +13 -0
- data/lib/rails-xapi/engine.rb +28 -0
- data/lib/rails-xapi/version.rb +5 -0
- data/lib/rails-xapi.rb +16 -0
- data/lib/tasks/auto_annotate_models.rake +62 -0
- data/lib/tasks/rails-xapi_tasks.rake +4 -0
- metadata +122 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateRailsXapiResults < ActiveRecord::Migration[7.1]
|
2
|
+
def up
|
3
|
+
create_table :rails_xapi_results do |t|
|
4
|
+
t.decimal :score_scaled, precision: 3, scale: 2
|
5
|
+
t.integer :score_raw
|
6
|
+
t.integer :score_min
|
7
|
+
t.integer :score_max
|
8
|
+
t.boolean :success, default: false
|
9
|
+
t.boolean :completion, default: false
|
10
|
+
t.text :response
|
11
|
+
t.string :duration
|
12
|
+
t.bigint :statement_id, null: false
|
13
|
+
end
|
14
|
+
|
15
|
+
add_index :rails_xapi_results, :statement_id
|
16
|
+
end
|
17
|
+
|
18
|
+
def down
|
19
|
+
drop_table :rails_xapi_results
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateRailsXapiContexts < ActiveRecord::Migration[7.1]
|
2
|
+
def up
|
3
|
+
create_table :rails_xapi_contexts do |t|
|
4
|
+
t.string :registration, null: true
|
5
|
+
t.bigint :instructor_id, null: true
|
6
|
+
t.bigint :team_id, null: true
|
7
|
+
t.string :revision, null: true
|
8
|
+
t.string :platform, null: true
|
9
|
+
t.string :language, null: true
|
10
|
+
t.bigint :statement_ref, null: true
|
11
|
+
t.bigint :statement_id, null: false
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :rails_xapi_contexts, :instructor_id
|
15
|
+
add_index :rails_xapi_contexts, :team_id
|
16
|
+
add_index :rails_xapi_contexts, :statement_ref
|
17
|
+
add_index :rails_xapi_contexts, :statement_id
|
18
|
+
end
|
19
|
+
|
20
|
+
def down
|
21
|
+
drop_table :rails_xapi_contexts
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateRailsXapiContextActivities < ActiveRecord::Migration[7.1]
|
2
|
+
def up
|
3
|
+
create_table :rails_xapi_context_activities do |t|
|
4
|
+
t.string :activity_type, null: false
|
5
|
+
t.bigint :context_id, null: false
|
6
|
+
t.string :object_id, null: false
|
7
|
+
end
|
8
|
+
|
9
|
+
add_index :rails_xapi_context_activities, :context_id
|
10
|
+
add_index :rails_xapi_context_activities, :object_id
|
11
|
+
end
|
12
|
+
|
13
|
+
def down
|
14
|
+
drop_table :rails_xapi_context_activities
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateRailsXapiGroupMembers < ActiveRecord::Migration[7.1]
|
2
|
+
def up
|
3
|
+
create_table :rails_xapi_group_members do |t|
|
4
|
+
t.bigint :group_id, null: false
|
5
|
+
t.bigint :actor_id, null: false
|
6
|
+
t.datetime :created_at, null: false
|
7
|
+
end
|
8
|
+
|
9
|
+
add_index :rails_xapi_group_members, :group_id
|
10
|
+
add_index :rails_xapi_group_members, :actor_id
|
11
|
+
end
|
12
|
+
|
13
|
+
def down
|
14
|
+
drop_table :rails_xapi_group_members
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateRailsXapiInteractionActivities < ActiveRecord::Migration[7.2]
|
2
|
+
def change
|
3
|
+
create_table :rails_xapi_interaction_activities do |t|
|
4
|
+
t.string :interaction_type, null: false
|
5
|
+
t.text :correct_responses_pattern, null: true
|
6
|
+
t.bigint :activity_definition_id, null: false
|
7
|
+
end
|
8
|
+
|
9
|
+
add_index :rails_xapi_interaction_activities, :activity_definition_id
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
drop_table :rails_xapi_interaction_activities
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateRailsXapiInteractionComponent < ActiveRecord::Migration[7.2]
|
2
|
+
def change
|
3
|
+
create_table :rails_xapi_interaction_components do |t|
|
4
|
+
t.string :component_type, null: false
|
5
|
+
t.string :component_id, null: false
|
6
|
+
t.text :description, null: true
|
7
|
+
t.bigint :interaction_activity_id, null: false
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :rails_xapi_interaction_components, :interaction_activity_id
|
11
|
+
end
|
12
|
+
|
13
|
+
def down
|
14
|
+
drop_table :rails_xapi_interaction_components
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsXapi
|
4
|
+
class Configuration
|
5
|
+
# mattr_accessor :output_xapi_logs, :colored_xapi_logs
|
6
|
+
attr_accessor :output_xapi_logs, :colored_xapi_logs
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@output_xapi_logs ||= true
|
10
|
+
@colored_xapi_logs ||= true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsXapi
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace RailsXapi
|
6
|
+
|
7
|
+
initializer "local_helper.action_controller" do
|
8
|
+
ActiveSupport.on_load :action_controller do
|
9
|
+
helper RailsXapi::ApplicationHelper
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
initializer :load_factories, after: "factory_bot.set_factory_paths" do
|
14
|
+
if defined?(FactoryBot) && !Rails.env.production?
|
15
|
+
FactoryBot.definition_file_paths.prepend(
|
16
|
+
File.join(RailsXapi::Engine.root, "spec", "factories")
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
config.before_configuration do
|
22
|
+
RailsXapi.configuration ||= RailsXapi::Configuration.new
|
23
|
+
end
|
24
|
+
|
25
|
+
config.i18n.default_locale = :en
|
26
|
+
config.i18n.fallbacks = [:en]
|
27
|
+
end
|
28
|
+
end
|
data/lib/rails-xapi.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails-xapi/version"
|
4
|
+
require "rails-xapi/engine"
|
5
|
+
require "rails-xapi/configuration"
|
6
|
+
|
7
|
+
module RailsXapi
|
8
|
+
class << self
|
9
|
+
attr_accessor :configuration
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.configure
|
13
|
+
self.configuration ||= Configuration.new
|
14
|
+
yield(configuration)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# NOTE: only doing this in development as some production environments (Heroku)
|
2
|
+
# NOTE: are sensitive to local FS writes, and besides -- it"s just not proper
|
3
|
+
# NOTE: to have a dev-mode tool do its thing in production.
|
4
|
+
if defined?(Rails) && Rails.env.development?
|
5
|
+
if Gem::Specification.find_all_by_name("annotate").any?
|
6
|
+
require "annotate"
|
7
|
+
|
8
|
+
task :set_annotation_options do
|
9
|
+
# You can override any of these by setting an environment variable of the
|
10
|
+
# same name.
|
11
|
+
Annotate.set_defaults(
|
12
|
+
"active_admin" => "false",
|
13
|
+
"additional_file_patterns" => [],
|
14
|
+
"routes" => "false",
|
15
|
+
"models" => "true",
|
16
|
+
"position_in_routes" => "after",
|
17
|
+
"position_in_class" => "after",
|
18
|
+
"position_in_test" => "after",
|
19
|
+
"position_in_fixture" => "before",
|
20
|
+
"position_in_factory" => "before",
|
21
|
+
"position_in_serializer" => "after",
|
22
|
+
"show_foreign_keys" => "true",
|
23
|
+
"show_complete_foreign_keys" => "false",
|
24
|
+
"show_indexes" => "true",
|
25
|
+
"simple_indexes" => "false",
|
26
|
+
"model_dir" => "app/models",
|
27
|
+
"root_dir" => "",
|
28
|
+
"include_version" => "false",
|
29
|
+
"require" => "",
|
30
|
+
"exclude_tests" => "false",
|
31
|
+
"exclude_fixtures" => "false",
|
32
|
+
"exclude_factories" => "false",
|
33
|
+
"exclude_serializers" => "false",
|
34
|
+
"exclude_scaffolds" => "true",
|
35
|
+
"exclude_controllers" => "true",
|
36
|
+
"exclude_helpers" => "true",
|
37
|
+
"exclude_sti_subclasses" => "false",
|
38
|
+
"ignore_model_sub_dir" => "false",
|
39
|
+
"ignore_columns" => nil,
|
40
|
+
"ignore_routes" => nil,
|
41
|
+
"ignore_unknown_models" => "false",
|
42
|
+
"hide_limit_column_types" => "integer,bigint,boolean",
|
43
|
+
"hide_default_column_types" => "json,jsonb,hstore",
|
44
|
+
"skip_on_db_migrate" => "false",
|
45
|
+
"format_bare" => "true",
|
46
|
+
"format_rdoc" => "false",
|
47
|
+
"format_yard" => "false",
|
48
|
+
"format_markdown" => "false",
|
49
|
+
"sort" => "false",
|
50
|
+
"force" => "false",
|
51
|
+
"frozen" => "false",
|
52
|
+
"classified_sort" => "true",
|
53
|
+
"trace" => "false",
|
54
|
+
"wrapper_open" => nil,
|
55
|
+
"wrapper_close" => nil,
|
56
|
+
"with_comment" => "true"
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
Annotate.load_tasks
|
61
|
+
end
|
62
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-xapi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hipjea
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: rails
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 7.1.2
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 7.1.2
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec-rails
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
description: Rails engine for generating xAPI statements.
|
41
|
+
email:
|
42
|
+
- pierre.duverneix@gmail.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- MIT-LICENSE
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- app/controllers/rails_xapi/application_controller.rb
|
51
|
+
- app/helpers/rails_xapi/application_helper.rb
|
52
|
+
- app/jobs/rails_xapi/application_job.rb
|
53
|
+
- app/jobs/rails_xapi/create_statement_job.rb
|
54
|
+
- app/mailers/rails_xapi/application_mailer.rb
|
55
|
+
- app/models/concerns/serializable.rb
|
56
|
+
- app/models/rails_xapi/account.rb
|
57
|
+
- app/models/rails_xapi/activity_definition.rb
|
58
|
+
- app/models/rails_xapi/actor.rb
|
59
|
+
- app/models/rails_xapi/application_record.rb
|
60
|
+
- app/models/rails_xapi/context.rb
|
61
|
+
- app/models/rails_xapi/context_activity.rb
|
62
|
+
- app/models/rails_xapi/errors/xapi_error.rb
|
63
|
+
- app/models/rails_xapi/extension.rb
|
64
|
+
- app/models/rails_xapi/group_member.rb
|
65
|
+
- app/models/rails_xapi/interaction_activity.rb
|
66
|
+
- app/models/rails_xapi/interaction_component.rb
|
67
|
+
- app/models/rails_xapi/object.rb
|
68
|
+
- app/models/rails_xapi/result.rb
|
69
|
+
- app/models/rails_xapi/statement.rb
|
70
|
+
- app/models/rails_xapi/validators/language_map_validator.rb
|
71
|
+
- app/models/rails_xapi/verb.rb
|
72
|
+
- app/services/application_service.rb
|
73
|
+
- app/services/rails_xapi/query.rb
|
74
|
+
- app/services/rails_xapi/statement_creator.rb
|
75
|
+
- app/views/layouts/rails_xapi/application.html.erb
|
76
|
+
- config/locales/rails_xapi.en.yml
|
77
|
+
- config/locales/rails_xapi.fr.yml
|
78
|
+
- config/routes.rb
|
79
|
+
- db/migrate/20240716144226_create_rails_xapi_actors.rb
|
80
|
+
- db/migrate/20240716144227_create_rails_xapi_accounts.rb
|
81
|
+
- db/migrate/20240716144228_create_rails_xapi_verbs.rb
|
82
|
+
- db/migrate/20240716144229_create_rails_xapi_objects.rb
|
83
|
+
- db/migrate/20240716144230_create_rails_xapi_activity_definitions.rb
|
84
|
+
- db/migrate/20240716144231_create_rails_xapi_extensions.rb
|
85
|
+
- db/migrate/20240716144232_create_rails_xapi_statements.rb
|
86
|
+
- db/migrate/20240716144233_create_rails_xapi_results.rb
|
87
|
+
- db/migrate/20240716144234_create_rails_xapi_contexts.rb
|
88
|
+
- db/migrate/20240716144235_create_rails_xapi_context_activities.rb
|
89
|
+
- db/migrate/20240716144236_create_rails_xapi_group_members.rb
|
90
|
+
- db/migrate/20250522093846_create_rails_xapi_interaction_activities.rb
|
91
|
+
- db/migrate/20250522122830_create_rails_xapi_interaction_component.rb
|
92
|
+
- lib/rails-xapi.rb
|
93
|
+
- lib/rails-xapi/configuration.rb
|
94
|
+
- lib/rails-xapi/engine.rb
|
95
|
+
- lib/rails-xapi/version.rb
|
96
|
+
- lib/tasks/auto_annotate_models.rake
|
97
|
+
- lib/tasks/rails-xapi_tasks.rake
|
98
|
+
homepage: https://github.com/fondation-unit/rails-xapi
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata:
|
102
|
+
homepage_uri: https://github.com/fondation-unit/rails-xapi
|
103
|
+
source_code_uri: https://github.com/fondation-unit/rails-xapi
|
104
|
+
changelog_uri: https://github.com/fondation-unit/rails-xapi/CHANGELOG.md
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubygems_version: 3.6.7
|
120
|
+
specification_version: 4
|
121
|
+
summary: Rails engine for generating xAPI statements.
|
122
|
+
test_files: []
|