Get trial (Loop & Merge sample) number

Home Forums Support Get trial (Loop & Merge sample) number

  • This topic has 2 replies, 2 voices, and was last updated 9 years ago by Becky.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2225
    Becky
    Guest

    Hi forum,

    Can anyone tell me how to access the current trial number (i.e. sample number from the Loop & Merge table)? I’m trying to display a break screen that is conditional on the trial number. I looked through the QRTE source code found

    currentLoops = '${lm://CurrentLoopNumber}'

    so I tried using

    return '${lm://CurrentLoopNumber}' === 20

    within the break screen conditional function, but that didn’t work.

    Thanks!
    Becky

    #2226
    Erwin Haasnoot
    Keymaster

    Hi Becky,

    You’re close! But there’s a slight issue.
    return '${lm://CurrentLoopNumber}' === 20

    Evaluates, in Qualtrics, on CurrentLoopNumber 20 to:

    return '20' === 20

    Now, see for yourself. Open the developer console and then type in: ’20’ === 20. You’ll notice that it evaluates to “false”.

    This is because === strictly type checks, next to value. ’20’ is a string, 20 is a number, these don’t match, so it’s false.

    Fixing it simple. Simply wrap the 20 in quotes, so that it becomes a string: ’20’

    return '${lm://CurrentLoopNumber}' === '20'

    Hopefully you’ll be able to figure it out from here!

    Best regards,

    Erwin

    #2232
    Becky
    Guest

    Hi Erwin,

    Thanks very much for explaining this! I’ve changed the right side of the equation to a string, and it works perfectly now.

    Thanks also for the link to the developer console. I wasn’t aware of this tool, and I’m sure it will be useful for debugging things like this in the future.

    Best regards,
    Becky

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Support’ is closed to new topics and replies.