Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preference test #91

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions configs/complete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,20 @@ pages:
label: Male
- value: other
label: Other
- type: dropdown
name: referral
label: How have you heard of us?
response:
- value: searchEngine
label: Google/internet search
- value: friends
label: Friends or colleagues
- value: participant
label: Previous experiment
- value: paper
label: Seen in published paper
- value: other
label: Other
- type: long_text
label: Feedback
name: feedback
Expand Down
30 changes: 30 additions & 0 deletions configs/pref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# test config preference test


testname: Preference test
testId: pref
bufferSize: 2048
stopOnErrors: true
showButtonPreviousPage: true
remoteService: service/write.php

pages:
- type: preference_test
id: trialpref
name: Preference test
content: |
<p><b>Which sound do you prefer?</b></p>
considerOrder: true
faroit marked this conversation as resolved.
Show resolved Hide resolved
mustPlayback: ended
Simon-Stone marked this conversation as resolved.
Show resolved Hide resolved
stimuli:
C1: configs/resources/audio/mono_c1.wav
C2: configs/resources/audio/mono_c2.wav
C3: configs/resources/audio/mono_c3.wav

- type: finish
name: Thank you
content: Thank you for attending
showResults: true
writeResults: true
generateSubjectId: true
confirmationCode: your_code_here
Simon-Stone marked this conversation as resolved.
Show resolved Hide resolved
28 changes: 28 additions & 0 deletions configs/pref_grouped.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# test config preference test


testname: Preference test
testId: pref_grouped
bufferSize: 2048
stopOnErrors: true
showButtonPreviousPage: true
remoteService: service/write.php

pages:
- type: preference_test
id: trialpref
name: Preference test
content: |
<p><b>Which sound do you prefer?</b></p>
considerOrder: true
stimuli:
- C1: configs/resources/audio/mono_c1.wav
C2: configs/resources/audio/mono_c2.wav
- C3: configs/resources/audio/mono_c3.wav
C2: configs/resources/audio/mono_c2.wav

- type: finish
name: Thank you
content: Thank you for attending
showResults: true
writeResults: true
14 changes: 14 additions & 0 deletions doc/experimenter.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ A paired comparison page creates a forced or unforced paired comparison (AB/ABX/
* **reference** Filepath to the reference stimulus (WAV file).
* **stimuli** A map of stimuli representing three conditions. The key is the name of the condition. The value is the filepath to the stimulus (WAV file).

#### `preference_test` page

A preference test page creates a forced paired comparison between two stimuli. The main difference to `paired_comparison` is that there is no reference or ground truth.

* **type** must be preference_test.
* **id** Identifier of the page.
* **name** Name of the page (is shown as title)
* **content** Content (HTML) of the page. The content is shown on the upper part of the page.
* **considerOrder** If set to true, a complete set of pairs is generated from the list of stimuli: A set of `{A, B}` would result in two pairs `(A, B)` and `(B, A)`. Otherwise only the pair `(A, B)` would be generated.
* **mustPlayback** If set to `ended`, the participant must fully play back all stimuli to the end. If set to `processUpdate`, the participant must start playing back all stimuli before responding becomes possible.
* **stimuli** Either a map of stimuli or an array of maps of stimuli. If it is a map, pairs will be generated from the list and then shuffled. If it is an array of maps, pairs will be generated for each map individually and then all the pairs from all maps are shuffled.

#### `likert_multi_stimulus` page

A likert multi stimulus page creates a multi-stimulus likert rating.
Expand Down Expand Up @@ -133,6 +145,8 @@ The finish page must be the last page of the experiment.
* **content** Content (HTML) of the page. The content is shown on the upper part of the page.
* **showResults** The results are shown to the participant.
* **writeResults** The results are sent to the remote service (which writes the results into a file).
* **generateSubjectId** If set to true, a random subject ID is generated and appended to the results.
* **confirmationCode:** If set, this code is displayed after the results were sent. This can be used to confirm that subjects have completed the experiment and facilitates


## Results
Expand Down
5 changes: 5 additions & 0 deletions doc/participant.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@
* <kbd>SPACE</kbd> Play/pause the current selection
* <kbd>a</kbd> Set begin of loop to current position
* <kbd>b</kbd> Set end of loop to current position

### Preference test

* <kbd>1</kbd> Play item A
* <kbd>2</kbd> Play item B
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<script src="lib/webmushra/datamodel/LikertSingleStimulusRating.js"></script>
<script src="lib/webmushra/datamodel/PairedComparisonChoice.js"></script>
<script src="lib/webmushra/datamodel/Participant.js"></script>
<script src="lib/webmushra/datamodel/PreferenceTestChoice.js"></script>
<script src="lib/webmushra/datamodel/Session.js"></script>
<script src="lib/webmushra/datamodel/Stimulus.js"></script>
<script src="lib/webmushra/datamodel/Trial.js"></script>
Expand Down Expand Up @@ -111,6 +112,8 @@
<script src="lib/webmushra/pages/MushraPage.js"></script>
<script src="lib/webmushra/pages/PairedComparisonPage.js"></script>
<script src="lib/webmushra/pages/PairedComparisonPageManager.js"></script>
<script src="lib/webmushra/pages/PreferenceTestPage.js"></script>
<script src="lib/webmushra/pages/PreferenceTestPageManager.js"></script>
<script src="lib/webmushra/pages/VolumePage.js"></script>
<script src="lib/webmushra/pages/LikertSingleStimulusPage.js"></script>
<script src="lib/webmushra/pages/LikertSingleStimulusPageManager.js"></script>
Expand Down
14 changes: 14 additions & 0 deletions lib/webmushra/datamodel/PreferenceTestChoice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*************************************************************************
(C) Copyright AudioLabs 2017

This source code is protected by copyright law and international treaties. This source code is made available to You subject to the terms and conditions of the Software License for the webMUSHRA.js Software. Said terms and conditions have been made available to You prior to Your download of this source code. By downloading this source code You agree to be bound by the above mentionend terms and conditions, which can also be found here: https://www.audiolabs-erlangen.de/resources/webMUSHRA. Any unauthorised use of this source code may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under law.

**************************************************************************/

function PreferenceTestChoice() {
this.optionA = null;
this.optionB = null;
this.answer = null;
this.comment = null;
this.time = null;
}
10 changes: 10 additions & 0 deletions lib/webmushra/nls/nls.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ nls['fr']['slightly'] = "Légèrement gênante";
nls['fr']['annoying'] = "Dégradation gênante";
nls['fr']['very'] = "Dégradation très gênante";

// captions Preference Test
nls['en']['pref'] = "Which item do you prefer?";
nls['de']['pref'] = "Welche Version bevorzugen Sie?";
nls['fr']['pref'] = "Quel item préférez-vous?";


// captions Paired Comparison AB/ABN
Expand All @@ -90,3 +94,9 @@ nls['fr']['results'] = "Vos résultats:";
nls['en']['attending'] = "Thank you for your participation!";
nls['de']['attending'] = "Vielen Dank für die Teilnahme!";
nls['fr']['attending'] = "Merci pour votre participation!";
nls['en']['response'] = "Response";
nls['de']['response'] = "Antwort";
nls['fr']['response'] = "Réponse";
nls['en']['code'] = "Your confirmation code:";
nls['de']['code'] = "Ihr Bestätigungscode:";
nls['fr']['code'] = "Votre code de confirmation:";
80 changes: 75 additions & 5 deletions lib/webmushra/pages/FinishPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,21 @@ FinishPage.prototype.getName = function () {
return this.pageConfig.name;
};

function getId(){
/* Returns an ID based on random number and the current timestampe */
return Math.floor(Math.random() * Date.now());
}


FinishPage.prototype.storeParticipantData = function() {
var i;
if (this.pageConfig.generateSubjectId){
this.session.participant.name[this.session.participant.name.length] = "subjectId";
this.session.participant.response[this.session.participant.response.length] = getId();
} else {
this.session.participant.name[this.session.participant.name.length] = "subjectId";
this.session.participant.response[this.session.participant.response.length] = null;
}
for (i = 0; i < this.pageConfig.questionnaire.length; ++i) {
var element = this.pageConfig.questionnaire[i];

Expand Down Expand Up @@ -64,20 +77,33 @@ FinishPage.prototype.render = function (_parent) {
for (i = 0; i < this.pageConfig.questionnaire.length; ++i) {
var element = this.pageConfig.questionnaire[i];
if (element.type === "text") {
table.append($("<tr><td><strong>"+ element.label +"</strong></td><td><input id='"+element.name+"' /></td></tr>"));
table.append($("<tr><td style='text-align:right; padding-right:2em;'><strong>"+ element.label +"</strong></td><td><input id='"+element.name+"' /></td></tr>"));
} else if (element.type === "number") {
table.append($("<tr><td><strong>"+ element.label +"</strong></td><td><input id='"+element.name+"' min='"+element.min+"' max='"+element.max+"' value='"+element.default+"' data-inline='true'/></td></tr>"));
table.append($("<tr><td style='text-align:right; padding-right:2em;'><strong>"+ element.label +"</strong></td><td><input id='"+element.name+"' min='"+element.min+"' max='"+element.max+"' data-inline='true' placeholder=''/></td></tr>"));
} else if(element.type === "likert") {
this.likert = new LikertScale(element.response, element.name + "_");
var td = $("<td></td>");
table.append($("<tr></tr>").append(
$("<td><strong>"+ element.label +"</strong></td>"),
$("<td style='text-align:right; padding-right:2em;'><strong>"+ element.label +"</strong></td>"),
td
));
this.likert.render(td);
}else if (element.type === "long_text"){
table.append($("<tr><td id='labeltd' style='vertical-align:top; padding-top:"+ $('#feedback').css('margin-top') +"'><strong>"+ element.label +"</strong></td><td><textarea name='"+element.name+"' id='"+element.name+"'></textarea></td></tr>"));
}
table.append($("<tr><td id='labeltd' style='text-align:right; vertical-align:top; padding-right:2em; padding-top:"+ $('#feedback').css('margin-top') +"'><strong>"+ element.label +"</strong></td><td><textarea name='"+element.name+"' id='"+element.name+"'></textarea></td></tr>"));
}else if (element.type === "dropdown"){
var td = $("<td></td>");
table.append($("<tr></tr>").append(
$("<td style='text-align:right; padding-right:2em;'><strong>"+ element.label +"</strong></td>"),
td));
dropdown = $("<select name='"+ element.name+"' id='"+element.name+"'></select>");
var opt = $("<option value=''></option>");
dropdown.append(opt);
for (i = 0; i < element.response.length; ++i) {
opt = $("<option value='" + element.response[i].value + "'>" + element.response[i].label + "</option>")
dropdown.append(opt);
}
td.append(dropdown);
}
console.log(element);
}
var button = $("<button id='send_results' data-role='button' data-inline='true' disabled='disabled'>" + this.pageManager.getLocalizer().getFragment(this.language, 'sendButton') +"</button>");
Expand All @@ -91,6 +117,14 @@ FinishPage.prototype.render = function (_parent) {

$("#popHeader").text(this.pageManager.getLocalizer().getFragment(this.language, 'attending'));

if (typeof this.pageConfig.confirmationCode !== "undefined"){
divCode = $("<p>" + this.pageManager.getLocalizer().getFragment(this.language, 'code') + "</p>");
code = $("<p>" + this.pageConfig.confirmationCode + "</p>");
code.css("font-size", "28px");
divCode.append(code);
$("#popupResultsContent").append(divCode);
}

var table = $("<table align='center'> </table>");
var trHeader = document.createElement("tr");
var trT;
Expand Down Expand Up @@ -166,6 +200,38 @@ FinishPage.prototype.render = function (_parent) {
trEmpty = $("<tr height='8px'></tr>");
$(table).append(trEmpty);

} else if (trial.type === "preference_test") {

trPref = document.createElement("tr");
thT = $("<th colspan='3'></th>");
$(thT).append(trial.id + " (Preference Test)" );
$(trPref).append(thT);
$(table).append(trPref);
trLabel = document.createElement("tr");
thT = $("<th>A</th><th>B</th><th>" + this.pageManager.getLocalizer().getFragment(this.language, 'response') + "</th>");
$(trLabel).append(thT);
$(table).append(trLabel);

var j;
for(j = 0; j < trial.responses.length; ++j){
trPT = document.createElement("tr");
tdPTOptionA = document.createElement("td");
tdPTOptionB = document.createElement("td");
tdPTAnswer = document.createElement("td");
var response = trial.responses[j];


$(tdPTOptionA).append(response.optionA);
$(tdPTOptionB).append(response.optionB);
$(tdPTAnswer).append(response.answer);
$(trPT).append(tdPTOptionA);
$(trPT).append(tdPTOptionB);
$(trPT).append(tdPTAnswer);
$(table).append(trPT);
}
trEmpty = $("<tr height='8px'></tr>");
$(table).append(trEmpty);

} else if(trial.type ==="bs1116") {
trPaired = document.createElement("tr");
thT = $("<th colspan='2'></th>");
Expand Down Expand Up @@ -287,6 +353,10 @@ FinishPage.prototype.load = function() {
if ($("#" + element.name).val() || element.optional == true) {
++counter;
}
} else if(element.type === "dropdown") {
if ($("#" + element.name).val() || element.optional == true) {
++counter;
}
}
if (counter == this.pageConfig.questionnaire.length) {
$('#send_results').removeAttr('disabled');
Expand Down
Loading