canvas-blueprint-tool 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +39 -0
- data/Gemfile +9 -0
- data/LICENSE.md +24 -0
- data/README.md +6 -0
- data/Rakefile +6 -0
- data/bin/canvas-blueprint-tool +77 -0
- data/lib/canvas-blueprint-tool.rb +17 -0
- data/lib/canvas-blueprint-tool/canvas_interface.rb +42 -0
- data/lib/canvas-blueprint-tool/version.rb +3 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b13c57b4437490890ed32335bc4d81a94c7f58e918261142c39381fde0138129
|
4
|
+
data.tar.gz: 6122505cc43913e8b9eb1f63e2c96bc2025b87e423ac92f244a6ebd46631ba1a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 873a646c543c73520d0d1d43c7562d385bae15e559c960a4eda03c8da6e8b8c5d0263dd573756baf87cd82b036790022533e3d114b5bd96fda1cb418f1c5f45b
|
7
|
+
data.tar.gz: f043a8b3e8af8bc86ed98fae7146443768a67a4b339591e525fde3d6f27701dc9000d1437a5fd41fc56e5c903b6ac0e2a4a0c750cc2b54299f31579bf2d9acea
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Contributing to Learn.co Curriculum
|
2
|
+
|
3
|
+
We're really excited that you're about to contribute to the
|
4
|
+
[open curriculum](https://learn.co/content-license) on
|
5
|
+
[Learn.co](https://learn.co). If this is your first time contributing, please
|
6
|
+
continue reading to learn how to make the most meaningful and useful impact
|
7
|
+
possible.
|
8
|
+
|
9
|
+
## Raising an Issue to Encourage a Contribution
|
10
|
+
|
11
|
+
If you notice a problem with the curriculum that you believe needs improvement
|
12
|
+
, but you're unable to make the change yourself, you should raise a Github issue
|
13
|
+
containing a clear description of the problem. Include relevant snippets of the
|
14
|
+
content and screenshots if applicable. Curriculum owners regularly review
|
15
|
+
issue lists, and your issue will be prioritized and addressed as appropriate.
|
16
|
+
|
17
|
+
## Submitting a Pull Request to Suggest an Improvement
|
18
|
+
|
19
|
+
If you see an opportunity for improvement and can make the change yourself go
|
20
|
+
ahead and use a typical git workflow to make it happen:
|
21
|
+
|
22
|
+
* Fork this curriculum repository
|
23
|
+
* Make the change on your fork, with descriptive commits in the standard format
|
24
|
+
* Open a Pull Request against this repo
|
25
|
+
|
26
|
+
A curriculum owner will review your change and approve or comment on it in due
|
27
|
+
course.
|
28
|
+
|
29
|
+
## Why Contribute?
|
30
|
+
|
31
|
+
Curriculum on Learn is publicly and freely available under Learn's
|
32
|
+
[Educational Content License](https://learn.co/content-license). By embracing an
|
33
|
+
open-source contribution model, our goal is for the curriculum on Learn to
|
34
|
+
become, in time, the best educational content the world has ever seen.
|
35
|
+
|
36
|
+
We need help from the community of Learners to maintain and improve the
|
37
|
+
educational content. Everything from fixing typos, to correcting out-dated
|
38
|
+
information, to improving exposition, to adding better examples, to fixing
|
39
|
+
tests—all contributions to making the curriculum more effective are welcome.
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Learn.co Educational Content License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Flatiron School, Inc
|
4
|
+
|
5
|
+
The Flatiron School, Inc. owns this Educational Content. However, the Flatiron
|
6
|
+
School supports the development and availability of educational materials in the
|
7
|
+
public domain. Therefore, the Flatiron School grants Users of the Flatiron
|
8
|
+
Educational Content set forth in this repository certain rights to reuse, build
|
9
|
+
upon and share such Educational Content subject to the terms of the Educational
|
10
|
+
Content License set forth
|
11
|
+
[here](http://learn.co/content-license)(http://learn.co/content-license). You
|
12
|
+
must read carefully the terms and conditions contained in the Educational
|
13
|
+
Content License as such terms govern access to and use of the Educational
|
14
|
+
Content.
|
15
|
+
|
16
|
+
Flatiron School is willing to allow you access to and use of the Educational
|
17
|
+
Content only on the condition that you accept all of the terms and conditions
|
18
|
+
contained in the Educational Content License set forth
|
19
|
+
[here](http://learn.co/content-license) (http://learn.co/content-license). By
|
20
|
+
accessing and/or using the Educational Content, you are agreeing to all of the
|
21
|
+
terms and conditions contained in the Educational Content License. If you do
|
22
|
+
not agree to any or all of the terms of the Educational Content License, you are
|
23
|
+
prohibited from accessing, reviewing or using in any way the Educational
|
24
|
+
Content.
|
data/README.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
# Canvas Blueprint Tool
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
The Canvas Blueprint Tool is a Ruby gem wrapper for specific Canvas LMS API endpoints. Using this gem,
|
6
|
+
a Canvas acourse can be associated with a blueprint course via the command-line. Canvas courses can also be published using this gem.
|
data/Rakefile
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'canvas-blueprint-tool'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.banner = <<-EOBANNER
|
9
|
+
Canvas Blueprint Tool
|
10
|
+
====================
|
11
|
+
|
12
|
+
canvas-blueprint-tool --associate --course <course_id> --blueprint <blueprint_id>
|
13
|
+
canvas-blueprint-tool --create-and-associate --blueprint <blueprint_id>
|
14
|
+
canvas-blueprint-tool --sync-courses --blueprint <course_id>
|
15
|
+
canvas-blueprint-tool --sync-courses --blueprint <course_id> --publish-newly-associated
|
16
|
+
|
17
|
+
EOBANNER
|
18
|
+
|
19
|
+
opts.on("-v", "--version",
|
20
|
+
"Output the gem version") do |version|
|
21
|
+
options[:version] = true
|
22
|
+
end
|
23
|
+
opts.on("-a", "--associate",
|
24
|
+
"Associate a course with a blueprint. Requires --course and --blueprint flags") do |associate|
|
25
|
+
options[:associate] = true
|
26
|
+
end
|
27
|
+
opts.on("-s", "--sync-courses",
|
28
|
+
"Sync a blueprint course and its associated courses. Requires --blueprint flag") do |publish|
|
29
|
+
options[:sync] = true
|
30
|
+
end
|
31
|
+
opts.on("-p", "--publish-newly-associated",
|
32
|
+
"Used with -s. Publishes any courses newly associated with a blueprintt. Requires --sync-courses and --blueprint flag") do |publish|
|
33
|
+
options[:publish_newly_associated] = true
|
34
|
+
end
|
35
|
+
opts.on("--create-and-associate",
|
36
|
+
"Creates a new course and associates it with the provided blueprint. Requires --blueprint flag") do |create_and_associate|
|
37
|
+
options[:create_and_associate] = true
|
38
|
+
end
|
39
|
+
opts.on("-cCOURSE", "--course COURSE",
|
40
|
+
"Provide a course ID. Used for associating and publishing") do |course_id|
|
41
|
+
options[:course_id] = course_id
|
42
|
+
end
|
43
|
+
opts.on("-bCOURSE", "--blueprint COURSE",
|
44
|
+
"Provide a blueprint course ID. Used for associating a course to a blueprint") do |blueprint_id|
|
45
|
+
options[:blueprint_id] = blueprint_id
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end.parse!
|
50
|
+
|
51
|
+
if options[:version]
|
52
|
+
CanvasBlueprintTool.new(mode: 'version')
|
53
|
+
abort
|
54
|
+
end
|
55
|
+
|
56
|
+
if options[:associate]
|
57
|
+
if !options[:course_id] || !options[:blueprint_id]
|
58
|
+
raise Exception.new "Associate option requires course and blueprint IDs using the --course and --blueprint flags"
|
59
|
+
abort
|
60
|
+
end
|
61
|
+
CanvasBlueprintTool.new(mode: 'associate',
|
62
|
+
course_id: options[:course_id],
|
63
|
+
blueprint_id: options[:blueprint_id])
|
64
|
+
abort
|
65
|
+
end
|
66
|
+
|
67
|
+
if options[:sync]
|
68
|
+
if !options[:blueprint_id]
|
69
|
+
raise Exception.new "Sync option requires a blueprint course ID using the --blueprint flag"
|
70
|
+
abort
|
71
|
+
end
|
72
|
+
CanvasBlueprintTool.new(mode: 'sync',
|
73
|
+
blueprint_id: options[:blueprint_id],
|
74
|
+
publish_newly_associated: !!options[:publish_newly_associated]
|
75
|
+
)
|
76
|
+
abort
|
77
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative './canvas-blueprint-tool/canvas_interface'
|
2
|
+
|
3
|
+
class CanvasBlueprintTool
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
case options[:mode]
|
7
|
+
when 'version'
|
8
|
+
puts VERSION
|
9
|
+
when 'associate'
|
10
|
+
CanvasInterface.associate(options)
|
11
|
+
when 'sync'
|
12
|
+
CanvasInterface.sync(options)
|
13
|
+
else
|
14
|
+
puts VERSION
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class CanvasInterface
|
5
|
+
|
6
|
+
def self.associate(options)
|
7
|
+
url = "#{ENV['CANVAS_API_PATH']}/courses/#{options[:blueprint_id]}/blueprint_templates/default/update_associations"
|
8
|
+
payload = {
|
9
|
+
'course_ids_to_add' => options[:course_id]
|
10
|
+
}
|
11
|
+
response = RestClient.put(url, payload, self.headers)
|
12
|
+
response = JSON.parse(response)
|
13
|
+
if response["success"]
|
14
|
+
puts "Success: Course #{options[:course_id]} newly associated or was already associated with blueprint course #{options[:blueprint_id]}"
|
15
|
+
else
|
16
|
+
puts "Something went wrong while trying to associate course #{options[:course_id]} with blueprint course #{options[:blueprint_id]}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.sync(options)
|
21
|
+
|
22
|
+
url = "#{ENV['CANVAS_API_PATH']}/courses/#{options[:blueprint_id]}/blueprint_templates/default/migrations"
|
23
|
+
payload = {
|
24
|
+
'comment' => "Automatic association using canvas-blueprint-tool gem",
|
25
|
+
'send_notification' => true,
|
26
|
+
'publish_after_initial_sync' => options[:publish_newly_associated]
|
27
|
+
}
|
28
|
+
response = RestClient.post(url, payload, self.headers)
|
29
|
+
response = JSON.parse(response)
|
30
|
+
if response["workflow_state"] == "queued"
|
31
|
+
puts "Syncing courses from blueprint course #{options[:blueprint_id]}"
|
32
|
+
else
|
33
|
+
puts "Something may have gone wrong syncing courses from blueprint course #{options[:blueprint_id]}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.headers
|
38
|
+
{
|
39
|
+
"Authorization" => "Bearer #{ENV['CANVAS_API_KEY']}"
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: canvas-blueprint-tool
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- maxwellbenton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-04-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.15'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.3'
|
55
|
+
description:
|
56
|
+
email: curriculum@flatironschool.com
|
57
|
+
executables:
|
58
|
+
- canvas-blueprint-tool
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- CONTRIBUTING.md
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.md
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/canvas-blueprint-tool
|
68
|
+
- lib/canvas-blueprint-tool.rb
|
69
|
+
- lib/canvas-blueprint-tool/canvas_interface.rb
|
70
|
+
- lib/canvas-blueprint-tool/version.rb
|
71
|
+
homepage: https://github.com/learn-co-curriculum/canvas-blueprint-tool
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubygems_version: 3.2.3
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: canvas-blueprint-tool is a tool for associating and publishing courses on
|
94
|
+
the Canvas LMS
|
95
|
+
test_files: []
|