Howdy, Stranger!

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

Supported by

OSWeb: t.replace is not a function

Hi folks,

I am trying to run my experiment through OSWeb. I can get through the first two blocks okay, but then I get an error that "t.replace is not a function" and the experiment stops. I should mention that it was working previously (maybe July or August?). I'm not familiar enough with Python to troubleshoot this.

Any help would be much appreciated!

Lena

Comments

  • edited October 2020

    Hi @lvkremin ,

    Can you post a screenshot of the browser console with the error message?

    I suspect that this is a bug in OSWeb related to showing a numeric value on a sketchpad , but I'd like to make sure.

    — Sebastiaan

  • Hi Sebastiaan,

    When I try to run the experiment in OpenSesame itself, I get the following:

    I'm not sure why it won't run at all in OpenSesame, but it will start in the browser. When I run it in the browser (Google Chrome), I get this:

    It may well be a bug about showing a numeric value. This is what the following screen should show:

    Thank you!

  • Hi @lvkremin ,

    Thanks for reporting this. That indeed seems to be the bug that I had in mind. This issue should be fixed for OSWeb 1.3.10.

    For now, a workaround would be to add some invisible text around the numbers, which will make sure that the numbers are treated as text. The   character (a space) is a good candidate. You can simply type this in front and after the number on the sketchpad , so that, if you view the script of the sketchpad , it should look something like this:

    draw textline center=1 color=white font_bold=no font_family=serif font_italic=no font_size=32 html=yes show_if=always text=" 1 " x=0 y=0 z_index=0
    

    Hope this helps!

    — Sebastiaan

  • Hi @sebastiaan

    Yes, that worked! Just a note, for me having " 1 " in the script didn't work - it still threw the error. But putting " 1 " did.

    Thanks!

  • edited February 2021

    Hi @sebastiaan (and @lvanderlinden),

    I have encountered the same problem as Lena even though the issue should've been fixed as stated in Issue #40. See the attached picture.

    I've tried to include the  [multichar_response]  as well as  around the numbers underneath the words in the script without any help.

    Do you know how to fix it?

    Thanks in advance!


    Best,

    Martin


  • Btw my backend is Legacy and I get the same error-message if I'm using Chrome or Edge.

    You can have a look at my .oexp file here:


  • Hi @marbh ,

    The error looks superficially similar, but in your case it comes from your own script (not OSWeb), and more specifically from the count_incorrect item. Here you are trying to call vars.multichar_response.replace() , but this function does not exist if participants have entered a number so that vars.multichar_response is a numeric value rather than a string. Do you see what I mean?

    You would be able to avoid this error by checking whether the value is a string or not before calling the function. However, the question is why this script is there to begin with, and therefore whether it is safe to just bypass it like that. To know this, I would carefully go through the logic of the experiment, and try to understand the purpose of each item. (I suspect that the experiment is largely the result of copy-pasting?)

    if (typeof vars.multichar_response === "string") {
        vars.res = vars.multichar_response.replace(/enter|return|/gi, "")
    }
    

    Cheers!

    Sebastiaan

  • Ah okay that makes sense. Thank you very much for your fast response. :)

    I definitely need to take a close look at the elements in the experiment as it is indeed a lot of copy-pasting.

    Best,

    Martin

Sign In or Register to comment.