Hello forum,
I am currently trying to enable a dataflow between limesurvey and our database and vice versa.
Inside the database we have a table, from where I determine which questions are to be asked and create an array of
the Question- Codes (for example questions_array = ["Q1","Q2_A1","Q4"]).
With this array loaded to the survey, I would like to
1) hide those (sub-)questions not in the array and
2) Get an array of the answers for these questions at the end of the survey
Here I face multiple problems for which I have not found a satisfactory answer yet:
--> for 1) For hiding questions in a group that are not in the questions_array, I need to get the codes of the questions in this group. I would next check, whether some are not in the questions_array and then hide the corresponding question-div. [The code would be written inside the group-description]
something like:
Code:
questions_array = /*..questions to be done, load from database..*/
question_codes_in_group = /*.. somehow get the question-codes of the questions in this group..*/
question_sgqa_in_group= /*..somehow get the SGQA of the questions in this group..*/
num_questions_in_group = questions_codes_in_group.length;
for(i=1; i<num_questions_in_group; i++)
{
if(!questions_array.includes(questions_group[i]))
{
//Question not to be asked
$("#question"+question_sgqa_in_group[i]).hide();
//-->when matrix??
$("#javatbd"+question_sgqa_in_group[i]).hide();
}
}
I know the question_codes_in_group and question_sgqa_in_group could be hardcoded into the survey, but I thought of it as redundant and a bit dirty.
--> for 2) Is there a way to get the answers from the EM via the variable name stored in a string?
I know that this following code does not work, but it is essentially what I want to do (at the very end of the survey):
Code:
questions_array = /*..questions to be done, load from database..*/
...
for(i=1; i<num_questions; i++)
{
answer_array[i] = {questions_array[i]};
}
/*... upload answer_array to database..*/
Is there maybe a way to gain access to the EM-Variables via functions or any other way?
Any help is very much appreciated, thank you!