使用 Django 提交 Mturk 响应

Submitting Mturk response with Django

我正在尝试将 Mechanical Turk 任务提交回我的 Django 应用程序和 Amazon Mturk 站点。它适用于我的 Django 应用程序,但我无法将其提交回 Amazon Mturk 站点。 "Submit HIT" 按钮也不可用。

我试过在 Javascript 中提交给亚马逊并在 Django 视图中提交给亚马逊,但都没有用。 "Submit HIT" 按钮在任何时候都不会突出显示。

HTML:

<form id="task_form"  method="POST">
    {% csrf_token %}
    <input type="hidden" name="id" value="{{ hit_id }}" />
    <input type="hidden" name="assignmentId" value="{{ assignment_id }}" />
    <input type="hidden" name="workerId" value="{{ worker_id }}" />
    <input type="hidden" id="task_score" name="task_score" value="" />
    <input type="radio" name="outcome_class" onclick="showCausal()" value="{{ s.class1_name }}">
</form>
<input class="btn btn-primary" type="submit" name="submit" id="submit_task_button2"/>

Javascript:

<script type="text/javascript">
    $(function(){
        $("#submit_task_button2").click(function(){
                var a = $('#slider_vals').slider("option", "value")
                document.getElementById("task_score").setAttribute('value', a);
                $.post("{% url 'task' %}", $('#task_form').serialize());
                $.post("{{ amazon_host }}", $('#task_form').serialize());   
            });
        });
</script>

姜戈:

def task_view(request):
    if request.method == 'POST':
        now_banned = False
        warning = False
        print request.POST
        task = Tasks.objects.get(mturk_hit_id = request.session['hit_id'])

        task.finished_at = timezone.now()
        task.updated_at = timezone.now()
        task.chosen_confidence = int(request.POST['task_score']) + 1
        task.chosen_outcome = request.POST['outcome_class']

        task.turker_comments = request.POST['turker_comments-input']
        task.save()
        request.session.clear()
    ...
    ...
    amazon_host = request.GET.get("turkSubmitTo", "") + "/mturk/externalSubmit"

解决了问题。我刚刚更改了以下几行:

Javascript:

<script type="text/javascript">
        $(function(){
            $("#submit_task_button2").click(function(){
                var a = $('#slider_vals').slider("option", "value")
                document.getElementById("task_score").setAttribute('value', a);
                $('#task_form').submit();
                $.post("{% url 'task' %}", $('#task_form').serialize());
            });
        });
</script>

HTML:

<form id="task_form"  method="POST" action="{{ amazon_host }}">

编辑:Amazon "Submit HIT" 按钮不可用,因为 Mturk 问题是外部问题(通过 Boto 提交):

boto.mturk.question.ExternalQuestion( URL, FRAME_HEIGHT )