Howdy, Stranger!

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

Supported by

Why is it that when I click "quick run" it works, but when I click "run in browser" it gets an error

I did a simple experiment, using inline_script insert statement to control the experiment time: exp.start_time =self.time (), and in the loop break if set = self.time-self. get('start_time') >= 120000.


However, in the process of testing, I found that "Quick Run" could be used, and the test in OSWeb would report an error. What is the problem? Thank you!


Comments

  • Hi @DDD ,


    Python inline_script items are not supported in OSWeb, the OpenSesame extension for running experiments online:



    Instead, you could using inline_javascript items.



    So if you are running a study online, by using OSWeb, you should transfer your Python code to JavaScript. To get the current time stamp, for example, you could use the following script in an inline_javascript item:


    // Get the starting time and store it in the vars object
    let date = new Date();
    vars.starting_time = date.getTime();
    


    Does this help?


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Hi, Lotje:

    I've tried your method, but it still doesn't work. Can I write the break if statement like this? Is it an error in break if?

    Thank you!

  • HI,

    It would be much easier to help you with your problems if we had an error message. That way, we could narrow down the problem to where in the script/sequence the problem occurred. In firefox, you can see the error message, if you open a console before running the experiment by pressing CTRL+SHIFT+C

    Can you try to find an error message and post it here?

    Can I write the break if statement like this? Is it an error in break if?

    I am not entirely sure, but I don't think so. I recommend you do following thing

    1. initialize a variable that tracks the duration of the period you are counting. This must occur before the loop in which you are using that variable is run. That would be something like `vars.duration = 0`
    2. the break if statement you can then write as "[duration]>120000"
    3. Make sure that on every iteration of the loop, you update the duration. For this you can basically use the code you have in your run if statement.

    But again, if we see an error message, we can have a closer look on what is happening. Alternatively, you can also share your experiment here, and we can have a look directly there.

    Eduard

    Buy Me A Coffee

  • Hi @DDD ,


    Sorry, I missed your post, but luckily Eduard helped out. Just to follow up:

    Can I write the break if statement like this? Is it an error in break if?

    No, this if-statement indeed won't work. If you precede an if-statement with the "equal" ("=") sign, this means that some Python script will follow. And Python script is not supported in OSWeb.

    Eduard's solution will work fine, because here the if-statement is written in OpenSesame script, by using the square-bracket notation.


    Hope this clarifies it a bit.


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

Sign In or Register to comment.