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

More
4 years 11 months ago - 4 years 11 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: 4 years 11 months ago by simogeo.

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
4 years 11 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

Please Log in or Create an account to join the conversation.

More
4 years 11 months ago #108298 by david2013
Have you tried "export_responses_by_token" method?

Please Log in or Create an account to join the conversation.

More
4 years 11 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

Please Log in or Create an account to join the conversation.

More
4 years 1 week 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.

Please Log in or Create an account to join the conversation.

More
4 years 1 week ago - 4 years 1 week ago #119156 by simogeo
Using PHP, I created a dedicated class to retrieve a given record :
<?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: 4 years 1 week ago by simogeo.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!