Skip to content

Commit

Permalink
Added a non-working question form
Browse files Browse the repository at this point in the history
  • Loading branch information
sdflem committed Oct 3, 2018
1 parent d666b50 commit f14cbcf
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/multiple_choice_questions.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/multiple_choice_questions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the MultipleChoiceQuestions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
7 changes: 7 additions & 0 deletions app/controllers/multiple_choice_questions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class MultipleChoiceQuestionsController < ApplicationController
def ask
@multiple_choice_question = MultipleChoiceQuestion.find(params[:id])
# TODO: Error handling
# render 'multiple_choice_questions/ask.html.erb'
end
end
2 changes: 2 additions & 0 deletions app/helpers/multiple_choice_questions_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module MultipleChoiceQuestionsHelper
end
55 changes: 55 additions & 0 deletions app/views/multiple_choice_questions/ask.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

<main role="main" class="container">

<h1>Answer This Question</h1>

<p>
<%= @multiple_choice_question.question %>
</p>

<%= form_tag do %>
<%
order = [0, 1, 2, 3, 4].shuffle
order.each do |a|
%>
<% if a == 0 %>
<p>
<%= radio_button_tag(:guess, '0') %>
<%= label_tag(:guess_0, @multiple_choice_question.answer) %>
</p>

<% elsif a == 1 %>
<p>
<%= radio_button_tag(:guess, '1') %>
<%= label_tag(:guess_1, @multiple_choice_question.distractor_1) %>
</p>

<% elsif a == 2 %>
<p>
<%= radio_button_tag(:guess, '2') %>
<%= label_tag(:guess_2, @multiple_choice_question.distractor_2) %>
</p>

<% elsif a == 3 %>
<p>
<%= radio_button_tag(:guess, '3') %>
<%= label_tag(:guess_3, @multiple_choice_question.distractor_3) %>
</p>

<% elsif a == 4 %>
<p>
<%= radio_button_tag(:guess, '4') %>
<%= label_tag(:guess_4, @multiple_choice_question.distractor_4) %>
</p>

<% end %>
<% end %>
<%= submit_tag("Submit Answer") %>
<% end %>

</main><!-- /.container -->
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
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'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
7 changes: 7 additions & 0 deletions test/controllers/multiple_choice_questions_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class MultipleChoiceQuestionsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end

0 comments on commit f14cbcf

Please sign in to comment.