Class: Criterion

Inherits:
Object
  • Object
show all
Defined in:
lib/ruql/open_assessment/criterion.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Criterion

Initializes a criterion



8
9
10
11
# File 'lib/ruql/open_assessment/criterion.rb', line 8

def initialize(options={})
  @options = []
  @feedback = options[:feedback] || "required"
end

Instance Attribute Details

#criterion_labelObject

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_nameObject

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_promptObject

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

#feedbackObject

Returns the value of attribute feedback.



3
4
5
# File 'lib/ruql/open_assessment/criterion.rb', line 3

def feedback
  @feedback
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/ruql/open_assessment/criterion.rb', line 3

def options
  @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)
  options << 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

Returns:

  • (Boolean)


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?
  options << 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