Results in php script
Hi all,
I have a concern with the results of the experiment when is finished. The original experiment has a php script which says that:
<?php // the $_POST[] array will contain the passed in filename and filedata // the directory "data" must be writable by the server $filename = "../data/".$_POST['filename']; $data = $_POST['filedata']; // write the file to disk file_put_contents($filename, $data,FILE_APPEND); ?>
in the experiment file, it says that:
function that appends data to an existing file (or creates the file if it does not exist) function appendData(filename, filedata) { $.ajax({ // make sure jquery-1.7.1.min.js is loaded in the html header for this to work type: 'post', cache: false, url: 'php/save_data_append.php', // IMPORTANT: change the php script to link to the directory of your server where you want to store the data! data: { filename: filename, filedata: filedata }, }); };
According what I read in the JATOS web site
I have to append result data to the already sent
var resultData = { "a": 123, "b": 789, "c": 100}; jatos.appendResultData(resultData);
However, I think I am not doing it properly because I am still having error at the end of the experiment.
Does anybody has experimented something similar? How did you solved it?
Thanks a lot in advance for your help!
Comments
Hi!
Can you please give us a bit more information so we can help you better:
Best,
Kristian
Hi Kristian,
Thank you very much for your answer and for your help!
The version of JATOS is 3.5.5
The error in the file I export when the experiment is completed (.txt file) aparently is because the experiment uses a php script to send the data back to the server after every trial.
The part of the experiment which involves JATOS is the head:
and at the end of the experiment.
Hi!
The error in the file I export when the experiment is completed (.txt file) aparently is because the experiment uses a php script to send the data back to the server after every trial.
I'm confused: do you still use a PHP script or did you moved from PHP to JATOS? What is the error message in this .txt file?
Then in your code: It's most likely not necessary to redirect in your
on_finish
- jatos.js does this for you if you set it up properly. Since you are using jsPsych I assume your experiment has only one component:Then you can set up your redirect URL in your study properties in JATOS' UI: http://www.jatos.org/End-page-after-your-study-finished.html#3-study-properties-end-redirect-url-since-jatos-v351. Alternatively you can use jatos.endStudyAndRedirect: http://www.jatos.org/jatos.js-Reference.html#jatosendstudyandredirect.
Best,
Kristian
Thank you again Kristian for your help,
The error It shows me is: Expression.Error: We cannot convert a value of type Record to type Text.
I don´t know if I still using the PHP. If I am doing that, should I have to modify something here?
or in the PHP script?
Thank you again!
Hi!
I'm not sure I understand your setup. You most likely need either JATOS or PHP scripts and not both. If you just want to send your experiment's result data to a server for safe keeping, both a valid ways. Unfortunately I have no clue about PHP.
Best,
Kristian
Hi, to add to this:
What you want to do is append the results from each trial to the results stored in JATOS. As Kristian said, you don't need an extra PHP script for this. JATOS provides a javascript library (jatos.js) that does this for you.
Because you have a jsPsych study, the best way to do this is to tell jsPsych to do the same couple of lines of code after each trial finishes (https://www.jspsych.org/overview/callbacks/#on_trial_finish). I'm no jsPsych expert but it will probably look something like this:
If that works, please get rid of all the php scripts and calls to them, because they will just make everything more confusing. Also keep in mind two things:
you might end up with duplicate information (please try).
Hi @elisa and @kri
I want to say thank you for all the help you provided me. I followed all the tips you gave me and now the experiment works good!
Thank you again. All the Best!