Thanks Jeremy, I was able to use the fetch extension for recording the results, the only problems are that from standard netlogo it posts the request twice (?) and from netlogo-web it originated an error message, so that I wrote a script to remove it from html (it is a generic error message complaining that something went wrong with the reception of the message -- after all the fetch module has the goal of retrieving, not posting things).
However, I think that many users would profit from a simple way of getting data from users, both from the standard netlogo desktop application and the web one, and feeding data on a google form is the simplest way. Anyhow, for the moment, with the inconvenients illustrated above I managed to get it working. Il giorno mar 28 nov 2023 alle ore 19:24 Jeremy Baker < jeremy.ba...@northwestern.edu> ha scritto: > Hey Franco, > Thanks for your interest in NetLogo. You're correct that the Web Extension > is not supported in NetLogo Web. There is some similar functionality > availability. > You mention web:make-request and using a Google Form, so I assume you're > doing an HTTP POST request? If so, you can use the http-req extension in > NetLogo Web. It's undocumented and mostly unsupported, but it does work. > After adding extensions [ http-req ] to your code you can do something > like http-req:post "https://netlogoweb.org" "hello" "text/plain", with > the arguments being the URL, the message itself, and the message type. It > will report the response from the server. The downsides are many. The > extension is not also supported in desktop NetLogo meaning you'll need > separate models for each platform. It's a blocking call, meaning your model > can freeze if the network is slow to respond or doesn't respond at all for > some reason. It doesn't handle any error conditions, so if anything goes > wrong the effects could be frustrating. > If you're just doing a simple HTTP GET request for your form URL, you can > actually use the Fetch Extension > <https://github.com/NetLogo/Fetch-Extension#readme>, like fetch:url-async > "http://www.netlogoweb.org/" show. It is supported in NetLogo Web and > desktop NetLogo and well documented. One difference from the Web Extension > is that if you want to check the response from the server you will have to > use an anonymous task that will run asynchronously after the request is > completed. It doesn't seem like that'd be a big deal for your use case, but > just pointing it out. > If you are still interested in implementing an extension in NetLogo Web, > we have some documentation on that in the Tortoise repository > <https://github.com/NetLogo/Tortoise/wiki/Experimental:-Extensions>. Some > important info there: > > "In NetLogo Web the target for an extension must be JavaScript, and at the > moment the only way to include an extension is by bundling it with the > NetLogo Web code itself as part of Tortoise. This is all experimental, and > we may change the definition file format or the way extensions are loaded > as needed for future work. Longer-term the NetLogo team has plans to > provide a mechanism to allow inclusion of third party extensions that are > external to the NetLogo Web site, but that work is not yet complete." > > So it's unfortunately not a simple matter to port an existing Java-based > extension like Web to the JavaScript target in NetLogo Web. > I hope that helps. If you have questions on using the HTTP-Req or Fetch > extensions, the Netlogo users group might be a more appropriate place to > answer them. If you have questions on implementing NetLogo Web extensions, > this is the appropriate forum. Thanks. > -Jeremy > > ------------------------------ > *From:* netlogo-devel@googlegroups.com <netlogo-devel@googlegroups.com> > on behalf of Franco Bagnoli <franco.bagn...@gmail.com> > *Sent:* Wednesday, November 22, 2023 10:28 AM > *To:* netlogo-devel <netlogo-devel@googlegroups.com> > *Subject:* [netlogo-devel] Porting web extension to netlogo web > > Hi, all. > > I am developing some games with netlogo (to teach aspects of complex > systems) and I need to collect the answers via a web form. > I know how to "hack" the url of a google form, and using the web > extension I am able to upload the answers to it. > However, It is much simpler for students to just use their mobile phone. > However the web extension is not working on netlogo web. > I can edit the html and add a button for fetching the value of a monitor > and send it to the google form, but it would make things more uniform to > being able to "web:make-request" from netlogo, both desktop and web > versions. > > I do not have a clear idea of how extensions are packaged for the web > version.. Some help? > > > -- > You received this message because you are subscribed to the Google Groups > "netlogo-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to netlogo-devel+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/netlogo-devel/ba47530d-c7f0-4859-9de7-b81ebd3fe541n%40googlegroups.com > <https://urldefense.com/v3/__https://groups.google.com/d/msgid/netlogo-devel/ba47530d-c7f0-4859-9de7-b81ebd3fe541n*40googlegroups.com?utm_medium=email&utm_source=footer__;JQ!!Dq0X2DkFhyF93HkjWTBQKhk!We2_wYtfsBFmMPS_5QgFl5k2bPQomHxxra5QUklHlqfFEwKl98ABaaK1EpNFvmynTkOJJp2emPnUMRPpWRE3jBkDYTxo1uyh9zU$> > . > -- *Franco Bagnoli <https://www.unifi.it/p-doc2-0-0-A-3f2a3d2c362f2c.html>* Direttore del Centro Interdipartimentale per lo Studio di Dinamiche Complesse (CSDC <https://www.csdc.unifi.it/>) Professore Associato (tel.) +39 0554572336; (cell.) +39 3386586493; UNIVERSITÀ DEGLI STUDI DI FIRENZE Dipartimento di Fisica e Astronomia -- You received this message because you are subscribed to the Google Groups "netlogo-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-devel/CAF2wp3tN2iHiTbL6vDoz%2BQH59z2a9xVmEx7d_kFiRqr52kfxYw%40mail.gmail.com.