Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

timed, export clear db

  • Loading branch information...
commit 9b34163ac0b8d9e25574ee65f0c809c21be4e515 1 parent f224159
@rposborne rposborne authored
View
22 app/controllers/responses_controller.rb
@@ -1,7 +1,7 @@
class ResponsesController < ApplicationController
# GET /responses
# GET /responses.xml
-layout proc{ |c| c.request.xhr? ? false : "application" }
+ layout proc{ |c| c.request.xhr? ? false : "application" }
def index
@responses = Response.all
@@ -37,36 +37,36 @@ def new
def edit
@response = Response.find(params[:id])
end
-
+
def empty
Response.delete_all
@responses = []
- render :index
+ redirect_to responses_url
end
-
+
def export_to_csv
@responses = Response.find(:all)
csv_string = FasterCSV.generate do |csv|
# header row
- csv << ["id", "participant_id", "group", "error", "essay", "Correct?", "Field Before Correction", "Time Corrected"]
+ csv << ["id", "participant_id", "group", "error", "essay", "Correct?", "Field Before Correction","Seconds to Complete", "Time Corrected"]
# data rows
@responses.each do |response|
- csv << [response.id, response.user_id, response.user.group,response.error, response.essay, response.correct, response.uncorrected, response.created_at ]
+ csv << [response.id, response.user_id, response.user.group,response.error, response.essay, response.correct, response.uncorrected, response.user.time_to_complete, response.created_at ]
end
end
# send it to the browsah
send_data csv_string,
- :type => 'text/csv; charset=iso-8859-1; header=present',
- :disposition => "attachment; filename=responses.csv"
+ :type => 'text/csv; charset=iso-8859-1; header=present',
+ :disposition => "attachment; filename=responses.csv"
end
# POST /responses
# POST /responses.xml
def create
-
+
@user = User.find_or_create_by_id(params[:participant_id], :group => params[:group])
@response = @user.responses.find_or_create_by_error(params[:response][:id])
@@ -77,12 +77,12 @@ def create
format.js
format.html { redirect_to(@response, :notice => 'Response was successfully created.') }
format.xml { render :xml => @response, :status => :created, :location => @response }
-
+
else
format.js {render :js => "#{ @response.errors}"}
format.html { render :action => "new" }
format.xml { render :xml => @response.errors, :status => :unprocessable_entity }
-
+
end
end
end
View
10 app/controllers/users_controller.rb
@@ -10,6 +10,16 @@ def index
format.xml { render :xml => @users }
end
end
+ def mark_completed
+ @user = User.find_or_create_by_id(params[:participant_id], :group => params[:group])
+ @time = params[:time_to_complete].split(":")
+ @seconds = @time[0].to_i*60
+ @seconds = @seconds + @time[1].to_i
+ @user.time_to_complete = 600 - @seconds
+ @user.save
+ render :js => "true"
+ end
+
def stats
@users = User.find_all_by_group(params[:group])
View
10 app/views/essays/index.haml
@@ -54,8 +54,10 @@
.instruction_body
%p
- Please wait.
-
+ Please wait for further instructions.
+ .button
+ Start
+
-# shown prompting us to finish or not, when we click finish
.confirm_quit
.label
@@ -67,7 +69,7 @@
.finished
-# note when this loads, turn off the unload handler
.label
- Congratulations you are done :-)
+ Thank you for Participating
.msg
-# body will contain the scores from russell's stuff
@@ -75,7 +77,7 @@
.continue
-# have this link to some setup page for ellie
- %a{:href => '#'}
+ %a{:href => '#', :onClick => "window.location.reload()"}
Prepare this computer for the next trial
View
2  app/views/responses/index.html.erb
@@ -19,6 +19,7 @@
<th>Essay ID</th>
<th>Correct? </th>
<th>Field Before Correction </th>
+ <th>Seconds To Complete </th>
<th><%= t("web-app-theme.created_at", :default => "Created at") %></th>
<th class="last">&nbsp;</th>
</tr>
@@ -37,6 +38,7 @@
<td><%= response.essay %></td>
<td><%= response.correct %></td>
<td><%= response.uncorrected %></td>
+ <td><%= response.user.time_to_complete %></td>
<td>
<%= response.created_at %>
View
57 config/routes.rb
@@ -15,66 +15,13 @@
resources :e
resources :f
match 'responses/empty' => "responses#empty"
- match 'responses/export' => "responses#export_to_csv"
+ match 'responses/export' => "responses#export_to_csv"
resources :responses
-
+ match 'users/complete' => 'users#mark_completed'
match 'users/stats' => 'users#stats'
resources :users
root :to => "a#index"
- # The priority is based upon order of creation:
- # first created -> highest priority.
-
- # Sample of regular route:
- # match 'products/:id' => 'catalog#view'
- # Keep in mind you can assign values other than :controller and :action
-
- # Sample of named route:
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
- # This route can be invoked with purchase_url(:id => product.id)
-
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # resources :products
-
- # Sample resource route with options:
- # resources :products do
- # member do
- # get 'short'
- # post 'toggle'
- # end
- #
- # collection do
- # get 'sold'
- # end
- # end
-
- # Sample resource route with sub-resources:
- # resources :products do
- # resources :comments, :sales
- # resource :seller
- # end
-
- # Sample resource route with more complex sub-resources
- # resources :products do
- # resources :comments
- # resources :sales do
- # get 'recent', :on => :collection
- # end
- # end
-
- # Sample resource route within a namespace:
- # namespace :admin do
- # # Directs /admin/products/* to Admin::ProductsController
- # # (app/controllers/admin/products_controller.rb)
- # resources :products
- # end
-
- # You can have the root of your site routed with "root"
- # just remember to delete public/index.html.
-
-
- # See how all your routes lay out with "rake routes"
- # This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
match ':controller(/:action(/:id(.:format)))'
end
View
9 db/migrate/20110418024004_time_to_complete_to_user.rb
@@ -0,0 +1,9 @@
+class TimeToCompleteToUser < ActiveRecord::Migration
+ def self.up
+ add_column :users, :time_to_complete, :string
+ end
+
+ def self.down
+ remove_column :users, :time_to_complete
+ end
+end
View
3  db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110402181907) do
+ActiveRecord::Schema.define(:version => 20110418024004) do
create_table "responses", :force => true do |t|
t.integer "user_id"
@@ -30,6 +30,7 @@
t.datetime "created_at"
t.datetime "updated_at"
t.string "group"
+ t.string "time_to_complete"
end
end
View
13 public/javascripts/ben/phd.js
@@ -168,13 +168,22 @@ $(document).ready(function() {
overlayId: 'quit-overlay',
containerId: 'quit-container',
onShow:function(){
-
+ // Hack to steal the time from the timer.
+ var time = $(".timer").html();
// TODO: k you may need to change the url to the score_card
// Do an ajax request to get the body we are looking for
$.get( window.path_to_controller + '/score_card?participant_id=' + window.participant_id, function(data) {
$('.finished .body').html(data);
});
-
+ //Send the time to the backend
+ $.ajax({
+ type: 'POST',
+ url: "users/complete",
+ data: {
+ "participant_id": window.participant_id,
+ "time_to_complete" : time
+ }
+ });
}
});
View
2  public/stylesheets/modal.css
@@ -27,7 +27,7 @@
#simplemodal-container a.modalCloseImg {background:url(../img/basic/x.png) no-repeat; width:25px; height:29px; display:inline; z-index:3200; position:absolute; top:-15px; right:-16px; cursor:pointer;}
#simplemodal-container h3 {color:#84b8d9;}
-#simplemodal-container input {
+#simplemodal-container input[type=text] {
height:30px;
width:150px;
padding:10px;
View
86 public/stylesheets/screen.css
@@ -11,7 +11,7 @@ a.modalCloseImg {
}
.label{
- font-weight: bold;
+ font-weight: bold;
}
@@ -24,47 +24,75 @@ a.modalCloseImg {
/*timer*/
.timer {
- position:absolute;
- right: 10px;
- top: 10px;
-
- font-size:50px;
- width:100px;
- height:100px;
+ position:absolute;
+ right: 10px;
+ top: 10px;
+
+ font-size:50px;
+ width:100px;
+ height:100px;
}
/*menu */
.menu {
- position:absolute;
- left:0px;
- top:0px;
+ position:absolute;
+ left:0px;
+ top:0px;
}
.menu ul {
- list-style:none;
+ list-style:none;
}
.menu li a {
- width:70px;
- text-align:center;
- border: 1px solid black;
- height:10px;
- padding:10px;
- background-color: #fff;
- display:block;
+ width:70px;
+ text-align:center;
+ border: 1px solid black;
+ height:10px;
+ padding:10px;
+ background-color: #fff;
+ display:block;
}
.menu li a.selected_link {
- text-decoration: bold;
- background-color: pink;
+ text-decoration: bold;
+ background-color: pink;
}
.content{
- display:none; /*start hidden */
- position:absolute;
- left:150px;
- top:10px;
- background-color:#fff;
- width:550px;
- padding:20px;
- border:2px solid black;
+ display:none; /*start hidden */
+ position:absolute;
+ left:150px;
+ top:10px;
+ background-color:#fff;
+ width:550px;
+ padding:20px;
+ border:2px solid black;
}
+.button, .button:visited {
+ text-align:center;
+ margin:10px;
+ width:150px;
+ background: #222 url(overlay.png) repeat-x;
+ display: inline-block;
+ padding:10px 5px 10px 15px;
+ color: #fff;
+ text-decoration: none;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.6);
+ -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.6);
+ text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
+ border-bottom: 1px solid rgba(0,0,0,0.25);
+ position: relative;
+ cursor: pointer
+}
+
+.button, .button:visited { font-size: 24px;
+ font-weight: bold;
+ line-height: 24px;
+ text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
+
+ }
+
+ .button, .button:visited { background-color: #91bd09; }
+ .button:hover { background-color: #749a02; }
Please sign in to comment.
Something went wrong with that request. Please try again.