Module: ExerciseInputHelper
- Defined in:
- app/helpers/exercise_input_helper.rb
Instance Method Summary collapse
- #exercise_container_type ⇒ Object
- #input_kids? ⇒ Boolean
- #render_custom_editor(exercise) ⇒ Object
- #render_exercise_input_editor(form, exercise) ⇒ Object
- #render_exercise_input_form(exercise) ⇒ Object
- #render_exercise_input_layout(exercise) ⇒ Object
- #render_submit_button(exercise) ⇒ Object
- #should_render_message_input?(exercise, organization = Organization.current) ⇒ Boolean
- #should_render_problem_tabs?(exercise, user) ⇒ Boolean
- #submit_button_options(exercise) ⇒ Object
Instance Method Details
#exercise_container_type ⇒ Object
42 43 44 |
# File 'app/helpers/exercise_input_helper.rb', line 42 def exercise_container_type input_kids? ? 'container-fluid' : 'container' end |
#input_kids? ⇒ Boolean
38 39 40 |
# File 'app/helpers/exercise_input_helper.rb', line 38 def input_kids? @exercise&.input_kids? end |
#render_custom_editor(exercise) ⇒ Object
33 34 35 36 |
# File 'app/helpers/exercise_input_helper.rb', line 33 def render_custom_editor(exercise) custom_editor_tag = "mu-#{exercise.language}-custom-editor" "<#{custom_editor_tag}> </#{custom_editor_tag}>".html_safe end |
#render_exercise_input_editor(form, exercise) ⇒ Object
10 11 12 |
# File 'app/helpers/exercise_input_helper.rb', line 10 def render_exercise_input_editor(form, exercise) render "layouts/exercise_inputs/editors/#{exercise.editor}", form: form, exercise: exercise end |
#render_exercise_input_form(exercise) ⇒ Object
6 7 8 |
# File 'app/helpers/exercise_input_helper.rb', line 6 def render_exercise_input_form(exercise) render "layouts/exercise_inputs/forms/#{exercise.class.name.underscore}_form" end |
#render_exercise_input_layout(exercise) ⇒ Object
2 3 4 |
# File 'app/helpers/exercise_input_helper.rb', line 2 def render_exercise_input_layout(exercise) render "layouts/exercise_inputs/layouts/#{exercise.layout}" end |
#render_submit_button(exercise) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/exercise_input_helper.rb', line 22 def (exercise) = (exercise) text = t(.t) if .t.present? waiting_text = t(.waiting_t) if .waiting_t.present? %Q{<#{.tag} for="#{.for}" class="btn btn-success btn-block btn-submit #{.classes}" data-waiting="#{waiting_text}"> #{fa_icon .fa_icon, text: text} </#{.tag}>}.html_safe end |
#should_render_message_input?(exercise, organization = Organization.current) ⇒ Boolean
18 19 20 |
# File 'app/helpers/exercise_input_helper.rb', line 18 def (exercise, organization = Organization.current) exercise.is_a?(Problem) && !exercise.hidden? && organization.raise_hand_enabled? end |
#should_render_problem_tabs?(exercise, user) ⇒ Boolean
14 15 16 |
# File 'app/helpers/exercise_input_helper.rb', line 14 def should_render_problem_tabs?(exercise, user) !exercise.hidden? && (exercise.queriable? || exercise.extra_visible? || exercise.(user)) end |
#submit_button_options(exercise) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/helpers/exercise_input_helper.rb', line 46 def (exercise) if exercise.upload? struct for: 'upload-input', tag: :label, waiting_t: :uploading_solution, fa_icon: :upload, t: :upload_solution elsif exercise.hidden? struct tag: :button, classes: 'submission_control', waiting_t: :working, fa_icon: :play, t: :continue_exercise elsif exercise.input_kids? struct tag: :button, classes: 'submission_control', fa_icon: :play else struct tag: :button, classes: 'submission_control', waiting_t: :sending_solution, fa_icon: :play, t: :create_submission end end |