aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--config/routes.rb7
-rw-r--r--db/schema.rb11
-rw-r--r--public/stylesheets/main.css9
-rw-r--r--spec/controllers/request_controller_spec.rb4
-rw-r--r--todo.txt11
9 files changed, 92 insertions, 34 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 %>
diff --git a/config/routes.rb b/config/routes.rb
index 832b3199e..8cb25a15a 100644
--- a/config/routes.rb
+++ b/config/routes.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: routes.rb,v 1.91 2009-10-03 10:23:44 francis Exp $
+# $Id: routes.rb,v 1.92 2009-10-14 22:01:27 francis Exp $
ActionController::Routing::Routes.draw do |map|
@@ -98,8 +98,9 @@ ActionController::Routing::Routes.draw do |map|
end
map.with_options :controller => 'request_game' do |game|
- game.play "/categorise/play", :action => 'play'
- game.stop "/categorise/stop", :action => 'stop'
+ game.play '/categorise/play', :action => 'play'
+ game.request '/categorise/request/:url_title', :action => 'show'
+ game.stop '/categorise/stop', :action => 'stop'
end
# NB: We don't use routes to *construct* admin URLs, as they need to be relative
diff --git a/db/schema.rb b/db/schema.rb
index 59d779cd8..50adde788 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 80) do
+ActiveRecord::Schema.define(:version => 81) do
create_table "acts_as_xapian_jobs", :force => true do |t|
t.string "model", :null => false
@@ -78,16 +78,17 @@ ActiveRecord::Schema.define(:version => 80) do
end
create_table "info_request_events", :force => true do |t|
- t.integer "info_request_id", :null => false
- t.text "event_type", :null => false
- t.text "params_yaml", :null => false
- t.datetime "created_at", :null => false
+ t.integer "info_request_id", :null => false
+ t.text "event_type", :null => false
+ t.text "params_yaml", :null => false
+ t.datetime "created_at", :null => false
t.string "described_state"
t.string "calculated_state"
t.datetime "last_described_at"
t.integer "incoming_message_id"
t.integer "outgoing_message_id"
t.integer "comment_id"
+ t.string "prominence", :default => "normal", :null => false
end
add_index "info_request_events", ["created_at"], :name => "index_info_request_events_on_created_at"
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index 3c4c7e1a0..4c2e490e2 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -1038,5 +1038,12 @@ div.act_link img {
#game_buttons {
}
-
+#game_sidebar
+{
+ float: right;
+ clear: none;
+ width: 12em;
+ margin: 0 0 0 2em;
+ font-size: 0.8em;
+}
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 847928076..bcd17f468 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -521,7 +521,7 @@ describe RequestController, "when classifying an information request" do
it 'should show a message thanking the user for a good deed' do
post_status('rejected')
- flash[:notice].should == '<p>Thank you for updating this request!</p>'
+ flash[:notice].should == 'Thank you for updating this request!'
end
end
@@ -562,7 +562,7 @@ describe RequestController, "when classifying an information request" do
it 'should show a message thanking the user for a good deed' do
post_status('rejected')
- flash[:notice].should == '<p>Thank you for updating this request!</p>'
+ flash[:notice].should == 'Thank you for updating this request!'
end
end
diff --git a/todo.txt b/todo.txt
index 8be54cb8d..4efa87a0b 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,3 +1,10 @@
+prominence code is gnarly - somehow make sure more reliably that you can never see requests
+which are hidden.
+ render :partial => 'correspondence'
+
+remove show_response?
+
+
test if get_attachments_for_display called multiple times in one request?
sending an email alert for this query takes crazy long
@@ -30,6 +37,10 @@ incorrectly. Change wording to make it clear statuses are users opinion ?.
* And ask that they include URL of requests in emails when talking about them
Finish up the request game, and market it a bit more.
+ * Let you see main page without login
+ * Or you can do it yourself (if you are not logged in and request isn't classified)
+ * Market it from every request that isn't categorised
+ (and when you categorise one)
Check up on how the public old request status editing is being used in
practice. Think about UI a bit more to try and up rate, and UI of
alerts to requester.