View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
16313 | Bug reports | Question editor | public | 2020-05-20 12:57 | 2020-10-19 10:13 |
Reporter | larjona | Assigned To | gabrieljenik | ||
Priority | low | Severity | partial_block | ||
Status | closed | Resolution | fixed | ||
Product Version | 4.2.4 | ||||
Summary | 16313: 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() | ||||
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, If I go to the database: 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: #0 /var/www/surveys/framework/base/CErrorHandler.php(131): CErrorHandler->handleException() And if I go now to the database: 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; 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; 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; but if I add any other option, or modify this option but keeping the XAO01 code, clicking save produces again the error. | ||||
Tags | No tags attached. | ||||
Bug heat | 14 | ||||
Complete LimeSurvey version number (& build) | Version 4.2.4+200520 | ||||
I will donate to the project if issue is resolved | No | ||||
Browser | Firefox 68.8.0esr (64-bit) | ||||
Database type & version | postgresql-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 Version | php 7.0.33 (latest Debian 9 package), php7.0-fpm | ||||
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! |
|
Hi! thanks for the quick answer. I have attached an export of the survey as zip. Kind regards, |
|
I had this same issue. my fix is below. The qid, oldQid, scale_id, oldScaleid are of different types. string / integer mix so !== fails even though the values are the string equivalents are the same. Hopefully cdorin can provide a more permanent fix. |
|
Hi, we're having the same issue on our installation, running Version 4.3.2+200629 and postgresql. Steps to reproduce: Create Survey -> Add Group -> Add Question -> choose List(Dropdown) Developer Console shows me this: The full Console Error Trace is attached. Kind regards and let me know if you need anything else! js-console-06072020.log (2,504 bytes)
QUESTIONEDIT {…} data: {…} error: {…} code: 500 errorCode: 0 file: "/var/www/limesurvey/application/controllers/QuestionEditorController.php" line: 339 message: "Question has been stored, but an error happened: \nAnswer option couldn't be saved. Error: Array\n(\n [code] => Array\n (\n [0] => Answer codes must be unique by question\n )\n\n)\n" trace: "#0 [internal function]: QuestionEditorController->actionSaveQuestionData('615754')\n#1 /var/www/limesurvey/framework/web/actions/CAction.php(109): ReflectionMethod->invokeArgs(Object(QuestionEditorController), Array)\n#2 /var/www/limesurvey/framework/web/actions/CInlineAction.php(47): CAction->runWithParamsInternal(Object(QuestionEditorController), Object(ReflectionMethod), Array)\n#3 /var/www/limesurvey/framework/web/CController.php(308): CInlineAction->runWithParams(Array)\n#4 /var/www/limesurvey/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))\n#5 /var/www/limesurvey/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)\n#6 /var/www/limesurvey/application/controllers/LSBaseController.php(140): CController->run('saveQuestionDat...')\n#7 /var/www/limesurvey/framework/web/CWebApplication.php(282): LSBaseController->run('saveQuestionDat...')\n#8 /var/www/limesurvey/framework/web/CWebApplication.php(141): CWebApplication->runController('questionEditor/...')\n#9 /var/www/limesurvey/framework/base/CApplication.php(185): CWebApplication->processRequest()\n#10 /var/www/limesurvey/index.php(182): CApplication->run()\n#11 {main}" traces: Array(11) [ {…}, {…}, {…}, … ] type: "LSJsonException" <prototype>: Object { … } message: "Question has been stored, but an error happened: \nAnswer option couldn't be saved. Error: Array\n(\n [code] => Array\n (\n [0] => Answer codes must be unique by question\n )\n\n)\n" redirectTo: "/index.php?r=questionEditor/view&surveyid=615754&gid=29&qid=153" success: false <prototype>: Object { … } error: "Internal Server Error" success: false transferStatus: "error" xhr: Object { readyState: 4, getResponseHeader: getResponseHeader(e), getAllResponseHeaders: getAllResponseHeaders(), … } <prototype>: Object { … } ConsoleShim.js:131:26 value ConsoleShim.js:131 submitCurrentState App.vue:476 |
|
Just a quick update to my previous post: |
|
This bug still exists in version 4.3.11 when using postgres. adding strval() still fixes the issue on my side. I am not sure why the types are different here when comparing oldQid and oldScaleId. Can a fix be put into the master branch so I do not have to apply this fix during each update? |
|
PR: https://github.com/LimeSurvey/LimeSurvey/pull/1558 Replaced comparison operators as they could end up having different types |
|
Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=30604 |
|
Fixed in Release 4.3.22+201019 |
|
LimeSurvey: master 56b5ac45 2020-10-16 07:13:08 Committer: GitHub Details Diff |
Fixed issue 16313: Issues saving/modifying answers: "Answer codes must be unique by question" (#1558) Replaced comparison operators as they could end up having different types |
Affected Issues 16313 |
|
mod - application/models/Answer.php | Diff File |
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 |
2020-05-20 20:53 | davidrgl | Issue Monitored: davidrgl | |
2020-06-05 20:53 | jcieszlak | Note Added: 58205 | |
2020-07-06 15:46 | xmasterninni | Note Added: 58724 | |
2020-07-06 15:46 | xmasterninni | File Added: js-console-06072020.log | |
2020-07-17 21:16 | xmasterninni | Note Added: 58997 | |
2020-07-29 22:43 | cdorin | Priority | normal => low |
2020-07-29 22:43 | cdorin | Status | new => confirmed |
2020-07-29 22:44 | cdorin | Zoho Sprints | => |Yes| |
2020-07-29 22:44 |
|
Zoho Sprints ID | => 14469000000197073 |
2020-08-19 18:11 | jcieszlak | Note Added: 59528 | |
2020-08-20 01:11 | gabrieljenik | Note Added: 59539 | |
2020-10-16 07:13 | gabrieljenik | Changeset attached | => LimeSurvey master 56b5ac45 |
2020-10-16 07:13 | gabrieljenik | Note Added: 60222 | |
2020-10-16 07:13 | gabrieljenik | Assigned To | => gabrieljenik |
2020-10-16 07:13 | gabrieljenik | Resolution | open => fixed |
2020-10-19 10:13 | lime_release_bot | Zoho Sprints | Yes => |Yes| |
2020-10-19 10:13 | lime_release_bot | Note Added: 60257 | |
2020-10-19 10:13 | lime_release_bot | Status | confirmed => closed |
2021-08-03 09:20 | guest | Bug heat | 12 => 14 |