Class: GithubToCanvasQuiz::Synchronizer::Quiz
- Inherits:
-
Object
- Object
- GithubToCanvasQuiz::Synchronizer::Quiz
- Defined in:
- lib/github_to_canvas_quiz/synchronizer/quiz.rb
Overview
Synchronize a quiz to Canvas based on the contents of a given directory Given a directory with valid markdown files:
phase-1-quiz-arrays | questions | |– 00.md | |– 01.md |– README.md
Useage:
client = CanvasAPI::Client.new(host: host, api_key: api_key)
Synchronizer::Quiz.new(client, 'phase-1-quiz-arrays')
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#questions_with_path ⇒ Object
readonly
Returns the value of attribute questions_with_path.
-
#quiz ⇒ Object
readonly
Returns the value of attribute quiz.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
-
#initialize(client, path) ⇒ Quiz
constructor
A new instance of Quiz.
- #sync ⇒ Object
Constructor Details
#initialize(client, path) ⇒ Quiz
Returns a new instance of Quiz.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/github_to_canvas_quiz/synchronizer/quiz.rb', line 22 def initialize(client, path) path = File.(path) raise DirectoryNotFoundError unless Pathname(path).directory? @client = client @path = path @repo = RepositoryInterface.new(path) @quiz = parse_quiz @questions_with_path = parse_questions_with_path if @quiz.id end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
20 21 22 |
# File 'lib/github_to_canvas_quiz/synchronizer/quiz.rb', line 20 def client @client end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
20 21 22 |
# File 'lib/github_to_canvas_quiz/synchronizer/quiz.rb', line 20 def path @path end |
#questions_with_path ⇒ Object (readonly)
Returns the value of attribute questions_with_path.
20 21 22 |
# File 'lib/github_to_canvas_quiz/synchronizer/quiz.rb', line 20 def questions_with_path @questions_with_path end |
#quiz ⇒ Object (readonly)
Returns the value of attribute quiz.
20 21 22 |
# File 'lib/github_to_canvas_quiz/synchronizer/quiz.rb', line 20 def quiz @quiz end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
20 21 22 |
# File 'lib/github_to_canvas_quiz/synchronizer/quiz.rb', line 20 def repo @repo end |
Instance Method Details
#sync ⇒ Object
33 34 35 36 37 38 |
# File 'lib/github_to_canvas_quiz/synchronizer/quiz.rb', line 33 def sync backup_canvas_to_json! if @quiz.id sync_quiz! sync_questions! backup_canvas_to_json! end |