scorm_engine 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f9f09bee2cb90376b11857112525d4f8b684fbf413efe376e4a1e62f13165bf
4
- data.tar.gz: 4ddb77b0f64f4f9da50851e79a106acade6e4f6e20a208702bcc0c241f54202f
3
+ metadata.gz: f03bd17c2d3fdd0d6c6327553e3ed8657a7f6c796fa4535944cc003b5cc37335
4
+ data.tar.gz: c136aefda64d406464d3f88cf8e6e9f4954df53c93fe351b1c03daff64ce3187
5
5
  SHA512:
6
- metadata.gz: d9f07c8575519f7b092ef0c2e035128276a76c6383167446a63559e5d311bc24bb2b2aa9867e7c00b110ec7508194c82aa3ec99c713ac59d1533186118b6db0f
7
- data.tar.gz: '040280d374b94fe5984c3812ab50e0cf683b925e2a0e146071b0356acdcfa5628b2e10e15f5470b60ad1f05efafa5c7ff00a2cc8fa961acf8ae8c5c9ef8a79c9'
6
+ metadata.gz: 98bdc0ec1d7dd57cdcb8cf64fcf2a64a5eb7a04b5da0763c4ab7c6ac7285b58119c93f8e5450f42bee9ad8c869a9824331ef4d9655b02a25880a2b2dfaa2aaf6
7
+ data.tar.gz: 7aefdb729d6c36ba334da198026f51f9bfbc78de9c8f65317c314e1e23f530961f4c4315b9654b582120603238990a2c06d7f8b535e05e63be845f9046c8efb7
@@ -13,10 +13,29 @@ module ScormEngine
13
13
  # TODO: Not sure we want this to be settable. Will depend on how we go
14
14
  # about creating/updating records. For now it makes it easier to create
15
15
  # instances from API options hash.
16
- attr_accessor :id, :instance, :updated, :registration_completion, :registration_success,
16
+ attr_accessor :id, :instance, :updated,
17
17
  :total_seconds_tracked, :score, :course, :learner, :activity_details,
18
- :first_access_date, :last_access_date, :completed_date, :created_date,
19
- :registration_completion_amount
18
+ :first_access_date, :last_access_date, :completed_date, :created_date
19
+
20
+ # @attr
21
+ # Has this registration been completed?
22
+ # @return [String] (UNKNOWN COMPLETED INCOMPLETE)
23
+ attr_accessor :registration_completion
24
+
25
+ # @attr
26
+ # Has this registration been passed?
27
+ # @return [String] (Unknown Passed Failed)
28
+ attr_accessor :registration_success
29
+
30
+ # @attr
31
+ # A decimal value between 0 and 1 representing the percentage of this
32
+ # course that the learner has completed so far, if known. Note: for
33
+ # learning standards other than SCORM 2004 4th Edition, this value is
34
+ # based on the percentage of activities completed/passed. This means that
35
+ # single-activity courses in those standards will always return either 0
36
+ # or 1.
37
+ # @return [Float] (Unknown Passed Failed)
38
+ attr_accessor :registration_completion_amount
20
39
 
21
40
  def self.new_from_api(options = {})
22
41
  this = new
@@ -44,6 +63,50 @@ module ScormEngine
44
63
  this
45
64
  end
46
65
 
66
+ #
67
+ # Has this registration been completed?
68
+ #
69
+ # @return [Boolean]
70
+ # Returns true, false or nil if completion status is unknown.
71
+ #
72
+ def complete?
73
+ return nil if registration_completion == "UNKNOWN"
74
+ registration_completion == "COMPLETED"
75
+ end
76
+
77
+ #
78
+ # Is this registration incomplete?
79
+ #
80
+ # @return [Boolean]
81
+ # Returns true, false or nil if completion status is unknown.
82
+ #
83
+ def incomplete?
84
+ return nil if registration_completion == "UNKNOWN"
85
+ registration_completion == "INCOMPLETE"
86
+ end
87
+
88
+ #
89
+ # Has this registration been passed?
90
+ #
91
+ # @return [Boolean]
92
+ # Returns true, false or nil if success status is unknown.
93
+ #
94
+ def passed?
95
+ return nil if registration_success == "Unknown"
96
+ registration_success == "Passed"
97
+ end
98
+
99
+ #
100
+ # Has this registration failed?
101
+ #
102
+ # @return [Boolean]
103
+ # Returns true, false or nil if success status is unknown.
104
+ #
105
+ def failed?
106
+ return nil if registration_success == "Unknown"
107
+ registration_success == "Failed"
108
+ end
109
+
47
110
  #
48
111
  # Extract and normalize the scaled passing score from the API options.
49
112
  #
@@ -6,11 +6,29 @@ module ScormEngine
6
6
  # instances from API options hash.
7
7
  attr_accessor :id, :children, :runtime_interactions
8
8
 
9
+ # @attr
10
+ # Represents whether the current attempt on the activity has been completed.
11
+ # @return [String] (UNKNOWN COMPLETED INCOMPLETE)
12
+ attr_accessor :activity_completion
13
+
14
+ # @attr
15
+ # Represents whether the previous attempt on the activity has been completed.
16
+ # @return [String] (Unknown Completed Incomplete)
17
+ attr_accessor :previous_attempt_completion
18
+
19
+ # @attr
20
+ # Pass/fail status of primary objective for this activity.
21
+ # @return [String] (UNKNOWN PASSED FAILED)
22
+ attr_accessor :activity_success
23
+
9
24
  def self.new_from_api(options = {})
10
25
  this = new
11
26
 
12
27
  this.options = options.dup
13
28
  this.id = options["id"]
29
+ this.activity_completion = options["activityCompletion"]
30
+ this.previous_attempt_completion = options["previousAttemptCompletion"]
31
+ this.activity_success = options["activitySuccess"]
14
32
 
15
33
  this.runtime_interactions = get_runtime_interactions_from_api(options)
16
34
 
@@ -19,6 +37,11 @@ module ScormEngine
19
37
  this
20
38
  end
21
39
 
40
+ #
41
+ # Return a flattened array of all runtime interactions
42
+ #
43
+ # @return [Array<RegistrationRuntimeInteraction>]
44
+ #
22
45
  def all_runtime_interactions
23
46
  (runtime_interactions + children.map(&:all_runtime_interactions)).flatten
24
47
  end
@@ -29,6 +52,73 @@ module ScormEngine
29
52
  .fetch("runtimeInteractions", [])
30
53
  .map { |e| RegistrationRuntimeInteraction.new_from_api(e) }
31
54
  end
55
+
56
+ #
57
+ # Has this activity been completed?
58
+ #
59
+ # @return [Boolean]
60
+ # Returns true, false or nil if completion status is unknown.
61
+ #
62
+ def complete?
63
+ return nil if activity_completion == "UNKNOWN"
64
+ activity_completion == "COMPLETED"
65
+ end
66
+
67
+ #
68
+ # Is this activity incomplete?
69
+ #
70
+ # @return [Boolean]
71
+ # Returns true, false or nil if completion status is unknown.
72
+ #
73
+ def incomplete?
74
+ return nil if activity_completion == "UNKNOWN"
75
+ activity_completion == "INCOMPLETE"
76
+ end
77
+
78
+ #
79
+ # Has the previous attempt of this activity been completed?
80
+ #
81
+ # @return [Boolean]
82
+ # Returns true, false or nil if completion status is unknown.
83
+ #
84
+ def previous_attempt_complete?
85
+ return nil if previous_attempt_completion == "Unknown"
86
+ previous_attempt_completion == "Completed"
87
+ end
88
+
89
+ #
90
+ # Is the previous attempt of this previous_attempt incomplete?
91
+ #
92
+ # @return [Boolean]
93
+ # Returns true, false or nil if completion status is unknown.
94
+ #
95
+ def previous_attempt_incomplete?
96
+ return nil if previous_attempt_completion == "Unknown"
97
+ previous_attempt_completion == "Incomplete"
98
+ end
99
+
100
+ #
101
+ # Has this activity been passed?
102
+ #
103
+ # @return [Boolean]
104
+ # Returns true, false or nil if success status is unknown.
105
+ #
106
+ def passed?
107
+ return nil if activity_success == "UNKNOWN"
108
+ activity_success == "PASSED"
109
+ end
110
+
111
+ #
112
+ # Has this activity failed?
113
+ #
114
+ # @return [Boolean]
115
+ # Returns true, false or nil if success status is unknown.
116
+ #
117
+ def failed?
118
+ return nil if activity_success == "UNKNOWN"
119
+ activity_success == "FAILED"
120
+ end
121
+
32
122
  end
33
123
  end
34
124
  end
@@ -1,3 +1,3 @@
1
1
  module ScormEngine
2
- VERSION = "0.6.1".freeze
2
+ VERSION = "0.6.2".freeze
3
3
  end
@@ -97,5 +97,107 @@ RSpec.describe ScormEngine::Models::RegistrationActivityDetail do
97
97
  ]
98
98
  end
99
99
  end
100
+
101
+ describe "#complete?" do
102
+ it "is nil when completion is UNKNOWN" do
103
+ activity = described_class.new_from_api("activityCompletion" => "UNKNOWN")
104
+ expect(activity.complete?).to eq nil
105
+ end
106
+
107
+ it "is false when completion is INCOMPLETE" do
108
+ activity = described_class.new_from_api("activityCompletion" => "INCOMPLETE")
109
+ expect(activity.complete?).to eq false
110
+ end
111
+
112
+ it "is true when completion is COMPLETED" do
113
+ activity = described_class.new_from_api("activityCompletion" => "COMPLETED")
114
+ expect(activity.complete?).to eq true
115
+ end
116
+ end
117
+
118
+ describe "#incomplete?" do
119
+ it "is nil when completion is UNKNOWN" do
120
+ activity = described_class.new_from_api("activityCompletion" => "UNKNOWN")
121
+ expect(activity.incomplete?).to eq nil
122
+ end
123
+
124
+ it "is true when completion is INCOMPLETE" do
125
+ activity = described_class.new_from_api("activityCompletion" => "INCOMPLETE")
126
+ expect(activity.incomplete?).to eq true
127
+ end
128
+
129
+ it "is false when completion is COMPLETED" do
130
+ activity = described_class.new_from_api("activityCompletion" => "COMPLETED")
131
+ expect(activity.incomplete?).to eq false
132
+ end
133
+ end
134
+
135
+ describe "#previous_attempt_complete?" do
136
+ it "is nil when completion is Unknown" do
137
+ activity = described_class.new_from_api("previousAttemptCompletion" => "Unknown")
138
+ expect(activity.previous_attempt_complete?).to eq nil
139
+ end
140
+
141
+ it "is false when completion is Incomplete" do
142
+ activity = described_class.new_from_api("previousAttemptCompletion" => "Incomplete")
143
+ expect(activity.previous_attempt_complete?).to eq false
144
+ end
145
+
146
+ it "is true when completion is Completed" do
147
+ activity = described_class.new_from_api("previousAttemptCompletion" => "Completed")
148
+ expect(activity.previous_attempt_complete?).to eq true
149
+ end
150
+ end
151
+
152
+ describe "#previous_atempt_incomplete?" do
153
+ it "is nil when completion is Unknown" do
154
+ activity = described_class.new_from_api("previousAttemptCompletion" => "Unknown")
155
+ expect(activity.previous_attempt_incomplete?).to eq nil
156
+ end
157
+
158
+ it "is true when completion is Incomplete" do
159
+ activity = described_class.new_from_api("previousAttemptCompletion" => "Incomplete")
160
+ expect(activity.previous_attempt_incomplete?).to eq true
161
+ end
162
+
163
+ it "is false when completion is Completed" do
164
+ activity = described_class.new_from_api("previousAttemptCompletion" => "Completed")
165
+ expect(activity.previous_attempt_incomplete?).to eq false
166
+ end
167
+ end
168
+
169
+ describe "#passed?" do
170
+ it "is nil when completion is UNKNOWN" do
171
+ activity = described_class.new_from_api("activitySuccess" => "UNKNOWN")
172
+ expect(activity.passed?).to eq nil
173
+ end
174
+
175
+ it "is false when completion is FAILED" do
176
+ activity = described_class.new_from_api("activitySuccess" => "FAILED")
177
+ expect(activity.passed?).to eq false
178
+ end
179
+
180
+ it "is true when completion is PASSED" do
181
+ activity = described_class.new_from_api("activitySuccess" => "PASSED")
182
+ expect(activity.passed?).to eq true
183
+ end
184
+ end
185
+
186
+ describe "#failed?" do
187
+ it "is nil when completion is UNKNOWN" do
188
+ activity = described_class.new_from_api("activitySuccess" => "UNKNOWN")
189
+ expect(activity.failed?).to eq nil
190
+ end
191
+
192
+ it "is true when completion is FAILED" do
193
+ activity = described_class.new_from_api("activitySuccess" => "FAILED")
194
+ expect(activity.failed?).to eq true
195
+ end
196
+
197
+ it "is false when completion is PASSED" do
198
+ activity = described_class.new_from_api("activitySuccess" => "PASSED")
199
+ expect(activity.failed?).to eq false
200
+ end
201
+ end
100
202
  end
101
203
  end
@@ -78,5 +78,73 @@ RSpec.describe ScormEngine::Models::Registration do
78
78
  expect(registration.learner).to eq nil
79
79
  end
80
80
  end
81
+
82
+ describe "#complete?" do
83
+ it "is nil when completion is UNKNOWN" do
84
+ registration = described_class.new_from_api("registrationCompletion" => "UNKNOWN")
85
+ expect(registration.complete?).to eq nil
86
+ end
87
+
88
+ it "is false when completion is INCOMPLETE" do
89
+ registration = described_class.new_from_api("registrationCompletion" => "INCOMPLETE")
90
+ expect(registration.complete?).to eq false
91
+ end
92
+
93
+ it "is true when completion is COMPLETED" do
94
+ registration = described_class.new_from_api("registrationCompletion" => "COMPLETED")
95
+ expect(registration.complete?).to eq true
96
+ end
97
+ end
98
+
99
+ describe "#incomplete?" do
100
+ it "is nil when completion is UNKNOWN" do
101
+ registration = described_class.new_from_api("registrationCompletion" => "UNKNOWN")
102
+ expect(registration.incomplete?).to eq nil
103
+ end
104
+
105
+ it "is true when completion is INCOMPLETE" do
106
+ registration = described_class.new_from_api("registrationCompletion" => "INCOMPLETE")
107
+ expect(registration.incomplete?).to eq true
108
+ end
109
+
110
+ it "is false when completion is COMPLETED" do
111
+ registration = described_class.new_from_api("registrationCompletion" => "COMPLETED")
112
+ expect(registration.incomplete?).to eq false
113
+ end
114
+ end
115
+
116
+ describe "#passed?" do
117
+ it "is nil when completion is Unknown" do
118
+ registration = described_class.new_from_api("registrationSuccess" => "Unknown")
119
+ expect(registration.passed?).to eq nil
120
+ end
121
+
122
+ it "is false when completion is Failed" do
123
+ registration = described_class.new_from_api("registrationSuccess" => "Failed")
124
+ expect(registration.passed?).to eq false
125
+ end
126
+
127
+ it "is true when completion is Passed" do
128
+ registration = described_class.new_from_api("registrationSuccess" => "Passed")
129
+ expect(registration.passed?).to eq true
130
+ end
131
+ end
132
+
133
+ describe "#failed?" do
134
+ it "is nil when completion is Unknown" do
135
+ registration = described_class.new_from_api("registrationSuccess" => "Unknown")
136
+ expect(registration.failed?).to eq nil
137
+ end
138
+
139
+ it "is true when completion is Failed" do
140
+ registration = described_class.new_from_api("registrationSuccess" => "Failed")
141
+ expect(registration.failed?).to eq true
142
+ end
143
+
144
+ it "is false when completion is Passed" do
145
+ registration = described_class.new_from_api("registrationSuccess" => "Passed")
146
+ expect(registration.failed?).to eq false
147
+ end
148
+ end
81
149
  end
82
150
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scorm_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Hallstrom
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-23 00:00:00.000000000 Z
11
+ date: 2018-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday