Welcome to the LimeSurvey Community Forum

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

createFieldMap and how to get the name of a column by question code

More
7 years 11 months ago - 7 years 11 months ago #175591 by Ronldesel_170163
I need to retrieve the column name of lime_survey_123456-table by the title of a question
Code:
function getColumnName($response, $title) { $fieldmap = createFieldMap($response->survey, 'full', null, false, $response->attributes['startlanguage']); foreach ($response->attributes as $key => $value) { if (array_key_exists($key, $fieldmap)) { if (array_key_exists('title', $fieldmap[$key]) && $fieldmap[$key]['title'] === $title) { return $key; } } } return false; }

So I can use this code
Code:
Yii::import('application.helpers.common_helper', true); $response = SurveyDynamic::model(123456)->findByPk(1); var_dump(getColumnName($response, 'completed')); // outputs '454344X20X386'

Is there already a method to do so?
Or is there already a method to update a lime_survey_123456 column directly?

markob.de
Last edit: 7 years 11 months ago by Ronldesel_170163. Reason: enhancing the question
The topic has been locked.
More
7 years 11 months ago - 7 years 11 months ago #175600 by DenisChenu
I need a lot such functionnality on 2 plugins … then i make a plugin helper plugin

Contribution are welcome : gitlab.com/SondagesPro/coreAndTools/getQuestionInformation

See gitlab.com/SondagesPro/coreAndTools/getQ...eyCodeHelper.php#L70

It does it by id, but do it by title/code seems easy with this helper

Else LimeSurvey use github.com/LimeSurvey/LimeSurvey/blob/c4...ager_helper.php#L840

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.
Last edit: 7 years 11 months ago by DenisChenu. Reason: Else LimeSurvey use
The topic has been locked.
Moderators: holch, tpartner

Lime-years ahead

Online-surveys for every purse and purpose