aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/request_controller.rb6
-rw-r--r--app/controllers/request_game_controller.rb44
-rw-r--r--app/views/request/_request_listing_single.rhtml2
-rw-r--r--app/views/request_game/play.rhtml32
4 files changed, 61 insertions, 23 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 0f6bb4010..461c2677a 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: request_controller.rb,v 1.190 2009-10-04 21:53:53 francis Exp $
+# $Id: request_controller.rb,v 1.191 2009-10-14 22:01:27 francis Exp $
class RequestController < ApplicationController
@@ -309,10 +309,10 @@ class RequestController < ApplicationController
# Don't give advice on what to do next, as it isn't their request
RequestMailer.deliver_old_unclassified_updated(@info_request)
if session[:request_game]
- flash[:notice] = '<p>Thank you for updating the status of the request \'<a href="' + CGI.escapeHTML(request_url(@info_request)) + '">' + CGI.escapeHTML(@info_request.title) + '</a>\'. There are some more requests below for you to classify.</p>'
+ flash[:notice] = 'Thank you for updating the status of the request \'<a href="' + CGI.escapeHTML(request_url(@info_request)) + '">' + CGI.escapeHTML(@info_request.title) + '</a>\'. There are some more requests below for you to classify.'
redirect_to play_url
else
- flash[:notice] = '<p>Thank you for updating this request!</p>'
+ flash[:notice] = 'Thank you for updating this request!'
redirect_to request_url(@info_request)
end
return
diff --git a/app/controllers/request_game_controller.rb b/app/controllers/request_game_controller.rb
index 4a95d4108..f665cce70 100644
--- a/app/controllers/request_game_controller.rb
+++ b/app/controllers/request_game_controller.rb
@@ -4,30 +4,54 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: request_game_controller.rb,v 1.5 2009-10-03 01:42:01 francis Exp $
+# $Id: request_game_controller.rb,v 1.6 2009-10-14 22:01:27 francis Exp $
class RequestGameController < ApplicationController
def play
- if !authenticated?(
- :web => "To play the request categorisation game",
- :email => "Then you can play the request categorisation game.",
- :email_subject => "Play the request categorisation game"
- )
- # do nothing - as "authenticated?" has done the redirect to signin page for us
- return
- end
-
session[:request_game] = Time.now
old = InfoRequest.find_old_unclassified(:conditions => ["prominence = 'normal'"])
@missing = old.size
+ @total = InfoRequest.count
+ @percentage = ((@total - @missing).to_f / @total.to_f * 10000).round / 100.0
+
@requests = old.sort_by{ rand }.slice(0..2)
if @missing == 0
flash[:notice] = 'All done! Thank you very much for your help.'
redirect_to frontpage_url
end
+
+ # Work out league table
+ status_update_events = InfoRequestEvent.find(:all,
+ :conditions => [ "event_type = 'status_update' and current_date - created_at < 28" ])
+ table = Hash.new { |h,k| h[k] = 0 }
+ for event in status_update_events
+ user_id = event.params[:user_id]
+ table[user_id] += 1
+ end
+ @league_table = []
+ for user_id, count in table
+ user = User.find(user_id)
+ @league_table.push([user, count])
+ end
+ @league_table.sort! { |a,b| b[1] <=> a[1] }
+
+ @play_urls = true
+ end
+
+ def show
+ url_title = params[:url_title]
+ if !authenticated?(
+ :web => "To play the request categorisation game",
+ :email => "Then you can play the request categorisation game.",
+ :email_subject => "Play the request categorisation game"
+ )
+ # do nothing - as "authenticated?" has done the redirect to signin page for us
+ return
+ end
+ redirect_to show_request_url(:url_title => url_title)
end
def stop
diff --git a/app/views/request/_request_listing_single.rhtml b/app/views/request/_request_listing_single.rhtml
index 0a060dece..0f6bf33ec 100644
--- a/app/views/request/_request_listing_single.rhtml
+++ b/app/views/request/_request_listing_single.rhtml
@@ -1,6 +1,6 @@
<div class="request_listing">
<span class="head">
- <%= link_to h(info_request.title), request_url(info_request) %>
+ <%= link_to h(info_request.title), (@play_urls ? "/categorise" : "") + request_url(info_request) %>
</span>
<span class="desc">
<%= excerpt(info_request.initial_request_text, "", 150) %>
diff --git a/app/views/request_game/play.rhtml b/app/views/request_game/play.rhtml
index edfd747bc..b4167878b 100644
--- a/app/views/request_game/play.rhtml
+++ b/app/views/request_game/play.rhtml
@@ -1,17 +1,31 @@
<% @title = 'Play the request categorisation game!' %>
-<h2>Play the request categorisation game!</h2>
+<div id="game_sidebar">
+ <p>
+ <img width=200 height=100 src="http://chart.apis.google.com/chart?chs=200x100&cht=gom&chd=t:<%=@percentage%>" alt="<%=@percentage%>% of requests have been categorised">
+ </p>
+
+ <h2>Top recent players</h2>
+ <table>
+ <% for user, count in @league_table %>
+ <tr>
+ <td> <%= user_link(user) %> </td>
+ <td> <%= count %> requests </td>
+ </tr>
+ <% end %>
+ </table>
+</div>
-<p>Hi! We need your help. We have <%= pluralize(@missing, "request") %> which had a
-response more than <%=InfoRequest::OLD_AGE_IN_DAYS.inspect %> ago, but where
-the person who made them hasn't told us whether or not they were successful.
-</p>
+<h2>Play the request categorisation game!</h2>
-<p>We would be exceedingly grateful if you could choose one of these requests,
-read it, and let everyone know whether or not the information has been
-provided.</p>
+<p>Some people who've made requests haven't let us know whether they were
+successful or not. We need <strong>your</strong> help &ndash;
+choose one of these requests, read it, and let everyone know whether or not the
+information has been provided. Everyone'll be exceedingly grateful.</p>
-<%= render :partial => 'request/request_listing', :locals => { :info_requests => @requests } %>
+<% for info_request in @requests %>
+ <%= render :partial => 'request/request_listing_single', :locals => { :info_request => info_request } %>
+<% end %>
<p id="game_buttons">
<%= button_to "I don't like these ones &mdash; give me some more!", play_url %>