View Issue Details

IDProjectCategoryView StatusLast Update
07593Feature requestsConditionspublic2021-03-07 21:10
Reportervitaly_repin Assigned Toc_schmitz  
Status closedResolutionwon't fix 
Summary07593: Increase the allowed length of the answer code
Descriptionlimesurvey limits answer code lengths to 5 characters and question code lengths to 20. Sometimes this limitation limits the use cases.

E.g., we want to be able to use human-readable answer codes and 5 characters is a very nasty limitation.

Other users reports the problems with importing the 3-party surveys:
Additional InformationA possible solution: Increase the allowed length of the answer code
Increase the max length to 128.

Table: lm_answers. Column: code. Current type: VARCHAR(5). Suggested type: VARCHAR(128).
TagsNo tags attached.


related to 05289 acknowledgedc_schmitz Redesign response storage to support more questions+answers (database columns) in a survey 




2017-06-19 09:46

reporter   ~43936

You may find a new entry in the forum directly releated with this 5y old feature request:

An increase of answer code length up to 12 alphanumeric chars will considerably provide a gain in interoperability and be welcome by new or recurrent users working in scientific fields and looking for a survey or data entry tool.
For example this will be enough to accept worldwild used SNOMED-CT and standardized Health Care Provider Taxonomy codes (no dot or hyphen chars) .

The new LS.3 beta release may be a good moment to introduce this update.


2017-06-26 12:26

developer   ~43977

Remind : if we put a big number : the we lower the number of allowed columns :/


2017-06-26 12:35

reporter   ~43978

Where? Why?


2017-06-26 12:45

developer   ~43979


2017-06-26 13:41

reporter   ~43980

ok... but for very extreme cases (imho).
I think the best would be a choice during the install standard/personalized (as many other softwares do) offering the possibility to adapt this setting and some other ones.... and more likely for LS4 !


2018-10-29 15:35

partner   ~49468

I vote for adding the feature of longer question and answer code fields at Limesurvey 4.0.
At Limesurvey 3.x the field size for question and subquestion codes is 20 and for answers it is still just 5. That's not much, it would be great if we could improve this.


2018-10-29 15:38

partner   ~49469

@c_schmitz, what is your opinion n this? What are the pros and cons?


2018-10-29 17:03

developer   ~49472

If we still use mysql/ISAM : this allow less single choice question …


2018-12-28 18:20

reporter   ~50077

answers.code is still varchar(5)


2018-12-28 21:14

partner   ~50079

I am assigning this to Carsten so he can decide if this improvement is doable with a reasonable effort because it would be very helpful to lots of users.


2019-06-13 11:32

partner   ~52385

@c_schmitz, any chance to improve/extend the answer code length at LS 4?


2019-06-13 11:39

administrator   ~52387

It is not planned for LS4 - probably LS5.


2019-06-13 11:47

reporter   ~52388

@c_schmitz, the question is why it is not simply possible to ```ALTER TABLE `answers` CHANGE `code` `code` VARCHAR(25) NOT NULL```


2019-06-13 11:57

developer   ~52389

> If we still use mysql/ISAM : this allow less single choice question …

You really want to allow less question ? Really ?
Original issue ask for 128 , but why not 512 or 1024 ? No limit‘s …

The only solution is QuestionObject with "column type"


2019-06-13 12:25

partner   ~52390

@DeniChenu: Good point. So why not having a global setting for this + maybe a local survey setting "Answer code length"? Then the user is free to adjust this as needed and we only need to apply the proper setting at survey activation.

Besides the DB limits/size, are there any further potential side-effects you can think of?


2019-06-13 13:31

developer   ~52392

A question : what is the purpose ?

When you need this code ?

Because if it's
- Survey ( {QUESTION_CODE}) : it can be already done
- Export : it can be already done
- ? …

Else if it's in config.php : what happen for answer table when it's updated … need to update too …


2019-06-13 13:36

partner   ~52393

Regarding the use case: At complex surveys if you want to use more speaking codes an answer code like "male" works fine but already "female" won't work. Some companies have predefined codebooks for their surveys and these often use longer answer codes.


2019-06-13 13:38

developer   ~52394

OK, but **WHEN** this is needed ?
As export : easy : create a plugin table with qid/code/newcode and use it when export.


2019-06-13 13:39

developer   ~52395

PS : i have such issue with code like BE_VSL : i do a recode (becaus it's only one comulon) : it's not really an issue


2019-06-13 13:53

partner   ~52397

Those codes are required at data export mostly.


2019-06-13 14:15

developer   ~52398

Then at data export : my opinion is

1. Create a plugin table `qid`,`code`,`exportcode`
2. When exporting : get this code from plugin table


You can do it too in question adv setting with a textera like this


Else : a 4.0 solution

1. Set answer code to 25 in answer table
2. Same for labels
3. Add an advanced setting 'code column width' : read only when active, default to 5
4. Min/max from 1 to 25

Create column when activate

What can broke
1. Import oid survey table
2. Import VV
3. Import LSA

This need time … and currently 4.0 have a lot of another issue


2019-06-13 15:06

partner   ~52400

I like the 4.0 solution.

@c_schmitz, any chance to add that at LS 4 if we take care of the coding?


2019-06-13 15:08

administrator   ~52401

No chance for this in 4.x - sorry.


2019-06-25 12:13

partner   ~52530

@DenisChenu, would a plugin be able to:

a) Extend the minimum character length for the code field when adding answer options? Maybe this could alternatively be done by some JS within a custom admin theme?

b) Alter the existing DB table: ALTER TABLE `answers` CHANGE `code` `code` VARCHAR(25) NOT NULL?

c) Adjust the code for survey activation so the related fields also provide 25 VARCHARS (simply do ALTER TABLE after activation?)?


2019-06-25 12:56

developer   ~52538

By plugin ?????

It can be risky, not before have an event in

This surely add more complexity and issue …

@c_schmitz : why not in 4.0 ? This can be easily added in `createFieldMap` as a new question adavanced setting without big issue … we wait for have a working develop since month now ([when other developer can really test new feature]( , but you still disable new feature ???


2019-06-25 21:29

partner   ~52556

@DenisChenu, does the createfieldmap() function rely on certain code lengths? Can there be any side-effect with longer answer codes?

@c_schmitz: One of our main customers urgently needs such a feature for route and location details within their transit surveys. No one will be hurt if we add a setting to increase this at LS 4.x and set the default to the know 5 characters, but several users (and Limesurvey as well) will benefit from more flexibility.
We would also provide the required code so you wouldn't need to spend any developer hours on this but just review and comment.


2019-06-26 15:16

developer   ~52566

Because activateSurvey use createFieldMap :


2019-07-02 15:02

administrator   ~52665

VARCHAR(128) will probably (?) reduce the amount of maximum columns. See and comments.


2019-07-05 11:22

administrator   ~52747

Last edited: 2019-07-05 11:23

View 2 revisions

My proposed solution: Make ALL answer columns configurable in config.php. Right now they are all hard-coded here:



2019-07-05 11:43

developer   ~52751

@ollehar : need update answer table.

Seems to be easiest solution, but : 100 VARCHAR(1) + 1 VARCHAR(25) take less place than 101 VARCHAR(5)

By question : you can have some VARCHAR(1), some VARCHAR(10), etc …


2019-07-05 11:45

administrator   ~52752

> need update answer table

What do you mean?


2019-07-05 12:00

developer   ~52753

> What do you mean?

If you set single choice column to 20 characters : answer column code mus contains same code.
Here the FR is to allow more than 5 characters to answer code …


2019-07-05 12:08

administrator   ~52754

Last edited: 2019-07-05 12:09

View 3 revisions

Oh, sorry, I misunderstood. But why then not simply run

`ALTER TABLE lime_answers MODIFY COLUMN code ...`

after installation, if you need longer values?



2019-07-05 12:12

partner   ~52755

...because you also need to adjust the GUI to allow >5 characters. You can adjust the source code but if you want to be able to update your Limesurvey system later that is no good approach. So using the configuration setting Denis had mentioned before seems like the best approach to me.


2019-07-05 12:19

administrator   ~52757

Do we have a PR for this?


2019-07-05 12:59

partner   ~52759

@PR: Nope, since we are still discussing if this can be added to LS 4.
If Carsten agrees to it, we could start working on it.


2019-07-05 13:22

administrator   ~52761

Other alternative: Let the UI limitations reflect the database length of the column. Then the `ALTER TABLE` command will work.


2019-07-05 14:28

developer   ~52762

> UI limitations reflect the database length

You mean answer DB length ? Because survey is not always activated :)


2019-07-05 15:03

administrator   ~52764

> You mean answer DB length ? Because survey is not always activated :)

Yes, I mean column `code` from `lime_answers`.


2019-07-05 15:09

developer   ~52766

Yes, a quick fix can be replace 5 by size of `code` in `lime_answers` (get config by database)
But then we always reduce the maximum column numbers :).

It work but not for all survey‘s


2019-07-05 16:54

administrator   ~52770

No, we don't change the size of `code` in the database - that's up the each owner to hack/patch. We just lets the UI reads that size instead of hard-coding it to 5.

Maybe we should have a "patch system", which lets you change core code even after an update...


2019-07-05 16:59

developer   ~52773

Last edited: 2019-07-05 17:00

View 2 revisions

Yes, i understand this :

And replace all 5 by App()->getConfig('answercodelenght');

And then : plugin can update confif by a lesser length \o/ for a survey (some hack , but possible)



2019-07-06 09:55

administrator   ~52776

Yes, exactly. Hacky but better than nothing, I guess.


2019-07-08 08:47

developer   ~52779

Why not, a quick solution before allowing a better one .

And since this quick solution us a fixed string : when update to a better one : we can more easily find wher it must be update with a simple grep :)


2019-07-08 10:10

administrator   ~52780

@Mazi a pull request to consider? Regarding removing the hard-coded UI limit.


2019-07-08 10:13

partner   ~52781

@ollehar, please talk about this with @c_schmitz. If he agrees to that approach, we can look into the code details.


2019-07-08 11:22

administrator   ~52787

He does not. This issue can be put on hold for now.

Issue History

Date Modified Username Field Change
2017-06-19 09:46 Ben_V Note Added: 43936
2017-06-26 12:26 DenisChenu Note Added: 43977
2017-06-26 12:35 Ben_V Note Added: 43978
2017-06-26 12:45 DenisChenu Note Added: 43979
2017-06-26 13:41 Ben_V Note Added: 43980
2018-10-29 15:35 Mazi Note Added: 49468
2018-10-29 15:38 Mazi Note Added: 49469
2018-10-29 17:03 DenisChenu Note Added: 49472
2018-12-28 18:20 bismark Note Added: 50077
2018-12-28 21:13 Mazi Assigned To => c_schmitz
2018-12-28 21:13 Mazi Status acknowledged => assigned
2018-12-28 21:14 Mazi Note Added: 50079
2019-06-13 11:32 Mazi Note Added: 52385
2019-06-13 11:39 c_schmitz Note Added: 52387
2019-06-13 11:47 bismark Note Added: 52388
2019-06-13 11:57 DenisChenu Note Added: 52389
2019-06-13 12:25 Mazi Note Added: 52390
2019-06-13 13:31 DenisChenu Note Added: 52392
2019-06-13 13:36 Mazi Note Added: 52393
2019-06-13 13:38 DenisChenu Note Added: 52394
2019-06-13 13:39 DenisChenu Note Added: 52395
2019-06-13 13:53 Mazi Note Added: 52397
2019-06-13 14:15 DenisChenu Note Added: 52398
2019-06-13 15:06 Mazi Note Added: 52400
2019-06-13 15:08 c_schmitz Note Added: 52401
2019-06-25 12:13 Mazi Note Added: 52530
2019-06-25 12:56 DenisChenu Note Added: 52538
2019-06-25 21:29 Mazi Note Added: 52556
2019-06-26 15:16 DenisChenu Note Added: 52566
2019-07-02 15:02 ollehar Note Added: 52665
2019-07-05 11:22 ollehar Note Added: 52747
2019-07-05 11:23 ollehar Note Edited: 52747 View Revisions
2019-07-05 11:43 DenisChenu Note Added: 52751
2019-07-05 11:45 ollehar Note Added: 52752
2019-07-05 12:00 DenisChenu Note Added: 52753
2019-07-05 12:08 ollehar Note Added: 52754
2019-07-05 12:09 ollehar Note Edited: 52754 View Revisions
2019-07-05 12:09 ollehar Note Edited: 52754 View Revisions
2019-07-05 12:12 Mazi Note Added: 52755
2019-07-05 12:19 ollehar Note Added: 52757
2019-07-05 12:59 Mazi Note Added: 52759
2019-07-05 13:22 ollehar Note Added: 52761
2019-07-05 14:28 DenisChenu Note Added: 52762
2019-07-05 15:03 ollehar Note Added: 52764
2019-07-05 15:09 DenisChenu Note Added: 52766
2019-07-05 16:54 ollehar Note Added: 52770
2019-07-05 16:59 DenisChenu Note Added: 52773
2019-07-05 17:00 DenisChenu Note Edited: 52773 View Revisions
2019-07-06 09:55 ollehar Note Added: 52776
2019-07-08 08:47 DenisChenu Note Added: 52779
2019-07-08 10:10 ollehar Note Added: 52780
2019-07-08 10:13 Mazi Note Added: 52781
2019-07-08 11:22 ollehar Note Added: 52787
2021-03-07 21:10 c_schmitz Status assigned => closed
2021-03-07 21:10 c_schmitz Resolution open => won't fix
2021-03-07 21:10 c_schmitz Relationship added related to 05289