Class: Criterion
- Inherits:
-
Object
- Object
- Criterion
- Defined in:
- lib/ruql/open_assessment/criterion.rb
Instance Attribute Summary collapse
-
#criterion_label ⇒ Object
Returns the value of attribute criterion_label.
-
#criterion_name ⇒ Object
Returns the value of attribute criterion_name.
-
#criterion_prompt ⇒ Object
Returns the value of attribute criterion_prompt.
-
#feedback ⇒ Object
Returns the value of attribute feedback.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#add_option(option) ⇒ Object
Adds an already initialized option.
-
#initialize(options = {}) ⇒ Criterion
constructor
Initializes a criterion.
-
#label(label) ⇒ Object
Sets the criterion label.
-
#missing_parameters? ⇒ Boolean
Validation to make sure that all the required fields are in.
-
#name(name) ⇒ Object
Sets the criterion name.
-
#option(*args, &block) ⇒ Object
Adds an option to the block and evaluates the proc bloc.
-
#prompt(prompt) ⇒ Object
Sets the criterion prompt.
Constructor Details
#initialize(options = {}) ⇒ Criterion
Initializes a criterion
8 9 10 11 |
# File 'lib/ruql/open_assessment/criterion.rb', line 8 def initialize(={}) @options = [] @feedback = [:feedback] || "required" end |
Instance Attribute Details
#criterion_label ⇒ Object
Returns the value of attribute criterion_label.
3 4 5 |
# File 'lib/ruql/open_assessment/criterion.rb', line 3 def criterion_label @criterion_label end |
#criterion_name ⇒ Object
Returns the value of attribute criterion_name.
3 4 5 |
# File 'lib/ruql/open_assessment/criterion.rb', line 3 def criterion_name @criterion_name end |
#criterion_prompt ⇒ Object
Returns the value of attribute criterion_prompt.
3 4 5 |
# File 'lib/ruql/open_assessment/criterion.rb', line 3 def criterion_prompt @criterion_prompt end |
#feedback ⇒ Object
Returns the value of attribute feedback.
3 4 5 |
# File 'lib/ruql/open_assessment/criterion.rb', line 3 def feedback @feedback end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/ruql/open_assessment/criterion.rb', line 3 def @options end |
Instance Method Details
#add_option(option) ⇒ Object
Adds an already initialized option
36 37 38 |
# File 'lib/ruql/open_assessment/criterion.rb', line 36 def add_option(option) << option end |
#label(label) ⇒ Object
Sets the criterion label
19 |
# File 'lib/ruql/open_assessment/criterion.rb', line 19 def label(label) ; @criterion_label = label ; end |
#missing_parameters? ⇒ Boolean
Validation to make sure that all the required fields are in
42 43 44 |
# File 'lib/ruql/open_assessment/criterion.rb', line 42 def missing_parameters? @criterion_name.nil? || @criterion_label.nil? || @criterion_prompt.nil? end |
#name(name) ⇒ Object
Sets the criterion name
15 |
# File 'lib/ruql/open_assessment/criterion.rb', line 15 def name(name) ; @criterion_name = name ; end |
#option(*args, &block) ⇒ Object
Adds an option to the block and evaluates the proc bloc
27 28 29 30 31 32 |
# File 'lib/ruql/open_assessment/criterion.rb', line 27 def option(*args, &block) option = Option.new(*args) option.instance_eval(&block) raise "Missing option parameters" if option.missing_parameters? << option end |
#prompt(prompt) ⇒ Object
Sets the criterion prompt
23 |
# File 'lib/ruql/open_assessment/criterion.rb', line 23 def prompt(prompt) ; @criterion_prompt = prompt ; end |