forked from ryantate/rturk
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Most features now working. Basic qualifications and auth
- Loading branch information
Mark Percival
committed
Jun 19, 2009
1 parent
944cc14
commit d970ace
Showing
11 changed files
with
148 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ | |
|
||
puts page | ||
|
||
p @turk.createHIT(props, page) | ||
p @turk.create_hit(props, page) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require '../lib/rturk' | ||
root = File.expand_path(File.dirname(__FILE__)) | ||
aws = YAML.load(File.open(File.join(root, 'mturk.yml'))) | ||
@turk = RTurk::Requester.new(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true) | ||
|
||
#GroupID PHAZMBRQNVRTGK0KZZ6Z | ||
#HIT ID CYBGWCWJAXETWZW23X20 | ||
|
||
p @turk.get_assignments_for_hit('CYBGWCWJAXETWZW23X20') | ||
|
||
|
||
p @turk.kill_hit('CYBGWCWJAXETWZW23X20') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module RTurk | ||
class Answer | ||
|
||
def self.parse(xml) | ||
answer = XmlSimple.xml_in(xml, {'ForceArray' => false}) | ||
response = {} | ||
answer['Answer'].each do |a| | ||
question = a['QuestionIdentifier'] | ||
a.delete('QuestionIdentifier') | ||
a.each_value do |v| | ||
response[question] = v | ||
end | ||
end | ||
response | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,5 @@ def stringify_keys(ahash) | |
end | ||
ahash | ||
end | ||
|
||
def url_for_hit | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
|
||
describe RTurk::Answer do | ||
|
||
before(:all) do | ||
@answer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> | ||
<QuestionFormAnswers xmlns=\"http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd\"> | ||
<Answer>\n<QuestionIdentifier>tweet</QuestionIdentifier>\n<FreeText>Spec example</FreeText>\n</Answer> | ||
<Answer>\n<QuestionIdentifier>Submit</QuestionIdentifier>\n<FreeText>Submit</FreeText>\n</Answer> | ||
<Answer>\n<QuestionIdentifier>Foo</QuestionIdentifier>\n<RandomSelector>Bar</RandomSelector>\n</Answer> | ||
</QuestionFormAnswers>\n" | ||
end | ||
|
||
it "should parse an answer" do | ||
RTurk::Answer.parse(@answer).should == {'Submit' => 'Submit', 'tweet' => 'Spec example', 'Foo' => 'Bar'} | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
|
||
describe RTurk::ExternalQuestionBuilder do | ||
|
||
|
||
it "should build a question with params" do | ||
RTurk::ExternalQuestionBuilder.build('http://google.com/', :id => 'foo').should == | ||
<<-XML | ||
<ExternalQuestion xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd"> | ||
<ExternalURL>http://google.com/?id=foo</ExternalURL> | ||
<FrameHeight>400</FrameHeight> | ||
</ExternalQuestion> | ||
XML | ||
end | ||
|
||
it "should build a question without params" do | ||
RTurk::ExternalQuestionBuilder.build('http://google.com/').should == | ||
<<-XML | ||
<ExternalQuestion xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd"> | ||
<ExternalURL>http://google.com/</ExternalURL> | ||
<FrameHeight>400</FrameHeight> | ||
</ExternalQuestion> | ||
XML | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters