Class: Gipper::Answers

Inherits:
Array
  • Object
show all
Includes:
Oniguruma
Defined in:
lib/answers.rb

Instance Method Summary collapse

Instance Method Details

#find_styleObject

find_style does it’s best to determine the questions style. It cannot determine the missing word questions since the necessary information is in the question object. use question.find_style for that purpose.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/answers.rb', line 41

def find_style
  return @style_hint if @style_hint

  if self.length == 1 && self[0].text.nil? && boolean?(self[0].correct.class)
    return :true_false
  end

  if self[0].text && self[0].correct.class == String
    return :matching
  end

  if (count_true < 2) && (self.length > 1)
    return :multiple_choice
  else
    return :short_answer
  end
end

#parse(answer) ⇒ Object

parses the answers an array of answer objects.



27
28
29
30
31
32
33
34
35
36
# File 'lib/answers.rb', line 27

def parse answer
  @answer_text = set_numerical_indicator answer
  parts = split_apart @answer_text

  parts.each do |clause|
    answer = Answer.new
    answer.parse(clause, @style_hint)
    self << answer
  end
end