View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
04659Bug reportsOtherpublic2010-10-13 16:22
ReporterSpydre13 Assigned ToDenisChenu  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version1.90+ 
Fixed in Version1.90+ 
Summary04659: Default answer overrides stored answer when going back to question
Description

When a question has a default answer, and the question is re-visited to complete, the default answer will apply again.

Steps To Reproduce

Create one or more questions of type "List (radio)" and assign a default answer. Take the survey, changing the default answer to another answer. Click "Next" or "Back" until you view that same question, and the default answer is selected again.

Additional Information

I have verified that the chosen answer is being stored in the database, but the page does not use that stored answer when re-visiting the question.

TagsNo tags attached.
Attached Files
surveytest.lss (23,692 bytes)
diff_index_04659.patch (201 bytes)   
2470a2471,2475
>         // Fill the session with defaultvalue
>         if (isset($field['defaultvalue']))
>         {
>             $_SESSION[$field['fieldname']]=$field['defaultvalue'];
>         }
diff_index_04659.patch (201 bytes)   
diff_qanda_04659.patch (2,625 bytes)   
1829,1833d1828
<             elseif ($ansrow['code']==$_SESSION['fieldmap'][$ia[1]]['defaultvalue'])
<             {
<                 $opt_select = SELECTED;
<                 $defexists=true;
<             }
1848c1843
<                 $defaultopts[] = array ( 'code' => $ansrow['code'], 'answer' => $answertext, 'default_value' => $_SESSION['fieldmap'][$ia[1]]['defaultvalue']);
---
>                 $defaultopts[] = array ( 'code' => $ansrow['code'], 'answer' => $answertext);
1852c1847
<                 $optgroups[$categorytext][] = array ( 'code' => $ansrow['code'], 'answer' => $answertext, 'default_value' => $_SESSION['fieldmap'][$ia[1]]['defaultvalue']);
---
>                 $optgroups[$categorytext][] = array ( 'code' => $ansrow['code'], 'answer' => $answertext);
1869,1873d1863
<                 elseif ($optionarray['default_value'] == 'Y')
<                 {
<                     $opt_select = SELECTED;
<                     $defexists = 'Y';
<                 }
1892,1896d1881
<             elseif ($optionarray['default_value'] == 'Y')
<             {
<                 $opt_select = SELECTED;
<                 $defexists = 'Y';
<             }
2116,2120d2100
<         elseif ($ansrow['code']==$_SESSION['fieldmap'][$ia[1]]['defaultvalue'])
<         {
<             $check_ans = CHECKED;
<             $defexists=true;
<         }
2344,2348d2323
<             elseif ($ansrow['code']==$_SESSION['fieldmap'][$ia[1]]['defaultvalue'])
<             {
<                 $check_ans = CHECKED;
<                 $defexists=true;
<             }
2414,2418d2388
<             elseif ($ansrow['code']==$_SESSION['fieldmap'][$ia[1]]['defaultvalue'])
<             {
<                 $check_ans = CHECKED;
<                 $defexists=true;
<             }
2921,2926d2890
<         // Or if the question is marked as a default selection, check the checkbox
<         elseif ($_SESSION['fieldmap'][$ia[1].$ansrow['title']]['defaultvalue']=='Y')
<         {
<             $answer .= CHECKED;
<         }            
< 
2973,2977d2936
<         // Or if the question is marked as a default selection, check the checkbox
<         elseif ($_SESSION['fieldmap'][$ia[1].$ansrow['title']]['defaultvalue']=='Y')
<         {
<             $answer .= 'Y';
<         }            
3337,3340d3295
<         elseif ($_SESSION['fieldmap'][$ia[1].$ansrow['title']]['defaultvalue']=='Y')
<         {
<             $answer_main .= CHECKED;
<         }            
3353,3356d3307
<         elseif ($_SESSION['fieldmap'][$ia[1].$ansrow['title']]['defaultvalue']=='Y')
<         {
<             $answer_main .= 'Y';
<         }
diff_qanda_04659.patch (2,625 bytes)   
Bug heat8
Complete LimeSurvey version number (& build)9130
I will donate to the project if issue is resolved
BrowserIE 8, Google Chrom
Database type & versionMysql 14.12
Server OS (if known)Debian Linux
Webserver software & version (if known)Apache2
PHP Version5.3.2-1

Users monitoring this issue

DenisChenu

Activities

DenisChenu

DenisChenu

2010-10-07 14:28

developer   ~13024

See the problem.

Have the fix : test if the fix work

Dev: put default value in $_SESSION at start (line 2468)

DenisChenu

DenisChenu

2010-10-07 15:18

developer   ~13026

If you have some times to test the diff :)

Spydre13

Spydre13

2010-10-07 17:58

reporter   ~13027

Thanks for your help Shnoulle. I tested the diff, it fixed most of the problem. Now if I navigate back and forth, or close the browser and re-enter, it does keep the changes values.

However, for both the "List (radio)" and "Multiple options" types, if I navigate back to the very first page and then view the questions again, they are set back to the defaults.

DenisChenu

DenisChenu

2010-10-08 09:08

developer   ~13040

Last edited: 2010-10-08 09:10

OK, thank's a lot for the return.

I try a fix for this condition ...
(and try too : close survey, save survey function ..)

(but it's better than before ;))

DenisChenu

DenisChenu

2010-10-09 22:41

developer   ~13056

fixed in 9198

Thanks for the report !!

c_schmitz

c_schmitz

2010-10-13 16:22

administrator   ~13123

Released in latest Plus version

Issue History

Date Modified Username Field Change
2010-10-06 22:01 Spydre13 New Issue
2010-10-06 22:01 Spydre13 File Added: surveytest.lss
2010-10-07 14:28 DenisChenu Note Added: 13024
2010-10-07 14:28 DenisChenu Assigned To => DenisChenu
2010-10-07 14:28 DenisChenu Status new => assigned
2010-10-07 14:29 DenisChenu Issue Monitored: DenisChenu
2010-10-07 15:17 DenisChenu File Added: diff_index_04659.patch
2010-10-07 15:17 DenisChenu File Added: diff_qanda_04659.patch
2010-10-07 15:18 DenisChenu Note Added: 13026
2010-10-07 17:58 Spydre13 Note Added: 13027
2010-10-08 09:08 DenisChenu Note Added: 13040
2010-10-08 09:08 DenisChenu Note Edited: 13040
2010-10-08 09:10 DenisChenu Note Edited: 13040
2010-10-09 22:41 DenisChenu Note Added: 13056
2010-10-09 22:44 DenisChenu Status assigned => resolved
2010-10-09 22:44 DenisChenu Fixed in Version => 1.90+
2010-10-09 22:44 DenisChenu Resolution open => fixed
2010-10-13 16:22 c_schmitz Note Added: 13123
2010-10-13 16:22 c_schmitz Status resolved => closed
2010-10-25 00:18 c_schmitz Category Survey Taking => (No Category)
2021-08-06 07:15 guest Bug heat 6 => 8