Skip to content

Commit

Permalink
Added index page 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 6cef563 commit 3d3da9d
Show file tree
Hide file tree
Showing 4 changed files with 39 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 @@ -23,4 +23,9 @@ def check_answer
redirect_to home_url, alert: "Error: Invalid answer."
end
end

def index
@multiple_choice_questions = MultipleChoiceQuestion.all
# render 'multiple_choice_questions/index.html.erb'
end
end
3 changes: 3 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<li class="nav-item <%= active_class(about_path) %>">
<%= link_to 'About', about_path, class: 'nav-link' %>
</li>
<li class="nav-item <%= active_class(multiple_choice_questions_path) %>">
<%= link_to 'Teachers', multiple_choice_questions_path, class: 'nav-link' %>
</li>
<%
=begin
<li class="nav-item">
Expand Down
27 changes: 27 additions & 0 deletions app/views/multiple_choice_questions/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

<h1>Multiple Choice Questions</h1>

<table class="table table-sm">
<thead>
<tr>
<th scope="col">Question</th>
<th scope="col">Answer</th>
<th scope="col">Distractor 1</th>
<th scope="col">Distractor 2</th>
<th scope="col">Distractor 3</th>
<th scope="col">Distractor 4</th>
</tr>
</thead>
<tbody>
<% @multiple_choice_questions.each do |question| %>
<tr>
<td><%= question.question %></td>
<td><%= question.answer %></td>
<td><%= question.distractor_1 %></td>
<td><%= question.distractor_2 %></td>
<td><%= question.distractor_3 %></td>
<td><%= question.distractor_4 %></td>
</tr>
<% end %>
</tbody>
</table>
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
Rails.application.routes.draw do
root to: 'pages#home'

get 'home', to: 'pages#home', as: 'home'
get 'about', to: 'pages#about', as: 'about'
get 'sdflming', to: 'pages#sdflming', as: 'sdflming'

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'

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

0 comments on commit 3d3da9d

Please sign in to comment.