OSDN Git Service

add special message
authorokimoto <okimoto@good-day.co.jp>
Tue, 9 Mar 2010 07:08:32 +0000 (16:08 +0900)
committerokimoto <okimoto@good-day.co.jp>
Tue, 9 Mar 2010 07:08:32 +0000 (16:08 +0900)
app/controllers/reports_controller.rb
app/helpers/reports_helper.rb
app/views/reports/show.html.erb

index 3ff27cd..cb3fcbb 100644 (file)
@@ -48,6 +48,7 @@ class ReportsController < ApplicationController
   end
 
   def show
+    @reports = @user.reports.by_date(Date.today)
     @report = @user.reports.first(:conditions => { :id => params[:id] })
     @results = @report.learning_results
     @problem_group_id = @report.problem_group_id
index da9864a..a7a9a0d 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 module ReportsHelper
 
   def gradient_intercept(expression)
@@ -7,4 +8,12 @@ module ReportsHelper
     m.map{|v| v ? v.gsub(/ */, "") : "1" }
   end
 
+  def message(count)
+    case count
+    when 1    then "一発完答!すごい!"
+    when 2, 3 then "快調ですね!"
+    else           "よくねばりました。一服してください。"
+    end
+  end
+
 end
index 3cbae98..d610a31 100644 (file)
@@ -12,6 +12,7 @@
 <%- unless @results.empty? -%>
   <%- if @results.all?(&:correct?) -%>
     <p>全問正解です。おめでとう!</p>
+    <p><%= message(@reports.size) %></p>
   <%- else -%>
     <p>まちがいがあります。</p>
   <%- end -%>