Participants hear a set of long samples (for example the same music played on different violins) and drag the sample columns into preference order. Each column has several play boxes that start the sample at different points, plus a notes box.
The engine in this folder runs any number of tests. Each test is a folder in
tests/, opened with listeningtest.html?test=<folder name>:
tests/stradivari/
config.json samples, start times, page list, texts
start.html the pages, in the order config.json lists them
background.html
instructions.html
ranking.html
end.html
thankyou.html shown after submitting
audio/ the samples
pictures/
To make a new test, copy tests/example/ (the smallest test) or
tests/stradivari/, then edit the copy.
{
"title": "Online violin listening test",
"pages": [
{ "file": "start.html", "button": "Start the Test" },
{ "file": "ranking.html", "button": "Next page" },
{ "file": "end.html" }
],
"reminder": "The test consists of {samples} draggable sample columns...",
"unlinkedFields": ["freeComments"],
"pointColors": ["rgba(189,49,232,1)", "rgba(67,139,255,1)", "rgba(49,232,133,1)"],
"samples": [
{ "id": "D00", "name": "Stradivari 1679 Hellier", "file": "audio/a.wav", "points": [2, 35, 52] },
{ "id": "D01", "name": "Stradivari 1690 Auer", "file": "audio/b.wav", "points": [0, 33, 50] }
]
}title: the browser tab title.pages: the pages in order.buttonis the text of the button that leads to the next page; leave it out on the last page, which needs its own submit button.reminder: text of the "View instructions" popup (see below).{samples}is replaced by the number of samples.unlinkedFields: form fields stored apart from the answers, with nothing linking them, for example free feedback.pointColors: background colours of the play boxes, top to bottom. They repeat if there are more play points than colours.stylesheet(optional): a CSS file in the test folder for extra styles.samples: one entry per sample column, in any number.id: saved in the results. Letters, digits,-and_.name: shown to the participant only on the thank you page.file: path of the audio file in the test folder.points: start times of the play boxes in seconds. Use them to line up the same musical moment across the samples. All samples need the same number of points.
Participants can see the id, the file path and the start times in their
browser, so don't let those give away which sample is which. The names stay
on the server: the page gets the config from testconfig.php, which leaves
them out, and .htaccess blocks the config.json files.
Each page is a piece of HTML: no <html> or <body>, just the content. The
engine puts the pages in one form, so every input, textarea, radio button and
checkbox on any page is saved with the answers. Checkboxes that share a name
need [] at the end of it, e.g. name="musicalType[]", or only the last
checked one is saved. Relative image and link paths point into the test
folder.
Special elements:
<ul id="sortable"></ul>: where the sample columns go. One page must have it.<div id="example_column"></div>: an example column for the instructions, playing the first sample.<span class="numSamples"></span>,numPoints,numBoxes: filled with the number of samples, play points and boxes per column (play points + 2).<button type="button" onclick="popUpInstructions()">: showsreminder.<input type="submit" value="Submit">: sends the answers; put it on the last page.
The columns are labelled A, B, C… in config order and shown in random order.
thankyou.html is a complete HTML page. <!-- results --> in it is replaced
by the sample names in the participant's order, worst to best. It is served
from the main folder, so image paths in it need the tests/<name>/ prefix.
python3 dev/serve.pyand open the address it prints for each test. No PHP or database is needed:
- Audio files that aren't in the test folder are replaced by generated test tones, one pitch per sample, rising over time so later play points sound higher. Copy real recordings into the test folder to hear them.
- Submitting prints the answers in the terminal and shows the thank you page. Nothing is stored.
- The config files are reread on every request, so just reload after editing.
Upload listeningtest.html, stradtest.html (forwards the old address to the
Stradivari test), stradstyle.css, js/, pictures/, endoftest.php,
testconfig.php, loadtest.php, .htaccess and tests/ with the audio.
Then check that https://<site>/<folder>/tests/<name>/config.json gives
403 Forbidden.
The answers go to the tables in sql/create-tables.sql; create them once.
Each answer stores the test name, the ranking, the notes by sample id, and
all other fields as JSON. The database login is read from
../../stradtest_config.ini, as before.