column :answer_type
column :r_min, :type => :integer
column :r_max, :type => :integer
+ column :p_minus, :type => :boolean
column :p_min, :type => :integer
column :p_max, :type => :integer
column :q_min, :type => :integer
:answer_type => answer_type,
:r_min => r_min,
:r_max => r_max,
+ :p_minus => p_minus,
:p_min => p_min,
:p_max => p_max,
:q_min => q_min,
self.answer_type = hash["answer_type"]
self.r_min = hash["r_min"]
self.r_max = hash["r_max"]
+ self.p_minus = hash["p_minus"]
self.p_min = hash["p_min"]
self.p_max = hash["p_max"]
self.q_min = hash["q_min"]
end
def validate
+ check_min_max(:p_min, :p_max)
+ check_min_max(:q_min, :q_max)
+ check_min_max(:r_min, :r_max)
end
end
<table class="problem">
<%= render :partial => "common" %>
<%= render :partial => "minus_min_max", :locals => { :prefix => "r_", :minus => false } %>
- <%= render :partial => "minus_min_max", :locals => { :prefix => "p_", :minus => false } %>
+ <%= render :partial => "minus_min_max", :locals => { :prefix => "p_", :minus => true } %>
<%= render :partial => "minus_min_max", :locals => { :prefix => "q_", :minus => false } %>
</table>
<table class="problem">
<%= render :partial => "common_edit_form", :locals => { :f => f } %>
<%= render :partial => "minus_min_max_edit_form", :locals => { :f => f, :prefix => "r_", :minus => false } %>
- <%= render :partial => "minus_min_max_edit_form", :locals => { :f => f, :prefix => "p_", :minus => false } %>
+ <%= render :partial => "minus_min_max_edit_form", :locals => { :f => f, :prefix => "p_", :minus => true } %>
<%= render :partial => "minus_min_max_edit_form", :locals => { :f => f, :prefix => "q_", :minus => false } %>
</table>
:answer_type => "rational",
:r_min => 1,
:r_max => 10,
+ :p_minus => true,
:p_min => 0,
:p_max => 20,
:q_min => 0,
end
end
+ context "relation" do
+ context "p" do
+ before do
+ @target_left = :p_min
+ @target_right = :p_max
+ @message = "P min must be greater than P max."
+ end
+ it_should_behave_like "check_min_max"
+ end
+
+ context "q" do
+ before do
+ @target_left = :q_min
+ @target_right = :q_max
+ @message = "Q min must be greater than Q max."
+ end
+ it_should_behave_like "check_min_max"
+ end
+
+ context "r" do
+ before do
+ @target_left = :r_min
+ @target_right = :r_max
+ @message = "R min must be greater than R max."
+ end
+ it_should_behave_like "check_min_max"
+ end
+ end
end
context "options_hash" do
:answer_type => "rational",
:r_min => 1,
:r_max => 10,
+ :p_minus => true,
:p_min => 0,
:p_max => 20,
:q_min => 0,
:answer_type => "irrational",
:r_min => 1,
:r_max => 11,
+ :p_minus => true,
:p_min => 2,
:p_max => 21,
:q_min => 2,
its(:answer_type){ should == "irrational" }
its(:r_min){ should == 1 }
its(:r_max){ should == 11 }
+ its(:p_minus){ should be_true }
its(:p_min){ should == 2 }
its(:p_max){ should == 21 }
its(:q_min){ should == 2 }