Skip to content

Commit

Permalink
Revise README a little
Browse files Browse the repository at this point in the history
  • Loading branch information
longouyang committed Mar 19, 2015
1 parent 6dcc7fa commit 7031e56
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ It creates a global JavaScript object, `turk`, that has these five properties:
* `previewMode`: true if we're currently in the external HIT preview mode.
* `turkSubmitTo`: the Mechanical Turk submission server (either production or sandbox).

These variables get read from `window.location.href`.
If they aren't in `window.location.href`, the script also tries `document.referer`, so you can conceivably split a task across two different pages.
The script provides a single method, `submit(object, [unwrap])`, which takes one required argument, `object`, and an optional argument, `unwrap`.
These properties get read from `location.href`.
If they aren't in `location.href`, the script also tries `document.referer`, so you can conceivably split a task across two different pages.
If `previewMode` is true, all other properties are empty strings.

mmturkey provides a single method, `turk.submit(object, [unwrap])`, which takes one required argument, `object`, and an optional argument, `unwrap`.

`object` is an object containing keys and values.
mmturkey will submit this object (potentially "unwrapped" - see below) via a POST request to the proper externalSubmit URL.
If `object` is empty or not supplied, mmturkey responds with an error.
mmturkey will submit this object (potentially "unwrapped" -- see below) via a POST request to the externalSubmit URL declared in `turk.turkSubmitTo`.

`unwrap`: Best illustrated with an example. Suppose that `object` is this:

Expand All @@ -35,7 +37,8 @@ By default, `unwrap=false`, which means that this will get submitted to Turk:
}
```

Note that what gets submitted to Turk has only a single key, `data`, whose value is the JSON stringified version of `object`. When `unwrap=true`, the data submitted to Turk looks like this:
Note that what gets submitted to Turk has only a single key, `data`, whose value is the JSON representation of `object`.
When `unwrap` is true, the data submitted to Turk looks like this:

```js
{
Expand All @@ -46,8 +49,8 @@ Note that what gets submitted to Turk has only a single key, `data`, whose value
}
```

Now, the submitted data has four keys, just like the argument `object`; `object` has been "unwrapped".
Now, the submitted data has four keys, just like `object`; `object` has been "unwrapped".
However, this unwrapping only goes one level deep -- note that the values for `demographics` and `trials` are JSON strings.
Unwrapping is most useful when the data you want to submit is relatively flat.
Ideally, with data that is one level deep, you can directly translate your data into something like a .csv file.
Ideally, with data that is one level deep, you can directly translate your data into something like a csv file.
For deeper data, you'll have to write your own post-processing code to turn the JSON into something useful for data analysis.

0 comments on commit 7031e56

Please sign in to comment.