Relationship Graph

Relationship Graph
related to related to child of child of duplicate of duplicate of

View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
18060Bug reportsSurvey editingpublic2022-05-30 11:14
Reporterc_schmitz Assigned Togabrieljenik  
PriorityurgentSeveritypartial_block 
Status closedResolutionfixed 
Product Version5.3.x 
Summary18060: 'Save as default values' question setting not working properly
Description

When using the option "Save as default values" it is not working for the most part.

Steps To Reproduce

Steps to reproduce

Create a text question, set it to mandatory, change some other advanced question attributes, activate 'Save as default values' and save. Then create a new question of the same type.

Expected result

After saving, the switch 'Save as default values' should automatically revert to 'off' again.
On creation of the new question the new default values would apply, so the new question should have set Mandatory to On, and have all the question attributes

Actual result

The switch 'Save as default values' stays on after save.
On creation no saved defaults are applied.

TagsNo tags attached.
Bug heat8
Complete LimeSurvey version number (& build)5.3.11
I will donate to the project if issue is resolvedNo
Browser
Database type & versionn/a
Server OS (if known)
Webserver software & version (if known)
PHP Version7.4

Relationships

related to 16734 closedc_schmitz Feature requests mandatory default N and same_default default 1 
related to 15982 assignedp_teichmann Bug reports Default attribute are saved in DB 

Activities

c_schmitz

c_schmitz

2022-04-28 12:46

administrator   ~69284

Something to check: Are the question type defaults user specific (they should) or global (god, please no).

DenisChenu

DenisChenu

2022-04-28 13:13

developer   ~69286

inherited by survey/group/global :D

c_schmitz

c_schmitz

2022-04-28 14:44

administrator   ~69287

inherited by survey/group/global :D

lol, I hope that was a joke ;)

gabrieljenik

gabrieljenik

2022-05-02 21:03

manager   ~69357

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

The value of the front_end switch depended on use_defaults, which has nothing to do with it. Now it always appears disabled, as this a one way switch: You can only set it to true and then defaults will be snapshot and saved. There is no link in between the default values sanpshot and the current question attributes. Question attributes can later be changed, and the default wouldn't be impacted.

Defaults were saved but not used for populating new questions. Now they do.

c_schmitz

c_schmitz

2022-05-19 20:14

administrator   ~69877

Tbh,. I am not sure how the default values are applied on a new question, because the question type is only select after the `default are already loaded

gabrieljenik

gabrieljenik

2022-05-19 21:22

manager   ~69887

I think you have a good argument there.
TBH, not big fan of this feature nor not sure how whidely used it is.

DenisChenu

DenisChenu

2022-05-20 08:22

developer   ~69891

TBH, not big fan of this feature nor not sure how whidely used it is.

+1 here

Else : the best place seems to be in QuestionAttribute or QuestionAttributeHelper ?

here : https://github.com/LimeSurvey/LimeSurvey/blob/b174a7d10a29017f120e9b0d47089b7b8240b668/application/models/services/QuestionAttributeHelper.php#L41 maybe

gabrieljenik

gabrieljenik

2022-05-20 14:17

manager   ~69910

QuestionAttributeFetcher does the following:

        // Get attribute values
        if (!empty($this->question->qid)) {
            $attributeValues = \QuestionAttribute::model()->getAttributesAsArrayFromDB($this->question->qid);
        } else {
            $attributeValues = $questionAttributeHelper->getUserDefaultsForQuestionType($this->question->type);
        }

In populateValues(), if the question is new (has no QID) it raises the default values.
So if you are creating a question and you change the type of question, without saving, it raises the defaults for the last type you chose.
It never changes the values if you are changing the type of a previously saved question.

That is kind the behaviour it used to have. Haven't changed it. Just fixed what was not working correctly.

I am not sure it is great feature. :)

DenisChenu

DenisChenu

2022-05-20 14:31

developer   ~69911

But :

Save 'placeholder' "enter a number" default value for numeric
Create a short text question
Save
Set it as numeric question type : 'placeholder' must be "enter a number" ? No ?

gabrieljenik

gabrieljenik

2022-05-20 15:42

manager   ~69914

Set it as numeric question type : 'placeholder' must be "enter a number" ? No ?

Hmm If I got it right, no, it must not.
If you save and then change the question type, the default values will not apply.
The default values only apply for new questions, before they are saved.

DenisChenu

DenisChenu

2022-05-20 16:00

developer   ~69917

It's not like that i understand the default value by question type :)
For me it must replace the default value for new question, or new attribute in same question (happen when you update question type)

It's more clear with

  1. Create a single choice question
  2. Save (no placeholder attribute (not set))
  3. Set it as numeric question type : 'placeholder' must be "enter a number" ? No ?

Short text didn't have placeholder too . If short text have it with already saved : yes , must not update.

@c_schmitz : do you have any specifications for this feature ?

gabrieljenik

gabrieljenik

2022-05-20 16:06

manager   ~69919

OK, how these defaults are applied was not specifically in the scope of this ticket.
I would suggest to follow up on a new ticket, as to be able to deliver this (which I believe is better than what is available now)
What do you think?

gabrieljenik

gabrieljenik

2022-05-25 14:25

manager   ~70038

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

LimeBot

LimeBot

2022-05-30 11:14

administrator   ~70096

Fixed in Release 5.3.18+220530

Related Changesets

LimeSurvey: master f9a58ce3

2022-05-25 14:25:36

gabrieljenik


Committer: GitHub Details Diff
Fixed issue 18060: 'Save as default values' question setting not working properly (#2386) Affected Issues
18060
mod - application/extensions/GeneralOptionWidget/settings/SaveAsDefaultGeneralOption.php Diff File
mod - application/models/services/QuestionAttributeFetcher.php Diff File
mod - application/models/services/QuestionAttributeHelper.php Diff File

Issue History

Date Modified Username Field Change
2022-04-28 12:45 c_schmitz New Issue
2022-04-28 12:46 c_schmitz Note Added: 69284
2022-04-28 12:46 c_schmitz Bug heat 0 => 2
2022-04-28 12:47 c_schmitz Relationship added related to 16734
2022-04-28 12:48 c_schmitz Assigned To => gabrieljenik
2022-04-28 12:48 c_schmitz Priority none => urgent
2022-04-28 12:48 c_schmitz Status new => assigned
2022-04-28 13:13 DenisChenu Note Added: 69286
2022-04-28 13:13 DenisChenu Bug heat 2 => 4
2022-04-28 14:44 c_schmitz Note Added: 69287
2022-04-28 15:27 DenisChenu Relationship added related to 15982
2022-05-02 21:03 gabrieljenik Note Added: 69357
2022-05-02 21:03 gabrieljenik Bug heat 4 => 6
2022-05-02 21:04 gabrieljenik Status assigned => ready for testing
2022-05-19 20:14 c_schmitz Note Added: 69877
2022-05-19 20:15 c_schmitz Status ready for testing => feedback
2022-05-19 21:22 gabrieljenik Note Added: 69887
2022-05-20 08:22 DenisChenu Note Added: 69891
2022-05-20 14:17 gabrieljenik Note Added: 69910
2022-05-20 14:31 DenisChenu Note Added: 69911
2022-05-20 15:42 gabrieljenik Note Added: 69914
2022-05-20 16:00 DenisChenu Note Added: 69917
2022-05-20 16:06 gabrieljenik Note Added: 69919
2022-05-25 14:25 gabrieljenik Changeset attached => LimeSurvey master f9a58ce3
2022-05-25 14:25 gabrieljenik Note Added: 70038
2022-05-25 14:25 gabrieljenik Resolution open => fixed
2022-05-25 14:25 c_schmitz Status feedback => resolved
2022-05-30 11:14 LimeBot Note Added: 70096
2022-05-30 11:14 LimeBot Status resolved => closed
2022-05-30 11:14 LimeBot Bug heat 6 => 8