Skip to content

Commit

Permalink
write result test1
Browse files Browse the repository at this point in the history
  • Loading branch information
bek0nik committed May 28, 2012
1 parent f9bda06 commit d085aac
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
15 changes: 9 additions & 6 deletions app/controllers/test_names_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ def start
counter = 0
@question.each { |q|
if q.correct == params[:correct]
counter = counter + 1
flash[:notice] = "Successfully"
counter += 1
else
counter = counter + 0
# render :action => :index
counter += 0
end
}
Report.create(:user_id => current_user.id, :test_name_id => @test.id, :result => counter, :finished => Time.now)
counter
# @result = Report.create(:user_id => current_user.id, :test_name_id => @test.id, :result => counter, :finished => Time.now)
# if @result.save
# render "reports/result"
# end

# if @question[1..5] == params[:correct]
# flash[:notice] = "Successfully"
# elsif == params[:fail]
Expand All @@ -47,5 +50,5 @@ def start
# end
# session[:test_step] = @test.current_step
end

private
end
1 change: 1 addition & 0 deletions app/models/report.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#encoding:UTF-8
class Report < ActiveRecord::Base
validates :user_id, :test_name_id, :result, presence: true
end
1 change: 1 addition & 0 deletions app/views/reports/result.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>yra</h1>
10 changes: 5 additions & 5 deletions app/views/test_names/start.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
<p class="testing"><%= q.title %></p>
<div class="controls testing">
<label class="radio">
<%= radio_button_tag q.id, q.variant_1, params[:fail] %>
<%= radio_button_tag q.id, params[:fail] %>
<%= label_tag q.variant_1 %>
</label>

<label class="radio">
<%= radio_button_tag q.id, q.variant_2, params[:fail] %>
<%= radio_button_tag q.id, params[:fail] %>
<%= label_tag q.variant_2 %>
</label>

<label class="radio">
<%= radio_button_tag q.id, q.variant_3, params[:fail] %>
<%= radio_button_tag q.id, params[:fail] %>
<%= label_tag q.variant_3 %>
</label>

<label class="radio">
<%= radio_button_tag q.id, q.variant_4, params[:fail] %>
<%= radio_button_tag q.id, params[:fail] %>
<%= label_tag q.variant_4 %>
</label>

<label class="radio">
<%= radio_button_tag q.id, q.correct, params[:correct] %>
<%= radio_button_tag q.id, params[:correct] %>
<%= label_tag q.correct %>
</label>
</div><br />
Expand Down

0 comments on commit d085aac

Please sign in to comment.