Howdy, Stranger!

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

Supported by

Switch to different window using inline script

Hi all,

First of all, I'd like to thank everyone who is actively contributing to the forum. I'm new to OpenSesame and Python and I've already fixed many issues by reading the posts.

At the very end of my experiment in OpenSesame, I'd like participants to continue with a survey on Qualtrics. Importantly, at the start of my procedure they already fill in part of the survey, then they do the experiment in OpenSesame, then they finish the survey. The browser survey window stays open (minimised) while they do the experiment.

I would like to include an inline script that tells Windows to switch to the browser window in full screen so that participants can continue the survey after finishing the experiment.

I am aware that there is the option to open a link using an inline script but that's not exactly what I need. I tried it and the browser opens the link in a new tab instead of switching to the tab that is already open. I don't want participants to start the survey again from the beginning but to continue exactly where they stopped.

In case anyone has a better idea how to implement this, I'm also happy to hear it.

Cheers!

Comments

  • Hi @Jeanette,

    I think it is pretty tricky to force the browser to open a link in an already existing tab or to force to the browser to change focus from one tab to another (in fact, I think browsers do not allow the latter for security reasons).

    I'm assuming you're planning to run your task online in the browser (in which case you should avoid Python coding and use in inline_javascript object).

    There might be a way to define an id for a web page within your first Qualtrics survey and then use Javascript in your OS experiment to open a link into the tab with that id (using something along the lines of this), but I'd just done a quick test and couldn't get it to work.

    Personally, my advice would be to split your study into three parts: Qualtrics Survey 1, JATOS experiment, Qualtrics Survey 2, with Survey 1 opening your JATOS experiment upon completion, passing the subject's id to your task through a parameter in the URL, then setting up your JATOS experiment to open Survey 2 upon completion, again passing on whatever parameters you need (such as subject id) through the URL. That way you'd have subjects switching smoothly from phase to phase (in the very same window if you wish to).

    Don't know if that's of any help... Hopefully other users with more knowledge of Javascript and experience mixing OSWeb and Qualtrics may be able to offer better solutions.

    Cheers,

    Fabrice.

    Buy Me A Coffee

  • Hi @Fab!

    Thanks a lot for your reply!

    I'm assuming you're planning to run your task online in the browser (in which case you should avoid Python coding and use in inline_javascript object).

    I'm actually running the experimental paradigms directly in OpenSesame, I'm not using the browser integration. It's a lab study but I wanted to reduce the times that the experimenters have to come in and do something manually so that the participant can continue with the next part.

    Personally, my advice would be to split your study into three parts: Qualtrics Survey 1, JATOS experiment, Qualtrics Survey 2, with Survey 1 opening your JATOS experiment upon completion, passing the subject's id to your task through a parameter in the URL, then setting up your JATOS experiment to open Survey 2 upon completion, again passing on whatever parameters you need (such as subject id) through the URL. That way you'd have subjects switching smoothly from phase to phase (in the very same window if you wish to).

    Yes, I've also been thinking about splitting up the survey in two parts, that way I could open the second survey at the end of the experiment with a simple Python inline script.

    Good idea to pass on the subject's ID through the URL. Would you recommend to do that with Python or JavaScript?

    Cheers!

  • Hi @Jeanette,

    I don't really know Python (am new to Open Sesame), but my guess is that if you're running your experiment from OS and not from a browser, you should use python code (because I don't think the OS would interpret Javascript code as a browser would). In fact, I did a quick test and the following Javascript in an inline_javascript object works if you run the experiment within a browser but not is you run it from OS itself:

    window.open("https://www.qualtrics.com/", "_blank")
    

    So, in your case, use Python:

    # importing webbrowser python module
    import webbrowser
    #Assigning URL to be opened
    strURL = "http://www.qualtrics.com"
    #Open url in default browser
    webbrowser.open(strURL)
    

    Note that you'd have to edit the strURL in this code to embed the relevant parameters, such as your participant id or whatever other variable you have in your OS task that you want to pass on to your second Qualtrics survey. You can find some information about how to handle query strings in Qualtrics here.

    Beware that if you run your task in OS; you don't have the option of having your first Quatrics survey launching the task and passing on participant id or other variables, so you'd want to make sure that you have some way of entering some data in your task that identifies your participants in a way that matches your record in the first survey, and that you pass that on to the second survey from your task. That way, you'll be able to make sure you can identify each individual participant in each of the three phases.

    Hope this helps.

    Cheers!

    Buy Me A Coffee

  • Thank you very much @Fab ! Will try it and post an update here :)

  • Update for anyone who would like to implement a similar procedure

    Here's how I solved it:

    I split my Qualtrics survey in two parts; one 'pre OS' and one 'post OS'.

    First, read how to pass on information to a survey in a query string in Qualtrics:

    https://www.qualtrics.com/support/survey-platform/survey-module/survey-flow/standard-elements/passing-information-through-query-strings/

    Read the article on embedded data elements, create and name a new field:

    https://www.qualtrics.com/support/survey-platform/survey-module/survey-flow/standard-elements/embedded-data/#CreatingAnEmbeddedDataElement

    In my case, I created 'part_id'.

    In OS, add a new sequence at the very end of the paradigm, add an inline script into the sequence. The value for the Qualtrics variable 'part_id' in the string will be set based on the value of the OS variable 'subject_nr'

    import webbrowser
    import urllib
    
    #open url of your survey, pass on the value of variable 'subject_nr' to Qualtrics
    webbrowser.open("https://unixyz.eu.qualtrics.com/somestring?part_id={}".format(var.subject_nr), autoraise=True)
    


Sign In or Register to comment.