RemoteControl list_questions behavior

Mehr
3 Jahre 2 Monate her #108116 von simogeo
simogeo erstellte das Thema RemoteControl list_questions behavior
Hi,

I use the RemoteControl list_questions() method but I noticed the returned questions are not ordered as in survey.

Is that the normal behavior or a bug ? Is there an easy way to get it ordered?

Many thanks,

simo

Bitte Anmelden um der Konversation beizutretten.

Mehr
1 Jahr 11 Monate her #123063 von lacd
lacd antwortete auf das Thema: RemoteControl list_questions behavior
Hello Simo,

I am facing a similar issue :( . In my case whenever I import a survey in LS, the order of question changes. When I use preview survey option, the questions are in correct order; however when I use RemoteControl API list_questions the order is changed. I queried lime_questions table and found that the questions are inserted in wrong order in DB :S .
Is there a work around for this? Did you figure out how to get the questions ordered?

Thanks in advance.
-LACD

Bitte Anmelden um der Konversation beizutretten.

Mehr
1 Jahr 11 Monate her #123071 von DenisChenu
DenisChenu antwortete auf das Thema: RemoteControl list_questions behavior
Bug can be reported to mantis ...

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 .

Bitte Anmelden um der Konversation beizutretten.

Mehr
1 Jahr 11 Monate her - 1 Jahr 11 Monate her #123085 von simogeo
simogeo antwortete auf das Thema: RemoteControl list_questions behavior
Hi lacd,

I worked on that more than 1 year back so it is not that fresh ..... but I can tell you how I did :

I'm getting all groups by using :
// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
 
// receive all ids and info of groups belonging to a given survey
 
$groups = $myJSONRPCClient->list_groups( $sessionKey, $survey_id );
 
$order = array();
// we sort group on name (they use numbers as prefix)
foreach ($groups as $key => $row) {
	$order[$key]  = $row['group_name'];
}
@array_multisort($order, SORT_ASC, $groups);
 
// print_r($groups, null );

Then, I loop on groups to retrieve questions and use 'question_order' property to sort them !
 
$all = array();
 
 
foreach($groups as $group ) {
 
	$questions = $myJSONRPCClient->list_questions( $sessionKey, $survey_id, $group['id']['gid'] );
 
	$all[$group['id']['gid']] = $group;
 
	// print_r($questions, null );
 
	$data = array();
	$order = array();
 
	foreach($questions as $q ) {
 
		// print_r($q );
		// echo "<br></br>";
 
		// rgetting questions properties
		$qproperties = $myJSONRPCClient->get_question_properties($sessionKey, $q['id']['qid'], array('title', 'question', 'type', 'other', 'subquestions', 'question_order', 'answeroptions', 'other'));
 
		// we add 'id' field to questions
		$qproperties['qid'] =  $q['id']['qid'];
		$data[] = $qproperties;
 
	}
 
	// we sort questions	
	foreach ($data as $key => $row) {
	    $order[$key]  = $row['question_order'];
	}
 
	// Sort the data with question_order ascending
	// Add $data as the last parameter, to sort by the common key
 
	// Affiche un warning : "array_multisort(): Array sizes are inconsistent" car la taille des tableaux n'est pas égal
	// on supprime l'affichage.
	// Le tri fonctionne correctement
	@array_multisort($order, SORT_ASC, $data);
 
 
	// we add the questions array to the main array
	$all[$group['id']['gid']]['questions'][] = $data;
 
	// echo "<br><br>";
}
 
//print_r($all);
Letzte Änderung: 1 Jahr 11 Monate her von simogeo.

Bitte Anmelden um der Konversation beizutretten.

Haben Sie schon bei unserer Kundenumfrage mitgemacht?

Verpassen Sie nicht Ihre Chance auf tolle Preise.

Klicken sie hier um teilzunehmen:

Jetzt starten

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten