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

More
3 years 2 months ago - 3 years 2 months ago #108087 by simogeo
simogeo created the topic: How to get questions / answers from a given survey? Through the RC API ?
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: 3 years 2 months ago by simogeo.

Please Log in to join the conversation.

More
3 years 2 months ago #108112 by simogeo
simogeo replied the topic: How to get questions / answers from a given survey? Through the RC API ?
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 to join the conversation.

More
3 years 2 months ago #108298 by david2013
david2013 replied the topic: How to get questions / answers from a given survey? Through the RC API ?
Have you tried "export_responses_by_token" method?

Please Log in to join the conversation.

More
3 years 2 months ago #108309 by simogeo
simogeo replied the topic: How to get questions / answers from a given survey? Through the RC API ?
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 to join the conversation.

More
2 years 3 months ago #119143 by jnjortn
jnjortn replied the topic: How to get questions / answers from a given survey? Through the RC API ?
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 to join the conversation.

More
2 years 3 months ago - 2 years 3 months ago #119156 by simogeo
simogeo replied the topic: How to get questions / answers from a given survey? Through the RC API ?
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: 2 years 3 months ago by simogeo.

Please Log in to join the conversation.

Did you already participate in our customer survey?

Don't miss your chance for great prices.

Please click here to participate:

Start now

Start now!

Just create your account and start using Limesurvey today.

Register now