Class: GithubToCanvasQuiz::Model::Quiz

Inherits:
Object
  • Object
show all
Defined in:
lib/github_to_canvas_quiz/model/quiz.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options)
  options.each do |key, value|
    send("#{key}=", value) if respond_to?("#{key}=")
  end
end

Instance Attribute Details

#course_idObject

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

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 6

def description
  @description
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 6

def id
  @id
end

#repoObject

Returns the value of attribute repo.



6
7
8
# File 'lib/github_to_canvas_quiz/model/quiz.rb', line 6

def repo
  @repo
end

#titleObject

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_hashObject



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_hObject



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_markdownObject



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