quiz_api_client 4.10.0 → 4.11.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52e4f7fca1b006d34c7396f45867f32c121b77a1d5f0f8a2c466e5e25cfc1cb1
4
- data.tar.gz: 74302f9f3bd2f5a6bc5971ae779e21fac29e3a4aac87eb887808e5dc2d732ece
3
+ metadata.gz: 296ae98e95e4fff6555495c5ae214e08fe3c54d5ed7ad0dcc5b6438097e4229e
4
+ data.tar.gz: f9b544b10bf67683f216e0f357fd6ce3862cfc8cc526b9f9eb62506a89f30745
5
5
  SHA512:
6
- metadata.gz: abc357f28d6f1c72d90f3f1ac4b2255f3e04d45d6cc85e71ac99fd2cdb919b705fdd630283b08bfd798e9ef3589df2f72e00c451c1adec99b176cd8a0d15ada6
7
- data.tar.gz: f0d5a44aeef52c5f3c19530e82ba02b76d54db50731b6b00b23f49e52e6545c499708c5209ce2d0ad342742c77b97c7964cf8d3793169d8cbaf30c38942725e4
6
+ metadata.gz: b00e342816f726c8f06bde41615b4e474866d99c3f63bc216e2a4bb3803c7c2e879ef1c82a08c4e08b571aed5af5091a91559b291214fe07f060bc6cf6c16bc5
7
+ data.tar.gz: f6f0e3ddd4197ae8dc2567a58c3e6b67ca6835cbf6ac7c21144e2bd3d021ba111f922794a1d499fd6b1110ccdb5b3fa7c13ebae52d179dbaf68ff61bd0e3ca1d
@@ -0,0 +1,16 @@
1
+ module QuizApiClient::Services
2
+ class AnalysesService < BaseApiService
3
+ def create(params:, token: nil)
4
+ post_to_quiz_api(params: params, token: token)
5
+ end
6
+
7
+ private
8
+
9
+ def post_to_quiz_api(params:, token:)
10
+ client(token: token).post(
11
+ "/api/quizzes/#{params[:quiz_id]}/stats",
12
+ quiz_sessions: params[:quiz_sessions]
13
+ )
14
+ end
15
+ end
16
+ end
@@ -4,6 +4,12 @@ module QuizApiClient::Services
4
4
  post_to_quiz_api(params: params, token: token)
5
5
  end
6
6
 
7
+ def show(params:, token: nil)
8
+ raise 'Content Export Id Required' unless params && params[:id]
9
+
10
+ get_from_quiz_api(params: params, token: token)
11
+ end
12
+
7
13
  private
8
14
 
9
15
  def post_to_quiz_api(params:, token:)
@@ -12,5 +18,11 @@ module QuizApiClient::Services
12
18
  content_export: params
13
19
  )
14
20
  end
21
+
22
+ def get_from_quiz_api(params:, token:)
23
+ client(token: token).get(
24
+ "/api/content_exports/#{params[:id]}"
25
+ )
26
+ end
15
27
  end
16
28
  end
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '4.10.0'.freeze
2
+ VERSION = '4.11.1'.freeze
3
3
  end
@@ -70,6 +70,10 @@ module QuizApiClient
70
70
  @_qti_imports_service ||= Services::QtiImportsService.new(config)
71
71
  end
72
72
 
73
+ def analyses_service
74
+ @_analyses_service ||= Services::AnalysesService.new(config)
75
+ end
76
+
73
77
  def item_analyses_service
74
78
  @_item_analyses_service ||= Services::ItemAnalysesService.new(config)
75
79
  end
@@ -125,6 +129,7 @@ require 'quiz_api_client/services/base_api_service'
125
129
  require 'quiz_api_client/services/content_exports_service'
126
130
  require 'quiz_api_client/services/courses_service'
127
131
  require 'quiz_api_client/services/interaction_types_service'
132
+ require 'quiz_api_client/services/analyses_service'
128
133
  require 'quiz_api_client/services/item_analyses_service'
129
134
  require 'quiz_api_client/services/items_service'
130
135
  require 'quiz_api_client/services/qti_imports_service'
@@ -93,6 +93,13 @@ describe QuizApiClient do
93
93
  end
94
94
  end
95
95
 
96
+ describe '#analyses_service' do
97
+ it 'should create the service' do
98
+ expect(QuizApiClient::Services::AnalysesService).to receive(:new).with(subject.config)
99
+ subject.analyses_service
100
+ end
101
+ end
102
+
96
103
  describe '#item_analyses_service' do
97
104
  it 'should create the service' do
98
105
  expect(QuizApiClient::Services::ItemAnalysesService).to receive(:new).with(subject.config)
@@ -0,0 +1,28 @@
1
+ describe QuizApiClient::Services::AnalysesService do
2
+ let(:host) { 'api.host' }
3
+ let(:config) { QuizApiClient::Config.new { |c| c.host = host } }
4
+ let(:subject) { described_class.new(config) }
5
+
6
+ describe '#create' do
7
+ let(:params) do
8
+ { quiz_id: 1, quiz_session: [1, 5, 10] }
9
+ end
10
+ let(:stubbed_response) { { 'job_id' => 1 } }
11
+ let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/stats" }
12
+ let(:status_code) { 200 }
13
+
14
+ before do
15
+ stub_request(:post, expected_url)
16
+ .to_return(
17
+ status: status_code,
18
+ body: stubbed_response.to_json,
19
+ headers: { 'Content-Type' => 'application/json' }
20
+ )
21
+ end
22
+
23
+ it 'posts to quiz_api/api/quizzes/{id}/stats and returns the response' do
24
+ result = subject.create(params: params, token: 'token')
25
+ expect(result.parsed_response).to eql(stubbed_response)
26
+ end
27
+ end
28
+ end
@@ -3,6 +3,20 @@ describe QuizApiClient::Services::ContentExportsService do
3
3
  let(:config) { QuizApiClient::Config.new { |c| c.host = host } }
4
4
  let(:subject) { described_class.new(config) }
5
5
 
6
+ let(:stubbed_response) do
7
+ {
8
+ 'id' => '1',
9
+ 'canvas_content_export_id' => '1234',
10
+ 'export_settings' => {
11
+ 'quizzes' => [10, 11],
12
+ 'everything' => false,
13
+ 'content_export_type' => 'qti'
14
+ },
15
+ 'created_at' => '2023-02-17T01:00:00.000Z',
16
+ 'updated_at' => '2023-02-17T01:00:00.000Z'
17
+ }
18
+ end
19
+
6
20
  describe '#create' do
7
21
  let(:params) do
8
22
  {
@@ -15,20 +29,6 @@ describe QuizApiClient::Services::ContentExportsService do
15
29
  }
16
30
  end
17
31
 
18
- let(:response) do
19
- {
20
- 'id' => '1',
21
- 'canvas_content_export_id' => '1234',
22
- 'export_settings' => {
23
- 'quizzes' => [10, 11],
24
- 'everything' => false,
25
- 'content_export_type' => 'qti'
26
- },
27
- 'created_at' => '2023-02-17T01:00:00.000Z',
28
- 'updated_at' => '2023-02-17T01:00:00.000Z'
29
- }
30
- end
31
-
32
32
  let(:expected_url) { "https://#{host}/api/content_exports" }
33
33
 
34
34
  before do
@@ -36,7 +36,7 @@ describe QuizApiClient::Services::ContentExportsService do
36
36
  .with(body: { content_export: params }.to_json)
37
37
  .to_return(
38
38
  status: 201,
39
- body: response.to_json,
39
+ body: stubbed_response.to_json,
40
40
  headers: { 'Content-Type' => 'application/json' }
41
41
  )
42
42
  end
@@ -44,7 +44,27 @@ describe QuizApiClient::Services::ContentExportsService do
44
44
  it 'posts to the correct endpoint and returns the response' do
45
45
  expect(
46
46
  subject.create(params: params, token: 'token').parsed_response
47
- ).to eq(response)
47
+ ).to eq(stubbed_response)
48
+ end
49
+ end
50
+
51
+ describe '#show' do
52
+ let(:params) { { id: 1 } }
53
+ let(:expected_url) { "https://#{host}/api/content_exports/#{params[:id]}" }
54
+ let(:status_code) { 200 }
55
+
56
+ before do
57
+ stub_request(:get, expected_url)
58
+ .to_return(
59
+ status: status_code,
60
+ body: stubbed_response.to_json,
61
+ headers: { 'Content-Type' => 'application/json' }
62
+ )
63
+ end
64
+
65
+ it 'gets from quiz_api/api/content_exports and returns the response' do
66
+ response = subject.show(params: params, token: 'token')
67
+ expect(response.parsed_response).to eql(stubbed_response)
48
68
  end
49
69
  end
50
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quiz_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.10.0
4
+ version: 4.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Slaughter
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: exe
17
17
  cert_chain: []
18
- date: 2023-03-28 00:00:00.000000000 Z
18
+ date: 2023-04-18 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty
@@ -179,6 +179,7 @@ files:
179
179
  - lib/quiz_api_client/http_request/failure.rb
180
180
  - lib/quiz_api_client/http_request/metrics.rb
181
181
  - lib/quiz_api_client/json_formatter.rb
182
+ - lib/quiz_api_client/services/analyses_service.rb
182
183
  - lib/quiz_api_client/services/base_api_service.rb
183
184
  - lib/quiz_api_client/services/content_exports_service.rb
184
185
  - lib/quiz_api_client/services/courses_service.rb
@@ -209,6 +210,7 @@ files:
209
210
  - spec/quiz_api_client/http_request/failure_spec.rb
210
211
  - spec/quiz_api_client/http_request/metrics_spec.rb
211
212
  - spec/quiz_api_client_spec.rb
213
+ - spec/services/analyses_service_spec.rb
212
214
  - spec/services/base_api_service_spec.rb
213
215
  - spec/services/content_exports_service_spec.rb
214
216
  - spec/services/courses_service_spec.rb
@@ -261,6 +263,7 @@ test_files:
261
263
  - spec/quiz_api_client/http_request/failure_spec.rb
262
264
  - spec/quiz_api_client/http_request/metrics_spec.rb
263
265
  - spec/quiz_api_client_spec.rb
266
+ - spec/services/analyses_service_spec.rb
264
267
  - spec/services/base_api_service_spec.rb
265
268
  - spec/services/content_exports_service_spec.rb
266
269
  - spec/services/courses_service_spec.rb