Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Write a script to upload and download response file

More
9 years 4 months ago #114106 by dtian
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.
The topic has been locked.
More
9 years 4 months ago #114157 by david2013
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.
The topic has been locked.
More
9 years 4 months ago #114173 by dtian
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.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 4 months ago - 9 years 4 months ago #114186 by DenisChenu
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 , plugin development .
I don't answer to private message.
Last edit: 9 years 4 months ago by DenisChenu.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
9 years 4 months ago - 9 years 4 months ago #114198 by Mazi
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
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Last edit: 9 years 4 months ago by Mazi.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 4 months ago #114209 by DenisChenu

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 , plugin development .
I don't answer to private message.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
9 years 4 months ago #114218 by Mazi

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
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 4 months ago #114222 by DenisChenu

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 , plugin development .
I don't answer to private message.
The topic has been locked.
More
9 years 4 months ago #114229 by dtian
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?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 4 months ago #114261 by DenisChenu
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 , plugin development .
I don't answer to private message.
The topic has been locked.
More
9 years 4 months ago #114684 by david2013
@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 );

?>
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose