bearcat 1.0.0 → 1.5.24
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 +7 -0
- data/bearcat.gemspec +15 -5
- data/lib/badgrcat/api_array.rb +25 -0
- data/lib/badgrcat/client/methods.rb +54 -0
- data/lib/badgrcat/client.rb +53 -0
- data/lib/badgrcat/version.rb +3 -0
- data/lib/bearcat/api_array.rb +132 -65
- data/lib/bearcat/client/account_reports.rb +6 -14
- data/lib/bearcat/client/accounts.rb +18 -6
- data/lib/bearcat/client/analytics.rb +12 -0
- data/lib/bearcat/client/assignment_groups.rb +15 -0
- data/lib/bearcat/client/assignments.rb +17 -9
- data/lib/bearcat/client/blueprint_courses.rb +25 -0
- data/lib/bearcat/client/calendar_events.rb +9 -17
- data/lib/bearcat/client/canvas_files.rb +0 -2
- data/lib/bearcat/client/conferences.rb +3 -8
- data/lib/bearcat/client/content_exports.rb +39 -0
- data/lib/bearcat/client/content_migrations.rb +54 -0
- data/lib/bearcat/client/conversations.rb +3 -8
- data/lib/bearcat/client/courses.rb +25 -14
- data/lib/bearcat/client/custom_gradebook_columns.rb +21 -0
- data/lib/bearcat/client/discussions.rb +10 -4
- data/lib/bearcat/client/enrollments.rb +9 -25
- data/lib/bearcat/client/external_tools.rb +18 -0
- data/lib/bearcat/client/file_helper.rb +36 -30
- data/lib/bearcat/client/files.rb +9 -0
- data/lib/bearcat/client/folders.rb +24 -0
- data/lib/bearcat/client/graph_ql.rb +17 -0
- data/lib/bearcat/client/group_categories.rb +18 -0
- data/lib/bearcat/client/group_memberships.rb +14 -0
- data/lib/bearcat/client/groups.rb +10 -2
- data/lib/bearcat/client/learning_outcomes.rb +17 -0
- data/lib/bearcat/client/logins.rb +20 -0
- data/lib/bearcat/client/module_items.rb +18 -0
- data/lib/bearcat/client/modules.rb +12 -7
- data/lib/bearcat/client/o_auth2.rb +18 -9
- data/lib/bearcat/client/outcome_groups.rb +2 -4
- data/lib/bearcat/client/outcome_imports.rb +48 -0
- data/lib/bearcat/client/outcomes.rb +4 -7
- data/lib/bearcat/client/pages.rb +15 -0
- data/lib/bearcat/client/progresses.rb +9 -0
- data/lib/bearcat/client/quizzes.rb +13 -9
- data/lib/bearcat/client/reports.rb +37 -17
- data/lib/bearcat/client/roles.rb +15 -0
- data/lib/bearcat/client/rubric.rb +17 -0
- data/lib/bearcat/client/rubric_assessment.rb +13 -0
- data/lib/bearcat/client/rubric_association.rb +13 -0
- data/lib/bearcat/client/search.rb +9 -0
- data/lib/bearcat/client/sections.rb +10 -17
- data/lib/bearcat/client/sis_imports.rb +6 -12
- data/lib/bearcat/client/submissions.rb +53 -21
- data/lib/bearcat/client/tabs.rb +12 -0
- data/lib/bearcat/client/users.rb +32 -13
- data/lib/bearcat/client.rb +111 -45
- data/lib/bearcat/client_module.rb +103 -0
- data/lib/bearcat/rate_limiting/increment_bucket.lua +33 -0
- data/lib/bearcat/rate_limiting/redis_script.rb +164 -0
- data/lib/bearcat/rate_limiting.rb +69 -0
- data/lib/bearcat/redis_connection.rb +106 -0
- data/lib/bearcat/spec_helpers.rb +125 -0
- data/lib/bearcat/version.rb +1 -1
- data/lib/bearcat.rb +49 -0
- data/lib/catalogcat/api_array.rb +22 -0
- data/lib/catalogcat/client/catalogs.rb +21 -0
- data/lib/catalogcat/client/certificates.rb +17 -0
- data/lib/catalogcat/client/courses.rb +25 -0
- data/lib/catalogcat/client/email_domain_sets.rb +17 -0
- data/lib/catalogcat/client/enrollments.rb +25 -0
- data/lib/catalogcat/client/orders.rb +13 -0
- data/lib/catalogcat/client/user_registrations.rb +9 -0
- data/lib/catalogcat/client.rb +26 -0
- data/lib/catalogcat/version.rb +3 -0
- data/lib/catalogcat.rb +14 -0
- data/spec/bearcat/api_array_spec.rb +112 -0
- data/spec/bearcat/client/accounts_spec.rb +71 -1
- data/spec/bearcat/client/analytics_spec.rb +22 -0
- data/spec/bearcat/client/assignment_groups_spec.rb +47 -0
- data/spec/bearcat/client/assignments_spec.rb +43 -0
- data/spec/bearcat/client/blueprint_courses_spec.rb +43 -0
- data/spec/bearcat/client/canvas_files_spec.rb +1 -2
- data/spec/bearcat/client/content_exports_spec.rb +68 -0
- data/spec/bearcat/client/content_migrations_spec.rb +94 -0
- data/spec/bearcat/client/courses_spec.rb +81 -2
- data/spec/bearcat/client/custom_gradebook_columns_spec.rb +66 -0
- data/spec/bearcat/client/discussions_spec.rb +73 -0
- data/spec/bearcat/client/enrollments_spec.rb +10 -0
- data/spec/bearcat/client/external_tools_spec.rb +106 -0
- data/spec/bearcat/client/files_spec.rb +15 -0
- data/spec/bearcat/client/folders_spec.rb +18 -0
- data/spec/bearcat/client/graph_ql_spec.rb +35 -0
- data/spec/bearcat/client/group_categories_spec.rb +45 -0
- data/spec/bearcat/client/group_membership_spec.rb +14 -0
- data/spec/bearcat/client/group_memberships_spec.rb +36 -0
- data/spec/bearcat/client/groups_spec.rb +46 -0
- data/spec/bearcat/client/learning_outcomes_spec.rb +25 -0
- data/spec/bearcat/client/module_items_spec.rb +60 -0
- data/spec/bearcat/client/modules_spec.rb +38 -1
- data/spec/bearcat/client/o_auth2_spec.rb +3 -3
- data/spec/bearcat/client/pages_spec.rb +17 -0
- data/spec/bearcat/client/quizzes_spec.rb +41 -4
- data/spec/bearcat/client/reports_spec.rb +40 -1
- data/spec/bearcat/client/roles_spec.rb +24 -0
- data/spec/bearcat/client/rubric_assessment_spec.rb +47 -0
- data/spec/bearcat/client/rubric_association_spec.rb +39 -0
- data/spec/bearcat/client/rubric_spec.rb +45 -0
- data/spec/bearcat/client/search_spec.rb +16 -0
- data/spec/bearcat/client/sections_spec.rb +12 -0
- data/spec/bearcat/client/submissions_spec.rb +47 -2
- data/spec/bearcat/client/users_spec.rb +43 -0
- data/spec/bearcat/client_spec.rb +1 -4
- data/spec/bearcat/rate_limiting_spec.rb +62 -0
- data/spec/bearcat/stub_bearcat_spec.rb +15 -0
- data/spec/fixtures/access_token.json +3 -0
- data/spec/fixtures/account_admin_create.json +14 -0
- data/spec/fixtures/account_admin_delete.json +15 -0
- data/spec/fixtures/account_admins.json +54 -0
- data/spec/fixtures/account_courses.json +48 -0
- data/spec/fixtures/account_grading_standards.json +20 -0
- data/spec/fixtures/account_groups.json +42 -0
- data/spec/fixtures/account_role.json +34 -0
- data/spec/fixtures/account_roles.json +35 -0
- data/spec/fixtures/account_sis_imports.json +39 -0
- data/spec/fixtures/account_sub_accounts.json +17 -0
- data/spec/fixtures/accounts.json +13 -0
- data/spec/fixtures/assignment.json +32 -0
- data/spec/fixtures/assignment_group.json +7 -0
- data/spec/fixtures/assignment_groups.json +16 -0
- data/spec/fixtures/blueprint_migration.json +12 -0
- data/spec/fixtures/blueprint_subscriptions.json +5 -0
- data/spec/fixtures/blueprint_template.json +7 -0
- data/spec/fixtures/blueprint_update_assocations_success.json +3 -0
- data/spec/fixtures/communication_channels.json +10 -0
- data/spec/fixtures/content_export.json +9 -0
- data/spec/fixtures/content_migration_files/content_migration.json +13 -0
- data/spec/fixtures/course_copy.json +18 -0
- data/spec/fixtures/course_files.json +38 -0
- data/spec/fixtures/course_folder.json +21 -0
- data/spec/fixtures/course_folders.json +44 -0
- data/spec/fixtures/course_grading_standards.json +20 -0
- data/spec/fixtures/course_settings.json +33 -0
- data/spec/fixtures/create_course_discussion.json +44 -0
- data/spec/fixtures/created_group.json +37 -0
- data/spec/fixtures/created_group_category.json +15 -0
- data/spec/fixtures/created_group_membership.json +8 -0
- data/spec/fixtures/created_module.json +13 -0
- data/spec/fixtures/custom_gradebook_columns/column_data.json +4 -0
- data/spec/fixtures/custom_gradebook_columns/custom_gradebook_column.json +7 -0
- data/spec/fixtures/custom_gradebook_columns/custom_gradebook_columns.json +16 -0
- data/spec/fixtures/custom_gradebook_columns/gradebook_column_progress.json +14 -0
- data/spec/fixtures/dashboard.json +6 -0
- data/spec/fixtures/delete_course.json +3 -0
- data/spec/fixtures/delete_group_category.json +3 -0
- data/spec/fixtures/deleted_group.json +37 -0
- data/spec/fixtures/department_level_participation.json +73 -0
- data/spec/fixtures/department_level_statistics.json +10 -0
- data/spec/fixtures/discussion_entries.json +21 -0
- data/spec/fixtures/discussion_entry_replies.json +21 -0
- data/spec/fixtures/discussion_topic.json +49 -0
- data/spec/fixtures/discussion_topics.json +51 -0
- data/spec/fixtures/edited_group.json +129 -0
- data/spec/fixtures/edited_group_category.json +15 -0
- data/spec/fixtures/enrollment_terms.json +1 -1
- data/spec/fixtures/external_tool.json +55 -0
- data/spec/fixtures/external_tools.json +57 -0
- data/spec/fixtures/file.csv +5 -0
- data/spec/fixtures/gradebook_history.json +52 -0
- data/spec/fixtures/graph_ql_scores.json +33 -0
- data/spec/fixtures/group.json +15 -0
- data/spec/fixtures/group_categories.json +28 -0
- data/spec/fixtures/group_category.json +13 -0
- data/spec/fixtures/group_category_groups.json +20 -0
- data/spec/fixtures/group_membership.json +7 -0
- data/spec/fixtures/learning_outcome.json +32 -0
- data/spec/fixtures/merge_user.json +8 -0
- data/spec/fixtures/module.json +15 -0
- data/spec/fixtures/module_item.json +15 -0
- data/spec/fixtures/module_items.json +47 -0
- data/spec/fixtures/ok.json +3 -0
- data/spec/fixtures/outcome_result.json +13 -0
- data/spec/fixtures/pages.json +40 -0
- data/spec/fixtures/progress.json +13 -0
- data/spec/fixtures/quizzes/course_quiz_questions.json +59 -0
- data/spec/fixtures/quizzes/quiz_assignment_override.json +31 -0
- data/spec/fixtures/reactivate_enrollment.json +20 -0
- data/spec/fixtures/rubric.json +13 -0
- data/spec/fixtures/rubric_assessment.json +32 -0
- data/spec/fixtures/rubric_association.json +13 -0
- data/spec/fixtures/search_find_recipients.json +10 -0
- data/spec/fixtures/update_section.json +1 -1
- data/spec/fixtures/user_details.json +16 -0
- data/spec/fixtures/user_logins.json +9 -0
- data/spec/helper.rb +2 -0
- metadata +336 -43
@@ -13,4 +13,50 @@ describe Bearcat::Client::Groups do
|
|
13
13
|
groups.last['id'].should == 4
|
14
14
|
end
|
15
15
|
|
16
|
+
it "returns account groups" do
|
17
|
+
stub_get(@client, "/api/v1/accounts/1/groups").to_return(json_response("account_groups.json"))
|
18
|
+
groups = @client.account_groups(1)
|
19
|
+
groups.count.should == 2
|
20
|
+
groups.first['name'].should == '2010'
|
21
|
+
groups.last['id'].should == 3
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns group category groups" do
|
25
|
+
stub_get(@client, "/api/v1/group_categories/1/groups").to_return(json_response("group_category_groups.json"))
|
26
|
+
groups = @client.category_groups(1)
|
27
|
+
groups.count.should == 1
|
28
|
+
groups.first['name'].should == 'test group in category'
|
29
|
+
groups.first['id'].should == 94
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns a single group" do
|
33
|
+
stub_get(@client, "/api/v1/groups/3").to_return(json_response("group.json"))
|
34
|
+
group = @client.group(3)
|
35
|
+
group['name'].should == 'group 1'
|
36
|
+
group['id'].should == 3
|
37
|
+
end
|
38
|
+
|
39
|
+
it "creates a group" do
|
40
|
+
name = 'created group 1'
|
41
|
+
stub_post(@client, "/api/v1/group_categories/2/groups").with(body: { name: name }).to_return(json_response("created_group.json"))
|
42
|
+
created_group = @client.create_group(2, { name: name })
|
43
|
+
created_group['name'] == 'created group 1'
|
44
|
+
created_group['context_type'] == 'Course'
|
45
|
+
created_group['group_category']['id'] == 2
|
46
|
+
end
|
47
|
+
|
48
|
+
it "edits a group" do
|
49
|
+
name = 'edited group 1'
|
50
|
+
description = 'edited group 1 description'
|
51
|
+
stub_put(@client, "/api/v1/groups/1").with(body: { name: name, description: description }).to_return(json_response("edited_group.json"))
|
52
|
+
edited_group = @client.edit_group(1, { name: name, description: description })
|
53
|
+
edited_group['name'] == name
|
54
|
+
edited_group['description'] == description
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'deleted a group' do
|
58
|
+
stub_delete(@client, "/api/v1/groups/7").to_return(json_response("deleted_group.json"))
|
59
|
+
deleted_group = @client.delete_group(7)
|
60
|
+
deleted_group['id'] == 7
|
61
|
+
end
|
16
62
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
|
5
|
+
describe Bearcat::Client::LearningOutcomes do
|
6
|
+
before do
|
7
|
+
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an individual learning outcome" do
|
11
|
+
stub_get(@client, "/api/v1/outcomes/1").to_return(json_response("learning_outcome.json"))
|
12
|
+
outcome = @client.learning_outcome(1)
|
13
|
+
outcome["id"].should == 1
|
14
|
+
outcome["context_type"].should == "Course"
|
15
|
+
outcome["title"].should == "First Outcome"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "updates an individual learning outcome" do
|
19
|
+
stub_put(@client, "/api/v1/outcomes/1").to_return(json_response("learning_outcome.json"))
|
20
|
+
outcome = @client.update_learning_outcome(1)
|
21
|
+
outcome["id"].should == 1
|
22
|
+
outcome["context_type"].should == "Course"
|
23
|
+
outcome["title"].should == "First Outcome"
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::ModuleItems do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'returns all items for a module' do
|
9
|
+
stub_get(@client, '/api/v1/courses/1/modules/1/items').to_return(json_response('module_items.json'))
|
10
|
+
items = @client.list_module_items(1,1)
|
11
|
+
items.count.should == 3
|
12
|
+
items.members[0]['id'].should == 1358
|
13
|
+
items.members[0]['type'].should == 'Page'
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#module_item' do
|
17
|
+
it 'returns a module' do
|
18
|
+
stub_get(@client, '/api/v1/courses/1/modules/1/items/2').to_return(json_response('module_item.json'))
|
19
|
+
item = @client.module_item(1, 1, 2)
|
20
|
+
expect(item['id']).to eq(2)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#create_module_item' do
|
25
|
+
it 'creates a module item' do
|
26
|
+
params = { module_item: { title: 'Test Page',
|
27
|
+
content_id: '1-dot-1-intro-to-disease',
|
28
|
+
type: 'Page' }}
|
29
|
+
stub_request(:post, "http://canvas.instructure.com/api/v1/courses/1/modules/1/items")
|
30
|
+
.with(body: params)
|
31
|
+
.to_return(json_response("module_item.json"))
|
32
|
+
module_item = @client.create_module_item(1, 1, params)
|
33
|
+
expect(module_item['title']).to eq('Test Page')
|
34
|
+
expect(module_item['page_url']).to eq('1-dot-1-intro-to-disease')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#update_module_item' do
|
39
|
+
it 'updates a module item' do
|
40
|
+
params = { module_item: { title: 'Test Page',
|
41
|
+
content_id: '1-dot-1-intro-to-disease',
|
42
|
+
type: 'Page' }}
|
43
|
+
stub_request(:put, "http://canvas.instructure.com/api/v1/courses/1/modules/1/items/2")
|
44
|
+
.with(body: params)
|
45
|
+
.to_return(json_response("module_item.json"))
|
46
|
+
module_item = @client.update_module_item(1, 1, 2, params)
|
47
|
+
expect(module_item['title']).to eq('Test Page')
|
48
|
+
expect(module_item['page_url']).to eq('1-dot-1-intro-to-disease')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#delete_module_item' do
|
53
|
+
it 'deletes a module item' do
|
54
|
+
stub_request(:delete, "http://canvas.instructure.com/api/v1/courses/1/modules/1/items/2")
|
55
|
+
.to_return(json_response('module_item.json'))
|
56
|
+
module_item = @client.delete_module_item(1, 1, 2)
|
57
|
+
expect(module_item["id"]).to eq(2)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -21,4 +21,41 @@ describe Bearcat::Client::Modules do
|
|
21
21
|
items.last["id"].should == 3
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
describe "#course_module" do
|
25
|
+
it "returns a course module" do
|
26
|
+
stub_get(@client, "/api/v1/courses/1/modules/2").to_return(json_response("module.json"))
|
27
|
+
context_module = @client.course_module(1, 2)
|
28
|
+
expect(context_module['id']).to eq(2)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#create_module" do
|
33
|
+
it "creates a new module" do
|
34
|
+
name = "new module"
|
35
|
+
stub_request(:post, "http://canvas.instructure.com/api/v1/courses/1/modules")
|
36
|
+
.with(body: {"name"=> name})
|
37
|
+
.to_return(json_response("created_module.json"))
|
38
|
+
course_module = @client.create_module(1, { name: name })
|
39
|
+
course_module["name"].should == name
|
40
|
+
course_module["id"].should == 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#update_module" do
|
45
|
+
it "updates a module" do
|
46
|
+
stub_request(:put, "http://canvas.instructure.com/api/v1/courses/3/modules/2")
|
47
|
+
.to_return(json_response("module.json"))
|
48
|
+
updated_module = @client.update_module(3, 2, {})
|
49
|
+
expect(updated_module['name']).to eq("Second Module")
|
50
|
+
expect(updated_module['id']).to eq(2)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#delete_module" do
|
55
|
+
it "deletes a module" do
|
56
|
+
stub_delete(@client, "/api/v1/courses/3/modules/2").to_return(json_response("module.json"))
|
57
|
+
course_module = @client.delete_module(3, 2)
|
58
|
+
expect(course_module["id"]).to eq(2)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -10,11 +10,11 @@ describe Bearcat::Client::Enrollments do
|
|
10
10
|
|
11
11
|
it "sets the auth_token" do
|
12
12
|
stub_post(client, "/login/oauth2/token").
|
13
|
-
with(:body => {"client_id"=>"10000000000002", "client_secret"=>"secret", "code"=>"code", "redirect_url"=>"http://localhost:9393"}).
|
14
|
-
to_return(
|
13
|
+
with(:body => {"client_id"=>"10000000000002", "client_secret"=>"secret", "code"=>"code", "redirect_url"=>"http://localhost:9393", 'grant_type' => 'authorization_code'}).
|
14
|
+
to_return(json_response('access_token.json'))
|
15
15
|
client.retrieve_token(10000000000002, 'http://localhost:9393', 'secret', 'code')
|
16
16
|
client.config.token.should == "foo_bar_token"
|
17
17
|
client.instance_variable_get(:@connection).headers[:authorization].should == 'Bearer foo_bar_token'
|
18
18
|
end
|
19
19
|
|
20
|
-
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::Pages do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns a courses pages" do
|
9
|
+
stub_get(@client, "/api/v1/courses/1/pages").to_return(json_response("pages.json"))
|
10
|
+
pages = @client.list_course_pages('1')
|
11
|
+
pages.class.should eq(Bearcat::ApiArray)
|
12
|
+
pages.count.should == 2
|
13
|
+
pages.first['page_id'].should == 1
|
14
|
+
pages.last['page_id'].should == 2
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -5,6 +5,14 @@ describe Bearcat::Client::Quizzes do
|
|
5
5
|
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
6
6
|
end
|
7
7
|
|
8
|
+
it "updates a single quiz" do
|
9
|
+
stub_put(@client, "/api/v1/courses/1/quizzes/38").to_return(json_response("quizzes/course_quiz.json"))
|
10
|
+
course_quiz = @client.edit_quiz('1', '38')
|
11
|
+
course_quiz.should be_a Hash
|
12
|
+
course_quiz['id'].should == 38
|
13
|
+
course_quiz[:id].should == 38
|
14
|
+
end
|
15
|
+
|
8
16
|
it "returns a courses quizzes" do
|
9
17
|
stub_get(@client, "/api/v1/courses/1/quizzes").to_return(json_response("quizzes/course_quizzes.json"))
|
10
18
|
course_quizzes = @client.list_course_quizzes('1')
|
@@ -17,15 +25,44 @@ describe Bearcat::Client::Quizzes do
|
|
17
25
|
it "returns a single quiz" do
|
18
26
|
stub_get(@client, "/api/v1/courses/1/quizzes/38").to_return(json_response("quizzes/course_quiz.json"))
|
19
27
|
course_quiz = @client.quiz('1', '38')
|
20
|
-
course_quiz.
|
28
|
+
course_quiz.should be_a Hash
|
21
29
|
course_quiz['id'].should == 38
|
30
|
+
course_quiz[:id].should == 38
|
22
31
|
end
|
23
32
|
|
24
33
|
it 'sets extensions on a quiz' do
|
25
|
-
stub_post(@client, "/api/v1/courses/1/
|
26
|
-
quiz_extension = @client.quiz_extensions('1', {quiz_extensions: [{user_id: 1}, {extra_time: 30}]})
|
27
|
-
quiz_extension.
|
34
|
+
stub_post(@client, "/api/v1/courses/1/quizzes/1/extensions").to_return(json_response("quizzes/quiz_extension.json"))
|
35
|
+
quiz_extension = @client.quiz_extensions('1', '1', {quiz_extensions: [{user_id: 1}, {extra_time: 30}]})
|
36
|
+
quiz_extension.should be_a Hash
|
28
37
|
quiz_extension['quiz_extensions'].first['extra_time'].should eq(30)
|
38
|
+
quiz_extension[:quiz_extensions].first[:extra_time].should eq(30)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns a quiz assignment override' do
|
42
|
+
stub_get(@client, "/api/v1/courses/1/quizzes/assignment_overrides?quiz_assignment_overrides%5B%5D%5Bquiz_ids%5D=13").to_return(json_response("quizzes/quiz_assignment_override.json"))
|
43
|
+
quiz_overrides = @client.quiz_assignment_overrides('1',{:quiz_assignment_overrides => [{ :quiz_ids => 13 }] })
|
44
|
+
quiz_overrides.should be_a Hash
|
45
|
+
quiz_overrides['quiz_assignment_overrides'].first['quiz_id'].should eq(1014)
|
46
|
+
quiz_overrides[:quiz_assignment_overrides].first[:quiz_id].should eq(1014)
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
it 'creates a new quiz' do
|
51
|
+
name = "test quiz"
|
52
|
+
stub_post(@client, "/api/v1/courses/1/quizzes").with(body: {"quiz" => {"title" => name}}).to_return(json_response("quizzes/course_quiz.json"))
|
53
|
+
quiz = @client.create_quiz(1, {"quiz" => {"title" => name}})
|
54
|
+
quiz["title"].should == 'Second Quiz'
|
55
|
+
quiz["id"].should == 38
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'returns quiz questions' do
|
59
|
+
stub_get(@client, "/api/v1/courses/1/quizzes/1/questions").to_return(json_response("quizzes/course_quiz_questions.json"))
|
60
|
+
course_quiz_questions = @client.quiz_questions('1', '1')
|
61
|
+
course_quiz_questions.class.should eq(Bearcat::ApiArray)
|
62
|
+
course_quiz_questions.count.should == 1
|
63
|
+
course_quiz_questions[0].should be_a Hash
|
64
|
+
course_quiz_questions[0]['id'].should == 1
|
65
|
+
course_quiz_questions[0][:id].should == 1
|
29
66
|
end
|
30
67
|
|
31
68
|
end
|
@@ -35,4 +35,43 @@ describe Bearcat::Client::Reports do
|
|
35
35
|
status['report'] == 'last_user_access_csv'
|
36
36
|
end
|
37
37
|
|
38
|
-
|
38
|
+
context '#download_report' do
|
39
|
+
it 'downloads a report to memory' do
|
40
|
+
report = IO.read(fixture('file.csv'))
|
41
|
+
stub_request(:head, 'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string').to_return(status: 200, body: report)
|
42
|
+
stub_request(:get, 'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string').to_return(status: 200, body: report)
|
43
|
+
csv = @client.download_report('https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string')
|
44
|
+
expect(csv.count).to eq 4
|
45
|
+
expect(csv.first.fields).to eq ['132',nil,'Alg202CR','Algebra 2 Semester 2 Credit Recovery','11',nil,'1',nil,'unpublished',nil,nil,'false']
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'downloads a report to disk' do
|
49
|
+
report = IO.read(fixture('file.csv'))
|
50
|
+
tempfile = Tempfile.new('report')
|
51
|
+
stub_request(:head, 'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string').to_return(status: 200, body: report)
|
52
|
+
stub_request(:get,'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string').to_return(status: 200, body: report)
|
53
|
+
@client.download_report('https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string', tempfile)
|
54
|
+
csv = CSV.read(tempfile, headers: true)
|
55
|
+
expect(csv.count).to eq 4
|
56
|
+
expect(csv.first.fields).to eq ['132',nil,'Alg202CR','Algebra 2 Semester 2 Credit Recovery','11',nil,'1',nil,'unpublished',nil,nil,'false']
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'follows redirects' do
|
60
|
+
report = IO.read(fixture('file.csv'))
|
61
|
+
tempfile = Tempfile.new('report')
|
62
|
+
stub_request(:head, 'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string')
|
63
|
+
.to_return(status: 302, body: 'You are being redirected',headers: {'Location' => 'https://cluster1-files.instructure.com/files/1/download?download_frd=1&sf_verifier=verifier=1478139862&user_id=1&verifier=verifier'})
|
64
|
+
stub_request(:head, 'https://cluster1-files.instructure.com/files/1/download?download_frd=1&sf_verifier=verifier=1478139862&user_id=1&verifier=verifier')
|
65
|
+
.to_return(status: 302, body: 'You are being redirected', headers: {'Location' => 'https://instructure-uploads.s3.amazonaws.com/account_1/attachments/1/assignment_submission.csv'})
|
66
|
+
stub_request(:head, 'https://instructure-uploads.s3.amazonaws.com/account_1/attachments/1/assignment_submission.csv')
|
67
|
+
.to_return(status: 200)
|
68
|
+
stub_request(:get, 'https://instructure-uploads.s3.amazonaws.com/account_1/attachments/1/assignment_submission.csv')
|
69
|
+
.to_return(status: 200, body: report)
|
70
|
+
@client.download_report('https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string', tempfile)
|
71
|
+
csv = CSV.read(tempfile, headers: true)
|
72
|
+
expect(csv.count).to eq 4
|
73
|
+
expect(csv.first.fields).to eq ['132',nil,'Alg202CR','Algebra 2 Semester 2 Credit Recovery','11',nil,'1',nil,'unpublished',nil,nil,'false']
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::Roles do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns all roles" do
|
9
|
+
stub_get(@client, "/api/v1/accounts/self/roles").to_return(json_response("account_roles.json"))
|
10
|
+
roles = @client.roles
|
11
|
+
roles.count.should == 1
|
12
|
+
roles.first["label"].should == 'Account Admin'
|
13
|
+
roles.first["id"].should == 1
|
14
|
+
roles.first["base_role_type"].should == 'AccountMembership'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns an individual role" do
|
18
|
+
stub_get(@client, "/api/v1/accounts/self/roles/1").to_return(json_response("account_role.json"))
|
19
|
+
role = @client.role(1)
|
20
|
+
role["label"].should == 'Account Admin'
|
21
|
+
role["id"].should == 1
|
22
|
+
role["base_role_type"].should == 'AccountMembership'
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::RubricAssessment do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix:"http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "creates a rubric assessment" do
|
9
|
+
stub_post(@client, "/api/v1/courses/72/rubric_associations/4/rubric_assessments")
|
10
|
+
.with(:body => {
|
11
|
+
"rubric_assessment"=>{
|
12
|
+
"user_id"=>"22",
|
13
|
+
"assessor_id"=>"1"
|
14
|
+
}
|
15
|
+
}).to_return(json_response("rubric_assessment.json"))
|
16
|
+
rubric = @client.create_course_rubric_assessment(72, 4,
|
17
|
+
{"rubric_assessment[user_id]" => "22", "rubric_assessment[assessor_id]" => "1"})
|
18
|
+
rubric['id'].should == 5
|
19
|
+
rubric['assessor_id'].should == 1
|
20
|
+
rubric['user_id'].should == 22
|
21
|
+
end
|
22
|
+
|
23
|
+
it "updates a rubric assessment" do
|
24
|
+
stub_put(@client, "/api/v1/courses/72/rubric_associations/4/rubric_assessments/5")
|
25
|
+
.with(:body => {
|
26
|
+
"rubric_assessment"=>{
|
27
|
+
"user_id"=>"22",
|
28
|
+
"assessor_id"=>"1"
|
29
|
+
}
|
30
|
+
}).to_return(json_response("rubric_assessment.json"))
|
31
|
+
rubric = @client.update_course_rubric_assessment(72, 4, 5,
|
32
|
+
{"rubric_assessment[user_id]" => "22", "rubric_assessment[assessor_id]" => "1"})
|
33
|
+
rubric['id'].should == 5
|
34
|
+
rubric['assessor_id'].should == 1
|
35
|
+
rubric['user_id'].should == 22
|
36
|
+
end
|
37
|
+
|
38
|
+
it "deletes a rubric assessment" do
|
39
|
+
stub_delete(@client, "/api/v1/courses/72/rubric_associations/4/rubric_assessments/5")
|
40
|
+
.to_return(json_response("rubric_assessment.json"))
|
41
|
+
rubric_assessment = @client.delete_course_rubric_assessment(72, 4, 5)
|
42
|
+
rubric_assessment['id'].should == 5
|
43
|
+
rubric_assessment['assessor_id'].should == 1
|
44
|
+
rubric_assessment['user_id'].should == 22
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::RubricAssessment do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix:"http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "creates a rubric association" do
|
9
|
+
stub_post(@client, "/api/v1/courses/72/rubric_associations")
|
10
|
+
.with(:body => {"rubric_id" => "1", "score" => "5"})
|
11
|
+
.to_return(json_response("rubric_association.json"))
|
12
|
+
rubric_association = @client.create_course_rubric_association(72,
|
13
|
+
{"rubric_id" => "1", "score" => "5"})
|
14
|
+
rubric_association['id'].should == 1
|
15
|
+
rubric_association['rubric_id'].should == 1
|
16
|
+
rubric_association['score'].should == 5
|
17
|
+
end
|
18
|
+
|
19
|
+
it "updates a rubric association" do
|
20
|
+
stub_put(@client, "/api/v1/courses/72/rubric_associations/4")
|
21
|
+
.with(:body => {"rubric_id" => "1", "score" => "5"})
|
22
|
+
.to_return(json_response("rubric_association.json"))
|
23
|
+
rubric_association = @client.update_course_rubric_association(72, 4,
|
24
|
+
{"rubric_id" => "1", "score" => "5"})
|
25
|
+
rubric_association['id'].should == 1
|
26
|
+
rubric_association['rubric_id'].should == 1
|
27
|
+
rubric_association['score'].should == 5
|
28
|
+
end
|
29
|
+
|
30
|
+
it "deletes a rubric association" do
|
31
|
+
stub_delete(@client, "/api/v1/courses/72/rubric_associations/4")
|
32
|
+
.to_return(json_response("rubric_association.json"))
|
33
|
+
rubric_association = @client.delete_course_rubric_association(72, 4)
|
34
|
+
rubric_association['id'].should == 1
|
35
|
+
rubric_association['rubric_id'].should == 1
|
36
|
+
rubric_association['score'].should == 5
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::Rubric do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix:"http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns a rubric for a course" do
|
9
|
+
stub_get(@client, "/api/v1/courses/72/rubrics/1").to_return(json_response("rubric.json"))
|
10
|
+
rubric = @client.course_rubric(72, 1)
|
11
|
+
rubric['id'].should == 1
|
12
|
+
rubric['title'].should == 'Rubric title'
|
13
|
+
rubric['context_type'].should == 'Course'
|
14
|
+
rubric['points_possible'].should == 10
|
15
|
+
end
|
16
|
+
|
17
|
+
it "creates a rubric" do
|
18
|
+
stub_post(@client, "/api/v1/courses/72/rubrics").
|
19
|
+
with(:body => {"rubric_assessment"=>{"user_id"=>"22"}}).to_return(json_response("rubric.json"))
|
20
|
+
rubric = @client.create_course_rubric(72, {rubric_assessment: {user_id: "22"}})
|
21
|
+
rubric['id'].should == 1
|
22
|
+
rubric['title'].should == 'Rubric title'
|
23
|
+
rubric['context_type'].should == 'Course'
|
24
|
+
rubric['points_possible'].should == 10
|
25
|
+
end
|
26
|
+
|
27
|
+
it "updates a rubric" do
|
28
|
+
stub_put(@client, "/api/v1/courses/72/rubrics/1")
|
29
|
+
.with(:body => {"rubric_assessment"=>{"user_id"=>"22"}}).to_return(json_response("rubric.json"))
|
30
|
+
rubric = @client.update_course_rubric(72, 1, {rubric_assessment: {user_id: "22"}})
|
31
|
+
rubric['id'].should == 1
|
32
|
+
rubric['title'].should == 'Rubric title'
|
33
|
+
rubric['context_type'].should == 'Course'
|
34
|
+
rubric['points_possible'].should == 10
|
35
|
+
end
|
36
|
+
|
37
|
+
it "deletes a rubric" do
|
38
|
+
stub_delete(@client, "/api/v1/courses/72/rubrics/1").to_return(json_response("rubric.json"))
|
39
|
+
rubric = @client.delete_course_rubric(72, 1)
|
40
|
+
rubric['title'].should == 'Rubric title'
|
41
|
+
rubric['context_type'].should == 'Course'
|
42
|
+
rubric['points_possible'].should == 10
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::Search do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix:"http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns search results for recipients" do
|
9
|
+
stub_get(@client, "/api/v1/conversations/find_recipients?search=test").to_return(json_response("search_find_recipients.json"))
|
10
|
+
results = @client.find_recipients(:search => 'test')
|
11
|
+
results.first['name'].should == 'Test'
|
12
|
+
results.first['id'].should == 9
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
end
|
@@ -46,4 +46,16 @@ describe Bearcat::Client::Sections do
|
|
46
46
|
section['name'].should == 'Section003'
|
47
47
|
end
|
48
48
|
|
49
|
+
it "crosslist a section" do
|
50
|
+
stub_post(@client, "/api/v1/sections/72/crosslist/2").to_return(json_response("update_section.json"))
|
51
|
+
section = @client.crosslist_section(72, 2)
|
52
|
+
section['nonxlist_course_id'].should == 2
|
53
|
+
end
|
54
|
+
|
55
|
+
it "de-crosslist a section" do
|
56
|
+
stub_delete(@client, "/api/v1/sections/72/crosslist").to_return(json_response("update_section.json"))
|
57
|
+
section = @client.decrosslist_section(72)
|
58
|
+
section['nonxlist_course_id'].should == 2
|
59
|
+
end
|
60
|
+
|
49
61
|
end
|
@@ -21,6 +21,22 @@ describe Bearcat::Client::Submissions do
|
|
21
21
|
submissions['workflow_state'].should =='unsubmitted'
|
22
22
|
end
|
23
23
|
|
24
|
+
it "returns all submissions for a course, user, submission" do
|
25
|
+
stub_get(@client, "/api/v1/courses/3/assignments/2353405/submissions/682285").to_return(json_response('submissions', "submission.json"))
|
26
|
+
submissions = @client.user_course_assignment_submission(3, 2353405, 682285)
|
27
|
+
submissions['assignment_id'].should == 2353405
|
28
|
+
submissions['id'].should == 8444510
|
29
|
+
submissions['score'].should == 1
|
30
|
+
submissions['grade'].should == '1'
|
31
|
+
submissions['user_id'].should == 682285
|
32
|
+
submissions['workflow_state'].should =='unsubmitted'
|
33
|
+
submissions['late'].should == false
|
34
|
+
submissions['preview_url'].should =='https://canvas.instructure.com/courses/218274/assignments/2353405/submissions/682285?preview=1'
|
35
|
+
submissions['workflow_state'].should =='unsubmitted'
|
36
|
+
submissions['workflow_state'].should =='unsubmitted'
|
37
|
+
submissions['workflow_state'].should =='unsubmitted'
|
38
|
+
end
|
39
|
+
|
24
40
|
context 'course' do
|
25
41
|
it "submits a file" do
|
26
42
|
@client.stub(:upload_file).and_return({})
|
@@ -28,16 +44,45 @@ describe Bearcat::Client::Submissions do
|
|
28
44
|
response = @client.course_file_upload_submission(1, 2, 3, fixture('bearcat.jpg'))
|
29
45
|
response['id'].should == 8444510
|
30
46
|
end
|
47
|
+
|
48
|
+
it "submits multiple files" do
|
49
|
+
@client.stub(:upload_file).and_return({})
|
50
|
+
stub_post(@client, '/api/v1/courses/1/assignments/2/submissions').to_return(json_response('submissions', 'submission.json'))
|
51
|
+
response = @client.course_file_upload_submission(1, 2, 3, [fixture('bearcat.jpg'), fixture('file.csv')])
|
52
|
+
response['id'].should == 8444510
|
53
|
+
end
|
54
|
+
|
55
|
+
it "updates grades" do
|
56
|
+
params = {"grade_data[123]" => "19"}
|
57
|
+
stub_post(@client, "/api/v1/courses/1/assignments/1/submissions/update_grades").with(body: {"grade_data"=>["19"]}).to_return(json_response("progress.json"))
|
58
|
+
response = @client.course_update_grades(1, 1, params)
|
59
|
+
expect(response['user_id']).to eq 123
|
60
|
+
expect(response['workflow_state']).to eq 'completed'
|
61
|
+
end
|
31
62
|
end
|
32
63
|
|
33
64
|
context 'section' do
|
34
65
|
it "submits a file" do
|
66
|
+
@client.stub(:upload_file).and_return({})
|
67
|
+
stub_post(@client, '/api/v1/sections/1/assignments/2/submissions').to_return(json_response('submissions', 'submission.json'))
|
68
|
+
response = @client.section_file_upload_submission(1, 2, 3, [fixture('bearcat.jpg'), fixture('file.csv')])
|
69
|
+
response['id'].should == 8444510
|
70
|
+
end
|
71
|
+
|
72
|
+
it "submits multiple files" do
|
35
73
|
@client.stub(:upload_file).and_return({})
|
36
74
|
stub_post(@client, '/api/v1/sections/1/assignments/2/submissions').to_return(json_response('submissions', 'submission.json'))
|
37
75
|
response = @client.section_file_upload_submission(1, 2, 3, fixture('bearcat.jpg'))
|
38
76
|
response['id'].should == 8444510
|
39
77
|
end
|
40
|
-
end
|
41
78
|
|
79
|
+
it "updates grades" do
|
80
|
+
params = {"grade_data[123]" => "19"}
|
81
|
+
stub_post(@client, "/api/v1/sections/9/assignments/1/submissions/update_grades").with(body: {"grade_data"=>["19"]}).to_return(json_response("progress.json"))
|
82
|
+
response = @client.section_update_grades(9, 1, params)
|
83
|
+
expect(response['user_id']).to eq 123
|
84
|
+
expect(response['workflow_state']).to eq 'completed'
|
85
|
+
end
|
86
|
+
end
|
42
87
|
|
43
|
-
end
|
88
|
+
end
|