0 votes
in SoSci Survey (English) by s126407 (215 points)
closed by SoSci Survey

Hi, I tried what was suggested for dynamical response time limits, but I can't make dynamical timeouts work. I'm copying the code (respectively, on the page there is first php than html, than the question), and if you have some further advice i would be eternally grateful :)
This is the PHP code:

$tPAT = valueMean(array('RT05_01a', 'RT05_02a',
'RT05_03a', 'RT05_04a', 'RT05_05a'));
registerVariable('tPAT');
replace('%remain%', $tPAT);
  • "RT05_01a" to "RT05_05a" are variable names for response times recorded during the Reading Test (RT). For the reading test, I used an Assignment question, and the ID is RT05. Participants are presented with some text, and when they have read it, they give response by pressing space. I need mean response time because it represents mean reading time that is supposed to be used in the next part (in which participants solve a task, with limited time for providing the answer, and the limit is mean reading time (tPAT in the code above) PLUS 500 milliseconds)

This is the html part, that is on the same page as PHP, but below:

<script type="text/javascript">
function next()
  // Forward participant onto the next page
  SoSciTools.submitPage();
}
 
window.addEventListener("load", function(evt) {
    SoSciTools.questionnaire.CR03.setTimeout({
        1: %remain% + 500
    });
});
</script>
  • CR03 is the question in which I want to set the dynamical timeout explained above the HTML code I copied. This is also an Assignment question, containing only one item, preceded by an instruction as "the text before the first stimulus".

In the debug mode I can see that the mean response time from the previous reading speed task has been calculated. Here is the printscreen you asked for:

However, the question (CR03) remains there for an unlimited amount of time instead of the mean reading time defined by tPAT + 500 milliseconds. I also tried without a placeholder, and it too doesn't work. Sorry for the lay questions, I've never done anything similar before, and javascript is a mystery for me still.
Do you have an idea what should i do?

closed with the note: Problem solved - a little syntax error stopped JavaScript from doing its job.
by SoSci Survey (304k points)
Thanks for the samples and the screenshot. Unfortunalely the debug information is so small that I am not able to read it. Would you mind to copy it down here to the comments, please?

I guess that $tPAT is a decimal number, causing the issues. Therefore you may try to replace

replace('%remain%', $tPAT);

by

replace('%remain%', round($tPAT));
by s126407 (215 points)
edited by s126407
Thanks, I tried this:
replace('%remain%', $tPAT);

by

replace('%remain%', round($tPAT));

Again, does not forward to the next page, I remain on the page until I give an answer.

Sorry for the pic, didn't realize the size :D. Here is the debug info (now that i changed the PHP part as you instructed me:
[Information]    Interview number 115 is to be continued
[Information]    Questionnaire CRT_i_MAT from project ramint will be used
[Information]    Retention period on page 3 has been 3 seconds
[Processing]    Reading answers from page 3
[Information]    Answer to K109 = 8
[Information]    100% of the questions have been answered so far
[Processing]    Create page 4 in questionnaire CRT_i_MAT
[Content]    Create question CR03
[Information]    The following placeholders have been prepared:
%remain% = (text) 280

The last line indeed did have decimal numbers before, say 249.2 instead of the round number, so that changed.

I also, now see that there is no open bracket "{" at the beginning of the HTML command to forward participants to the next page, and I added it after "function next()" but it still doesn't work.
by s126407 (215 points)
It's working!! deleted the first part of html, I don't know why I ever added it. Thank you so so much!
by SoSci Survey (304k points)
Thanks for the update! I was just about to ask what the next() function was intended for, as it seems to appear nowhere in the other code. I was about to say that "this did probably not cause the problem", but you were absolutely right with the missing bracket.

Good to hear you made it working.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...