Millisecond Forums

End option in Math Effort Task

https://forums.millisecond.com/Topic23125.aspx

By N.Solozano - 12/19/2017

Hi,

I'm trying to add an option to allow participants to stop the Math Effort Task (http://www.millisecond.com/download/library/mathefforttask/) whenever they want, but showing them their final score (that is, the end of the task). I add a radiobutton with the question: "Do you want to end the task?" in the surveypage that appears when they have to write the answer to each problem (and allows to change level too). I'm trying to make the "end radiobutton" just like the previous "change level raddiobutton", but i can't do it. If participants choose the "change level option" they can choose another level, but if  they choose the "end option" the task just continues as normal.

Below is the code for the experiment.

1) I create an exit radiobutton just like the "changelevel" radiobutton.

<radiobuttons exit>
/ caption = "Optional: Do you want to end the task ?"
/ options = ("Yes")
/ required = false
/ txcolor = blue
/ fontstyle = ("Arial", 2%, false, false, false, false, 5, 1)
/ position = (28%, 65%)
</radiobuttons>

2) I add a value to "exit" variable (again just like changeLevel)
<values>
/ completed = 0

/ nrDigits = 0
/ currentLevel = 0
/ previousLevel = 0
/ number1 = ""
/ number2 = ""
/ number3 = ""
/ number4 = ""
/ number5 = ""
/ solution = ""
/ response = ""
/ correct = 0
/ rt = ""
/ countTrialsCurrentLevel = 0
/ countTotalTrials = 0
/ changeLevel = 0
/ exit = 0

/ countLevel1 = 0
/ countLevel2 = 0
/ countLevel3 = 0
/ countLevel4 = 0
/ countLevel5 = 0
/ countcorrectLevel1 = 0
/ countcorrectLevel2 = 0
/ countcorrectLevel3 = 0
/ countcorrectLevel4 = 0
/ countcorrectLevel5 = 0

/ countLevelChange = 0
/ selectFeedback = 0
/ selectInstructions = 0
</values>

3) I try to add a conditional, but it doesn't work. 

<surveypage response>
/ questions = [1 = response, changeLevel, exit]
/ fontstyle = ("Arial", 3.5%, true, false, false, false, 5, 1)
/ itemfontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
/ responsefontstyle = ("Arial", 2.5%, false, false, false, false, 5, 1)
/ timeout = parameters.RW
/ showbackbutton = false
/ showmousecursor = true
/ showpagenumbers = false
/ showquestionnumbers = false
/ ontrialend = [
if (radiobuttons.exit.response == "Sí") {
values.exit = 1;
} else {
values.exit = 0;
};
if (radiobuttons.changeLevel.response == "Sí") {
values.changeLevel = 1;
} else {
values.changeLevel = 0;
};
values.response = textbox.response.response;
if (monkey.monkeymode && replace(0,1) == 1){
values.response = values.solution;
};
if (values.response == values.solution) {
values.correct = 1;
} else {
values.correct = 0;
};
if (values.currentLevel == 1) {
values.countcorrectLevel1 += values.correct;
} else if (values.currentLevel == 2) {
values.countcorrectLevel2 += values.correct;
} else if (values.currentLevel == 3) {
values.countcorrectLevel3 += values.correct;
} else if (values.currentLevel == 4) {
values.countcorrectLevel4 += values.correct;
} else if (values.currentLevel == 5) {
values.countcorrectLevel5 += values.correct;
};
values.rt = surveypage.response.latency;
]
/ branch = [
if (values.exit == 1) {
page.End;

if (values.changeLevel == 1) {
surveypage.chooseLevel;
} else {
if (values.countTrialsCurrentLevel == parameters.numberBatchedProblems) {
values.countTrialsCurrentLevel = 0;
surveypage.chooseLevel;
} else {
trial.getReady;
};
};

]

/ nextbuttonposition = (45%, 70%)
/ finishlabel = "enviar"
/ recorddata = true
</surveypage>


By Dave - 12/19/2017

N.Solozano - Tuesday, December 19, 2017
Hi,

I'm trying to add an option to allow participants to stop the Math Effort Task (http://www.millisecond.com/download/library/mathefforttask/) whenever they want, but showing them their final score (that is, the end of the task). I add a radiobutton with the question: "Do you want to end the task?" in the surveypage that appears when they have to write the answer to each problem (and allows to change level too). I'm trying to make the "end radiobutton" just like the previous "change level raddiobutton", but i can't do it. If participants choose the "change level option" they can choose another level, but if  they choose the "end option" the task just continues as normal.

Below is the code for the experiment.

1) I create an exit radiobutton just like the "changelevel" radiobutton.

<radiobuttons exit>
/ caption = "Optional: Do you want to end the task ?"
/ options = ("Yes")
/ required = false
/ txcolor = blue
/ fontstyle = ("Arial", 2%, false, false, false, false, 5, 1)
/ position = (28%, 65%)
</radiobuttons>

2) I add a value to "exit" variable (again just like changeLevel)
<values>
/ completed = 0

/ nrDigits = 0
/ currentLevel = 0
/ previousLevel = 0
/ number1 = ""
/ number2 = ""
/ number3 = ""
/ number4 = ""
/ number5 = ""
/ solution = ""
/ response = ""
/ correct = 0
/ rt = ""
/ countTrialsCurrentLevel = 0
/ countTotalTrials = 0
/ changeLevel = 0
/ exit = 0

/ countLevel1 = 0
/ countLevel2 = 0
/ countLevel3 = 0
/ countLevel4 = 0
/ countLevel5 = 0
/ countcorrectLevel1 = 0
/ countcorrectLevel2 = 0
/ countcorrectLevel3 = 0
/ countcorrectLevel4 = 0
/ countcorrectLevel5 = 0

/ countLevelChange = 0
/ selectFeedback = 0
/ selectInstructions = 0
</values>

3) I try to add a conditional, but it doesn't work. 

<surveypage response>
/ questions = [1 = response, changeLevel, exit]
/ fontstyle = ("Arial", 3.5%, true, false, false, false, 5, 1)
/ itemfontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
/ responsefontstyle = ("Arial", 2.5%, false, false, false, false, 5, 1)
/ timeout = parameters.RW
/ showbackbutton = false
/ showmousecursor = true
/ showpagenumbers = false
/ showquestionnumbers = false
/ ontrialend = [
if (radiobuttons.exit.response == "Sí") {
values.exit = 1;
} else {
values.exit = 0;
};
if (radiobuttons.changeLevel.response == "Sí") {
values.changeLevel = 1;
} else {
values.changeLevel = 0;
};
values.response = textbox.response.response;
if (monkey.monkeymode && replace(0,1) == 1){
values.response = values.solution;
};
if (values.response == values.solution) {
values.correct = 1;
} else {
values.correct = 0;
};
if (values.currentLevel == 1) {
values.countcorrectLevel1 += values.correct;
} else if (values.currentLevel == 2) {
values.countcorrectLevel2 += values.correct;
} else if (values.currentLevel == 3) {
values.countcorrectLevel3 += values.correct;
} else if (values.currentLevel == 4) {
values.countcorrectLevel4 += values.correct;
} else if (values.currentLevel == 5) {
values.countcorrectLevel5 += values.correct;
};
values.rt = surveypage.response.latency;
]
/ branch = [
if (values.exit == 1) {
page.End;

if (values.changeLevel == 1) {
surveypage.chooseLevel;
} else {
if (values.countTrialsCurrentLevel == parameters.numberBatchedProblems) {
values.countTrialsCurrentLevel = 0;
surveypage.chooseLevel;
} else {
trial.getReady;
};
};

]

/ nextbuttonposition = (45%, 70%)
/ finishlabel = "enviar"
/ recorddata = true
</surveypage>



/ branch = [
if (values.exit == 1) {
page.End;
}

You cannot /branch to a <page> element. A <page> is not a <trial> element. Set up a <surveypage> to serve as your "end page" and /branch to that. You'll also need to build in some more logic that then actually terminates the script, by e.g. calling the script.abort() function on the "end" surveypage.