View Issue Details

This bug affects 1 person(s).
 22
IDProjectCategoryView StatusLast Update
18976Bug reportsSurvey editingpublic2023-10-10 04:15
Reporteradamzammit Assigned Toadamzammit  
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Product Version6.1.x 
Fixed in Version6.2.x 
Summary18976: Saving a question with subquestions deletes default answers
Description

When a question has default answers set for subquestions, they work fine.

Once the question is saved again (even if no changes made) the default answers disappear.

Looking at the code here: https://github.com/LimeSurvey/LimeSurvey/blob/5a08c33c58b0e7477f840e062219c9b102b82c82/application/controllers/QuestionAdministrationController.php#L477

The subquestions are deleted and recreated on the save form submit. This creates a new qid for each of the subquestions.

The associated default answers (if any exist) are not deleted and left dangling in the database.

Now that the subquestions have new sids, the default answers do not link up again.

Steps To Reproduce

Steps to reproduce

Create a question that supports sub questions
Set default answers
Go back to the question and press save

Expected result

Default answers remain

Actual result

Default answers disappear

TagsNo tags attached.
Bug heat22
Complete LimeSurvey version number (& build)6.2.x
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMariadb 10.5
Server OS (if known)
Webserver software & version (if known)
PHP Version8.1

Relationships

has duplicate 18817 closedkfoster Editing a question deletes default answers 
related to 19160 confirmedkfoster Unable to save subquestions 

Users monitoring this issue

DenisChenu

Activities

DenisChenu

DenisChenu

2023-07-21 08:03

developer   ~76206

Seems 5.X have same issue : https://github.com/LimeSurvey/LimeSurvey/blob/6afbecb3db2b252c345eac35e1d8b6aac369b04d/application/controllers/QuestionAdministrationController.php#L472

In 3.X :

Surely the way to do (maybe with another method)

adamzammit

adamzammit

2023-07-24 05:57

developer   ~76238

this is quite important to one of my clients so I have worked on a patch for this.

@DenisChenu are you able to review?

Now it will delete missing, add new, then update:

https://github.com/LimeSurvey/LimeSurvey/pull/3302

DenisChenu

DenisChenu

2023-07-24 08:52

developer   ~76239

Thanks !!

Maybe try to avoid to loose forum data sent more ? Adding error in save view bu don't throw error .

And try to save the maximum part we can ?

User see error and can update after.

Throw error according to debug >1

DenisChenu

DenisChenu

2023-07-24 13:04

developer   ~76241

Needed for 5.X too ?

kfoster

kfoster

2023-08-15 16:36

developer   ~76604

I can confirm this is a bug. The PR provided is too complicated to apply to the code base because we have quite a large refactoring going on in the develop branch. I have created a simpler bug fix: https://github.com/LimeSurvey/LimeSurvey/pull/3357

kfoster

kfoster

2023-08-15 21:11

developer   ~76608

Fix has been merged to the master branch.

guest

guest

2023-08-15 21:28

viewer   ~76609

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=35359

adamzammit

adamzammit

2023-08-16 01:10

developer   ~76610

thanks for fixing this @kfoster. I'll close my initial PR now.

LimeBot

LimeBot

2023-08-21 09:51

administrator   ~76653

Fixed in Release 6.2.3+230821

Related Changesets

LimeSurvey: master 4420f625

2023-08-15 23:08

K Foster

Committer: GitHub


Details Diff
Fixed issue 18976 - default answers should persist with subquestions (03357) Affected Issues
18976
mod - application/controllers/QuestionAdministrationController.php Diff File
mod - application/models/Question.php Diff File

LimeSurvey: 5.x 0cea5e54

2023-10-04 13:15

Gabriel Jenik

Committer: GitHub


Details Diff
Fixed issue 18817: Editing a question deletes default answers (#3457)

Fix ported from issue 18976 - default answers should persist with subquestions

Co-authored-by: Kevin Foster <kevin.foster.uk@gmail.com>
Affected Issues
18817, 18976
mod - application/controllers/QuestionAdministrationController.php Diff File
mod - application/models/Question.php Diff File

Issue History

Date Modified Username Field Change
2023-07-21 05:35 adamzammit New Issue
2023-07-21 07:58 DenisChenu Issue Monitored: DenisChenu
2023-07-21 07:58 DenisChenu Bug heat 0 => 2
2023-07-21 08:03 DenisChenu Note Added: 76206
2023-07-21 08:03 DenisChenu Bug heat 2 => 4
2023-07-24 05:57 adamzammit Note Added: 76238
2023-07-24 05:57 adamzammit Bug heat 4 => 6
2023-07-24 08:42 DenisChenu Assigned To => DenisChenu
2023-07-24 08:42 DenisChenu Status new => ready for code review
2023-07-24 08:52 DenisChenu Status ready for code review => in code review
2023-07-24 08:52 DenisChenu Note Added: 76239
2023-07-24 13:04 DenisChenu Note Added: 76241
2023-07-24 17:56 DenisChenu Assigned To DenisChenu => gabrieljenik
2023-08-08 23:38 gabrieljenik Assigned To gabrieljenik => adamzammit
2023-08-08 23:38 gabrieljenik Status in code review => assigned
2023-08-15 16:36 kfoster Status assigned => confirmed
2023-08-15 16:36 kfoster Complete LimeSurvey version number (& build) 6.1.8 => 6.2.x
2023-08-15 16:36 kfoster Note Added: 76604
2023-08-15 16:36 kfoster Bug heat 6 => 8
2023-08-15 21:11 kfoster Status confirmed => resolved
2023-08-15 21:11 kfoster Resolution open => fixed
2023-08-15 21:11 kfoster Fixed in Version => 6.2.x
2023-08-15 21:11 kfoster Note Added: 76608
2023-08-15 21:28 Changeset attached => LimeSurvey master 4420f625
2023-08-15 21:28 guest Note Added: 76609
2023-08-15 21:28 guest Bug heat 8 => 10
2023-08-16 01:10 adamzammit Note Added: 76610
2023-08-21 09:51 LimeBot Note Added: 76653
2023-08-21 09:51 LimeBot Status resolved => closed
2023-08-21 09:51 LimeBot Bug heat 10 => 12
2023-09-13 16:27 DenisChenu Relationship added has duplicate 18817
2023-09-13 16:27 DenisChenu Bug heat 12 => 20
2023-09-13 17:58 gabrieljenik Bug heat 20 => 22
2023-10-04 11:32 Changeset attached => LimeSurvey 5.x 0cea5e54
2023-10-10 04:15 mfavetti Relationship added related to 19160