Howdy, Stranger!

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

Supported by

JATOS url of assets incorrect (basepath missing)

Hello everyone,

I have this problem that my experiment (lab.js) works on my local JATOS as well as on the Covid-Server., but it does not run on our university's server. I get the message in the console that the assets (lab.js, jatos.js, script.js) from the assets and study_assets folders can't be loaded. In the path provided there, there is a part missing from our server's url: our-server.com/xyz/ --> the xyz is missing. Do you have any idea why this problem occurs and how we can solve it?

(I tried to change the path in my .html file, but it still doesn't work. Not sure where else the path is used.)

Thanks!

Lea

Comments

  • Hi Lea!

    What type of path do you use in your experiments: relative like "lib/survey.js" or absolute like "/study_assets/my-exp-folder/survey.js". I guess it is the later and then the easiest solution is to switch to a relative path. But you have to switch in all paths with all HTML, JavaScript, CSS, images etc.

    E.g.

    If you have right now:

    <script src="/study_assets/my-exp/lib/survey.js" />
    

    you'd have to change this to

    <script src="lib/survey.js"></script>
    

    Best,

    Kristian

  • Hi Lea, hi Kristian,

    thanks to you both for taking this apart! Over on the lab.js support channel, we discussed this in a bit more detail -- specifically, if the relative paths are a better idea, I'd be happy to change how our export function sets the paths, but Lea (if I understood correctly) tested this and found that the files were served with an incorrect mime type (always text/html), which broke importing scripts and styles.

    Kristian, what would you suggest? I'd be glad to implement JATOS best practices, and this looks like an easy fix (we use relative paths in all other exports).

    Thanks again to you both, and many kind regards,


    -Felix

  • Hi Felix and Kristian,

    I'm not sure what the mime types mean, but it only didn't work for me when I used the exported folder structure. It worked well for me when I

    1. unzipped the exported folder (for JATOS) (which gives me an "study_export" folder that contains a "study_name" subfolder and a study_name.jas file)
    2. went to the "study_name" subfolder and changed the paths in the html file (didn't check the other files)
    3. went to my local JATOS and created a new study, copied the content of the subfolder (!!) and the study_name.jas file (not sure whether that's necessary) into the new jatos/study folder
    4. created a new component that linked to the html file (it did not work when I had the file in the subfolder and typed "study_name/index.html" in the HTML path box!)
    5. exported and imported it to our server JATOS.

    So could the problem with the mime type be due to the folder hierarchy?

    Thanks for all your effort!

    Lea

  • ... but this might be a completely different problem. So to summarize: I think it should work without problems with the relative paths in the export! :D

  • Thanks so much, @Lea, for your update! That was enormously helpful -- I hadn't (and probably still haven't) fully grokked what's going on; you know JATOS a lot better than I do. πŸ˜…

    There's still some points I'm not quite sure about, if you can spare a moment to clarify (hoping you haven't addressed this already):

    • Do you move files around during your import process, relative to what the lab.js export provides? (it sounds like you might be moving the study from a subdirectory to a superordinate one, I'm not sure)
    • I take it that the jsPsych studies work both locally and on your department server (with relative paths), did I catch that right? If so, I'm even more confused, since it feels like the technical setup should be identical πŸ€”

    Ok, that's what I'm still wondering about. @kri, if you could confirm that there are no issues with using relative paths for study assets, I'd be happy to try an implementation.

    Kind regards,


    -Felix

  • Hi Felix,

    yes, I moved the files from the subfolder to the main folder after exporting - but I am not sure this is necessary because the direct export/import usually works in JATOS (at least locally).

    And yes, the jsPsych example study always works. On my local JATOS, there is no basepath, so there is no problem with absolute vs. relative paths. So everything (lab.js, jspsych...) should probably work locally.

    I hope that answers your questions!

    Best,

    Lea

  • Hi Lea! Hi Felix!

    The thing with the relative paths is, although they are much handier and less error prone, they are only supported since JATOS 3.3.1. If you use relative paths and import your study into an old JATOS < 3.3.1 then it will not work.

    @mezzopiano But I just checked: 3.3.1 was released on Jun 17, 2018 and the current version is 3.5.8. Maybe it's time to give up backwards compatibility and switch to relative paths? But this decision I'll leave to Felix. And unfortunately I have no information if and how many JATOS servers out there are using older versions < 3.3.1.

    And then about the 'incorrect mime type (always text/html)': I just checked and they all content-type headers seemed to be fine. Can you give me an example how to replicate this?

    Best,

    Kristian

  • Thanks a lot, Kristian, for your update and sleuthing! We started supporting JATOS around version 3.3, which is likely where the scripts come from (I should read your changelogs more carefully πŸ˜‰).

    I'd be happy to move to relative paths, and have a local version that implements that. For the study files, this is no issue, but what I'm not clear on is how to link to jatos.js via relative path -- the JATOS docs use an absolute path, and @Lea, the jsPsych example you sent assumes that the file is directly in the experiment folder. Is that a given?

    Kristian, if you could comment on that briefly that would be massively helpful, and if you could provide a heads-up with regard to studies needing to be in a subdirectory (right now, we generate a file $study_name.jas and the associated directory $study_name, both of which result in issues sometimes because we need to generate that name, and if I'm not mistaken it should be consistent, but also unique per study?).

    A heartfelt thanks again to both of you, this has been among the most amazing support conversations I've had this year! πŸ€—πŸ™‡‍♂️

    -Felix

  • krikri
    edited December 2020

    Hi Felix!

    Let me answer your 2 questions:

    but what I'm not clear on is how to link to jatos.js via relative path

    jatos.js get a special treatment in JATOS since its JATOS' own library. The relative path that works since 3.3.1 is:

    <script src="jatos.js"></script>
    

    and the absolute path before 3.3.1 is:

    <script src="/assets/javascripts/jatos.js"></script>
    

    We should probably update the JATOS docs to use the relative path everywhere by now.


    regard to studies needing to be in a subdirectory (right now, we generate a file $study_name.jas and the associated directory $study_name, both of which result in issues sometimes because we need to generate that name, and if I'm not mistaken it should be consistent, but also unique per study?).

    It is still like that: within the .jzip file (which is just a zip file) must be a subdirectory with a unique name that includes all your study assets (HTML, JavaScript, CSS, images etc) and a .jas file that describes the study in JSON format. The only thing that changed here is that you can now use relative paths in your HTML and JavaScript and don't have to specify the subdirectory anymore. So instead of e.g.

    <script src="/study_assets/my-exp/lib/survey.js" />
    

    you can just write

    <script src="lib/survey.js"></script>
    

    You still have to specify the sub-subdirectories of course ('lib' in the example).

    Best,

    Kristian

  • Hi Felix & Kristian,

    this is great!

    I think the problem with the subfolder was rather due to the fact that I didn't import the study but created a new one (after I changed the paths). So I think you can just ignore everything I wrote about that, Felix. So I think the only thing that needs to be changed is the paths in the html. Let me know if you still need someone to test it, I'd be happy to do so on our server.

    (And the jatos path is exatly what worked for me after a short trial-and-error phase.)

    Thanks a lot!

    Lea

  • Hi @Lea, hi @kri,

    thanks soo much you two, for the clarifications and feedback, this is awesome! πŸ’› The fix is now in, and should be online in the beta version (and soon-ish in stable). Lea, if you can spare a moment to export your study from there and try it in your JATOS installation (I've already tested on the COVID server), that would be awesome.

    (as a quick word of warning concerning our beta, please note that we update the experiment file format in the latest release, so while you're welcome to use the development version and your studies should upgrade automatically, please be aware of the fact that you'll need to continue work with that version).

    Ok, so much real quick. Thanks again, and a great new week to you both! πŸ€—


    -Felix

  • Hi Felix, it works like a charm! πŸ’š Thanks so much!

  • Sure thing @Lea, my pleasure πŸ™‚

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