View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
17158Bug reportsMenu systempublic2021-04-06 14:43
ReporterPMagel Assigned Toollehar  
PriorityhighSeverityblock 
Status closedResolutionfixed 
Product Version4.4.0-RC2 
Fixed in Version4.4.12 
Summary17158: Question type: List (Ratio) does not save state.
Description

We found a Problem regarding the List (Ratio) question type.
When you create It with the entry 0 and 1, then select the 0 as the option and go to the next step. After this go back a step to the selection of the List (Ratio) and you see the answer is not selected anymore.
When you do the same steps with the 1 as your answer it stays selected.

Steps To Reproduce

Just create 2 questions, first a List (Ratio) type and the second one I selected a Long free text as an example.
For the first one you need two entries (0 and 1).
Or you take the import file I provided for example.

Additional Information

We found a solution for this in the file 'application/models/QuestionBaseRenderer.php' in 'protected function setDefaultIfEmpty($value, $default)' at Line 294-303 we added this:

if (($value === 0) || ($value === "0")) {
return $value;
}

It solves the Problem.

TagsNo tags attached.
Attached Files
Bug heat4
Complete LimeSurvey version number (& build)Version 4.4.0-RC4+210120 on my PC but also in version 4.3.30.
I will donate to the project if issue is resolvedYes
BrowserChrome
Database type & versionPostgresSQL
Server OS (if known)
Webserver software & version (if known)
PHP Version7.4.15

Users monitoring this issue

There are no users monitoring this issue.

Activities

ollehar

ollehar

2021-03-03 14:28

administrator   ~62644

You're using an outdated version of LimeSurvey. Please update to the latest version and check if the bug can still be reproduced. Thank you.

PMagel

PMagel

2021-03-03 14:51

reporter   ~62655

I now tested it on version 4.4.11+210301 and the bug is still there. I also tested the described solution and it also worked in this version.

ollehar

ollehar

2021-03-03 14:56

administrator   ~62657

Can you enable debug = 2 in application/config/config.php and try again, please? Paste the complete error message here.

PMagel

PMagel

2021-03-04 11:25

reporter   ~62709

As you told me, I enabled the debug mode, then I specified a 'error_log' destination and there are no errors showing. I even put a test 'error_log()' in the functions that are related to the problem and they are shown as expected.

ollehar

ollehar

2021-03-04 11:53

administrator   ~62710

Thanks! We will look closer.

ollehar

ollehar

2021-03-04 19:55

administrator   ~62740

Wait, how does your suggested fix interact with default values?

ollehar

ollehar

2021-03-04 19:58

administrator   ~62741

Maybe it's better to check for === null?

PMagel

PMagel

2021-03-05 09:27

reporter   ~62747

Okay I checkt your suggestion and It solves the problem and is slimmer. So you can just do it like this:

protected function setDefaultIfEmpty($value, $default)
{
if(is_null($value)) {
return $default;
}
return trim($value) == '' ? $default : $value;
}

ollehar

ollehar

2021-03-05 11:00

administrator   ~62748

Thanks for the help!

ollehar

ollehar

2021-04-06 14:43

administrator   ~63824

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

Related Changesets

LimeSurvey: master e94f4c05

2021-03-05 10:58:12

ollehar

Details Diff
Fixed issue 17158: Question type: List (Radio) does not save state Affected Issues
17158
mod - application/models/QuestionBaseRenderer.php Diff File

Issue History

Date Modified Username Field Change
2021-03-03 12:45 PMagel New Issue
2021-03-03 12:45 PMagel File Added: limesurvey_survey_319611.lss
2021-03-03 14:28 ollehar Assigned To => ollehar
2021-03-03 14:28 ollehar Status new => feedback
2021-03-03 14:28 ollehar Note Added: 62644
2021-03-03 14:51 PMagel Note Added: 62655
2021-03-03 14:51 PMagel Status feedback => assigned
2021-03-03 14:56 ollehar Priority none => high
2021-03-03 14:56 ollehar Severity minor => block
2021-03-03 14:56 ollehar Description Updated
2021-03-03 14:56 ollehar Steps to Reproduce Updated
2021-03-03 14:56 ollehar Additional Information Updated
2021-03-03 14:56 ollehar Note Added: 62657
2021-03-04 11:25 PMagel Note Added: 62709
2021-03-04 11:53 ollehar Note Added: 62710
2021-03-04 19:55 ollehar Note Added: 62740
2021-03-04 19:55 ollehar Status assigned => feedback
2021-03-04 19:58 ollehar Note Added: 62741
2021-03-05 09:27 PMagel Note Added: 62747
2021-03-05 09:27 PMagel Status feedback => assigned
2021-03-05 11:00 ollehar Status assigned => resolved
2021-03-05 11:00 ollehar Resolution open => fixed
2021-03-05 11:00 ollehar Note Added: 62748
2021-03-08 19:31 c_schmitz Fixed in Version => 4.4.12
2021-03-08 19:33 c_schmitz Status resolved => closed
2021-04-06 14:43 ollehar Changeset attached => LimeSurvey master e94f4c05
2021-04-06 14:43 ollehar Note Added: 63824