quiz_api_client 4.17.1 → 4.18.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba0876cb763ece686d1cedc404bb62633c5971bea43528a718b6fee780dedcff
|
4
|
+
data.tar.gz: 128e36dfb1454227664c0ba02aafe361003407f7dbf30d9d7c29c9e52b95e3bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daf54ed83085516b8f6e1715baf2fe39428f0cc39631361b4a70ddffd4a7f0a4efddf7563cd03c9112a35578f68786799656eceefe904932b26592a8a826b6a8
|
7
|
+
data.tar.gz: b78454c69b4e7d505a8eca415bee8c85206975ca03af2cd801f3f4ad1264981aeec1d95192f642cba8b959897522ac7457d13c5e94d835aadee79dfbc9b8bc31
|
@@ -4,6 +4,27 @@ 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
|
+
client(token: token).get(
|
9
|
+
"/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}",
|
10
|
+
query: { filter: :last_attempt }
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def export(params:, token: nil)
|
15
|
+
client(token: token).get(
|
16
|
+
"/api/quizzes/#{params[:quiz_id]}/analyses/export",
|
17
|
+
query: { filter: :last_attempt, format: :csv, analysis_type: params[:analysis_type] }
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def status(params:, token: nil)
|
22
|
+
client(token: token).get(
|
23
|
+
"/api/quizzes/#{params[:quiz_id]}/analyses/status",
|
24
|
+
query: { filter: :last_attempt, analysis_type: params[:analysis_type] }
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
7
28
|
private
|
8
29
|
|
9
30
|
def post_to_quiz_api(params:, token:)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
1
3
|
describe QuizApiClient::Services::AnalysesService do
|
2
4
|
let(:host) { 'api.host' }
|
3
5
|
let(:config) { QuizApiClient::Config.new { |c| c.host = host } }
|
@@ -28,4 +30,83 @@ describe QuizApiClient::Services::AnalysesService do
|
|
28
30
|
expect(result.parsed_response).to eql(stubbed_response)
|
29
31
|
end
|
30
32
|
end
|
33
|
+
|
34
|
+
describe '#show' do
|
35
|
+
let(:params) do
|
36
|
+
{ quiz_id: 1, id: 2 }
|
37
|
+
end
|
38
|
+
let(:stubbed_response) { { 'id' => 1 } }
|
39
|
+
let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}?filter=last_attempt" }
|
40
|
+
let(:status_code) { 200 }
|
41
|
+
|
42
|
+
before do
|
43
|
+
stub_request(:get, expected_url)
|
44
|
+
.to_return(
|
45
|
+
status: status_code,
|
46
|
+
body: stubbed_response.to_json,
|
47
|
+
headers: { 'Content-Type' => 'application/json' }
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'gets to quiz_api/api/quizzes/{id}/reports/{id} and returns the response' do
|
52
|
+
result = subject.show(params: params, token: 'token')
|
53
|
+
expect(result.parsed_response).to eql(stubbed_response)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'status' do
|
58
|
+
let(:params) do
|
59
|
+
{ quiz_id: 1, analysis_type: 'item_analysis' }
|
60
|
+
end
|
61
|
+
let(:stubbed_response) { { 'id' => 1 } }
|
62
|
+
let(:expected_url) do
|
63
|
+
"https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/status?filter=last_attempt" +
|
64
|
+
+ "&analysis_type=#{params[:analysis_type]}"
|
65
|
+
end
|
66
|
+
let(:status_code) { 200 }
|
67
|
+
|
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
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'gets to quiz_api/api/quizzes/{id}/analyses/status and returns the response' do
|
78
|
+
result = subject.status(params: params, token: 'token')
|
79
|
+
expect(result.parsed_response).to eql(stubbed_response)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'export' do
|
84
|
+
let(:params) do
|
85
|
+
{ quiz_id: 1, analysis_type: 'item_analysis' }
|
86
|
+
end
|
87
|
+
let(:stubbed_response) do
|
88
|
+
CSV.generate(headers: true) do |csv|
|
89
|
+
csv << %w[column1 column2 column3]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
let(:expected_url) do
|
93
|
+
"https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/export" \
|
94
|
+
"?analysis_type=#{params[:analysis_type]}&filter=last_attempt&format=csv"
|
95
|
+
end
|
96
|
+
let(:status_code) { 200 }
|
97
|
+
|
98
|
+
before do
|
99
|
+
stub_request(:get, expected_url)
|
100
|
+
.to_return(
|
101
|
+
status: status_code,
|
102
|
+
body: stubbed_response,
|
103
|
+
headers: { 'Content-Type' => 'text/csv' }
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'gets to quiz_api/api/quizzes/{id}/analyses/export and returns the response' do
|
108
|
+
result = subject.export(params: params, token: 'token')
|
109
|
+
expect(result.parsed_response).to eql([%w[column1 column2 column3]])
|
110
|
+
end
|
111
|
+
end
|
31
112
|
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.
|
4
|
+
version: 4.18.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-
|
18
|
+
date: 2024-11-21 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: httparty
|