View Issue Details

IDProjectCategoryView StatusLast Update
16313Bug reportsQuestion editorpublic2020-05-20 20:53
Reporterlarjona Assigned To 
PrioritynormalSeveritypartial_block 
Status newResolutionopen 
Product Version4.2.4 
Summary16313: Issues saving/modifying answers: "Answer codes must be unique by question"
Description

Hello, this is an instance running Version 4.2.4+200520, but it had surveys created from former versions.

it seems each time I want to add answer options or modify answer options, I need to change the answer options code to something different than the codes that were present. If I try to save without changing the answer codes, I obtain this error:

Question has been stored, but an error happened: Answer option couldn't be saved. Error: Array ( [code] => Array ( [0] => Answer codes must be unique by question ) ) (/var/www/surveys/application/controllers/admin/questionedit.php:299)

#0 /var/www/surveys/framework/base/CErrorHandler.php(131): CErrorHandler->handleException()
#1 /var/www/surveys/framework/base/CApplication.php(750): CErrorHandler->handle()
#2 unknown(0): LSYii_Application->handleException()

Steps To Reproduce

I have created a new survey, added a new group and a new question "favourite colour", selected Single Choice question, list (Radio) type L, and went to Answer options to create some test answer options. There is already a line there with code AO01, value 0 so I just type black in the Answer option box and click the button "Add answer option" to get AO02, value 0 and type white in the Answer option, add another answer, I get AO03, value 0, and type red as answer option,
Then I click "Save" and they are saved.

If I go to the database:
select * from lime_answers where qid=556;
aid | qid | code | sortorder | assessment_value | scale_id
------+-----+------+-----------+------------------+----------
1030 | 556 | AO01 | 1 | 0 | 0
1031 | 556 | AO02 | 2 | 0 | 0
1032 | 556 | AO03 | 3 | 0 | 0
(3 rows)

Then I go to the text boxes and I change the texts for example to upper caps (BLACK, WHITE, RED) and try to save and obtain the following error:
Question has been stored, but an error happened: Answer option couldn't be saved. Error: Array ( [code] => Array ( [0] => Answer codes must be unique by question ) ) (/var/www/surveys/application/controllers/admin/questionedit.php:299)

#0 /var/www/surveys/framework/base/CErrorHandler.php(131): CErrorHandler->handleException()
#1 /var/www/surveys/framework/base/CApplication.php(750): CErrorHandler->handle()
#2 unknown(0): LSYii_Application->handleException()

And if I go now to the database:
select * from lime_answers where qid=556;
aid | qid | code | sortorder | assessment_value | scale_id
------+-----+------+-----------+------------------+----------
1030 | 556 | AO01 | 1 | 0 | 0
(1 fila)

Strange.

Now I modify the question codes to PAO01, PAO02 and PAO03, and click save, and they are successfully saved, but look at the "aid" codes:

select * from lime_answers where qid=556;
aid | qid | code | sortorder | assessment_value | scale_id
------+-----+-------+-----------+------------------+----------
1030 | 556 | PAO01 | 1 | 0 | 0
1033 | 556 | PAO02 | 2 | 0 | 0
1034 | 556 | PAO03 | 3 | 0 | 0
(3 rows)

Now if I change the assessment values to 10, 20, 30 and click save, I obtain again the error, and the database looks like this:

select * from lime_answers where qid=556;
aid | qid | code | sortorder | assessment_value | scale_id
------+-----+-------+-----------+------------------+----------
1030 | 556 | PAO01 | 1 | 0 | 0
(1 row)

If I delete all the answer options (from the web interface) and create a new answer option XAO01, I can save:

select * from lime_answers where qid=556;
aid | qid | code | sortorder | assessment_value | scale_id
------+-----+-------+-----------+------------------+----------
1035 | 556 | XAO01 | 1 | 0 | 0
(1 row)

but if I add any other option, or modify this option but keeping the XAO01 code, clicking save produces again the error.

TagsNo tags attached.
Complete LimeSurvey version number (& build)Version 4.2.4+200520
I will donate to the project if issue is resolvedNo
BrowserFirefox 68.8.0esr (64-bit)
Database & DB-Versionpostgresql-9.6 (latest Debian 9 package)
Server OS (if known)Debian 9 stretch
Webserver software & version (if known)nginx 1.10.3 (latest Debian 9 package)
PHP Versionphp 7.0.33 (latest Debian 9 package), php7.0-fpm

Activities

cdorin

cdorin

2020-05-20 14:19

manager   ~57958

Hello and thank for your report. Could you please share with us the .lss file? So that everyone works on the same example? Thanks for report!

larjona

larjona

2020-05-20 15:11

reporter   ~57965

Hi! thanks for the quick answer. I have attached an export of the survey as zip.
I think it's not related to particularities of the survey, since this was a new one, created as test.
I can provide a dump of the related rows of the database, if you tell me which sql commands to run (I have other surveys there with sensitive content so I cannot provide a whole database dump).

Kind regards,

surveys_archive.zip (3,821 bytes)

Issue History

Date Modified Username Field Change
2020-05-20 12:57 larjona New Issue
2020-05-20 14:19 cdorin Note Added: 57958
2020-05-20 14:20 cdorin Status new => feedback
2020-05-20 15:11 larjona Note Added: 57965
2020-05-20 15:11 larjona File Added: surveys_archive.zip
2020-05-20 15:11 larjona Status feedback => new
2020-05-20 17:01 ollehar Priority none => normal