Class: Ruql::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/ruql/stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(quiz, options = {}) ⇒ Stats

a pseudo-renderer that just prints stats about the quiz



5
6
7
8
# File 'lib/ruql/stats.rb', line 5

def initialize(quiz, options={})
  @quiz = quiz
  @output = []
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



3
4
5
# File 'lib/ruql/stats.rb', line 3

def output
  @output
end

#quizObject (readonly)

Returns the value of attribute quiz.



3
4
5
# File 'lib/ruql/stats.rb', line 3

def quiz
  @quiz
end

Instance Method Details

#render_quizObject



9
10
11
12
13
14
15
16
# File 'lib/ruql/stats.rb', line 9

def render_quiz
  @output << "%3d questions" % quiz.questions.length
  @output << "    %3d (%d points) in no group" % [quiz.ungrouped_questions.length, quiz.ungrouped_points]
  @output << "    %3d (%d points) in %d groups" % [quiz.grouped_questions.length, quiz.grouped_points, quiz.groups.length]
  @output << "%3d effective questions on quiz" % quiz.num_questions
  @output << "%3d max points possible" % quiz.points
  @output.join("\n")
end