github-to-canvas 0.0.55 → 0.1.1
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 +4 -4
- data/README.md +320 -52
- data/bin/github-to-canvas +147 -25
- data/lib/github-to-canvas.rb +124 -39
- data/lib/github-to-canvas/canvas_dotfile.rb +9 -9
- data/lib/github-to-canvas/canvas_interface.rb +327 -68
- data/lib/github-to-canvas/course_creation_interface.rb +9 -0
- data/lib/github-to-canvas/create_canvas_lesson.rb +8 -32
- data/lib/github-to-canvas/github_interface.rb +34 -0
- data/lib/github-to-canvas/repository_converter.rb +123 -31
- data/lib/github-to-canvas/repository_interface.rb +33 -0
- data/lib/github-to-canvas/update_canvas_lesson.rb +0 -32
- data/lib/github-to-canvas/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a091b1eff741a97c405fa521cdc476c674f0d3dedb915d919045fab6244b5037
|
4
|
+
data.tar.gz: 5c384485dfcbb6da42dcf8db87115173d72b1ef548d3bfe99cfe6fec3af9ce98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ae4d1c9c1ade17a0a15d148267f2e9c5949857c3f76ce0a65c1a0f6ac5e7c382ab29c2ae1ef9c37ace078178a7ae8a342e3f543813384d350279093cd483233
|
7
|
+
data.tar.gz: b2165b3675bc12d80149975edeaf77341ccade1687b1558a4463613853df78362c16f3520f1ae5baf394854cb06f4e21e1c90525feefeecccbd2103b684f712d
|
data/README.md
CHANGED
@@ -4,19 +4,15 @@
|
|
4
4
|
|
5
5
|
The `github-to-canvas` gem is designed to aid in integrating GitHub and the
|
6
6
|
Canvas LMS. This gem takes a GitHub repository's `README.md` file, converts it
|
7
|
-
to HTML, and pushes it to Canvas using the Canvas API.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
With the `.canvas` file in place, this gem can be used to continuously align
|
12
|
-
content between GitHub and Canvas using the GitHub repository as the single
|
13
|
-
source of truth.
|
7
|
+
to HTML, and pushes it to Canvas using the Canvas API. This gem can also update
|
8
|
+
existing Canvas lessons, allowing continuous alignment of content between GitHub
|
9
|
+
and Canvas, using the GitHub repository as the single source of truth.
|
14
10
|
|
15
11
|
This gem is built for use internally at [Flatiron School][], so some features may be
|
16
12
|
specific to Flatiron School branding and needs. Access to the
|
17
13
|
[Canvas LMS API][] and the ability to add pages and assignments to a Canvas
|
18
14
|
course are required. Write access to the GitHub repository being converted is
|
19
|
-
also required for
|
15
|
+
also required for some features.
|
20
16
|
|
21
17
|
## Installation
|
22
18
|
|
@@ -47,7 +43,7 @@ echo "$(export 'CANVAS_API_KEY=your-new-API-key-here' | cat - ~/.bash_profile)"
|
|
47
43
|
|
48
44
|
### Add Canvas API Base Path
|
49
45
|
|
50
|
-
The exact Canvas API path is specific to where
|
46
|
+
The exact Canvas API path is specific to where your Canvas LMS is located. For example,
|
51
47
|
Flatiron School's base path is `https://learning.flatironschool.com/api/v1`. Add this path
|
52
48
|
as an `ENV` variable like the API key. **Do not add a `/` at the end after `/api/v1`.**
|
53
49
|
|
@@ -65,67 +61,339 @@ After both the API key and path are added to `~/.zshrc`, run `source ~/.zshrc` (
|
|
65
61
|
to make them available in your current terminal. You can verify these variables
|
66
62
|
are present by running `ENV` and finding them in the output list.
|
67
63
|
|
68
|
-
##
|
64
|
+
## Common Uses
|
65
|
+
|
66
|
+
### Creating and Updating Canvas Lessons
|
67
|
+
|
68
|
+
Relevant options:
|
69
|
+
|
70
|
+
- `--create-lesson`, `-c`: Requires a Canvas course ID. Creates a new Canvas
|
71
|
+
lesson, converting the local repository's README.md to HTML. Adds `.canvas`
|
72
|
+
file to remote repository
|
73
|
+
- `--align`, `-a`: Updates a canvas lesson based on the local repository's
|
74
|
+
README.md. If no other options are used, `--align` will look for a `.canvas`
|
75
|
+
file to know what to lesson to update
|
76
|
+
- `--course`: Provide a specific course ID. When used with `--id`, this can
|
77
|
+
override the default behavior for `--align`, allowing you to update any
|
78
|
+
existing lesson and ignore the `.canvas` file if present.
|
79
|
+
- `--id`: Provide a specific lesson ID. This can be found in the URL of the
|
80
|
+
specific lesson. For Pages, used the slugified lesson title.
|
81
|
+
- `--type`: Sets the type of Canvas lesson to be created (page, assignment or
|
82
|
+
discussion). If no type, type decided based on repository structure.
|
83
|
+
- `--name`: Can be used to override default naming behavior. By default, Canvas
|
84
|
+
lesson names are determined by the first top-level (`#`) header in the
|
85
|
+
repository's markdown file.
|
86
|
+
- `--fis-links`, `-l`: Adds additional Flatiron School HTML header after
|
87
|
+
markdown conversion, including links back to the GitHub repo and it's issue
|
88
|
+
form.
|
89
|
+
- `--forkable`: Adds a **Fork** button to the Flatiron School HTML header. For
|
90
|
+
use with custom Canvas JS to enable Canvas assignment forking workflow for
|
91
|
+
Flatiron School students.
|
92
|
+
- `--remove-header-and-footer`, `-r`: Removes top lesson header and any Flatiron
|
93
|
+
School specific footer links before converting to HTML. Removing top lesson
|
94
|
+
header prevent duplicate titles while viewing in Canvas.
|
95
|
+
- `--create-from-github`: Requires a GitHub repository URL. Also requires
|
96
|
+
`--course` and `--type`. Creates a Canvas lesson, reading from the remote repo
|
97
|
+
instead of a local repository. Repository must be public.
|
98
|
+
- `--align-from-github`: Requires a GitHub repo URL, `--course`, `--id`, and
|
99
|
+
`--type`. Updates a Canvas lesson from a remote repository.
|
100
|
+
- `--read-from-github`: Requires a GitHub repo URL. Reads a remote repository
|
101
|
+
and converts its contents to HTML, but does not push to Canvas.
|
102
|
+
|
103
|
+
#### Create a Canvas Lesson from a Local Repository
|
104
|
+
|
105
|
+
Navigate into a repository folder cloned down to your local machine and run:
|
106
|
+
|
107
|
+
```sh
|
108
|
+
github-to-canvas -c <CANVAS_COURSE_ID> -lr --forkable
|
109
|
+
```
|
110
|
+
|
111
|
+
The command above will create a Canvas lesson in the course provided. It will
|
112
|
+
also remove the repositories top-level header and remove any old Flatiron
|
113
|
+
branded footers. It will also add an HTML header for Canvas that includes links
|
114
|
+
back to the repository.
|
115
|
+
|
116
|
+
If the lesson type is an assignment, a Fork button will also be added to the
|
117
|
+
HTML header. Because the command didn't specify, the type of lesson is
|
118
|
+
determined based on the structure of the local repo - if it has sub-folders, the
|
119
|
+
lesson will become an assignment; if there are no sub-folders, the lesson will
|
120
|
+
become a page. If the lesson type is a page, the `--forkable` option will be
|
121
|
+
ignored.
|
122
|
+
|
123
|
+
Creating a lesson this way will also produce a `.canvas` file. This file
|
124
|
+
contains info about the Canvas lesson that was created.
|
125
|
+
|
126
|
+
#### Create a Canvas Lesson from a Remote Repository
|
127
|
+
|
128
|
+
To create from a remote repo, run the following command:
|
129
|
+
|
130
|
+
```sh
|
131
|
+
github-to-canvas --create-from-github <URL> --course <CANVAS_COURSE_ID> --type <TYPE> -lr --forkable
|
132
|
+
```
|
133
|
+
|
134
|
+
This command will read a GitHub markdown based on the provided URL and create a
|
135
|
+
Canvas lesson based on it. We need to provide the Course ID and the type of
|
136
|
+
lesson (`page` or `assignment`) as type can't be determined automatically. We'll
|
137
|
+
also continue to use `-lr --forkable` like the previous command to set up the
|
138
|
+
lesson the same way as before.
|
139
|
+
|
140
|
+
The repository must be public in order to read the markdown file.
|
141
|
+
|
142
|
+
#### Read a Remote Repository as HTML
|
143
|
+
|
144
|
+
To read the contents of a remote repo:
|
145
|
+
|
146
|
+
```sh
|
147
|
+
github-to-canvas --read-from-github <URL>
|
148
|
+
```
|
149
|
+
|
150
|
+
This will produce an HTML conversion of the repository's markdwon. This HTML can
|
151
|
+
be directly pasted into Canvas' HTML editor if a manual process is needed.
|
152
|
+
|
153
|
+
#### Update a Canvas Lesson from a Local Repository
|
154
|
+
|
155
|
+
If you previously created a Canvas lesson from a local repository, you should
|
156
|
+
have a `.canvas` file present in the repo. If that file is present, you can run
|
157
|
+
the following command to automatically update that same Canvas lesson:
|
158
|
+
|
159
|
+
```sh
|
160
|
+
github-to-canvas -a -lr --forkable
|
161
|
+
```
|
162
|
+
|
163
|
+
If you don't have or want to use the `.canvas` file, you can also specify the
|
164
|
+
course ID and lesson ID:
|
165
|
+
|
166
|
+
```sh
|
167
|
+
github-to-canvas -a --course <CANVAS_COURSE_ID> --id <CANVAS_LESSON_ID> -lr --forkable
|
168
|
+
```
|
169
|
+
|
170
|
+
Canvas course and lesson IDs can be found in the URL.
|
171
|
+
|
172
|
+
#### Update a Canvas Lesson from a Remote Repository
|
173
|
+
|
174
|
+
You can update an existing Canvas course using a remote GitHub repository like so:
|
175
|
+
|
176
|
+
```sh
|
177
|
+
github-to-canvas --align-from-github <URL> --course <COURSE_ID> --id <LESSON_ID> --type <TYPE> -lr --forkable
|
178
|
+
```
|
179
|
+
|
180
|
+
This will read remote markdown using the provided URL and update a Canvas course
|
181
|
+
using the info provided. Type must match the existing lesson type.
|
182
|
+
|
183
|
+
### Course Creation
|
184
|
+
|
185
|
+
This gem has the ability to create Canvas courses from scratch. These features
|
186
|
+
are still in development and may not work for all course designs. Quiz and
|
187
|
+
Discussion Topic lesson creation is still under development and will not work.
|
188
|
+
|
189
|
+
By providing a YAML file of the desired course structure, this gem can create a
|
190
|
+
course, add in modules, and populate those modules with pages and assignments.
|
191
|
+
The required YAML file must follow a specific structure. Using the steps below,
|
192
|
+
this gem can create the necessary YAML markup from existing Canvas courses.
|
193
|
+
|
194
|
+
#### Retrieve Canvas Course Information as YAML
|
195
|
+
|
196
|
+
To create YAML markup of an existing Canvas course, use the following:
|
197
|
+
|
198
|
+
```sh
|
199
|
+
github-to-canvas --query <CANVAS_COURSE_ID>
|
200
|
+
```
|
201
|
+
|
202
|
+
This command will use the Canvas API to read a course's information, including
|
203
|
+
its module and lesson structure and lesson URLs. YAML markup will be produced as a result. This
|
204
|
+
output can be directly saved to a file, which will make the next step a little
|
205
|
+
easier:
|
206
|
+
|
207
|
+
```sh
|
208
|
+
github-to-canvas --query <CANVAS_COURSE_ID> > query_results.yml
|
209
|
+
```
|
210
|
+
|
211
|
+
The output will look similar to this:
|
212
|
+
|
213
|
+
```yml
|
214
|
+
---
|
215
|
+
:name: The Course's Title
|
216
|
+
:id: 111
|
217
|
+
:modules:
|
218
|
+
- :id: 2020
|
219
|
+
:name: First Module's Name
|
220
|
+
:lessons:
|
221
|
+
- id: slugified-page-name
|
222
|
+
title: This is the Title Of The First Lesson, a Page
|
223
|
+
indent: 0
|
224
|
+
type: Page
|
225
|
+
html_url: https://learning.flatironschool.com/courses/111/modules/items/27001
|
226
|
+
page_url: slugified-page-name
|
227
|
+
url: https://learning.flatironschool.com/api/v1/courses/111/pages/slugified-page-name
|
228
|
+
published: false
|
229
|
+
repository: ''
|
230
|
+
- id: 333
|
231
|
+
title: This is the Title Of The Second Lesson, an Assignment
|
232
|
+
indent: 1
|
233
|
+
type: Assignment
|
234
|
+
html_url: https://learning.flatironschool.com/courses/111/modules/items/27002
|
235
|
+
page_url: ''
|
236
|
+
url: https://learning.flatironschool.com/api/v1/courses/111/assignments/333
|
237
|
+
published: false
|
238
|
+
repository: ''
|
239
|
+
- :id: 2021
|
240
|
+
:name: Second Module's Name
|
241
|
+
:lessons:
|
242
|
+
```
|
243
|
+
|
244
|
+
The output YAML will not include associated GitHub repository information.
|
245
|
+
|
246
|
+
#### Map GitHub Repositories to a Canvas Course YAML
|
247
|
+
|
248
|
+
To associate repositories to an existing course YAML, the following command can be used:
|
249
|
+
|
250
|
+
```sh
|
251
|
+
github-to-canvas --map <YAML_FILE>
|
252
|
+
```
|
253
|
+
|
254
|
+
For this feature to work, all Canvas lessons must have the GitHub HTML header
|
255
|
+
that is added using `-l`. This header contains the necessary repo information.
|
256
|
+
|
257
|
+
Save the output YAML to another file if you want to use it for later course
|
258
|
+
creation. For example:
|
259
|
+
|
260
|
+
```sh
|
261
|
+
github-to-canvas --map query_results.yml > course_structure.yml
|
262
|
+
```
|
263
|
+
|
264
|
+
The resulting YAML file will contain course information, the module and lesson
|
265
|
+
structure, and each lesson's associated GitHub repository.
|
266
|
+
|
267
|
+
#### Create New Canvas Course from YAML
|
268
|
+
|
269
|
+
To create a Canvas course with this gem, you will need a correctly structured
|
270
|
+
YAML file with the course info, modules, lessons and associated lesson
|
271
|
+
repositories. In addition, all lessons must have a type (`Page` or
|
272
|
+
`Assignment`), a repository, and a title. Other lesson options are currently
|
273
|
+
ignored.
|
274
|
+
|
275
|
+
With the necessary data configured, use the `--build-course` option and pass in
|
276
|
+
the course's YAML file:
|
277
|
+
|
278
|
+
```sh
|
279
|
+
github-to-canvas --build-course course_structure.yml -lr --forkable
|
280
|
+
```
|
281
|
+
|
282
|
+
This command will cause the following to happen:
|
69
283
|
|
70
|
-
|
284
|
+
- Create a Canvas course using the top level `:name:` in the YAML data
|
285
|
+
- Create the first module
|
286
|
+
- Create the first lesson using the repository, title and type, as well as additional command options
|
287
|
+
- Add the newly created lesson to the current module
|
288
|
+
- Create the second lesson and add it to the module...
|
289
|
+
- Repeate process until all modules and lessons are created
|
71
290
|
|
72
|
-
|
73
|
-
need to know the Canvas course id you are going to add to. This id can be found
|
74
|
-
in the URL of the course.
|
291
|
+
#### Align an Existing Course from YAML
|
75
292
|
|
76
|
-
|
293
|
+
After you've created a course using the previous process, go through the
|
294
|
+
previous steps of `--query` and `--map` to get a fully updated YAML for your
|
295
|
+
newly created course.
|
77
296
|
|
78
|
-
|
79
|
-
|
80
|
-
|
297
|
+
```sh
|
298
|
+
github-to-canvas --query <COURSE_ID> > query_results.yml
|
299
|
+
github-to-canvas --map query_results.yml > your_new_course.yml
|
300
|
+
```
|
301
|
+
|
302
|
+
With this data file, you can use the following command to update all lessons in
|
303
|
+
a course based on their GitHub repo:
|
304
|
+
|
305
|
+
```sh
|
306
|
+
github-to-canvas --update-course YAML_FILE -lr --forkable
|
307
|
+
```
|
81
308
|
|
82
|
-
|
83
|
-
|
84
|
-
default, if the repository contains folders, an **assignment** will be created.
|
85
|
-
Otherwise, a **page** will be created.
|
309
|
+
The gem will iterate over the data and update every lesson according to the
|
310
|
+
associated repository.
|
86
311
|
|
87
|
-
|
312
|
+
## Known Issues
|
88
313
|
|
89
|
-
|
90
|
-
|
91
|
-
|
314
|
+
### HTML Code Snippets Do Not Render
|
315
|
+
|
316
|
+
The Canvas API renders all HTML it receives. If your repository's markdown
|
317
|
+
includes HTML that is not meant to be rendered (i.e. lessons on HTML or
|
318
|
+
JavaScript that include HTML code snippets), the content will be rendered as
|
319
|
+
part of the page's HTML, resulting in unusual display errors in Canvas.
|
320
|
+
|
321
|
+
To fix any rendering issues in Canvas, go to the Canvas WYSIWYG editor for the
|
322
|
+
afflicted lesson. Click the HTML editor option (`</>` button in the lower right) to
|
323
|
+
switch to HTML.
|
324
|
+
|
325
|
+
Read the GitHub repo as HTML:
|
326
|
+
|
327
|
+
```sh
|
328
|
+
github-to-canvas --read-from-github URL
|
329
|
+
```
|
92
330
|
|
93
|
-
|
94
|
-
|
331
|
+
Copy the output HTML and paste it in to the Canvas editor. This should clear up
|
332
|
+
some larger page rendering issues, but may not fix all code snippets issues. To
|
333
|
+
fix these, switch back to the regular Canvas WYSIWYG editor, then open a second
|
334
|
+
tab to the GitHub repo you're converting from. Copy any HTML code snippets from
|
335
|
+
GitHub and paste them into the Canvas editor where they should be displayed.
|
95
336
|
|
96
|
-
|
337
|
+
The Canvas editor will treat the pasted HTML content as code and will
|
338
|
+
automatically replace some characters, escaping the code from the
|
339
|
+
normal rendering process.
|
97
340
|
|
98
|
-
|
99
|
-
|
100
|
-
|
341
|
+
Note that realigning after fixing this content with the gem will break the
|
342
|
+
rendering for these lessons again. A fix is planned for this issue, but has not
|
343
|
+
been implemented.
|
101
344
|
|
102
|
-
|
103
|
-
2. Run `github-to-canvas --align` from inside the local repo
|
345
|
+
### Multi-Line Code Snippets Render as a Single Line
|
104
346
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
347
|
+
The Github to Canvas gem uses an existing gem, Redcarpet, to handle the Markdown to HTML
|
348
|
+
conversion. This gem does not currently support multi-line codeblocks. This
|
349
|
+
functionality has been added in the Github to Canvas gem through monkeypatching.
|
350
|
+
This error should be resolved, but if you encounter code snippet rendering
|
351
|
+
issues, please open a new issue with a markdown example to replicate the error.
|
109
352
|
|
110
|
-
###
|
353
|
+
### Markdown Formatting Issues Cause Errors in Canvas
|
111
354
|
|
112
|
-
|
355
|
+
Individual markdown headers, paragraphs and code snippets should be separated by
|
356
|
+
an empty line in the markdown. Without these empty lines, the contents will be
|
357
|
+
interpretted as one continuous paragraph and ignore formatting.
|
113
358
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
359
|
+
## Overview of GitHub to Canvas workflows
|
360
|
+
|
361
|
+
Using this gem, you can maintain Canvas courses in multiple ways - either by
|
362
|
+
creating and updating individual Canvas lessons or through the YAML file process.
|
363
|
+
|
364
|
+
At Flatiron School, we use the Canvas blueprint course feature. We use the
|
365
|
+
github-to-canvas gem to update the blueprint copy of lessons. These updates will
|
366
|
+
appear in future copies of the course, or can be synced down to existing course
|
367
|
+
copies.
|
368
|
+
|
369
|
+

|
370
|
+
|
371
|
+
This can either be done with individual lessons or using a YAML files to keep
|
372
|
+
entire courses updated.
|
373
|
+
|
374
|
+
If you are using github-to-canvas in this way, changes should always be made on
|
375
|
+
the repository, not on Canvas. Any changes made only on Canvas will get
|
376
|
+
overwritten if the lesson is updated using the gem.
|
377
|
+
|
378
|
+
## Additional Options
|
379
|
+
|
380
|
+
### Specify Branch
|
381
|
+
|
382
|
+
When creating or aligning content locally, you can use `--branch` (`-b`) to
|
383
|
+
specify which branch you want to use. If you have a newer repository with a
|
384
|
+
`main` branch instead of `master`, use this option.
|
385
|
+
|
386
|
+
If you are are creating or aligning content locally, the `.canvas` file is not
|
387
|
+
automatically committed to the repo. You can automatically commit this file by
|
388
|
+
including the `--save-to-github` (`-s`) option. This option will attempt to
|
389
|
+
commit and push the `.canvas` file to the remote repository.
|
390
|
+
|
391
|
+
Run `github-to-canvas --help` for additional options not listed in this Readme.
|
126
392
|
|
127
393
|
## Examples of Valid Images This Gem Can Convert
|
128
394
|
|
395
|
+
This gem can convert both standard inline markdown and HTML images.
|
396
|
+
|
129
397
|
Inline Markdown:
|
130
398
|
|
131
399
|

|
data/bin/github-to-canvas
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'optparse'
|
3
3
|
require 'github-to-canvas'
|
4
|
+
|
4
5
|
options = {}
|
5
6
|
OptionParser.new do |opts|
|
6
7
|
opts.banner = <<-EOBANNER
|
@@ -29,23 +30,40 @@ OptionParser.new do |opts|
|
|
29
30
|
Run these commands from inside a local GitHub repository. This gem is built for Flatiron School's internal use.
|
30
31
|
Some default behaviors assume this, like the default Canvas API path.
|
31
32
|
|
32
|
-
|
33
|
+
Create and Update Canvas Lessons From Inside a Local GitHub Repo Folder:
|
34
|
+
|
35
|
+
github-to-canvas --create-lesson 154 -> Creates a lesson in course 154, derives the name and type from the local repo
|
36
|
+
github-to-canvas --create-lesson 154 --name "Fetch Lab" -> Creates a lesson in course 154 with the provided name, derives the type from the local repo
|
37
|
+
github-to-canvas --create-lesson 154 --name "Fetch Lab" --type assignment -> Creates an assignment in course 154 with the provided name
|
38
|
+
github-to-canvas --create-lesson 154 --name "Fetch Lab" --branch solution -> Creates a lesson in course 154 with the provided name, uses the repository's solution branch and derives the type from the local repo
|
39
|
+
github-to-canvas --align -> Patches existing lessons in Canvas based on the .canvas file
|
40
|
+
github-to-canvas --align --fis-links -> Patches existing lessons in Canvas based on the .canvas file, adds additional Flatiron School specific HTML and meta-data
|
41
|
+
github-to-canvas --align --remove-header-and-footer -> Patches existing lessons in Canvas based on the .canvas file, removes top lesson header before converting to HTML
|
42
|
+
|
43
|
+
Get Info on a Canvas Course, Lesson or GitHub Repo:
|
44
|
+
|
45
|
+
github-to-canvas --query COURSE -> Displays a course's modules and their lessons in course order as YAML
|
46
|
+
github-to-canvas --map YAML -> Uses a YAML file created with --query to retrieve repositories that were associated with Canvas lessons using --fis-links. Returns an updated YAML.
|
47
|
+
github-to-canvas --read-from-canvas CANVAS_LESSON_URL -> Retrieves a lesson's contents and information from Canvas
|
48
|
+
github-to-canvas --read-from-github GITHUB_URL -> Retrieves the provided GitHub markdown file, converted into HTML
|
49
|
+
|
50
|
+
Create and Update Canvas Lessons Using Remote GitHub Repositories:
|
51
|
+
|
52
|
+
github-to-canvas --create-from-github GITHUB_URL --course COURSE_ID --type TYPE -> Creates a lesson in the provided course using the remote GitHub URL. Source must be from a public repo.
|
53
|
+
github-to-canvas --align-from-github GITHUB_URL --course COURSE_ID --id LESSON_ID --type TYPE -> Updates a lesson in the provided course using the remote GitHub URL. Source must be from a public repo.
|
33
54
|
|
34
|
-
|
35
|
-
|
36
|
-
github-to-canvas --
|
37
|
-
github-to-canvas --
|
38
|
-
github-to-canvas --
|
39
|
-
github-to-canvas --align --fis-links -> Patches existing lessons in Canvas based on the .canvas file, adds additional Flatiron School specific HTML and meta-data
|
40
|
-
github-to-canvas --align --remove-header-and-footer -> Patches existing lessons in Canvas based on the .canvas file, removes top lesson header before converting to HTML
|
41
|
-
github-to-canvas --info COURSE -> Displays a course's lesson and assignment names
|
55
|
+
Create and Update Canvas Courses From YAML:
|
56
|
+
|
57
|
+
github-to-canvas --build-course YAML_FILE -> Uses the provided YAML file to create a course, add modules and populate them with lessons using remote GitHub repositories
|
58
|
+
github-to-canvas --add-to-course YAML_FILE --course -> Uses a YAML file to a modules and lessons to an existing course.
|
59
|
+
github-to-canvas --update-course YAML_FILE -> Uses a YAML file to update lessons using their associated GitHub repositories (ignores module/course structure in YAML file)
|
42
60
|
|
43
61
|
EOBANNER
|
44
62
|
|
45
63
|
opts.on("-cCOURSE", "--create-lesson COURSE",
|
46
64
|
"Creates a new canvas lesson, converting the local repository's README.md to HTML. Adds .canvas file to remote repository") do |course|
|
47
65
|
options[:create_lesson] = true
|
48
|
-
options[:
|
66
|
+
options[:course_id] = course
|
49
67
|
end
|
50
68
|
opts.on("-bBRANCH", "--branch BRANCH",
|
51
69
|
"Sets the repository branch used for lesson creation") do |branch|
|
@@ -93,8 +111,8 @@ OptionParser.new do |opts|
|
|
93
111
|
options[:remove_header_and_footer] = true
|
94
112
|
end
|
95
113
|
opts.on("--course COURSE",
|
96
|
-
"For align functionality only - updates the HTML content of a lesson using the provided course ID. Use with --id.") do |
|
97
|
-
options[:
|
114
|
+
"For align functionality only - updates the HTML content of a lesson using the provided course ID. Use with --id.") do |course_id|
|
115
|
+
options[:course_id] = course_id
|
98
116
|
end
|
99
117
|
opts.on("--id ID",
|
100
118
|
"For align functionality only - updates the HTML content of a lesson using the provided assignment or page ID. Use with --course.") do |id|
|
@@ -108,30 +126,134 @@ OptionParser.new do |opts|
|
|
108
126
|
"Displays a course's lessons and assignments") do |course|
|
109
127
|
options[:query] = course
|
110
128
|
end
|
111
|
-
opts.on("--
|
112
|
-
"
|
113
|
-
options[:
|
129
|
+
opts.on("--map YAML_FILE",
|
130
|
+
"REQUIRES -f or --file Associates canvas lessons with repositories. Use query to create required YAML file") do |file|
|
131
|
+
options[:map] = file
|
132
|
+
end
|
133
|
+
opts.on("--read-from-canvas CANVAS_URL",
|
134
|
+
"Retrieves an existing Canvas lesson using the provided URL") do |url|
|
135
|
+
options[:read_from_canvas] = url
|
136
|
+
end
|
137
|
+
opts.on("--read-from-github GITHUB_URL",
|
138
|
+
"Converts an existing GitHub Readme to HTML using the provided URL. URL must be for a GitHub markdown file") do |url|
|
139
|
+
options[:read_from_github] = url
|
140
|
+
end
|
141
|
+
opts.on("--create-from-github GITHUB_URL",
|
142
|
+
"Creates a new Canvas lesson from a remote GitHub Readme. --course and --type options required") do |url|
|
143
|
+
options[:create_from_github] = url
|
144
|
+
end
|
145
|
+
# opts.on("--create-quiz-from-github GITHUB_URL",
|
146
|
+
# "Creates a new Canvas quiz from a remote GitHub YAML file. --course option required") do |url|
|
147
|
+
# options[:quiz_from_github] = url
|
148
|
+
# end
|
149
|
+
opts.on("--align-from-github GITHUB_URL",
|
150
|
+
"Aligns an existing Canvas lesson using a remote GitHub Readme. --course, --id, and --type options required") do |url|
|
151
|
+
options[:align_from_github] = url
|
152
|
+
end
|
153
|
+
opts.on("--build-course YAML_FILE",
|
154
|
+
"Creates Canvas course using provided YAML file") do |file|
|
155
|
+
options[:build_course] = file
|
156
|
+
end
|
157
|
+
opts.on("--add-to-course YAML_FILE",
|
158
|
+
"Creates Canvas course using provided YAML file") do |file|
|
159
|
+
options[:add_to_course] = file
|
160
|
+
end
|
161
|
+
opts.on("--update-course-lessons YAML_FILE",
|
162
|
+
"Updates all lessons in a course using remote repos in provided YAML file") do |file|
|
163
|
+
options[:update_course_lessons] = file
|
114
164
|
end
|
115
|
-
|
116
165
|
|
117
166
|
end.parse!
|
118
167
|
|
119
168
|
if options[:version]
|
120
|
-
GithubToCanvas.new(mode: 'version',
|
169
|
+
GithubToCanvas.new(mode: 'version', course_id: nil)
|
170
|
+
abort
|
171
|
+
end
|
172
|
+
|
173
|
+
if options[:read_from_canvas]
|
174
|
+
GithubToCanvas.new(mode: 'canvas_read', filepath: options[:read_from_canvas])
|
175
|
+
abort
|
176
|
+
end
|
177
|
+
|
178
|
+
if options[:read_from_github]
|
179
|
+
GithubToCanvas.new(mode: 'github_read', filepath: options[:read_from_github])
|
180
|
+
abort
|
181
|
+
end
|
182
|
+
|
183
|
+
if options[:create_from_github]
|
184
|
+
if options[:course_id] && options[:type]
|
185
|
+
GithubToCanvas.new(mode: 'github_create',
|
186
|
+
filepath: options[:create_from_github],
|
187
|
+
course_id: options[:course_id],
|
188
|
+
type: options[:type],
|
189
|
+
remove_header_and_footer: !!options[:remove_header_and_footer],
|
190
|
+
forkable: !!options[:forkable],
|
191
|
+
fis_links: !!options[:fis])
|
192
|
+
else
|
193
|
+
puts 'Canvas course ID and lesson type required. Example: github-to-canvas --create-from-github URL --course ID --type TYPE'
|
194
|
+
end
|
195
|
+
abort
|
196
|
+
end
|
197
|
+
|
198
|
+
if options[:align_from_github]
|
199
|
+
if options[:course_id] && options[:type] && options[:id]
|
200
|
+
GithubToCanvas.new(mode: 'github_align',
|
201
|
+
filepath: options[:align_from_github],
|
202
|
+
course_id: options[:course_id],
|
203
|
+
type: options[:type],
|
204
|
+
id: options[:id],
|
205
|
+
remove_header_and_footer: !!options[:remove_header_and_footer],
|
206
|
+
forkable: !!options[:forkable],
|
207
|
+
fis_links: !!options[:fis])
|
208
|
+
else
|
209
|
+
puts 'Canvas course ID, lesson ID, and type required. Example: github-to-canvas --create-from-github URL --course COURSE_ID --id LESSON_ID --type TYPE'
|
210
|
+
end
|
211
|
+
abort
|
121
212
|
end
|
122
213
|
|
123
214
|
if options[:query]
|
124
|
-
GithubToCanvas.new(mode: 'query',
|
215
|
+
GithubToCanvas.new(mode: 'query', course_id: options[:query], id: options[:id])
|
216
|
+
abort
|
217
|
+
end
|
218
|
+
|
219
|
+
if options[:map]
|
220
|
+
GithubToCanvas.new(mode: 'map', file_to_convert: options[:map])
|
221
|
+
abort
|
222
|
+
end
|
223
|
+
|
224
|
+
if options[:build_course]
|
225
|
+
GithubToCanvas.new(mode: 'build_course',
|
226
|
+
file_to_convert: options[:build_course],
|
227
|
+
fis_links: !!options[:fis],
|
228
|
+
remove_header_and_footer: !!options[:remove_header_and_footer],
|
229
|
+
forkable: !!options[:forkable])
|
230
|
+
abort
|
125
231
|
end
|
126
232
|
|
127
|
-
if options[:
|
128
|
-
if
|
129
|
-
|
130
|
-
|
233
|
+
if options[:add_to_course]
|
234
|
+
if options[:course_id]
|
235
|
+
GithubToCanvas.new(mode: 'add_to_course',
|
236
|
+
course_id: options[:course_id],
|
237
|
+
file_to_convert: options[:add_to_course],
|
238
|
+
fis_links: !!options[:fis],
|
239
|
+
remove_header_and_footer: !!options[:remove_header_and_footer],
|
240
|
+
forkable: !!options[:forkable])
|
241
|
+
else
|
242
|
+
puts '--course required'
|
131
243
|
end
|
132
|
-
|
244
|
+
abort
|
245
|
+
end
|
246
|
+
|
247
|
+
if options[:update_course_lessons]
|
248
|
+
GithubToCanvas.new(mode: 'update_course_lessons',
|
249
|
+
file_to_convert: options[:update_course_lessons],
|
250
|
+
fis_links: !!options[:fis],
|
251
|
+
remove_header_and_footer: !!options[:remove_header_and_footer],
|
252
|
+
forkable: !!options[:forkable])
|
253
|
+
abort
|
133
254
|
end
|
134
255
|
|
256
|
+
|
135
257
|
if !options[:type]
|
136
258
|
if Dir.glob("**/*/").empty?
|
137
259
|
options[:type] = "page"
|
@@ -174,7 +296,7 @@ end
|
|
174
296
|
|
175
297
|
if options[:create_lesson]
|
176
298
|
GithubToCanvas.new(mode: "create",
|
177
|
-
|
299
|
+
course_id: options[:course_id],
|
178
300
|
filepath: Dir.pwd,
|
179
301
|
file_to_convert: options[:file_to_convert],
|
180
302
|
branch: options[:branch],
|
@@ -189,7 +311,7 @@ end
|
|
189
311
|
|
190
312
|
if options[:align]
|
191
313
|
GithubToCanvas.new(mode: "align",
|
192
|
-
|
314
|
+
course_id: options[:course_id],
|
193
315
|
id: options[:id],
|
194
316
|
filepath: Dir.pwd,
|
195
317
|
file_to_convert: options[:file_to_convert],
|