github-to-canvas 0.0.42 → 0.0.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/github-to-canvas/canvas_dotfile.rb +5 -6
- data/lib/github-to-canvas/canvas_interface.rb +1 -1
- data/lib/github-to-canvas/create_canvas_lesson.rb +10 -4
- data/lib/github-to-canvas/update_canvas_lesson.rb +28 -7
- data/lib/github-to-canvas/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e37325db45799844237ba747240be9e85d677e9dc1289836c01205e51cd9f4f
|
4
|
+
data.tar.gz: cad741664204320b94a578ab4e617afd8c4b0e8e209c8ead9e8b91493d97b693
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45753e9af5e7da01e1daccb8b89fe76d3edd6bda219cc47c6662d03e047e7ce323b0d2270fbc04120a2f7b57224f9eea31f3bade71a3a5d2fbddf4278f73dac2
|
7
|
+
data.tar.gz: 95c4ce9a722bd3ce2e8e4f9ec9ea933fbf92ad627f29719c02ce8fc7b547616baed012b26059d91b6e6d3df8d60b52b74f7b8587a7589237c80c740cda1f177f
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
class CanvasDotfile
|
3
3
|
|
4
|
+
def self.exists?
|
5
|
+
File.file?(".canvas")
|
6
|
+
end
|
7
|
+
|
4
8
|
def self.update_or_create(filepath, response, course, type)
|
5
|
-
if
|
9
|
+
if self.exists?
|
6
10
|
if type == "assignment" || type == "discussion"
|
7
11
|
canvas_data = self.update_assignment_data(response, course, type)
|
8
12
|
else
|
@@ -22,11 +26,6 @@ class CanvasDotfile
|
|
22
26
|
File.write("#{filepath}/.canvas", canvas_data.to_yaml)
|
23
27
|
end
|
24
28
|
|
25
|
-
def self.commit_canvas_dotfile(filepath)
|
26
|
-
GithubInterface.git_add(filepath, '.canvas')
|
27
|
-
GithubInterface.git_commit(filepath, 'AUTO: add .canvas file after migration')
|
28
|
-
end
|
29
|
-
|
30
29
|
def self.read_canvas_data
|
31
30
|
if File.file?(".canvas")
|
32
31
|
YAML.load(File.read(".canvas"))
|
@@ -18,15 +18,21 @@ class CreateCanvasLesson
|
|
18
18
|
new_html = RepositoryConverter.add_fis_links(filepath, new_html)
|
19
19
|
end
|
20
20
|
response = CanvasInterface.submit_to_canvas(course, type, name, new_html)
|
21
|
+
|
22
|
+
puts 'Creating .canvas file'
|
23
|
+
CanvasDotfile.update_or_create(filepath, response, course, type)
|
24
|
+
|
25
|
+
puts "Canvas lesson created. Lesson available at #{response['html_url']}."
|
26
|
+
|
27
|
+
# If --save option is used, the .canvas file gets committed and pushed to the remote repo
|
21
28
|
if save_to_github
|
22
|
-
puts '
|
23
|
-
|
29
|
+
puts 'Adding .canvas file'
|
30
|
+
GithubInterface.git_add(filepath, '.canvas')
|
24
31
|
puts 'Commiting .canvas file'
|
25
|
-
|
32
|
+
GithubInterface.git_commit(filepath, 'AUTO: add .canvas file after migration')
|
26
33
|
puts 'Pushing .canvas file'
|
27
34
|
GithubInterface.git_push(filepath, branch)
|
28
35
|
end
|
29
|
-
puts "Canvas lesson created. Lesson available at #{response['html_url']}."
|
30
36
|
end
|
31
37
|
|
32
38
|
end
|
@@ -12,25 +12,46 @@ class UpdateCanvasLesson
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def update_canvas_lesson(course, markdown, filepath, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id)
|
15
|
+
# Pulls any updates that exist on GitHub
|
15
16
|
GithubInterface.get_updated_repo(filepath, branch)
|
17
|
+
|
18
|
+
# Converts markdown to HTML
|
19
|
+
# Default is README.md. --file <FILENAME> can be used to override default.
|
16
20
|
new_html = RepositoryConverter.convert(filepath, markdown, branch, remove_header_and_footer)
|
21
|
+
|
22
|
+
# adds Flatiron School specific header and footer
|
17
23
|
if fis_links
|
18
|
-
new_html = RepositoryConverter.add_fis_links(filepath, new_html)
|
24
|
+
new_html = RepositoryConverter.add_fis_links(filepath, new_html)
|
19
25
|
end
|
26
|
+
|
27
|
+
# Read the local .canvas file if --id <ID> is not used. Otherwise, use provided ID (--course <COURSE> also required)
|
20
28
|
if !id
|
21
|
-
# If no assignment or page ID is provided, tries to get info from a .canvas file
|
22
29
|
canvas_data = CanvasDotfile.read_canvas_data
|
23
|
-
canvas_data[:lessons].
|
30
|
+
canvas_data[:lessons] = canvas_data[:lessons].map { |lesson|
|
24
31
|
response = CanvasInterface.update_existing_lesson(lesson[:course_id], lesson[:id], lesson[:type], name, new_html, only_update_content)
|
25
|
-
# puts "Canvas lesson created. Lesson available at #{response['html_url']}."
|
26
32
|
}
|
27
33
|
else
|
28
|
-
# If an ID
|
34
|
+
# If an ID (and course) are provided, they are used instead of the .canvas file
|
35
|
+
# Gets the current lesson's type (page or assignment)
|
29
36
|
info = CanvasInterface.get_lesson_info(course, id)
|
30
|
-
|
37
|
+
|
38
|
+
# Implements update on Canvas
|
39
|
+
response = JSON.parse(CanvasInterface.update_existing_lesson(course, id, info[1], name, new_html, only_update_content))
|
40
|
+
|
41
|
+
# Updates or creates a local .canvas file
|
42
|
+
CanvasDotfile.update_or_create(filepath, response, course, info[1])
|
31
43
|
end
|
44
|
+
# If --save option is used, the .canvas file gets committed and pushed to the remote repo
|
45
|
+
if save_to_github
|
46
|
+
puts 'Adding .canvas file'
|
47
|
+
GithubInterface.git_add(filepath, '.canvas')
|
48
|
+
puts 'Commiting .canvas file'
|
49
|
+
GithubInterface.git_commit(filepath, 'AUTO: add .canvas file after migration')
|
50
|
+
puts 'Pushing .canvas file'
|
51
|
+
GithubInterface.git_push(filepath, branch)
|
52
|
+
end
|
53
|
+
|
32
54
|
end
|
33
|
-
|
34
55
|
|
35
56
|
|
36
57
|
end
|