Welcome to the LimeSurvey Community Forum

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

How to get questions / answers from a given survey? Through the RC API ?

  • simogeo
  • simogeo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago - 9 years 10 months ago #108087 by simogeo
Hi all,


I've seen the RemoteControl API : manual.limesurvey.org/RemoteControl_2_API . Which seem to be great!

I have in fact 2 questions :
  • I'd like to know how can I get the list of questions for a given survey ID ? Is it possible through the API or through another tool/class/method ?
  • I'd also like to know how can I get the list of answers for a given answer ID (SAVEDID) ? Is it possible through the API or through another tool/class/method ?


I haven't explore fully the API yet -sorry if it's obvious. Any way, any precision would be appreciated. Thanks in advance.

edit : I use Version 2.05+ Build 140320

simo
Last edit: 9 years 10 months ago by simogeo.
The topic has been locked.
  • simogeo
  • simogeo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago #108112 by simogeo
OK,

I'm able to list all my questions with the remoteControl API with the use of list_groups, list_questions and get_question_properties.


I would like now to get all given answer for a specific record. I haven't found this feature into the remoteControl ? Did I miss it?

According to you limesurvey gurus, how can I do that?

Thanks
The topic has been locked.
More
9 years 10 months ago #108298 by david2013
Have you tried "export_responses_by_token" method?
The topic has been locked.
  • simogeo
  • simogeo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago #108309 by simogeo
Thanks for your reply,

I haven't tried since it exports the result to pdf,csv,xls,doc according to the doc ( manual.limesurvey.org/RemoteControl_2_AP...t_responses_by_token )

Anyway, I handled all this manually.

Thanks
The topic has been locked.
More
8 years 11 months ago #119143 by jnjortn
Hi,
I am successfully using the API to access a survey's results but cannot figure out how to get the answers to the questions. Here is the ruby statement to access the results and the resulting output.

response = survey.export_responses_by_token(session_key, 948387,"json","ttvfgd35yfqqagx","English",'complete','full','long' )

Output
Responses: {"responses": [{"1":{"Response ID":"1","Date submitted":"2015-04-10 16:51:46","Last page":"1","Start language":"en","Token":"ttvfgd35yfqqagx","Date started":"2015-04-10 16:51:35","Date last action":"2015-04-10 16:51:46"}}]}

What is required to get the answers ? Any help would be appreciated.
The topic has been locked.
  • simogeo
  • simogeo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 11 months ago - 8 years 11 months ago #119156 by simogeo
Using PHP, I created a dedicated class to retrieve a given record :
Code:
<?php
 
class lmAnswerManager {
 
  private $db; // PDO Instance
 
  /**
   * Constructeur du manager de la class Users
   */
  public function __construct(){
    $this->db = DbConnect::GetInstance()->GetConnexion();
  }
 
  /**
   * Méthode permettant de lister toutes les réponses aux questionnaires
   * @return Array
   */
  public function ListAnswers(){
 
    $tabResult = false;
 
    $query = $this->db->prepare('SELECT * FROM lime_survey_'.$_SESSION["CONFIG"]["LS_SURVEYID"]);
    $result = $query->execute();
    $tabResult = array();
    while($result = $query->fetch(PDO::FETCH_ASSOC)){
      $tabResult[] = $result;
    }
    return $tabResult;
  }
 
 
  /**
   * Méthode permettant d'instancier une réponse
   * @param int $id 
   * @return Array
   */
  public function GetAnswer($id){
 
    $tabResult = false;
 
    $query = $this->db->prepare('SELECT * FROM lime_survey_'.$_SESSION["CONFIG"]["LS_SURVEYID"].' WHERE id=:id  ');
    $query->bindValue(':id',$id);
    $query->execute();
 
    while($result = $query->fetch(PDO::FETCH_ASSOC)){
      $tabResult[] = $result;
    }
    return $tabResult;
  }
 
 
}
?>

And I use LSRC ( manual.limesurvey.org/RemoteControl_2_AP...w_to_configure_LSRC2 ) to retrieve questions.
Last edit: 8 years 11 months ago by simogeo.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose