saving data from a revlet

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
howeyb
Posts: 7
Joined: Tue Jul 21, 2009 9:42 pm

saving data from a revlet

Post by howeyb » Tue Sep 21, 2010 9:15 pm

Help anyone:

I recently upgraded from studio 2.8 to version 4.0 mainly to see if I can run the psych experiments I program using revolution over the web (direct multiple participants to go to a website and click on an experiment "revlet"). What I am wondering is how I can collect data/results (such as reaction times, text from text boxes, and ratings from scrollbars). Normally, I used script (see below) to export data into a separate folder named "data" that is in the same location as the experiment stack (which is usually on my Mac destop):

set the itemdel to "/"
get the filename of this stack
delete the last item of it
put it into PATH
put SUBJECTID into FNAME
put fld mousedata into url ("file:"&PATH&"/data/"&FNAME&"_mdata.xls") --for instance, fld mousedata has time and mouse pixel location data that I need to analyze for the experiment

Is there a way to get data from an experiment when somebody does a revlet version of an experiment from a website?
ps I looked at Jacque Day's great tutorial on that at HyperActiveSW.com. and it looked scary; CGI's are new to me...do I have to go that route?

Betty
howeyb

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Re: saving data from a revlet

Post by Janschenkel » Tue Sep 21, 2010 9:49 pm

Do you intend to save the data locally or on a central server?
If your goal is to save them on the central server, you would probably 'post' them to a URL on your web server, where a cgi-script of PHP page takes care of storing the data in a MySQL or PostgreSQL database that is located on the server.
If you want to give the user the chance to save data on their local hard drive, you'll have to ask for permission to write files - which you can do in the 'Web' panel of the standalone application settings. Bear in mind that your user will then see a security warning dialog box as soon as the revlet is loaded.

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

howeyb
Posts: 7
Joined: Tue Jul 21, 2009 9:42 pm

Re: saving data from a revlet

Post by howeyb » Wed Sep 22, 2010 3:46 pm

I plan to save the data on a central server. Below is some more information that may be helpful to others. If you have anything to add, that would be great. Thanks.

1) Writing data to file on individual user's disk:

A revlet can write data to a file on the user's disk only if the user gives permission. When a user goes to a page with a revlet that has the capability to write to disk, the user will be asked if they want to run the revlet. Without explicit permission from the user, a revlet, or any other web plugin, cannot write to the user's disk, with the exception of writing temporary data to a web browser cookie file.

The permission dialog box may be a little scary to some users. In that case, you can avoid having to ask permission and have the user copy data to the clipboard. Then the user would have to paste it into a file.


2) Writing data to file on web server:

You should also be able to send data from a revlet to the web server using the html POST method, in the same way you would post data from an html form to the web server. You would need a CGI script on the web server to handle the data, or irev files if you have a hosting account at www.on-rev.com, or have the new rev server software on your own host, or PHP script. CGI scripts can be written in a variety of languages - check which are supported by your server - and even in Rev if you can load the Rev 3.5 engine on your server.

Saving data from revlets
Sat, Sep 26, 2009 12:18 PM

With RunRev's new plugin to run stacks in the browser I've seen a lot of questions about how to save changes the user makes in those stacks.

With distributed systems like this the challenge is that there is no "there" there. :)

That is, the revlet stack file is indeed sitting on the server, but in an inert form. It's just a blob of binary data that the server copies to anyone who asks for it.

What's running in the browser is a copy of the file that's been downloaded over the web, hundreds or maybe thousands of miles away, on the client computer.

Since we can't have random web browsers altering files on our servers, no client process can write to a server file system directly. Instead we must go through some other intermediary process designed for such communication, like FTP, POST, or GET. The latter two are most commonly use in web apps, and fortunately the Rev CGI engine makes it pretty easy to accept such data to do anything you want with it on the server side.

For details on setting up and using the Rev engine as a CGI, see Jacque Day's great tutorial on that at HyperActiveSW.com.
howeyb

Post Reply