1

I am using amazon mechanical turk, a platform to get simple tasks done. I am using it to get audio files transcribed. Here is my setup: I am using the basic web form to create HITs, having embed an audio-player using JWplayer

Mechanical turk has two views on tasks (called HIT), a preview and the regular view when you accept taking the task. What I want to do, is showing only a 15sec preview of the audio file when somebody has not yet accepted the task (and show the full audio when accepted)

I thought I include two objects, the preview 15sec audio and the full audio, and hide or show them depending on the URL, which is changing when you preview/or accept a task (and the rules of confidentially).

If a task is previewed, the URL looks like: https://www.mturk.com/mturk/preview?groupId=3IQQTV3
When the task is accepted it also contain an assignmentId=3493something (also look here, they suggest to use "assignmentId=ASSIGNMENT_ID_NOT_AVAILABLE" to determine the preview URL http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_ExternalQuestionArticle.html)

Can somebody help me with that? I thing its possible javascript, but I have no idea how to do that.

Josef
  • 11
  • 2

1 Answers1

1

This is an incomplete answer because it only shows how to distinguish between preview and accepted modes. I'm marking this "community wiki" so another developer can plug in the audio previewing code if they know how to do that.

<script type="text/javascript">
/* DEFINE FUNCTION TO EXTRACT PARAMETERS FROM URL */
function turkGetParam( name ) { 
  var regexS = "[\?&]"+name+"=([^&#]*)"; 
  var regex = new RegExp( regexS ); 
  var tmpURL = fullurl; 
  var results = regex.exec( tmpURL ); 
  if( results == null ) { 
    return ""; 
  } else { 
    return results[1];    
  } 
}

/* THIS IS THE LINE TO CAPTURE THE ACTUAL URL: */
var fullurl = window.location.href;

/* ASSIGNS THE URL PARAMETERS TO JAVASCRIPT VARIABLES */
var assign = turkGetParam('assignmentId');
var hit = turkGetParam('hitId');
var worker = turkGetParam('workerId');

/* WHAT TO DO IF THE WORKER IS PREVIEWING THE HIT: */
if(assign=="ASSIGNMENT_ID_NOT_AVAILABLE") {
    // CODE FOR PREVIEW
}
else {
    // CODE FOR ACCEPTED HIT
}
</script>
Thomas
  • 43,637
  • 12
  • 109
  • 140
  • Thank you very much Thomas! I am going to implement this with the code snippets of the player, and tell you if it worked! – Josef Sep 05 '15 at 10:08
  • So the 15sec snippet would be that one: but it didn't work, neither way – Josef Sep 05 '15 at 14:06
  • @Josef Can you elaborate on what you mean by "it didn't work"? – Thomas Sep 05 '15 at 14:23
  • Sorry, of course. I thought taking the snippet "" and putting it there were you wrote //code for preview and Code for accepted HIT would do the trick, but it didn't. (Usually if just insert the snippet in a html it will show the player). The player didn't load, nothing was shown. I hoped there might be a quick copy&paste solution, for this problem, but it looks like it is not that easy. – Josef Sep 06 '15 at 14:58
  • @Josef That snippet is HTML, so you can't you just paste that into a block of javascript code. You may want to see information [here](http://stackoverflow.com/questions/950087/include-a-javascript-file-in-another-javascript-file) about how to include javascript in another block of javascript code. – Thomas Sep 07 '15 at 01:59
  • Oh, diddn't know that. Thank you, I am going to try that out. – Josef Sep 07 '15 at 12:51