quiz_api_client 4.17.0 → 4.18.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:
|
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,14 +4,33 @@ 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:)
|
10
31
|
client(token: token).post(
|
11
32
|
"/api/quizzes/#{params[:quiz_id]}/analyses",
|
12
|
-
|
13
|
-
filter: params[:filter],
|
14
|
-
analysis_type: params[:analysis_type]
|
33
|
+
params
|
15
34
|
)
|
16
35
|
end
|
17
36
|
end
|
@@ -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 } }
|
@@ -9,13 +11,12 @@ describe QuizApiClient::Services::AnalysesService do
|
|
9
11
|
end
|
10
12
|
let(:stubbed_response) { { 'job_id' => 1 } }
|
11
13
|
let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses" }
|
12
|
-
let(:expected_params) { { quiz_session_ids: [1, 5, 10], filter: :last_attempt, analysis_type: 'student_analysis' } }
|
13
14
|
let(:status_code) { 200 }
|
14
15
|
|
15
16
|
before do
|
16
17
|
stub_request(:post, expected_url)
|
17
18
|
.with(
|
18
|
-
body:
|
19
|
+
body: params.to_json
|
19
20
|
)
|
20
21
|
.to_return(
|
21
22
|
status: status_code,
|
@@ -29,4 +30,83 @@ describe QuizApiClient::Services::AnalysesService do
|
|
29
30
|
expect(result.parsed_response).to eql(stubbed_response)
|
30
31
|
end
|
31
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
|
32
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
|