Write a script to upload and download response file

More
3 years 1 week ago #114106 by dtian
dtian created the topic: Write a script to upload and download response file
Hi guys. I have a question and thanks in advance for your help. I would like to write a python or java script to download the VV Survey file, make some modification and upload the new VV Survey file. Do you have any idea how I should do this. I assume I need to use a browser simulator such as spynner or mechanize.

Please Log in to join the conversation.

More
3 years 1 week ago #114157 by david2013
david2013 replied the topic: Write a script to upload and download response file
Did browser simulator work? That's very interesting idea. I didn't know there is browser simulator out there. Not sure if we can use it to generate some random survey data so that we can do data check before real survey launch.

Anyway, regarding your question, it will be better to RemoteControl 2 API. However, I just check, the VV import/export function is not available. May be you can request the feature and hopefully the LS team will implement it.

Alternatively, you can write PHP script to query the database directly if you have access to the database.

Please Log in to join the conversation.

More
3 years 1 week ago #114173 by dtian
dtian replied the topic: Write a script to upload and download response file
Thanks a lot for your replay. I am still looking into browser simulator and it seems I may have to use HtmlUnit with Java to implement this. I never used PHP before and could you give me some more details about use PHP or some reference?

Such as where I should place PHP script and how to run it? It looks silly though.

Please Log in to join the conversation.

More
3 years 1 week ago - 3 years 1 week ago #114186 by DenisChenu
DenisChenu replied the topic: Write a script to upload and download response file
Hi ,

remote_control API don't need VV import, VV export : it need a:
export_responses : existing
import_responses : not existing
or delete_responses + add_response : delete not exist.

If you want to manage survey responses, surely better to do it :
- Updating LimeSurvey core remote control function and make a pull request
- Doing this in Plugin (you can take some code from VV import/export)

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Last Edit: 3 years 1 week ago by DenisChenu.

Please Log in to join the conversation.

More
3 years 1 week ago - 3 years 1 week ago #114198 by Mazi
Mazi replied the topic: Write a script to upload and download response file
I think the main question here is: What kind of edit should be made to the downloaded file?

...because when uploading the file later the syntax still needs to be valid in order to use VV import.

Maybe directly updating the DB is an easier alternative solution.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
Last Edit: 3 years 1 week ago by Mazi.

Please Log in to join the conversation.

More
3 years 1 week ago #114209 by DenisChenu
DenisChenu replied the topic: Write a script to upload and download response file

Mazi wrote: ...because when uploading the file later the syntax still needs to be valid in order to use VV import.

VV2 file : Question code (and SGQA) correspondance ;)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
3 years 1 week ago #114218 by Mazi
Mazi replied the topic: Write a script to upload and download response file

DenisChenu wrote:

Mazi wrote: ...because when uploading the file later the syntax still needs to be valid in order to use VV import.

VV2 file : Question code (and SGQA) correspondance ;)

Sure, but when editing the fiel you can still easily break the structure by missing line breaks or tab or ...


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
3 years 1 week ago #114222 by DenisChenu
DenisChenu replied the topic: Write a script to upload and download response file

Mazi wrote:

DenisChenu wrote:

Mazi wrote: ...because when uploading the file later the syntax still needs to be valid in order to use VV import.

VV2 file : Question code (and SGQA) correspondance ;)

Sure, but when editing the fiel you can still easily break the structure by missing line breaks or tab or ...

Oh,

Your totally rigth, i think it's a easiest solution to do this directly in DB too.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
3 years 1 week ago #114229 by dtian
dtian replied the topic: Write a script to upload and download response file
Thanks Denis. I think remote control is better. Now I got an TCPDF error: unable to create output file :/usr/local/...
Do you have any idea what could go wrong here?

Please Log in to join the conversation.

More
3 years 1 week ago #114261 by DenisChenu
DenisChenu replied the topic: Write a script to upload and download response file
I'm not your server admin, then no idea.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
2 years 11 months ago #114684 by david2013
david2013 replied the topic: Write a script to upload and download response file
@dajuntian: Actually, remote control has function called "update_response" which can update the answer of particular record by providing case id or token. However, not sure why it's not documented, but it's there (/application/helpers/remotecontrol/remotecontrol_handle.php).

In case you need an example of how to use it:

<?php
require_once 'jsonRPCClient.php';
define( 'LS_BASEURL', 'http://127.0.0.1/survey21/index.php/'); // need to update to your remote url
define( 'LS_USER', 'admin' ); // your user name
define( 'LS_PASSWORD', 'admin' ); // your password

// instanciate a new client
$myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );

// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );

$survey_id=211586; // the survey to process

// need to provide case id or token. And field name and value to update.
$data = array(
'id' => '9',
'211586X3X3' => '21'
);

$output=$myJSONRPCClient->update_response($sessionKey, $survey_id, $data);
print_r($output, null ); // output if any error. if you see 1. it means ok.

// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );

?>

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!