Class: GithubToCanvasQuiz::Model::Quiz
- Inherits:
-
Object
- Object
- GithubToCanvasQuiz::Model::Quiz
- Defined in:
- lib/github_to_canvas_quiz/model/quiz.rb
Instance Attribute Summary collapse
-
#course_id ⇒ Object
Returns the value of attribute course_id.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #frontmatter_hash ⇒ Object
-
#initialize(options) ⇒ Quiz
constructor
A new instance of Quiz.
- #to_h ⇒ Object
- #to_markdown ⇒ Object
Constructor Details
#initialize(options) ⇒ Quiz
Returns a new instance of Quiz.
8 9 10 11 12 |
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 8 def initialize() .each do |key, value| send("#{key}=", value) if respond_to?("#{key}=") end end |
Instance Attribute Details
#course_id ⇒ Object
Returns the value of attribute course_id.
6 7 8 |
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 6 def course_id @course_id end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 6 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 6 def id @id end |
#repo ⇒ Object
Returns the value of attribute repo.
6 7 8 |
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 6 def repo @repo end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 6 def title @title end |
Instance Method Details
#frontmatter_hash ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 36 def frontmatter_hash { 'id' => id, 'course_id' => course_id, 'repo' => repo } end |
#to_h ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 22 def to_h { 'title' => title, 'description' => description_with_header, 'quiz_type' => 'assignment', 'shuffle_answers' => true, 'hide_results' => nil, 'show_correct_answers_last_attempt' => true, 'allowed_attempts' => 3, 'scoring_policy' => 'keep_highest', 'one_question_at_a_time' => true } end |
#to_markdown ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 14 def to_markdown MarkdownBuilder.build do |md| md.frontmatter(frontmatter_hash) md.h1(title) md.md(md.html_to_markdown(description)) end end |