Skip to content

Commit

Permalink
Added show pages for multiple choice questions
Browse files Browse the repository at this point in the history
  • Loading branch information
sdflem committed Oct 8, 2018
1 parent 3d3da9d commit 1d90ad3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/multiple_choice_questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ def index
@multiple_choice_questions = MultipleChoiceQuestion.all
# render 'multiple_choice_questions/index.html.erb'
end

def show
@multiple_choice_question = MultipleChoiceQuestion.find(params[:id])
# render 'multiple_choice_questions/show.html.erb'
end
end
2 changes: 2 additions & 0 deletions app/views/multiple_choice_questions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<th scope="col">Distractor 2</th>
<th scope="col">Distractor 3</th>
<th scope="col">Distractor 4</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
Expand All @@ -21,6 +22,7 @@
<td><%= question.distractor_2 %></td>
<td><%= question.distractor_3 %></td>
<td><%= question.distractor_4 %></td>
<td><%= link_to 'Show', multiple_choice_question_path(question) %></td>
</tr>
<% end %>
</tbody>
Expand Down
28 changes: 28 additions & 0 deletions app/views/multiple_choice_questions/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

<p>
<b>Question:</b> <%= @multiple_choice_question.question %>
</p>

<p>
<b>Answer:</b> <%= @multiple_choice_question.answer %>
</p>

<p>
<b>Distractor 1:</b> <%= @multiple_choice_question.distractor_1 %>
</p>

<p>
<b>Distractor 2:</b> <%= @multiple_choice_question.distractor_2 %>
</p>

<p>
<b>Distractor 3:</b> <%= @multiple_choice_question.distractor_3 %>
</p>

<p>
<b>Distractor 4:</b> <%= @multiple_choice_question.distractor_4 %>
</p>

<p>
<%= link_to 'Back', multiple_choice_questions_path %>
</p>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
get 'multiple_choice_questions/:id/ask', to: 'multiple_choice_questions#ask', as: 'ask_multiple_choice_question'
post 'multiple_choice_questions/:id/ask', to: 'multiple_choice_questions#check_answer'
get 'multiple_choice_questions', to: 'multiple_choice_questions#index', as: 'multiple_choice_questions'
get 'multiple_choice_questions/:id', to: 'multiple_choice_questions#show', as: 'multiple_choice_question'

# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

0 comments on commit 1d90ad3

Please sign in to comment.