Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

OSWeb play audios read from csv list depending on participant ID

Dear everyone,

I am trying to run my first OSWeb experiment. It works fine until I run it in the external browser.

In my experiment participants have to listen to audio recordings. There are two versions within this one experiment, which assign participants different audio files based on their participation ID.

I “coded” this with the help of lists in two csv files and this reference to the files: “version_[=var.subject_nr%2+1].csv” in the loop.

When the first audio is supposed to play I receive this message: “TypeError: r is undefined”

Does anybody have an idea how to fix that?

Thanks so much!

Comments

  • FabFab
    edited August 2022

    Hi @julia_,

    If you print that same expression to the console, you'll be able to see what file name that expression is actually generating (my guess is that it generates a filename that does not correspond to your actual csv files). That'll make it easier to debug the issue. I don't think you can use operators within the [] because this defines the name of a variable.

    Hope this helps,

    Fabrice.

    Buy Me A Coffee

  • @julia_

    Here's a example of how you can do it...

    The method consists in setting up a variable containing the filename in Javascript before the loop is executed (1). It is best to insert that code under the "prepare" tab (when running the task in OS, running it under the "run" tab works, but if you're running it in a browser, it won't. Make sure your csv files are loaded in the files pool.

    You can define stimfile using this javascript code:

    vars.stimfile=vars.subject_nr%2+1+".csv"
    console.log ("stim file : "+vars.stimfile)
    

    Outputting the variable's content to the console is good practice, it helps you check whether the content is correct (useful for debuging).

    Last bit needed: call that variable from the loop object:

    That's it!

    Yo can download this example here:


    Hope it helps!

    Fabrice.

    Buy Me A Coffee

  • Hi @Fab

    Thank you so much for your quick reply! And also for the step by step tutorial! Unfortunately I don't know anything about coding and also just received the variable string from someone else.

    I did what you said, but now I don't know where to find the generated file name?

    There's nothing else written in the console except for In [1] :

  • Hi @julia_,

    It should show in the console when the code gets executed:

    If you run the task in the browser, you can view the console too but have to bring it up (Ctrl+Shift+i in Edge, might be the same in Chrome; otherwise also accessible somewhere in your browser's menus).

    What you write to the console has no consequence for the task itself, it is just useful for you to be able to track what is going on while the task runs.

    With the example I sent you, you should hopefully be able to amend your task accordingly, though depending on how the task is setup you may need to adapt it a little.

    Hope this helps,

    Fabrice.

    Buy Me A Coffee

  • Hi @Fab

    Thank you again! I did what you said, even had someone with more knowledge than me have a look at it but we could not figure out how to fix it.

    I saw that some people post their experiments in the forum so that y'all can have a look at it, which seems to be my hail mary right now.

    You can find it here:

    https://drive.google.com/drive/folders/1Nz0PpteI4sHyVmWdlc_2nPh71yC4WDxS?usp=sharing

    I changed everything back to how it was when I ran into my problem in the first place, we're talking about the "listening_task_loop" here, where it will stop playing in the browser.

  • Hi Julia,

    The suggestions of @Fab were solely meant to find out whether your experiment generates the path to the files correctly, and not to fix anything. The first part in helping you with your problem is to find out whether OSweb messes up the file names, or the actual presentation of the videos.

    Have you found out whether the correct file names are presented in the console?

    Perhaps it would also help if you shared your experiment here with us. Ideally, in a simplified way that removes as much of the complexity as possible, while still retaining the error and including the video files that are called.

    Thanks,

    Eduard

    Buy Me A Coffee

  • Hi @eduard


    Thank you so much for your message. Yes, the correct file names were presented in the console.

    And my experiment is actually running now, I'm sorry, I forgot to mention it here! I downloaded the newest OS version and then it worked most of the time. Sometimes there was still an error message but that has now disappeared, I don't really know what fixed it though, I tried a few things.

    Anyways, it's now all working out fine, also in Jatos.

    Thank you all for your help and willingness to help :))

Sign In or Register to comment.