Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

workerId and assignmentId are now persisted through cookies so that a…

… study can be completed beyond the initial HIT page.
  • Loading branch information...
commit 16193e94e1bb16881ed509b527db21ca30a45f75 1 parent b1e0c8f
@aantix authored
View
1  .gitignore
@@ -7,6 +7,7 @@ build.sh
## TEXTMATE
*.tmproj
tmtags
+*.log
## EMACS
*~
View
2  lib/generators/turkee/templates/create_turkee_study.rb.erb
@@ -3,7 +3,7 @@ class CreateTurkeeStudy < ActiveRecord::Migration
def self.up
create_table "turkee_studies" do |t|
t.integer "turkee_task_id"
- t.string "feedback"
+ t.text "feedback"
t.timestamps
end
View
6 lib/helpers/turkee_forms_helper.rb
@@ -11,8 +11,14 @@ def turkee_form_for(record, params, options = {}, &proc)
params.each do |k,v|
unless ['action','controller'].include?(k) || !v.is_a?(String)
buffer << hidden_field_tag(k, v)
+ cookies[k] = v
end
end
+
+ ['assignmentId', 'workerId', 'hitId'].each do |k|
+ buffer << hidden_field_tag(k, cookies[k]) if !params.has_key?(k) && cookies.has_key?(k)
+ end
+
buffer << yield(f)
buffer.html_safe
end
View
3  lib/models/turkee_task.rb
@@ -65,7 +65,8 @@ def self.save_imported_values(model, param_hash)
end
# Creates a new Mechanical Turk task on AMZN with the given title, desc, etc
- def self.create_hit(host, hit_title, hit_description, typ, num_assignments, reward, lifetime, duration = nil, qualifications = {}, params = {}, opts = {})
+ def self.create_hit(host, hit_title, hit_description, typ, num_assignments, reward, lifetime,
+ duration = nil, qualifications = {}, params = {}, opts = {})
model = typ.to_s.constantize
f_url = build_url(host, model, params, opts)
View
10 lib/tasks/turkee.rb
@@ -6,7 +6,7 @@
task :post_hit, [:host, :title, :description, :model, :num_assignments, :reward, :lifetime] => :environment do |t, args|
hit = Turkee::TurkeeTask.create_hit(args[:host],args[:title], args[:description], args[:model],
args[:num_assignments], args[:reward], args[:lifetime])
- puts "Hit created ( #{hit.hit_url} )."
+ puts "Hit created : #{hit.hit_url}"
end
desc "Retrieve all results from Mechanical Turk for all open HITs."
@@ -16,9 +16,13 @@
desc "Create a usability study. Task takes the application's full url, HIT title, HIT description, model name, number of responses, reward for each response, number of days the HIT should be valid, and number of hours a worker has to complete the HIT."
task :create_study, [:url, :title, :description, :num_assignments, :reward, :lifetime] => :environment do |t, args|
+ qualifications = {:approval_rate => {:gt => 70}, :country => {:eql => 'US'}}
+
hit = Turkee::TurkeeTask.create_hit(args[:url], args[:title], args[:description], "Turkee::TurkeeStudy",
- args[:num_assignments], args[:reward], args[:lifetime], nil, {}, {}, {:form_url => args[:url]})
- puts "Study created ( #{hit.hit_url} )."
+ args[:num_assignments], args[:reward], args[:lifetime],
+ nil, qualifications, {}, {:form_url => args[:url]})
+ puts
+ puts "Study created : #{hit.hit_url}"
end
View
50 spec/dummy/log/development.log
@@ -1,50 +0,0 @@
-  (1.1ms) select sqlite_version(*)
-  (0.3ms) CREATE TABLE "turkee_tasks" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "hit_url" varchar(255), "sandbox" boolean, "task_type" varchar(255), "hit_title" text, "hit_description" text, "hit_id" varchar(255), "hit_reward" decimal(10,2), "hit_num_assignments" integer, "hit_lifetime" integer, "form_url" varchar(255), "completed_assignments" integer DEFAULT 0, "complete" boolean, "expired" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "turkee_flow_id" integer, "hit_duration" integer)
-  (0.1ms) CREATE TABLE "surveys" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "answer" varchar(255)) 
-  (0.1ms) CREATE TABLE "turkee_studies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "turkee_task_id" integer, "feedback" varchar(255))
-  (0.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
-  (0.0ms) PRAGMA index_list("schema_migrations")
-  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
-  (0.0ms) SELECT version FROM "schema_migrations"
-  (0.0ms) INSERT INTO "schema_migrations" (version) VALUES ('1')
-DEPRECATION WARNING: Factory(:name) is deprecated; use FactoryGirl.create(:name) instead. (called from block (3 levels) in <top (required)> at /Users/aantix/dev/turkee/spec/helpers/turkee_forms_helper_spec.rb:18)
-  (0.0ms) begin transaction
- SQL (1.1ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 0], ["created_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 100], ["hit_reward", #<BigDecimal:7ff5703cf538,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
- Turkee::TurkeeTask Load (0.1ms) SELECT "turkee_tasks".* FROM "turkee_tasks" ORDER BY "turkee_tasks"."id" DESC LIMIT 1
-  (0.1ms) begin transaction
- SQL (0.2ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 0], ["created_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 100], ["hit_reward", #<BigDecimal:7ff57010f730,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
- SQL (0.2ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 100], ["created_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 100], ["hit_reward", #<BigDecimal:7ff56c8dd038,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
- SQL (0.2ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 0], ["created_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 100], ["hit_reward", #<BigDecimal:7ff56f0bc518,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
- SQL (0.2ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 0], ["created_at", Sun, 21 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 100], ["hit_reward", #<BigDecimal:7ff56f25c648,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
- SQL (0.2ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 0], ["created_at", Mon, 22 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 100], ["hit_reward", #<BigDecimal:7ff57007b530,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
- SQL (0.2ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 100], ["created_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 100], ["hit_reward", #<BigDecimal:7ff57067fe18,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
-  (0.1ms) UPDATE "turkee_tasks" SET "complete" = 't', "updated_at" = '2013-04-23 06:23:11.307442' WHERE "turkee_tasks"."id" = 7
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
- SQL (0.2ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 100], ["created_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 99], ["hit_reward", #<BigDecimal:7ff56e06a930,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
- SQL (0.2ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 0], ["created_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 100], ["hit_reward", #<BigDecimal:7ff56e4c46c0,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
- SQL (0.2ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 0], ["created_at", Sun, 21 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 100], ["hit_reward", #<BigDecimal:7ff57061cac0,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
-  (0.1ms) UPDATE "turkee_tasks" SET "expired" = 't', "updated_at" = '2013-04-23 06:23:11.316700' WHERE "turkee_tasks"."id" = 10
-  (0.0ms) commit transaction
-  (0.0ms) begin transaction
- SQL (0.2ms) INSERT INTO "turkee_tasks" ("complete", "completed_assignments", "created_at", "expired", "form_url", "hit_description", "hit_duration", "hit_id", "hit_lifetime", "hit_num_assignments", "hit_reward", "hit_title", "hit_url", "sandbox", "task_type", "turkee_flow_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["complete", false], ["completed_assignments", 0], ["created_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00], ["expired", false], ["form_url", "http://localhost/test_task/new"], ["hit_description", "Test Desc"], ["hit_duration", 1], ["hit_id", "123"], ["hit_lifetime", 1], ["hit_num_assignments", 100], ["hit_reward", #<BigDecimal:7ff56e029390,'0.5E-1',9(45)>], ["hit_title", "Test Title"], ["hit_url", "http://workersandbox.mturk.com/mturk/preview?groupId=248SVGULF395SZ65OC6S6NYNJDXAO5"], ["sandbox", true], ["task_type", "TestTask"], ["turkee_flow_id", nil], ["updated_at", Tue, 23 Apr 2013 06:23:11 UTC +00:00]]
-  (0.0ms) commit transaction
View
15 spec/helpers/turkee_forms_helper_spec.rb
@@ -23,7 +23,22 @@
helper.stub(:params).and_return {}
study_form = turkee_study
study_form.should =~ /Test Desc/
+ study_form.should =~ /feedback/
study_form.should match /workersandbox.mturk.com/
end
+
+ it "saves the assignmentId to a cookie for later retrieval" do
+ helper.stub(:params).and_return({'assignmentId' => '123456'})
+
+ helper.turkee_study
+
+ helper.cookies['assignmentId'].should == '123456'
+
+ # Subsequent requests should still return form fields for assignmentId
+ helper.stub(:params).and_return({})
+ study_form = helper.turkee_study
+
+ study_form.should =~ /123456/
+ end
end
end

5 comments on commit 16193e9

@eggie5

what are these new changes you are adding? Are you going to merge them w/ master soon? I am interested...

@aantix
Owner

I'm adding in the concept of a "Study"; it will make it easy to ask for Feedback from MT for any given page (or pages).

I'm speaking at RailsConf and it's part of the demo that I'll be showing off next week.

@eggie5

That's cool, I'll pull this and check it out. Are you trying to reach parity w/ clockwork raven. That project is cool except it doesn't integrate w/ your app's models and it doesn't support ExternalHits (like turkee does).

@aantix
Owner

Clockwork Raven is incredibly cool, but I'm not sure a Turkee integration makes sense.

I'm interested in iterative content development (100 Turkers submit a sentence, top sentences are voted upon, Turkers submit another sentence building off the first one, etc, the loop continues).

I'm open sourcing a project I did a year ago that does such content creation.

@eggie5
Please sign in to comment.
Something went wrong with that request. Please try again.