Skip to content

Commit

Permalink
Refactored multiple choice questions form to use partial
Browse files Browse the repository at this point in the history
  • Loading branch information
sdflem committed Oct 9, 2018
1 parent 36eb7f1 commit a8ccbf8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 71 deletions.
36 changes: 36 additions & 0 deletions app/views/multiple_choice_questions/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<%= form_with model: multiple_choice_question, local: true do |form| %>
<div class="field">
<%= form.label :question %>
<%= form.text_field :question, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :answer %>
<%= form.text_field :answer, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_1 %>
<%= form.text_field :distractor_1, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_2 %>
<%= form.text_field :distractor_2, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_3 %>
<%= form.text_field :distractor_3, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_4 %>
<%= form.text_field :distractor_4, class: 'form-control' %>
</div>

<div class="actions">
<%= form.submit 'Submit', class: 'btn btn-primary' %>
</div>
<% end %>
38 changes: 2 additions & 36 deletions app/views/multiple_choice_questions/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,8 @@

<h1>Edit Multiple Choice Question</h1>

<%= form_with model: @multiple_choice_question, local: true do |form| %>
<div class="field">
<%= form.label :question %>
<%= form.text_field :question, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :answer %>
<%= form.text_field :answer, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_1 %>
<%= form.text_field :distractor_1, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_2 %>
<%= form.text_field :distractor_2, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_3 %>
<%= form.text_field :distractor_3, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_4 %>
<%= form.text_field :distractor_4, class: 'form-control' %>
</div>

<div class="actions">
<%= form.submit 'Update Multiple Choice Question', class: 'btn btn-primary' %>
</div>
<% end %>

<%= render 'form', multiple_choice_question: @multiple_choice_question %>

<p>
<%= link_to 'Back', multiple_choice_questions_path %>
</p>
Expand Down
36 changes: 1 addition & 35 deletions app/views/multiple_choice_questions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,7 @@

<h1>New Multiple Choice Question</h1>

<%= form_with model: @multiple_choice_question, local: true do |form| %>
<div class="field">
<%= form.label :question %>
<%= form.text_field :question, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :answer %>
<%= form.text_field :answer, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_1 %>
<%= form.text_field :distractor_1, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_2 %>
<%= form.text_field :distractor_2, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_3 %>
<%= form.text_field :distractor_3, class: 'form-control' %>
</div>

<div class="field">
<%= form.label :distractor_4 %>
<%= form.text_field :distractor_4, class: 'form-control' %>
</div>

<div class="actions">
<%= form.submit 'Create Multiple Choice Question', class: 'btn btn-primary' %>
</div>
<% end %>
<%= render 'form', multiple_choice_question: @multiple_choice_question %>

<p>
<%= link_to 'Back', multiple_choice_questions_path %>
Expand Down

0 comments on commit a8ccbf8

Please sign in to comment.