Welcome to the LimeSurvey Community Forum

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

Pass Array through QuestionAttribute?

More
4 years 10 months ago #207191 by sodiumchl
I need to pass an array of strings from beforeQuestionRender() to newDirectRequest(). What's the proper way of doing this?

I tried the following, but it does not work.

In beforeQuestionRender():
Code:
QuestionAttribute::model()->setQuestionAttribute($qid, 'myarray', $myArray);
log_var($myArray);

In newDirectRequest():
Code:
$aAttributes=QuestionAttribute::model()->getQuestionAttributes($qid);
$output = $aAttributes['myarray'];
log_var($output);

Now $output is empty. It is not $myArray. What's wrong?

Thank you!
The topic has been locked.
More
4 years 10 months ago #207200 by DenisChenu
Direct request can use only url params (POST or GET).

You can't really send a param via PHP only.

Add your parameteres directly in the url

You have sample on gitlab.com/SondagesPro/QuestionSettingsType/questionExtraSurvey
(but giltal is broken currently)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
4 years 10 months ago #207203 by sodiumchl
But in the example, $oAttributeExtraSurvey is passed via QuestionAttribute, right?
The topic has been locked.
More
4 years 10 months ago #207207 by DenisChenu
There are code, using $qid

Get the qid in URL
Code:
$qid = $this->api->getRequest()->getParam('qid');
Search the attribut using this var
Code:
$oAttributeExtraSurvey=QuestionAttribute::model()->find('attribute=:attribute AND qid=:qid', array(
                    ':attribute' => 'extraSurvey',
                    ':qid' => $qid,
                ));

You NEED to pass the variable via url (or session), it's a DIRECT request.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose