I am using the provided html template from Amazon MTurk, to test Audio Naturalness (https://requestersandbox.mturk.com/create/projects/new). In my experiment, each audio sample will have two sentences. The worker will need to select a rating for each of the two sentences before proceeding.
I've successfully modified the template so that there is only 1 audio sample, and two groups of radio buttons. However, I cannot omit the Submit
button after the first group (see screenshot).
Here is the modified code. What should I omit or concatenate so there is only one Submit
button after both groups of radio buttons? It seems from the documentation that since there is only 1 crowd-form
element, there should only be 1 "Submit" button.
<!-- 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', '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 second voice sample?"
name="audio-naturalness-2">
</crowd-classifier>
</crowd-form>
I am not sure if it is possible with classification element, but
the crowd-radio-group
& crowd-radio-button
should solve work for your purpose.
The documentation includes a bare-bones template for a single group. For multiple, I included a unique name
attribute in each and ran it through the 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>
From there, the output should produce:
{
"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
}
I could not find anything for form validation, but here is a simple approach to check and highlight a missing group. 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();
}
}
}
You can always ditch the crowd-elements. The crowd-form may be necessary, but standard HTML elements seem to work fine. Here is an example I was working with before I stumbled on the crowd-radio-group. https://gitlab.com/snippets/2013533/raw