问题描述
我正在使用Amazon MTurk提供的html模板来测试音频自然度(https://requestersandbox.mturk.com/create/projects/new)。在我的实验中,每个音频样本将包含两个句子。在继续之前,工作人员需要为两个句子中的每个句子选择一个等级。
我已经成功修改了模板,因此只有1个音频样本和两组单选按钮。但是,我不能在第一组之后省略Submit
按钮(请参见屏幕截图)。
这是修改后的代码。我应该省略或连接什么,以便两组单选按钮之后只有一个Submit
按钮?从the documentation看来,由于只有1个crowd-form
元素,因此应该只有1个“提交”按钮。
<!-- You must include this JavaScript file -->
<script src="https://assets.crowd.aws/crowd-html-elements.js"></script>
<!-- You must include crowd-form so that your task successfully submit answers -->
<crowd-form answer-format="flatten-objects">
<!-- The crowd-classifier element will create a tool for the Worker to select the
correct answer to your question -->
<crowd-classifier
categories="['Excellent - Completely natural speech','Good - Mostly natural speech','Fair - Equally natural and unnatural speech','Poor - Mostly unnatural speech','Bad - Completely unnatural speech']"
header="How natural (i.e. human-sounding) is the first voice sample?"
name="audio-naturalness-1">
<classification-target>
<audio controls="" style="width: 100%">
<!-- Your audio file URLs will be substituted for the "audio_url" variable
when you publish a batch with a CSV input file containing multiple
audio file URLs -->
<source src="${audio_url}" type="audio/mp3" />
</audio>
</classification-target>
</crowd-classifier>
<crowd-classifier
categories="['Excellent - Completely natural speech','Bad - Completely unnatural speech']"
header="How natural (i.e. human-sounding) is the second voice sample?"
name="audio-naturalness-2">
</crowd-classifier>
</crowd-form>
解决方法
我不确定分类元素是否可行,但是
crowd-radio-group
和crowd-radio-button
应该根据您的目的解决工作。
文档包括单个组的准系统模板。对于多个,我在每个参数中都包含一个唯一的name
属性,并将其运行在Requester Sandbox中。 image
<crowd-radio-group name="S1">
<crowd-radio-button name="S1_1" value="Poor">Poor</crowd-radio-button>
...
<crowd-radio-button name="S1_5" value="Excellent">Excellent</crowd-radio-button>
</crowd-radio-group>
<crowd-radio-group name="S2">
<crowd-radio-button name="S2_1" value="Poor">Poor</crowd-radio-button>
...
<crowd-radio-button name="S2_5" value="Excellent">Excellent</crowd-radio-button>
</crowd-radio-group>
从那里,输出应产生:
{
"S1_1.Poor": false,"S1_2.Bad": false,"S1_3.Fair": false,"S1_4.Good": false,"S1_5.Excellent": true,"S2_1.Poor": false,"S2_2.Bad": false,"S2_3.Fair": false,"S2_4.Good": false,"S2_5.Excellent": true
}
我找不到用于表单验证的任何内容,但这是一种简单的方法 检查并突出显示丢失的组。 image
function is_valid_group(rbg)
{
'use strict';
var radio_group=document.querySelector(`crowd-radio-group[name="${rbg}"`);
var radios = radio_group.querySelectorAll(`crowd-radio-button[role="radio"]`);
var valid_group = false;
for (let i = 0,j = radios.length; i < j; i++)
{
valid_group = valid_group || radios[i].checked;
}
if (valid_group === false)
{
for (let i = 0,j = radios.length; i < j; i++)
{
radios[i].parentElement.style.backgroundColor = 'pink';
}
}
return valid_group;
}
window.onload = function()
{
'use strict';
document.querySelector(`crowd-form`).onsubmit = event =>
{
if (!is_valid_group("S1") || !is_valid_group("S2"))
{
alert("Please answer both questions");
event.preventDefault();
}
}
}
您总是可以抛弃人群元素。人群形式可能是必需的,但是标准HTML元素似乎可以正常工作。这是一个 例如,在偶然发现人群广播小组之前,我曾与之共事。 https://gitlab.com/snippets/2013533/raw