Define correct answers in


Author
Message
L123
L123
Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)
Group: Forum Members
Posts: 4, Visits: 10
Hey,

I have an experiment where I want to have users decide between 1, 2 or 3 (keyboard input). If they decide for a specific number (either 1 or 3), they should get a message of being correct or incorrect. If they decide for number 2, they should see another trial. This works fine so far, but now I want to specify the correct (and incorrect) numbers using a list. Unfortunately, it doesn't work and the correct number is not assigned in my data either. 


Here is the code: (copied the relevant parts only):

<item item_correct_answers>
/1 = "1"
/2 = "3"
/3 = "1"
/4 = "3"
</item>

<list correct_answers>
/ items = [item.item_correct_answers]
/ select = values.currentscenario
// select = 2
</list>

<item item_incorrect_answers>
/1 = "3"
/2 = "1"
/3 = "3"
/4 = "1"
</item>

<list incorrect_answers>
/ items = [item.item_incorrect_answers]
/ select = values.currentscenario
</list>

<values>
/ currentscenario = 0
</values>

<trial task_70>
/ stimulusframes = [1 = fixation; 100 = override_fixation, instruction, stimulus_70, orangeChoice, blueChoice, automationChoice, press_1, press_2, press_3]
/ inputdevice = keyboard
/ validresponse = ("1", "2", "3")
/ correctresponse = (list.correct_answers.currentvalue)
/ responsemessage = (list.correct_answers.currentvalue, feedback_correct, 1500)
/ responsetrial = ("2", task_70_advice)
/ responsemessage = (list.incorrect_answers.currentvalue, feedback_incorrect, 1500)
/ ontrialbegin = [
  values.currentscenario = values.currentscenario + 1;
]
</trial>

<block task>
/ trials = [1-4 = sequence(task_70)]
</block>

<expt>
/ blocks = [
    1 = task;
]
</expt>


Thanks in advance!
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
L123 - 8/1/2022
Hey,

I have an experiment where I want to have users decide between 1, 2 or 3 (keyboard input). If they decide for a specific number (either 1 or 3), they should get a message of being correct or incorrect. If they decide for number 2, they should see another trial. This works fine so far, but now I want to specify the correct (and incorrect) numbers using a list. Unfortunately, it doesn't work and the correct number is not assigned in my data either. 


Here is the code: (copied the relevant parts only):

<item item_correct_answers>
/1 = "1"
/2 = "3"
/3 = "1"
/4 = "3"
</item>

<list correct_answers>
/ items = [item.item_correct_answers]
/ select = values.currentscenario
// select = 2
</list>

<item item_incorrect_answers>
/1 = "3"
/2 = "1"
/3 = "3"
/4 = "1"
</item>

<list incorrect_answers>
/ items = [item.item_incorrect_answers]
/ select = values.currentscenario
</list>

<values>
/ currentscenario = 0
</values>

<trial task_70>
/ stimulusframes = [1 = fixation; 100 = override_fixation, instruction, stimulus_70, orangeChoice, blueChoice, automationChoice, press_1, press_2, press_3]
/ inputdevice = keyboard
/ validresponse = ("1", "2", "3")
/ correctresponse = (list.correct_answers.currentvalue)
/ responsemessage = (list.correct_answers.currentvalue, feedback_correct, 1500)
/ responsetrial = ("2", task_70_advice)
/ responsemessage = (list.incorrect_answers.currentvalue, feedback_incorrect, 1500)
/ ontrialbegin = [
  values.currentscenario = values.currentscenario + 1;
]
</trial>

<block task>
/ trials = [1-4 = sequence(task_70)]
</block>

<expt>
/ blocks = [
    1 = task;
]
</expt>


Thanks in advance!

<list correct_answers>
/ items = [item.item_correct_answers]
/ select = values.currentscenario
// select = 2
</list>

This is not how you define items in a list. Lists don't use <item> elements.
L123
L123
Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)
Group: Forum Members
Posts: 4, Visits: 10
Can I get it working with a textbox then?

I also tried adding the correct answers directly within the list element:

<list correct_answers>
/ items = ("1" "3" "1" "3")
/ select = values.currentscenario
</list>

It still does not work though. 
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
L123 - 8/1/2022
Can I get it working with a textbox then?

I also tried adding the correct answers directly within the list element:

<list correct_answers>
/ items = ("1" "3" "1" "3")
/ select = values.currentscenario
</list>

It still does not work though. 

There are multple other issues with your code. It's not even clear what exactly it's supposed to do, since you only posted some non-runnable excerpts. Do the following:

- Create a small, self-contained demo that mirrors the actual script's setup.
- Post that code here and explain clearly what you intend it to do.

Then I can show you how to do it right
L123
L123
Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)
Group: Forum Members
Posts: 4, Visits: 10
Thank you!
Below you can find a small demo that runs. What I want to do is iterate over a list with different answers. Participants have to choose between A or B. In the first trial, A is correct, in the second trial, B is correct (and so on - that is subject to change in the future). They can also request advice. Now the advice also iterates over a list of items. However, I cannot set the correct and incorrect responses (with corresponding response message) based on the current trial / list. The iteration of advice works for each trial, but setting the correct answers and response message and incorrect answers and response message for the current trial does not work. 


// define correct answers (would be great to use this item element for easier customization)
<item item_correct_answers>
/ 1 = "1"
/ 2 = "3"
/ 3 = "1"
/ 4 = "3"
</item>

// define the correct answers, as of now in a list element
<list correct_answers>
/ items = (1, 3, 1, 3)
/ select = values.currentscenario
// select = 2
</list>

// define incorrect answers (would be great to use this item element for easier customization)
<item item_incorrect_answers>
/ 1 = "3"
/ 2 = "1"
/ 3 = "3"
/ 4 = "1"
</item>

// define the incorrect answers, as of now in a list element
<list incorrect_answers>
/ items = [item.item_incorrect_answers]
/ select = values.currentscenario
// select = 2
</list>


// define texts
<text fixation>
/items = ("+")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ size = (30%, 30%)
/ txbgcolor = white
/ txcolor = black
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</text>

<text feedback_correct>
/items = ("Correct!")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ size = (30%, 30%)
/ txbgcolor = white
/ txcolor = black
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</text>

<text feedback_incorrect>
/ items = ("Incorrect!")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ size = (30%, 30%)
/ txbgcolor = white
/ txcolor = black
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</text>

// Ask participants to press either 1 or 3 on their keyboard, if they want help, they should press 2
<text instruction>
/ items = ("A (Press 1) or B (Press 3)? If you want support, press 2")
/ fontstyle = ("Arial", 4%)
/ position = (50%, 60%)
/ txcolor = black
/ txbgcolor = white
</text>

// Override the fixation with a white screen
<shape override_fixation>
/ shape = rectangle
/ size = (30%, 30%)
/ color = (255,255,255)
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</shape>

// specify advice
<item advice_answer_text>
/1 = "Advice: 1"
/2 = "Advice: 3"
/3 = "Advice: 1"
/4 = "Advice: 3"
</item>

// provide advice
<text advice_answer>
/ items = advice_answer_text
/ select = values.currentscenario
/ fontstyle = ("Arial", 5%)
/ position = (50%, 75%)
/ size = (32%, 15%)
/ vjustify = center
/ hjustify = center
/ txcolor = white
/ txbgcolor = grey
</text>

// define data to be recorded
<data>
/ columns = (build, computer.platform, date, time, subject, group, session,
blockcode, blocknum, trialcode, trialnum, list.correct_answers.currentvalue, response, latency, correct)
</data>

// define values
<values>
/ currentscenario = 0
</values>


// In this practice trial, I can define the correct answers. 1 is correct, 1 gives the "correct" Feedback and 3 gives the "incorrect" feedback. However, the correct response might change in other trials (to be B, so 3, for example)
<trial practice>
/ stimulusframes = [1 = fixation; 100 = override_fixation, instruction]
/ inputdevice = keyboard
/ validresponse = ("1", "2", "3")
/ correctresponse = ("1")
/ responsemessage = ("1", feedback_correct, 0)
/ responsemessage = ("3", feedback_incorrect, 0)
/ posttrialpause = 1500
</trial>

// this code works, but it does not give the "feedback_correct" or "feedback_incorrect" response and also does not code the correctresponse in the data section
<trial task_70>
/ stimulusframes = [1 = fixation; 100 = override_fixation, instruction]
/ inputdevice = keyboard
/ validresponse = ("1", "2", "3")
/ correctresponse = (list.correct_answers.currentvalue)
/ responsemessage = (list.correct_answers.currentvalue, feedback_correct, 1500)
/ responsetrial = ("2", task_70_advice)
/ responsemessage = (list.incorrect_answers.currentvalue, feedback_incorrect, 1500)
/ ontrialbegin = [
  values.currentscenario = values.currentscenario + 1;
]
</trial>

// if participants wanted to get advice (pressed 2 in the other trial), they can get advice here and choose again. However, it does not correctly code correct/incorrect either
<trial task_70_advice>
/ stimulusframes = [1 = override_fixation, instruction, advice_answer]
/ inputdevice = keyboard
/ validresponse = ("1", "3")
/ responsemessage = (list.correct_answers.currentvalue, feedback_correct, 1500)
/ responsemessage = (list.incorrect_answers.currentvalue, feedback_incorrect, 1500)
</trial>

// define blocks
<block practice_task>
/ trials = [1 = practice]
</block>

<block task>
/ trials = [1-4 = sequence(task_70)]
</block>

// define experiment
<expt>
/ blocks = [
    1 = practice_task;
    2 = task;
]
</expt>
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
L123 - 8/1/2022
Thank you!
Below you can find a small demo that runs. What I want to do is iterate over a list with different answers. Participants have to choose between A or B. In the first trial, A is correct, in the second trial, B is correct (and so on - that is subject to change in the future). They can also request advice. Now the advice also iterates over a list of items. However, I cannot set the correct and incorrect responses (with corresponding response message) based on the current trial / list. The iteration of advice works for each trial, but setting the correct answers and response message and incorrect answers and response message for the current trial does not work. 


// define correct answers (would be great to use this item element for easier customization)
<item item_correct_answers>
/ 1 = "1"
/ 2 = "3"
/ 3 = "1"
/ 4 = "3"
</item>

// define the correct answers, as of now in a list element
<list correct_answers>
/ items = (1, 3, 1, 3)
/ select = values.currentscenario
// select = 2
</list>

// define incorrect answers (would be great to use this item element for easier customization)
<item item_incorrect_answers>
/ 1 = "3"
/ 2 = "1"
/ 3 = "3"
/ 4 = "1"
</item>

// define the incorrect answers, as of now in a list element
<list incorrect_answers>
/ items = [item.item_incorrect_answers]
/ select = values.currentscenario
// select = 2
</list>


// define texts
<text fixation>
/items = ("+")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ size = (30%, 30%)
/ txbgcolor = white
/ txcolor = black
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</text>

<text feedback_correct>
/items = ("Correct!")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ size = (30%, 30%)
/ txbgcolor = white
/ txcolor = black
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</text>

<text feedback_incorrect>
/ items = ("Incorrect!")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ size = (30%, 30%)
/ txbgcolor = white
/ txcolor = black
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</text>

// Ask participants to press either 1 or 3 on their keyboard, if they want help, they should press 2
<text instruction>
/ items = ("A (Press 1) or B (Press 3)? If you want support, press 2")
/ fontstyle = ("Arial", 4%)
/ position = (50%, 60%)
/ txcolor = black
/ txbgcolor = white
</text>

// Override the fixation with a white screen
<shape override_fixation>
/ shape = rectangle
/ size = (30%, 30%)
/ color = (255,255,255)
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</shape>

// specify advice
<item advice_answer_text>
/1 = "Advice: 1"
/2 = "Advice: 3"
/3 = "Advice: 1"
/4 = "Advice: 3"
</item>

// provide advice
<text advice_answer>
/ items = advice_answer_text
/ select = values.currentscenario
/ fontstyle = ("Arial", 5%)
/ position = (50%, 75%)
/ size = (32%, 15%)
/ vjustify = center
/ hjustify = center
/ txcolor = white
/ txbgcolor = grey
</text>

// define data to be recorded
<data>
/ columns = (build, computer.platform, date, time, subject, group, session,
blockcode, blocknum, trialcode, trialnum, list.correct_answers.currentvalue, response, latency, correct)
</data>

// define values
<values>
/ currentscenario = 0
</values>


// In this practice trial, I can define the correct answers. 1 is correct, 1 gives the "correct" Feedback and 3 gives the "incorrect" feedback. However, the correct response might change in other trials (to be B, so 3, for example)
<trial practice>
/ stimulusframes = [1 = fixation; 100 = override_fixation, instruction]
/ inputdevice = keyboard
/ validresponse = ("1", "2", "3")
/ correctresponse = ("1")
/ responsemessage = ("1", feedback_correct, 0)
/ responsemessage = ("3", feedback_incorrect, 0)
/ posttrialpause = 1500
</trial>

// this code works, but it does not give the "feedback_correct" or "feedback_incorrect" response and also does not code the correctresponse in the data section
<trial task_70>
/ stimulusframes = [1 = fixation; 100 = override_fixation, instruction]
/ inputdevice = keyboard
/ validresponse = ("1", "2", "3")
/ correctresponse = (list.correct_answers.currentvalue)
/ responsemessage = (list.correct_answers.currentvalue, feedback_correct, 1500)
/ responsetrial = ("2", task_70_advice)
/ responsemessage = (list.incorrect_answers.currentvalue, feedback_incorrect, 1500)
/ ontrialbegin = [
  values.currentscenario = values.currentscenario + 1;
]
</trial>

// if participants wanted to get advice (pressed 2 in the other trial), they can get advice here and choose again. However, it does not correctly code correct/incorrect either
<trial task_70_advice>
/ stimulusframes = [1 = override_fixation, instruction, advice_answer]
/ inputdevice = keyboard
/ validresponse = ("1", "3")
/ responsemessage = (list.correct_answers.currentvalue, feedback_correct, 1500)
/ responsemessage = (list.incorrect_answers.currentvalue, feedback_incorrect, 1500)
</trial>

// define blocks
<block practice_task>
/ trials = [1 = practice]
</block>

<block task>
/ trials = [1-4 = sequence(task_70)]
</block>

// define experiment
<expt>
/ blocks = [
    1 = practice_task;
    2 = task;
]
</expt>

I don't see any need to use lists here at all. The simplest way to get this working properly based on what you have is this:

// define correct answers (would be great to use this item element for easier customization)
<item item_correct_answers>
/ 1 = "1"
/ 2 = "3"
/ 3 = "1"
/ 4 = "3"
</item>

// define incorrect answers (would be great to use this item element for easier customization)
<item item_incorrect_answers>
/ 1 = "3"
/ 2 = "1"
/ 3 = "3"
/ 4 = "1"
</item>

// define texts
<text fixation>
/items = ("+")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ size = (30%, 30%)
/ txbgcolor = white
/ txcolor = black
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</text>

<text feedback_correct>
/items = ("Correct!")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ size = (30%, 30%)
/ txbgcolor = white
/ txcolor = black
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</text>

<text feedback_incorrect>
/ items = ("Incorrect!")
/ fontstyle = ("Arial", 5%, false, false, false, false, 5, 1)
/ size = (30%, 30%)
/ txbgcolor = white
/ txcolor = black
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</text>

// Ask participants to press either 1 or 3 on their keyboard, if they want help, they should press 2
<text instruction>
/ items = ("A (Press 1) or B (Press 3)? If you want support, press 2")
/ fontstyle = ("Arial", 4%)
/ position = (50%, 60%)
/ txcolor = black
/ txbgcolor = white
</text>

// Override the fixation with a white screen
<shape override_fixation>
/ shape = rectangle
/ size = (30%, 30%)
/ color = (255,255,255)
/ vjustify = center
/ hjustify = center
/ position = (50%, 50%)
</shape>

// specify advice
<item advice_answer_text>
/1 = "Advice: 1"
/2 = "Advice: 3"
/3 = "Advice: 1"
/4 = "Advice: 3"
</item>

// provide advice
<text advice_answer>
/ items = advice_answer_text
/ select = values.currentscenario
/ fontstyle = ("Arial", 5%)
/ position = (50%, 75%)
/ size = (32%, 15%)
/ vjustify = center
/ hjustify = center
/ txcolor = white
/ txbgcolor = grey
</text>

// define data to be recorded
<data>
/ columns = (build, computer.platform, date, time, subject, group, session,
blockcode, blocknum, trialcode, trialnum, values.incorrectanswer, values.correctanswer, responsetext, latency, correct)
</data>

// define values
<values>
/ currentscenario = 0
/ correctanswer = " "
/ incorrectanswer = " "
</values>


// In this practice trial, I can define the correct answers. 1 is correct, 1 gives the "correct" Feedback and 3 gives the "incorrect" feedback. However, the correct response might change in other trials (to be B, so 3, for example)
<trial practice>
/ stimulusframes = [1 = fixation; 100 = override_fixation, instruction]
/ inputdevice = keyboard
/ validresponse = ("1", "2", "3")
/ correctresponse = ("1")
/ responsemessage = ("1", feedback_correct, 0)
/ responsemessage = ("3", feedback_incorrect, 0)
/ posttrialpause = 1500
</trial>

// this code works, but it does not give the "feedback_correct" or "feedback_incorrect" response and also does not code the correctresponse in the data section
<trial task_70>
/ stimulusframes = [1 = fixation; 100 = override_fixation, instruction]
/ inputdevice = keyboard
/ validresponse = ("1", "2", "3")
/ correctresponse = (values.correctanswer) // correct answer is pressing the correct key as stored in values.correctanswer
/ responsemessage = (values.correctanswer, feedback_correct, 1500) // give correct feedback
/ responsetrial = ("2", task_70_advice)
/ responsemessage = (values.incorrectanswer, feedback_incorrect, 1500) // give error feedback
/ ontrialbegin = [
values.currentscenario = values.currentscenario + 1;
// store correct key for the current scenario in a variable
values.correctanswer = item.item_correct_answers.item(values.currentscenario);
// store incorrect key for the current scenario in a variable
values.incorrectanswer = item.item_incorrect_answers.item(values.currentscenario);
]
</trial>

// if participants wanted to get advice (pressed 2 in the other trial), they can get advice here and choose again. However, it does not correctly code correct/incorrect either
<trial task_70_advice>
/ stimulusframes = [1 = override_fixation, instruction, advice_answer]
/ inputdevice = keyboard
/ validresponse = ("1", "3")
/ responsemessage = (values.correctanswer, feedback_correct, 1500) // give correct feedback
/ responsemessage = (values.incorrectanswer, feedback_incorrect, 1500) // give error feedback
</trial>

// define blocks
<block practice_task>
/ trials = [1 = practice]
</block>

<block task>
/ trials = [1-4 = sequence(task_70)]
</block>

// define experiment
<expt>
/ blocks = [
1 = practice_task;
2 = task;
]
</expt>

L123
L123
Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)Associate Member (67 reputation)
Group: Forum Members
Posts: 4, Visits: 10
Works perfectly! Thank you so much!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search