assignmentId在MTurk接受URL中不可见

时间:2014-04-22 09:08:44

标签: url amazon-web-services mechanicalturk

我设法使用iframe(外部问题)将我的外部html页面嵌入到mturk-hit中。

如果工作人员接受我的HIT,则生成的URL为:

https://workersandbox.mturk.com/mturk/return?groupId=260LVCNHMVHY0UMXMCB2A4K8CRQ20A&requesterId=A165LMPFHNTKFG&hitId=3180JW2OT5IAV9ZKJ6GHA2GH8KXJ51&signature=hAyO0wvGxW%2BX3Kewgv%2F2%2FhyloSI%3D&externalHit=true&canAccept=

如何从网址中获取assignmentId以便在我的表单中使用它来提交?

这是我的表格:

<form name='mturk_form' method='post' id='mturk_form' action='https://workersandbox.mturk.com/mturk/externalSubmit'> <!- For real submit use : https://www.mturk.com/mturk/externalSubmit-->
<input type='hidden' value='' name='assignmentId' id='here the assignmentId from the url should be inserted'/>
<h1>What's up?</h1>
<p><textarea name='comment' cols='80' rows='3'></textarea></p>
<p><input type='submit' id='submitButton' value='Submit' /></p>
</form>

1 个答案:

答案 0 :(得分:0)

您需要向ExternalHIT HTML添加一些javascript,它将从自己的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];    
    } 
}

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

然后,您可以使用assign变量执行任何操作(例如,打印到写入表单字段的页面等)。