quiz_api_client 4.18.0 → 4.20.0

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: ba0876cb763ece686d1cedc404bb62633c5971bea43528a718b6fee780dedcff
4
- data.tar.gz: 128e36dfb1454227664c0ba02aafe361003407f7dbf30d9d7c29c9e52b95e3bc
3
+ metadata.gz: 790a9d7b1622cf0d9d98e9eb3f62c1e481178223ee8e8f32f2461be744c2577a
4
+ data.tar.gz: 36c83c014b77e91890c91e6f3081c38ef2d81965d274196dd5559eb9f644a556
5
5
  SHA512:
6
- metadata.gz: daf54ed83085516b8f6e1715baf2fe39428f0cc39631361b4a70ddffd4a7f0a4efddf7563cd03c9112a35578f68786799656eceefe904932b26592a8a826b6a8
7
- data.tar.gz: b78454c69b4e7d505a8eca415bee8c85206975ca03af2cd801f3f4ad1264981aeec1d95192f642cba8b959897522ac7457d13c5e94d835aadee79dfbc9b8bc31
6
+ metadata.gz: a0a74a8ea7236a4778eaeb13dd1d1e98d3f18d766260ca6151fbab889b7e036e3dc588282f587342fce1b2c867a690c8d6d091df8e2c04c117dcd164dd46d2d6
7
+ data.tar.gz: c00de63348f7bf03c024ff5eb5f81d379139168a8e22faeedecacd7aa17692959a77a23e0ecefcc46c722ab0ce93a1ae0fd15536754a6ae0882dc746951d9d76
@@ -1,7 +1,15 @@
1
1
  module QuizApiClient::Services
2
2
  class AnalysesService < BaseApiService
3
3
  def create(params:, token: nil)
4
- post_to_quiz_api(params: params, token: token)
4
+ post_to_analyses(params: params, token: token)
5
+ end
6
+
7
+ def create_report(params:, token: nil)
8
+ post_to_create_report(params: params, token: token)
9
+ end
10
+
11
+ def abort_report(params:, token: nil)
12
+ post_to_abort_report(params: params, token: token)
5
13
  end
6
14
 
7
15
  def show(params:, token: nil)
@@ -27,11 +35,23 @@ module QuizApiClient::Services
27
35
 
28
36
  private
29
37
 
30
- def post_to_quiz_api(params:, token:)
31
- client(token: token).post(
32
- "/api/quizzes/#{params[:quiz_id]}/analyses",
33
- params
34
- )
38
+ def post_to_create_report(params:, token:)
39
+ path = "/api/quizzes/#{params[:quiz_id]}/analyses/create_report"
40
+ post_to_quiz_api(path: path, params: params, token: token)
41
+ end
42
+
43
+ def post_to_abort_report(params:, token:)
44
+ path = "/api/quizzes/#{params[:quiz_id]}/analyses/abort"
45
+ post_to_quiz_api(path: path, params: params, token: token)
46
+ end
47
+
48
+ def post_to_analyses(params:, token:)
49
+ path = "/api/quizzes/#{params[:quiz_id]}/analyses"
50
+ post_to_quiz_api(path: path, params: params, token: token)
51
+ end
52
+
53
+ def post_to_quiz_api(path:, params:, token:)
54
+ client(token: token).post(path, params)
35
55
  end
36
56
  end
37
57
  end
@@ -8,6 +8,10 @@ module QuizApiClient::Services
8
8
  get_from_quiz_api(params: params, token: token, all: all)
9
9
  end
10
10
 
11
+ def quiz_question_counts(params:, token: nil, all: false)
12
+ get_quiz_question_counts(params: params, token: token, all: all)
13
+ end
14
+
11
15
  private
12
16
 
13
17
  def post_to_quiz_api(params:, token:)
@@ -24,5 +28,13 @@ module QuizApiClient::Services
24
28
  query: params
25
29
  )
26
30
  end
31
+
32
+ def get_quiz_question_counts(params:, token:, all:)
33
+ client(token: token).get(
34
+ '/api/quizzes/question_count',
35
+ all: all,
36
+ query: params
37
+ )
38
+ end
27
39
  end
28
40
  end
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '4.18.0'.freeze
2
+ VERSION = '4.20.0'.freeze
3
3
  end
@@ -31,6 +31,32 @@ describe QuizApiClient::Services::AnalysesService do
31
31
  end
32
32
  end
33
33
 
34
+ describe '#create_report' do
35
+ let(:params) do
36
+ { quiz_id: 1, quiz_session_ids: [1, 5, 10], filter: :last_attempt, analysis_type: 'student_analysis' }
37
+ end
38
+ let(:stubbed_response) { { 'job_id' => 1 } }
39
+ let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/create_report" }
40
+ let(:status_code) { 200 }
41
+
42
+ before do
43
+ stub_request(:post, expected_url)
44
+ .with(
45
+ body: params.to_json
46
+ )
47
+ .to_return(
48
+ status: status_code,
49
+ body: stubbed_response.to_json,
50
+ headers: { 'Content-Type' => 'application/json' }
51
+ )
52
+ end
53
+
54
+ it 'posts to quiz_api/api/quizzes/{id}/analyses and returns the response' do
55
+ result = subject.create_report(params: params, token: 'token')
56
+ expect(result.parsed_response).to eql(stubbed_response)
57
+ end
58
+ end
59
+
34
60
  describe '#show' do
35
61
  let(:params) do
36
62
  { quiz_id: 1, id: 2 }
@@ -109,4 +135,27 @@ describe QuizApiClient::Services::AnalysesService do
109
135
  expect(result.parsed_response).to eql([%w[column1 column2 column3]])
110
136
  end
111
137
  end
138
+
139
+ describe 'abort_report' do
140
+ let(:params) do
141
+ { quiz_id: 1, report_id: 2 }
142
+ end
143
+ let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/abort" }
144
+ let(:status_code) { 204 }
145
+
146
+ before do
147
+ stub_request(:post, expected_url)
148
+ .with(
149
+ body: params.to_json
150
+ )
151
+ .to_return(
152
+ status: status_code
153
+ )
154
+ end
155
+
156
+ it 'posts to quiz_api/api/quizzes/{id}/analyses/abort and returns the response' do
157
+ result = subject.abort_report(params: params, token: 'token')
158
+ expect(result.code).to eql(status_code)
159
+ end
160
+ end
112
161
  end
@@ -68,4 +68,42 @@ describe QuizApiClient::Services::QuizzesService do
68
68
  end
69
69
  end
70
70
  end
71
+
72
+ describe '#quiz_question_counts' do
73
+ let(:quiz_ids) { [1, 2, 3] }
74
+ let(:params) { { quiz_ids: quiz_ids } }
75
+ let(:stubbed_response) { { 'quiz_id' => '1', 'question_count' => 10 } }
76
+
77
+ context 'on success' do
78
+ before do
79
+ query_params = URI.encode_www_form(quiz_ids.map { |id| ['quiz_ids[]', id] })
80
+ expected_url = "https://#{host}/api/quizzes/question_count?#{query_params}"
81
+ stub_request(:get, expected_url)
82
+ .to_return(
83
+ status: 200,
84
+ body: [stubbed_response].to_json,
85
+ headers: { 'Content-Type' => 'application/json' }
86
+ )
87
+ end
88
+
89
+ it 'gets quiz_api/api/quizzes/question_count and returns the response' do
90
+ result = subject.quiz_question_counts(params: params, token: 'token')
91
+ expect(result.parsed_response[0]).to eql(stubbed_response)
92
+ end
93
+ end
94
+
95
+ context 'on failure' do
96
+ let(:status_code) { 401 }
97
+ before do
98
+ expected_url = "https://#{host}/api/quizzes/question_count"
99
+ stub_request(:get, expected_url)
100
+ .to_return(status: status_code)
101
+ end
102
+
103
+ it 'returns the response with the correct code' do
104
+ response = subject.quiz_question_counts(params: nil, token: 'token')
105
+ expect(response.code).to eq(status_code)
106
+ end
107
+ end
108
+ end
71
109
  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.18.0
4
+ version: 4.20.0
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: 2024-11-21 00:00:00.000000000 Z
18
+ date: 2025-04-15 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty