Class: CalculatedQuestion
- Inherits:
-
Object
- Object
- CalculatedQuestion
- Includes:
- DataFactory, Foundry, StringFactory, Workflows
- Defined in:
- lib/sambal-cle/data_objects/questions.rb
Instance Attribute Summary collapse
-
#formulas ⇒ Object
Returns the value of attribute formulas.
-
#part ⇒ Object
Returns the value of attribute part.
-
#point_value ⇒ Object
Returns the value of attribute point_value.
-
#pool ⇒ Object
Returns the value of attribute pool.
-
#text ⇒ Object
Returns the value of attribute text.
-
#variables ⇒ Object
Returns the value of attribute variables.
Instance Method Summary collapse
- #calculation(x, y, z) ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #edit(opts = {}) ⇒ Object
-
#initialize(browser, opts = {}) ⇒ CalculatedQuestion
constructor
TODO: Add randomization to this class!.
- #view ⇒ Object
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 } = defaults.merge(opts) () requires @text end |
Instance Attribute Details
#formulas ⇒ Object
Returns the value of attribute formulas.
578 579 580 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 578 def formulas @formulas end |
#part ⇒ Object
Returns the value of attribute part.
578 579 580 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 578 def part @part end |
#point_value ⇒ Object
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 |
#pool ⇒ Object
Returns the value of attribute pool.
578 579 580 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 578 def pool @pool end |
#text ⇒ Object
Returns the value of attribute text.
578 579 580 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 578 def text @text end |
#variables ⇒ Object
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 |
#create ⇒ Object
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 |
#delete ⇒ Object
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={} (opts) end |
#view ⇒ Object
645 646 647 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 645 def view end |