Welcome to the LimeSurvey Community Forum

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

Pass Array through QuestionAttribute?

  • sodiumchl
  • sodiumchl's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 1 month ago #207191 by sodiumchl
Pass Array through QuestionAttribute? was created 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.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
4 years 1 month ago #207200 by DenisChenu
Replied by DenisChenu on topic Pass Array through QuestionAttribute?
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.
  • sodiumchl
  • sodiumchl's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 1 month ago #207203 by sodiumchl
Replied by sodiumchl on topic Pass Array through QuestionAttribute?
But in the example, $oAttributeExtraSurvey is passed via QuestionAttribute, right?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
4 years 1 month ago #207207 by DenisChenu
Replied by DenisChenu on topic Pass Array through QuestionAttribute?
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