diff --git a/example.rb b/example.rb
index 2761d43..bdfdf31 100644
--- a/example.rb
+++ b/example.rb
@@ -1,7 +1,7 @@
-# A quiz has a mandatory name and optional time limit in minutes.
+# A quiz has a mandatory name and optional duration (time limit) in seconds.
# There's also various other obscure options not documented here.
-quiz 'Example quiz', :time_limit => 45 do
+quiz 'Example quiz', :duration => 2700 do
# Examples of quiz questions.
# All questions have an optional :points => n that determines the
@@ -35,8 +35,8 @@
# true/false questions - explanation is optional
- truefalse true, 'The week has 7 days.'
- truefalse false, 'The earth is flat.', :explanation => 'No, just looks that way'
+ truefalse 'The week has 7 days.', true
+ truefalse 'The earth is flat.', false, :explanation => 'No, just looks that way'
# multiple choice questions (one correct answer):
# - can provide a generic 'explanation' clause and/or override it
diff --git a/html_template/template.html.erb b/html_template/template.html.erb
index 7e7d4a7..e1ea289 100644
--- a/html_template/template.html.erb
+++ b/html_template/template.html.erb
@@ -24,7 +24,7 @@
- No books, notes, or electronic devices allowed.
- - Time limit is 30 minutes.
+ - Time limit is <%= duration / 60 %> minutes.
- <%= num_questions %> multiple-choice questions, points indicated per question,
<%= total_points %> points total. Points per question are intended
to reflect approximate times they should take, at about 1 point per minute.
diff --git a/lib/html5_renderer.rb b/lib/html5_renderer.rb
index 23d2377..ca31ce7 100644
--- a/lib/html5_renderer.rb
+++ b/lib/html5_renderer.rb
@@ -34,10 +34,11 @@ def render_quiz
end
def render_with_template
- # 3 local variables that can should be in scope in the template:
+ # local variables that can be used in the template:
title = @quiz.title
total_points = @quiz.points
num_questions = @quiz.num_questions
+ duration = @quiz.options[:duration]
output = ERB.new(IO.read(File.expand_path @template)).result(binding)
@output = output
end
diff --git a/spec/html5_renderer_spec.rb b/spec/html5_renderer_spec.rb
index a86efde..b22661c 100644
--- a/spec/html5_renderer_spec.rb
+++ b/spec/html5_renderer_spec.rb
@@ -51,10 +51,10 @@ def write_template(str)
return f.path
end
before :each do
- @atts = {:title => 'My Quiz', :points => 20, :num_questions => 5}
- @quiz = mock('quiz', @atts.merge(:questions => []))
+ @atts = {:title => 'My Quiz', :points => 20, :num_questions => 5, :duration => 1200}
+ @quiz = mock('quiz', @atts.merge(:questions => [], :options => {:duration => @atts[:duration]}))
end
- %w(title total_points num_questions).each do |var|
+ %w(title total_points num_questions duration).each do |var|
it "should set '#{var}'" do
value = @atts[var]
Html5Renderer.new(@quiz, 't' => write_template("#{var}: <%= #{value} %>")).render_quiz.output.
diff --git a/spec/quiz_spec.rb b/spec/quiz_spec.rb
index 0cdc2d3..a788d7f 100644
--- a/spec/quiz_spec.rb
+++ b/spec/quiz_spec.rb
@@ -10,7 +10,7 @@
Quiz.new('quiz',:questions => Array.new(3) { mock 'question', :points => 7 }).points.should == 21
end
describe 'should include required XML elements when XML renderer used' do
- subject { Quiz.new('Foo', :maximum_submissions => 2, :start => '2011-01-01 00:00', :time_limit => 60).render_with(:xml) }
+ subject { Quiz.new('Foo', :maximum_submissions => 2, :start => '2011-01-01 00:00', :duration => 3600).render_with(:xml) }
{'title' => 'Foo',
'maximum_submissions' => '2',
'type' => 'quiz' }.each_pair do |element, value|