quiz_api_client 4.20.0 → 4.21.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: 790a9d7b1622cf0d9d98e9eb3f62c1e481178223ee8e8f32f2461be744c2577a
4
- data.tar.gz: 36c83c014b77e91890c91e6f3081c38ef2d81965d274196dd5559eb9f644a556
3
+ metadata.gz: 1163e85cb5fd4c258330d4d8a6fdd298e6a252bc453b28ca7f3a02cbfb06b968
4
+ data.tar.gz: 230852d9477251d2b97a49a3ab5b7f84bdc96505e9636d01f1257859c3641d80
5
5
  SHA512:
6
- metadata.gz: a0a74a8ea7236a4778eaeb13dd1d1e98d3f18d766260ca6151fbab889b7e036e3dc588282f587342fce1b2c867a690c8d6d091df8e2c04c117dcd164dd46d2d6
7
- data.tar.gz: c00de63348f7bf03c024ff5eb5f81d379139168a8e22faeedecacd7aa17692959a77a23e0ecefcc46c722ab0ce93a1ae0fd15536754a6ae0882dc746951d9d76
6
+ metadata.gz: 4d550ce6a725dc72a605a4ef037662143d553cc6ac2ea47411e1739abdf32f3e3e1a61f24e80c00755aafaad0c410df753f26cd83e90b4efca241ed5a9a91812
7
+ data.tar.gz: ca76400aee18a66010e821cb3b4a3e8b720f69106031445da5dbdb1851f9bf7d2976683c4a711d3ae762e288576d5ae06fbfd643393f41afc8070b330dd0bbf4
@@ -15,26 +15,30 @@ module QuizApiClient::Services
15
15
  def show(params:, token: nil)
16
16
  client(token: token).get(
17
17
  "/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}",
18
- query: { filter: :last_attempt }
18
+ query: { filter: filter_value(params) }
19
19
  )
20
20
  end
21
21
 
22
22
  def export(params:, token: nil)
23
23
  client(token: token).get(
24
24
  "/api/quizzes/#{params[:quiz_id]}/analyses/export",
25
- query: { filter: :last_attempt, format: :csv, analysis_type: params[:analysis_type] }
25
+ query: { filter: filter_value(params), format: :csv, analysis_type: params[:analysis_type] }
26
26
  )
27
27
  end
28
28
 
29
29
  def status(params:, token: nil)
30
30
  client(token: token).get(
31
31
  "/api/quizzes/#{params[:quiz_id]}/analyses/status",
32
- query: { filter: :last_attempt, analysis_type: params[:analysis_type] }
32
+ query: { filter: filter_value(params), analysis_type: params[:analysis_type] }
33
33
  )
34
34
  end
35
35
 
36
36
  private
37
37
 
38
+ def filter_value(params)
39
+ params[:filter] || :last_attempt
40
+ end
41
+
38
42
  def post_to_create_report(params:, token:)
39
43
  path = "/api/quizzes/#{params[:quiz_id]}/analyses/create_report"
40
44
  post_to_quiz_api(path: path, params: params, token: token)
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '4.20.0'.freeze
2
+ VERSION = '4.21.0'.freeze
3
3
  end
@@ -58,81 +58,152 @@ describe QuizApiClient::Services::AnalysesService do
58
58
  end
59
59
 
60
60
  describe '#show' do
61
- let(:params) do
62
- { quiz_id: 1, id: 2 }
63
- end
61
+ let(:params) { { quiz_id: 1, id: 2 } }
64
62
  let(:stubbed_response) { { 'id' => 1 } }
65
- let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}?filter=last_attempt" }
66
63
  let(:status_code) { 200 }
67
64
 
68
- before do
69
- stub_request(:get, expected_url)
70
- .to_return(
71
- status: status_code,
72
- body: stubbed_response.to_json,
73
- headers: { 'Content-Type' => 'application/json' }
74
- )
65
+ context 'when filter is last_attempt' do
66
+ let(:expected_url) do
67
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}?filter=last_attempt"
68
+ end
69
+
70
+ before do
71
+ stub_request(:get, expected_url)
72
+ .to_return(
73
+ status: status_code,
74
+ body: stubbed_response.to_json,
75
+ headers: { 'Content-Type' => 'application/json' }
76
+ )
77
+ end
78
+
79
+ it 'returns the last_attempt report' do
80
+ result = subject.show(params: params.merge(filter: 'last_attempt'), token: 'token')
81
+ expect(result.parsed_response).to eql(stubbed_response)
82
+ end
75
83
  end
76
84
 
77
- it 'gets to quiz_api/api/quizzes/{id}/reports/{id} and returns the response' do
78
- result = subject.show(params: params, token: 'token')
79
- expect(result.parsed_response).to eql(stubbed_response)
85
+ context 'when filter is all_attempts' do
86
+ let(:expected_url) do
87
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}?filter=all_attempts"
88
+ end
89
+
90
+ before do
91
+ stub_request(:get, expected_url)
92
+ .to_return(
93
+ status: status_code,
94
+ body: stubbed_response.to_json,
95
+ headers: { 'Content-Type' => 'application/json' }
96
+ )
97
+ end
98
+
99
+ it 'returns the all_attempts report' do
100
+ result = subject.show(params: params.merge(filter: 'all_attempts'), token: 'token')
101
+ expect(result.parsed_response).to eql(stubbed_response)
102
+ end
80
103
  end
81
104
  end
82
105
 
83
- describe 'status' do
84
- let(:params) do
85
- { quiz_id: 1, analysis_type: 'item_analysis' }
86
- end
106
+ describe '#status' do
107
+ let(:base_params) { { quiz_id: 1, analysis_type: 'item_analysis' } }
87
108
  let(:stubbed_response) { { 'id' => 1 } }
88
- let(:expected_url) do
89
- "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/status?filter=last_attempt" +
90
- + "&analysis_type=#{params[:analysis_type]}"
91
- end
92
109
  let(:status_code) { 200 }
93
110
 
94
- before do
95
- stub_request(:get, expected_url)
96
- .to_return(
97
- status: status_code,
98
- body: stubbed_response.to_json,
99
- headers: { 'Content-Type' => 'application/json' }
100
- )
111
+ context 'when filter is last_attempt' do
112
+ let(:params) { base_params.merge(filter: 'last_attempt') }
113
+ let(:expected_url) do
114
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/status" \
115
+ "?filter=#{params[:filter]}&analysis_type=#{params[:analysis_type]}"
116
+ end
117
+
118
+ before do
119
+ stub_request(:get, expected_url)
120
+ .to_return(
121
+ status: status_code,
122
+ body: stubbed_response.to_json,
123
+ headers: { 'Content-Type' => 'application/json' }
124
+ )
125
+ end
126
+
127
+ it 'returns the last_attempt analysis status' do
128
+ result = subject.status(params: params, token: 'token')
129
+ expect(result.parsed_response).to eql(stubbed_response)
130
+ end
101
131
  end
102
132
 
103
- it 'gets to quiz_api/api/quizzes/{id}/analyses/status and returns the response' do
104
- result = subject.status(params: params, token: 'token')
105
- expect(result.parsed_response).to eql(stubbed_response)
133
+ context 'when filter is all_attempts' do
134
+ let(:params) { base_params.merge(filter: 'all_attempts') }
135
+ let(:expected_url) do
136
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/status" \
137
+ "?filter=#{params[:filter]}&analysis_type=#{params[:analysis_type]}"
138
+ end
139
+
140
+ before do
141
+ stub_request(:get, expected_url)
142
+ .to_return(
143
+ status: status_code,
144
+ body: stubbed_response.to_json,
145
+ headers: { 'Content-Type' => 'application/json' }
146
+ )
147
+ end
148
+
149
+ it 'returns the all_attempts analysis status' do
150
+ result = subject.status(params: params, token: 'token')
151
+ expect(result.parsed_response).to eql(stubbed_response)
152
+ end
106
153
  end
107
154
  end
108
155
 
109
- describe 'export' do
110
- let(:params) do
111
- { quiz_id: 1, analysis_type: 'item_analysis' }
112
- end
156
+ describe '#export' do
157
+ let(:base_params) { { quiz_id: 1, analysis_type: 'item_analysis' } }
113
158
  let(:stubbed_response) do
114
159
  CSV.generate(headers: true) do |csv|
115
160
  csv << %w[column1 column2 column3]
116
161
  end
117
162
  end
118
- let(:expected_url) do
119
- "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/export" \
120
- "?analysis_type=#{params[:analysis_type]}&filter=last_attempt&format=csv"
121
- end
122
163
  let(:status_code) { 200 }
123
164
 
124
- before do
125
- stub_request(:get, expected_url)
126
- .to_return(
127
- status: status_code,
128
- body: stubbed_response,
129
- headers: { 'Content-Type' => 'text/csv' }
130
- )
165
+ context 'when filter is last_attempt' do
166
+ let(:params) { base_params.merge(filter: 'last_attempt') }
167
+ let(:expected_url) do
168
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/export" \
169
+ "?analysis_type=#{params[:analysis_type]}&filter=#{params[:filter]}&format=csv"
170
+ end
171
+
172
+ before do
173
+ stub_request(:get, expected_url)
174
+ .to_return(
175
+ status: status_code,
176
+ body: stubbed_response,
177
+ headers: { 'Content-Type' => 'text/csv' }
178
+ )
179
+ end
180
+
181
+ it 'returns the last_attempt CSV export' do
182
+ result = subject.export(params: params, token: 'token')
183
+ expect(result.parsed_response).to eql([%w[column1 column2 column3]])
184
+ end
131
185
  end
132
186
 
133
- it 'gets to quiz_api/api/quizzes/{id}/analyses/export and returns the response' do
134
- result = subject.export(params: params, token: 'token')
135
- expect(result.parsed_response).to eql([%w[column1 column2 column3]])
187
+ context 'when filter is all_attempts' do
188
+ let(:params) { base_params.merge(filter: 'all_attempts') }
189
+ let(:expected_url) do
190
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/export" \
191
+ "?analysis_type=#{params[:analysis_type]}&filter=#{params[:filter]}&format=csv"
192
+ end
193
+
194
+ before do
195
+ stub_request(:get, expected_url)
196
+ .to_return(
197
+ status: status_code,
198
+ body: stubbed_response,
199
+ headers: { 'Content-Type' => 'text/csv' }
200
+ )
201
+ end
202
+
203
+ it 'returns the all_attempts CSV export' do
204
+ result = subject.export(params: params, token: 'token')
205
+ expect(result.parsed_response).to eql([%w[column1 column2 column3]])
206
+ end
136
207
  end
137
208
  end
138
209
 
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.20.0
4
+ version: 4.21.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: 2025-04-15 00:00:00.000000000 Z
18
+ date: 2025-05-06 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty