Class: CalculatedQuestion

Inherits:
Object
  • Object
show all
Includes:
DataFactory, Foundry, StringFactory, Workflows
Defined in:
lib/sambal-cle/data_objects/questions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Workflows

menu_link, #open_my_site_by_name, #reset

Constructor Details

#initialize(browser, opts = {}) ⇒ CalculatedQuestion

TODO: Add randomization to this class!



582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
# File 'lib/sambal-cle/data_objects/questions.rb', line 582

def initialize(browser, opts={})
  @browser = browser

  defaults = {
      :text=>"Two cars left from the same point at the same time, one traveling East at {x} mph and the other traveling South at {y} mph. In how many minutes will they be {z} miles apart?\n\nRound to the nearest minute.\n\n{{abc}}",
      :variables=>{
          :x=>{:min=>rand(50)+1,:max=>rand(50)+51, :decimals=>rand(11)},
          :y=>{:min=>rand(50)+1,:max=>rand(50)+51, :decimals=>rand(11)},
          :z=>{:min=>rand(50)+1,:max=>rand(50)+51, :decimals=>rand(11)}
      },
      :formulas=>[{
                      :name=>"abc",
                      :text=>"SQRT({z}^2/({x}^2+{y}^2))*60",
                      :tolerance=>"0.01",
                      :decimals=>"0"
                  }],
      :point_value=>(rand(100)+1).to_s
  }

  options = defaults.merge(opts)

  set_options(options)
  requires @text
end

Instance Attribute Details

#formulasObject

Returns the value of attribute formulas.



578
579
580
# File 'lib/sambal-cle/data_objects/questions.rb', line 578

def formulas
  @formulas
end

#partObject

Returns the value of attribute part.



578
579
580
# File 'lib/sambal-cle/data_objects/questions.rb', line 578

def part
  @part
end

#point_valueObject

Returns the value of attribute point_value.



578
579
580
# File 'lib/sambal-cle/data_objects/questions.rb', line 578

def point_value
  @point_value
end

#poolObject

Returns the value of attribute pool.



578
579
580
# File 'lib/sambal-cle/data_objects/questions.rb', line 578

def pool
  @pool
end

#textObject

Returns the value of attribute text.



578
579
580
# File 'lib/sambal-cle/data_objects/questions.rb', line 578

def text
  @text
end

#variablesObject

Returns the value of attribute variables.



578
579
580
# File 'lib/sambal-cle/data_objects/questions.rb', line 578

def variables
  @variables
end

Instance Method Details

#calculation(x, y, z) ⇒ Object



607
608
609
# File 'lib/sambal-cle/data_objects/questions.rb', line 607

def calculation(x, y, z)
  (Math.sqrt((z**2)/((x**2)+(y**2))))*60
end

#createObject



611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/sambal-cle/data_objects/questions.rb', line 611

def create
  on EditAssessment do |edit|
    edit.question_type "Calculated Question"
  end
  on CalculatedQuestions do |add|
    add.question_text.set @text
    add.answer_point_value.set @point_value
    add.assign_to_part.select /#{@part}/
    add.assign_to_pool.fit @pool
    add.question_text.set @text
    add.extract_vs_and_fs

    @variables.each do |name, attribs|
      var = name.to_s
      add.min_value(var).set attribs[:min]
      add.max_value(var).set attribs[:max]
      add.var_decimals(var).select attribs[:decimals]
    end
    @formulas.each do |formula|
      add.formula(formula[:name]).set formula[:text]
      add.tolerance(formula[:name]).set formula[:tolerance]
      add.form_decimals(formula[:name]).select formula[:decimals]
    end
    add.correct_answer_feedback.fit @correct_answer_feedback
    add.incorrect_answer_feedback.fit @incorrect_answer_feedback
    add.save
  end
end

#deleteObject



649
650
651
# File 'lib/sambal-cle/data_objects/questions.rb', line 649

def delete

end

#edit(opts = {}) ⇒ Object



640
641
642
643
# File 'lib/sambal-cle/data_objects/questions.rb', line 640

def edit opts={}

  set_options(opts)
end

#viewObject



645
646
647
# File 'lib/sambal-cle/data_objects/questions.rb', line 645

def view

end