github-to-canvas 0.0.11 → 0.0.12
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: 292c75129f49e571976390d008441b48b83af93ffcecbabc5071799aef6656f8
|
4
|
+
data.tar.gz: 831f32335f994923d179b8e819bbed986ee7a57ababa8789064b904b39407f32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0b0a5114f5e92d37ba700713c6d8071034f5915e9000e9e0174fef948f56b32ed42355badddf367fc6863e2f6947efbbaa450a7d0887a5b343c97fb75e76d22
|
7
|
+
data.tar.gz: df8a0118fccacf35ac7c93823899830c4ec7e82f62915f15d29ae4e713161a097997b254510089f1b79aca1c298939f2c01bd42f55cc1aab15d89808f4b8b982
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# GitHub to Canvas Gem
|
2
|
-
|
2
|
+
|
3
3
|
## Introduction
|
4
4
|
|
5
5
|
The `github-to-canvas` gem is designed to enable GitHub to Canvas LMS
|
@@ -8,11 +8,13 @@ file, convert it to HTML, and push it to Canvas. The gem also updates the
|
|
8
8
|
repository to include a `.canvas` file containing Canvas specific information.
|
9
9
|
|
10
10
|
With the `.canvas` file in place, this gem can be used to continuously align
|
11
|
-
content between GitHub and Canvas
|
11
|
+
content between GitHub and Canvas using the GitHub repository as the single
|
12
|
+
source of truth.
|
12
13
|
|
13
14
|
This gem is built for use internally at [Flatiron School][]. Access to the
|
14
15
|
[Canvas LMS API][] and the ability to add pages and assignments to a Canvas
|
15
|
-
course are required.
|
16
|
+
course are required. Write access to the GitHub repository being converted is
|
17
|
+
also required.
|
16
18
|
|
17
19
|
## Installation
|
18
20
|
|
@@ -51,11 +53,17 @@ are present by running `ENV`.
|
|
51
53
|
|
52
54
|
## Usage
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
+
### Create a Canvas Lesson
|
57
|
+
|
58
|
+
To create a Canvas lesson from a GitHub `README.md` file, at minimum, you will
|
59
|
+
need to know the Canvas course id you are going to add to. This id can be found
|
60
|
+
in the URL of the course.
|
61
|
+
|
62
|
+
Once you have the course id, you will need to do the following:
|
56
63
|
|
57
|
-
1.
|
58
|
-
2.
|
64
|
+
1. Clone down the repository you'd like to push to Canvas.
|
65
|
+
2. Change directory into the new local repository
|
66
|
+
3. Run `github-to-canvas --create <your-course-id>` from inside the local repo
|
59
67
|
|
60
68
|
If everything is set up properly, `github-to-canvas` will create a Canvas lesson
|
61
69
|
using `master` branch `README.md` and the name of the current folder. By
|
@@ -63,8 +71,30 @@ default, if the repository contains folders, an **assignment** will be created.
|
|
63
71
|
Otherwise, a **page** will be created.
|
64
72
|
|
65
73
|
After a successful lesson creation, `github-to-canvas` will use the API response
|
66
|
-
to build a `.canvas` YAML file. This file contains the course id, the newly
|
67
|
-
page id, and the Canvas URL to the lesson for future reference.
|
74
|
+
to build a `.canvas` YAML file. This file contains the course id, the newly
|
75
|
+
created page id, and the Canvas URL to the lesson for future reference. With the
|
76
|
+
newly created `.canvas` file, `github-to-canvas` will attempt to commit and push the
|
77
|
+
file up to the remote GitHub repository.
|
78
|
+
|
79
|
+
If you create multiple Canvas lessons from the same repository, each lesson's
|
80
|
+
Canvas data will be stored in the `.canvas` file.
|
81
|
+
|
82
|
+
> **Note:** If you don't have write access to the repository, the `.canvas` file
|
83
|
+
> will still be created locally.
|
84
|
+
|
85
|
+
### Update an existing Canvas Lesson
|
86
|
+
|
87
|
+
To update an existing Canvas lesson using a local repository, **a `.canvas` file
|
88
|
+
must be present in the repo**, as it contains the lesson information for the
|
89
|
+
Canvas API.
|
90
|
+
|
91
|
+
1. Clone down and/or change directory into the repository you'd like to update
|
92
|
+
2. Run `github-to-canvas --align <your-course-id>` from inside the local repo
|
93
|
+
|
94
|
+
`github-to-canvas` will get the course id and page/assignment id from the
|
95
|
+
`.canvas` file and update the associated Canvas lesson. If there are multiple
|
96
|
+
Canvas lessons included in the `.canvas` file, each lesson will be updated (i.e.
|
97
|
+
you have the same lesson in two courses created from one repository).
|
68
98
|
|
69
99
|
### Options
|
70
100
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'rest-client'
|
3
|
-
|
3
|
+
|
4
4
|
class CanvasInterface
|
5
5
|
|
6
6
|
def self.submit_to_canvas(course_id, type, name, readme, dry_run = false)
|
@@ -25,8 +25,8 @@ class CanvasInterface
|
|
25
25
|
})
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.update_existing_lesson(course_id,
|
29
|
-
url = "#{ENV['CANVAS_API_PATH']}/courses/#{course_id}/#{type}s/#{
|
28
|
+
def self.update_existing_lesson(course_id, id, type, name, new_readme, dry_run)
|
29
|
+
url = "#{ENV['CANVAS_API_PATH']}/courses/#{course_id}/#{type}s/#{id}"
|
30
30
|
payload = self.build_payload(type, name, new_readme)
|
31
31
|
RestClient.put(url, payload, headers={
|
32
32
|
"Authorization" => "Bearer #{ENV['CANVAS_API_KEY']}"
|
@@ -13,7 +13,7 @@ class GithubInterface
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.git_co_branch(filepath, branch)
|
16
|
-
branch = self.cd_into_and(filepath, "git
|
16
|
+
branch = self.cd_into_and(filepath, "git checkout #{branch}")
|
17
17
|
if branch.to_s.strip.empty?
|
18
18
|
puts "#{branch} branch not found. Exiting..."
|
19
19
|
abort
|