Class: GithubToCanvasQuiz::Parser::Canvas::Question

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/github_to_canvas_quiz/parser/canvas/question.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#choose_text, #clean_html, #remove_canvas_cruft

Constructor Details

#initialize(data) ⇒ Question

Returns a new instance of Question.



11
12
13
# File 'lib/github_to_canvas_quiz/parser/canvas/question.rb', line 11

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/github_to_canvas_quiz/parser/canvas/question.rb', line 9

def data
  @data
end

Instance Method Details

#parseObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/github_to_canvas_quiz/parser/canvas/question.rb', line 15

def parse
  Model::Question.new(
    course_id: data['course_id'],
    quiz_id: data['quiz_id'],
    id: data['id'],
    type: data['question_type'],
    name: data['question_name'],
    description: clean_html(data['question_text']),
    sources: sources,
    answers: answers,
    distractors: distractors
  )
end