Class: CourseAssessmentAnswerMultipleResponseInput

Inherits:
SimpleForm::Inputs::CollectionRadioButtonsInput
  • Object
show all
Defined in:
app/inputs/course_assessment_answer_multiple_response_input.rb

Instance Method Summary collapse

Instance Method Details

#build_nested_boolean_style_item_tag(collection_builder) ⇒ Object (protected)


17
18
19
20
# File 'app/inputs/course_assessment_answer_multiple_response_input.rb', line 17

def build_nested_boolean_style_item_tag(collection_builder)
  collection_builder.public_send(builder_input_type) +
    (:span, collection_builder.text, class: [correct_class(collection_builder.object)])
end

#builder_input_typeObject (protected)


33
34
35
# File 'app/inputs/course_assessment_answer_multiple_response_input.rb', line 33

def builder_input_type
  check_boxes? ? :check_box : :radio_button
end

#check_boxes?Boolean (protected)

Returns:

  • (Boolean)

9
10
11
# File 'app/inputs/course_assessment_answer_multiple_response_input.rb', line 9

def check_boxes?
  !object.question.specific.multiple_choice?
end

#correct_class(option) ⇒ nil, String (protected)

Gets the CSS class for the answer's correct state.

Parameters:

Returns:

  • (nil)

    When no solution is supposed to be displayed, or the option is incorrect.

  • (String)

    When the answer is correct.


28
29
30
31
# File 'app/inputs/course_assessment_answer_multiple_response_input.rb', line 28

def correct_class(option)
  return nil unless options[:display_solution]
  option.correct? ? 'correct' : nil
end

#has_required?Boolean (protected)

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)

13
14
15
# File 'app/inputs/course_assessment_answer_multiple_response_input.rb', line 13

def has_required? # rubocop:disable Naming/PredicateName
  !check_boxes?
end

#input_typeObject


3
4
5
# File 'app/inputs/course_assessment_answer_multiple_response_input.rb', line 3

def input_type
  check_boxes? ? :check_boxes : :radio_buttons
end

#item_wrapper_classObject (protected)


37
38
39
# File 'app/inputs/course_assessment_answer_multiple_response_input.rb', line 37

def item_wrapper_class
  check_boxes? ? 'checkbox' : 'radio'
end