Howdy, Stranger!

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

Supported by

Difficulty to access pool file using javascript

Hi! I'm developing an experiment that has, as one of its phases, kind of a preference test. The choices are between 48 png images. At the end of this phase, the application shows to the participants their top 3 favorite images. The top 3 are showed in individual screens, 1 by 1, that where made using inline_html item. It can not be made through a sketchpad, because the participants will need to confirm their agreement with the results, in a likert scale, at the same screen.

The problem is that the <img scr> html tag is not showing the image, even though the console shows that's everything ok. I've been trying to access the image in the pool, to inform to the complete image path to the html code, but I had no success, despite 3 days of million different tries.

I've being trying specially the orientations available on 332 and 7279 topics. But it's like the "file" attribute is not working anymore (and I really dind't find it at the js files). I'm using OpenSesame 3.3.14 and OSWeb

Is there any other way to do this, and bring the complete path of the image at the pool to a variable?

Tks a lot!


  • Hi @conrado ,

    Here's an example of how you can do this in an inline_html item in the upcoming OpenSesame 4.0.

    • We first define an empty <img> tag with an id that we can refer to ('target_img').
    • Next, we retrieve an image from the pool by the name of the image ('pupil-cat.jpg'). The data property of that file-pool object is itself an object (a JavaScript object is equivalent to an tag.)
    • Finally, we assign the src property from the file-pool object to the newly created <img> tag.

    It's not very elegant, but do you see the logic?

    <input type='text' name='text_response'>
    <img id="target_img">
    <input type='submit' value='ok'>
    # This gets the IMG element
    const targetImg = document.getElementById('target_img')
    # pool['pupil-cat.jpg'].data is also an image element
    # we can assign the source to the target-image source
    # to make the image visible
    targetImg.src = pool['pupil-cat.jpg'].data.src

    Hope this helps!

    — Sebastiaan

  • Thanks, @sebastiaan!

    I was very excited to try OpenSesame 4.0, and I tried last weekend, but it demands me some adaptations that I don't have time enough to do for now. I need to finish this work until Friday morning. For example, I have js scripts inside my inline_html items to review. OS 4.0 also loses some rules and conditions, when it opens an experiment developed in an older version, like the details of mouse_response item, some "run if" of sequence items and inside repeat_cycle item. It's not too much, If would not have so many of them with different parameters.

    I found a solution to my problem, copying all the images to the img directory inside the zip file of my application, before upload it to a Jatos server. I made this renaming the root directory and using the entire path at the html tag, and not renaming, juts pointing to img directory. Until now, both ways are working.

    But I'll keep trying a better way when I have more time, to not duplicate the 48 png images inside my application at Jatos server.

    One more time, thanks a lot for your help!


  • Hi, @sebastiaan!

    I came back to tell you that today your suggestion worked very well.

    In my previous attempts, I was making a wrong reference to the variable that would have the name of the image which I needed to locate in the pool. Like, the name of the image file was at img_name variable, and I wrote the code as OpenSesame generally references the variables, pool['img_name'].data.src, when the right way should be pool[vars.img_name].data.src.

    That kind of silly mistake that we don't see a million times and end up naturally not making again when rewriting the code from zero.

    Tks again!


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 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