quiz_api_client 4.17.1 → 4.19.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: c6a0d785f0b483d712f8c6cbbef7407ef0f41831f013d7c90d1bbf686236681a
|
4
|
+
data.tar.gz: 2ab9f601ee6ec4f73b2319bbe0fedb7f733932266f6ebe5d306248811c2b1e98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f331cf1b2338ff28c863a920694783c615e42ecaeedf9b50d273c6e37b36da6a9285931ee8ab86ac7b898b22118442893595b2981a07443179e952d70f76922e
|
7
|
+
data.tar.gz: 8b2761df171c12a676dd3d7efb01af5eb9da737330d03023159c8178d60056ed94d799d0871301fbf9897d481591e33a76f07609f1c038621f2d7d07d96d8995
|
@@ -1,16 +1,57 @@
|
|
1
1
|
module QuizApiClient::Services
|
2
2
|
class AnalysesService < BaseApiService
|
3
3
|
def create(params:, token: nil)
|
4
|
-
|
4
|
+
post_to_analyses(params: params, token: token)
|
5
5
|
end
|
6
6
|
|
7
|
-
|
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)
|
13
|
+
end
|
14
|
+
|
15
|
+
def show(params:, token: nil)
|
16
|
+
client(token: token).get(
|
17
|
+
"/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}",
|
18
|
+
query: { filter: :last_attempt }
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def export(params:, token: nil)
|
23
|
+
client(token: token).get(
|
24
|
+
"/api/quizzes/#{params[:quiz_id]}/analyses/export",
|
25
|
+
query: { filter: :last_attempt, format: :csv, analysis_type: params[:analysis_type] }
|
26
|
+
)
|
27
|
+
end
|
8
28
|
|
9
|
-
def
|
10
|
-
client(token: token).
|
11
|
-
"/api/quizzes/#{params[:quiz_id]}/analyses",
|
12
|
-
params
|
29
|
+
def status(params:, token: nil)
|
30
|
+
client(token: token).get(
|
31
|
+
"/api/quizzes/#{params[:quiz_id]}/analyses/status",
|
32
|
+
query: { filter: :last_attempt, analysis_type: params[:analysis_type] }
|
13
33
|
)
|
14
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
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)
|
55
|
+
end
|
15
56
|
end
|
16
57
|
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 } }
|
@@ -28,4 +30,132 @@ describe QuizApiClient::Services::AnalysesService do
|
|
28
30
|
expect(result.parsed_response).to eql(stubbed_response)
|
29
31
|
end
|
30
32
|
end
|
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
|
+
|
60
|
+
describe '#show' do
|
61
|
+
let(:params) do
|
62
|
+
{ quiz_id: 1, id: 2 }
|
63
|
+
end
|
64
|
+
let(:stubbed_response) { { 'id' => 1 } }
|
65
|
+
let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}?filter=last_attempt" }
|
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}/reports/{id} and returns the response' do
|
78
|
+
result = subject.show(params: params, token: 'token')
|
79
|
+
expect(result.parsed_response).to eql(stubbed_response)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'status' do
|
84
|
+
let(:params) do
|
85
|
+
{ quiz_id: 1, analysis_type: 'item_analysis' }
|
86
|
+
end
|
87
|
+
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
|
+
let(:status_code) { 200 }
|
93
|
+
|
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
|
+
)
|
101
|
+
end
|
102
|
+
|
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)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'export' do
|
110
|
+
let(:params) do
|
111
|
+
{ quiz_id: 1, analysis_type: 'item_analysis' }
|
112
|
+
end
|
113
|
+
let(:stubbed_response) do
|
114
|
+
CSV.generate(headers: true) do |csv|
|
115
|
+
csv << %w[column1 column2 column3]
|
116
|
+
end
|
117
|
+
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
|
+
let(:status_code) { 200 }
|
123
|
+
|
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
|
+
)
|
131
|
+
end
|
132
|
+
|
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]])
|
136
|
+
end
|
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
|
31
161
|
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.19.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:
|
18
|
+
date: 2025-01-27 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: httparty
|