Howdy, Stranger!

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

Supported by

Resources for translating Python to JavaScript

Hi!

I currently have a working experiment in OpenSesame with Python inline code. However due to the pandemic going on, it's best if we run the experiment online. Therefore I want to use the OSweb functionality.

For this I of course have to translate my Python inline code to JavaScript code. I don't have any experience with the latter. Are there any good resources on translating Python to Javascript?

I did see that there was another thread about translating Python to Javascript currently on the forum, but that one was very specific, so I thought I would ask more generally.

Also is there a list of all the things that are NOT possible in JavaScript somewhere? The webpage about Javascrip (https://osdoc.cogsci.nl/3.3/manual/osweb/javascript/) basically says, "Canvas, Keyboard objects, etc", but I'm not sure if the "etc" are a few more things, or are a whole lot of things that will make it impossible in the first place to translate the script.

I personally need at least some randomization, a dataframe (now using pandas in Python) and a form.

I hope anyone can help and kind regards in advance!

Sanne

Comments

  • Hi Sanne,

    I'm not an expert in JS myself yet, but in general I think there's the following rule of thumb: interaction between the GUI (sketchpads etc.) and the java_inlinescript is only possible by storing and retrieving variables with the vars.object, as described here:

    More advanced ways of communication between script and GUI, such as running items from the GUI via an java_inlinescript, or reading loop tables with datamatrix are not possible. Also, as you mentioned yourself, Python classes such as Canvas, Keyboard, Mouse, Sampler do not have a JS equivalent yet.

    Unfortunately, form items are also not supported by OSWeb yet. Instead, you will have to use sketchpad items combined with mouse_response or keyboard_response items to show questionnaires and collect responses. Perhaps this discussion can be of help:


    Randomization and reading in dataframes should be possible in JS, although I don't know how, from the top of my mind. I can look into this, if wanted.


    Good luck and let us know if you need more specific help!!


    Cheers,


    Lotje

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

  • Hi @Sannee , me again. To shuffle/ randomize you could do something like described here:

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

  • Hi Lotje,

    Thank you so much for your clear answer!

    Sadly enough most of my experiment is build on a form, so I think I'd either have to rebuild the entire experiment from the ground up then or find another way to distribute it. (although that is also on me, I should have checked before I started building)

    Is there any other way to let an OpenSesame experiment run remotely without others having to install OpenSesame themselves?

    Kind regards,

    Sanne

  • Hi Sanne,

    On windows systems, I used to simply download the zip file of Opensesame from github, extract it, and then started Opensesame by double clicking on the .exe file. Like that no installation was necessary (which was my way of bypassing not having adminstrator rights on our lab computers, while not messing up the entire system). However, last time I checked it was 3 years ago. No guarantee that it still would work like that. I also have no clue whether something comparable exists for Mac/Linux systems.

    If you have Windows, you can try yourself:

    1) Go to Github, pick a version, download the zip and extract

    2) Find the opensesame.exe file in the folder and execute it


    Hope this helps,

    Eduard

    Buy Me A Coffee

  • Hi!

    Thanks for the suggestion! It works fine for some people I tested it with, but not for others sadly.

    It seems like, if there is already an older version of Python on the computer, OpenSesame will run with that version of Python and then crash because some functionalities aren't there yet.

    Kind regards,

    Sanne

  • Hi!

    I had one more question about JavaScript and its functionalities. I've seen the survey templates that have been uploaded, but is there any way to create text boxes that people can fill in values in with a Javascript/Sketchpad combination?

    Kind regards,

    Sanne

  • Hi Sanne,

    Not sure whether this is what you mean, but there is a osweb version of the text input funcionality (users type in responses that are longer then a single character). See this discussion for example experiments:

    I think there are also other discussion around that deal with that issue. Perhaps you could browse a little if this link doesn't help you.

    Good luck,

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    This does indeed seem to be exactly what I'm looking for! Thank you so much!

    Kind regards,

    Sanne

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games