View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
10052Bug reportsSurvey takingpublic2015-12-04 15:13
Reporteradamwebb Assigned ToDenisChenu  
PrioritynormalSeveritypartial_block 
Status closedResolutionfixed 
Product Version2.06+ 
Fixed in Version2.06+ 
Summary10052: 0 as answer code in radio list causes problems when 'No answer' is enabled
Description

Using 0 as a code for radio buttons causes problems when revisiting a previously answered question. Can result in data loss.

Steps To Reproduce
  1. Create a new survey with 'No answer' enabled. 'Previous' button should be enabled.

  2. Create two groups.

  3. In the first group create a single radio list question with a number of possible responses. One of the answer codes should be zero (0). Question should be non-mandatory.

  4. In the second group place a single question.

  5. Run the survey. In the first question the answer 'Zero' (coded 0) and click next.

  6. Click previous.

  7. The answer reverts to 'No answer' although the database still stores Zero as a response.

  8. Clicking next would replace the database recorded response with NULL

  9. Other options (1,2,3 etc) work fine. Only code 0 is affected.

Additional Information

The correct answer is initially stored in the database, and remains in the database after 'Previous' is selected. The problem lies in rendering the HTML for the radio list after 'Previous' button is selected. The original value (0) remains in the hidden field, but the option relating to Zero is unchecked. No answer is marked as checked instead.

Th problem arises because

if (!$var) evaluates to TRUE if $var == 0;
Use !isset($var) instead.

TagsNo tags attached.
Attached Files
limesurvey_survey_345929.lss.xml (13,833 bytes)   
<?xml version="1.0" encoding="UTF-8"?>
<document>
 <LimeSurveyDocType>Survey</LimeSurveyDocType>
 <DBVersion>184</DBVersion>
 <languages>
  <language>en</language>
 </languages>
 <answers>
  <fields>
   <fieldname>qid</fieldname>
   <fieldname>code</fieldname>
   <fieldname>answer</fieldname>
   <fieldname>sortorder</fieldname>
   <fieldname>assessment_value</fieldname>
   <fieldname>language</fieldname>
   <fieldname>scale_id</fieldname>
  </fields>
  <rows>
   <row>
    <qid><![CDATA[993]]></qid>
    <code><![CDATA[0]]></code>
    <answer><![CDATA[Zero]]></answer>
    <sortorder><![CDATA[1]]></sortorder>
    <assessment_value><![CDATA[1]]></assessment_value>
    <language><![CDATA[en]]></language>
    <scale_id><![CDATA[0]]></scale_id>
   </row>
   <row>
    <qid><![CDATA[993]]></qid>
    <code><![CDATA[1]]></code>
    <answer><![CDATA[One]]></answer>
    <sortorder><![CDATA[2]]></sortorder>
    <assessment_value><![CDATA[0]]></assessment_value>
    <language><![CDATA[en]]></language>
    <scale_id><![CDATA[0]]></scale_id>
   </row>
   <row>
    <qid><![CDATA[993]]></qid>
    <code><![CDATA[2]]></code>
    <answer><![CDATA[Two]]></answer>
    <sortorder><![CDATA[3]]></sortorder>
    <assessment_value><![CDATA[1]]></assessment_value>
    <language><![CDATA[en]]></language>
    <scale_id><![CDATA[0]]></scale_id>
   </row>
  </rows>
 </answers>
 <groups>
  <fields>
   <fieldname>gid</fieldname>
   <fieldname>sid</fieldname>
   <fieldname>group_name</fieldname>
   <fieldname>group_order</fieldname>
   <fieldname>description</fieldname>
   <fieldname>language</fieldname>
   <fieldname>randomization_group</fieldname>
   <fieldname>grelevance</fieldname>
  </fields>
  <rows>
   <row>
    <gid><![CDATA[72]]></gid>
    <sid><![CDATA[345929]]></sid>
    <group_name><![CDATA[Group 1]]></group_name>
    <group_order><![CDATA[28]]></group_order>
    <description/>
    <language><![CDATA[en]]></language>
    <randomization_group/>
    <grelevance/>
   </row>
   <row>
    <gid><![CDATA[73]]></gid>
    <sid><![CDATA[345929]]></sid>
    <group_name><![CDATA[Group 2]]></group_name>
    <group_order><![CDATA[29]]></group_order>
    <description/>
    <language><![CDATA[en]]></language>
    <randomization_group/>
    <grelevance/>
   </row>
  </rows>
 </groups>
 <questions>
  <fields>
   <fieldname>qid</fieldname>
   <fieldname>parent_qid</fieldname>
   <fieldname>sid</fieldname>
   <fieldname>gid</fieldname>
   <fieldname>type</fieldname>
   <fieldname>title</fieldname>
   <fieldname>question</fieldname>
   <fieldname>preg</fieldname>
   <fieldname>help</fieldname>
   <fieldname>other</fieldname>
   <fieldname>mandatory</fieldname>
   <fieldname>question_order</fieldname>
   <fieldname>language</fieldname>
   <fieldname>scale_id</fieldname>
   <fieldname>same_default</fieldname>
   <fieldname>relevance</fieldname>
  </fields>
  <rows>
   <row>
    <qid><![CDATA[993]]></qid>
    <parent_qid><![CDATA[0]]></parent_qid>
    <sid><![CDATA[345929]]></sid>
    <gid><![CDATA[72]]></gid>
    <type><![CDATA[L]]></type>
    <title><![CDATA[A1]]></title>
    <question><![CDATA[Pick a number less than 1.]]></question>
    <preg/>
    <help/>
    <other><![CDATA[N]]></other>
    <mandatory><![CDATA[N]]></mandatory>
    <question_order><![CDATA[1]]></question_order>
    <language><![CDATA[en]]></language>
    <scale_id><![CDATA[0]]></scale_id>
    <same_default><![CDATA[0]]></same_default>
    <relevance><![CDATA[1]]></relevance>
   </row>
   <row>
    <qid><![CDATA[994]]></qid>
    <parent_qid><![CDATA[0]]></parent_qid>
    <sid><![CDATA[345929]]></sid>
    <gid><![CDATA[73]]></gid>
    <type><![CDATA[Y]]></type>
    <title><![CDATA[B1]]></title>
    <question><![CDATA[Have you enjoyed filling in this survey today?]]></question>
    <preg/>
    <help/>
    <other><![CDATA[N]]></other>
    <mandatory><![CDATA[N]]></mandatory>
    <question_order><![CDATA[1]]></question_order>
    <language><![CDATA[en]]></language>
    <scale_id><![CDATA[0]]></scale_id>
    <same_default><![CDATA[0]]></same_default>
    <relevance><![CDATA[1]]></relevance>
   </row>
  </rows>
 </questions>
 <surveys>
  <fields>
   <fieldname>sid</fieldname>
   <fieldname>admin</fieldname>
   <fieldname>expires</fieldname>
   <fieldname>startdate</fieldname>
   <fieldname>adminemail</fieldname>
   <fieldname>anonymized</fieldname>
   <fieldname>faxto</fieldname>
   <fieldname>format</fieldname>
   <fieldname>savetimings</fieldname>
   <fieldname>template</fieldname>
   <fieldname>language</fieldname>
   <fieldname>additional_languages</fieldname>
   <fieldname>datestamp</fieldname>
   <fieldname>usecookie</fieldname>
   <fieldname>allowregister</fieldname>
   <fieldname>allowsave</fieldname>
   <fieldname>autonumber_start</fieldname>
   <fieldname>autoredirect</fieldname>
   <fieldname>allowprev</fieldname>
   <fieldname>printanswers</fieldname>
   <fieldname>ipaddr</fieldname>
   <fieldname>refurl</fieldname>
   <fieldname>publicstatistics</fieldname>
   <fieldname>publicgraphs</fieldname>
   <fieldname>listpublic</fieldname>
   <fieldname>htmlemail</fieldname>
   <fieldname>sendconfirmation</fieldname>
   <fieldname>tokenanswerspersistence</fieldname>
   <fieldname>assessments</fieldname>
   <fieldname>usecaptcha</fieldname>
   <fieldname>usetokens</fieldname>
   <fieldname>bounce_email</fieldname>
   <fieldname>attributedescriptions</fieldname>
   <fieldname>emailresponseto</fieldname>
   <fieldname>emailnotificationto</fieldname>
   <fieldname>tokenlength</fieldname>
   <fieldname>showxquestions</fieldname>
   <fieldname>showgroupinfo</fieldname>
   <fieldname>shownoanswer</fieldname>
   <fieldname>showqnumcode</fieldname>
   <fieldname>bouncetime</fieldname>
   <fieldname>bounceprocessing</fieldname>
   <fieldname>bounceaccounttype</fieldname>
   <fieldname>bounceaccounthost</fieldname>
   <fieldname>bounceaccountpass</fieldname>
   <fieldname>bounceaccountencryption</fieldname>
   <fieldname>bounceaccountuser</fieldname>
   <fieldname>showwelcome</fieldname>
   <fieldname>showprogress</fieldname>
   <fieldname>questionindex</fieldname>
   <fieldname>navigationdelay</fieldname>
   <fieldname>nokeyboard</fieldname>
   <fieldname>alloweditaftercompletion</fieldname>
   <fieldname>googleanalyticsstyle</fieldname>
   <fieldname>googleanalyticsapikey</fieldname>
  </fields>
  <rows>
   <row>
    <sid><![CDATA[345929]]></sid>
    <admin><![CDATA[Administrator]]></admin>
    <adminemail><![CDATA[ajw51@le.ac.uk]]></adminemail>
    <anonymized><![CDATA[N]]></anonymized>
    <faxto/>
    <format><![CDATA[G]]></format>
    <savetimings><![CDATA[N]]></savetimings>
    <template><![CDATA[default]]></template>
    <language><![CDATA[en]]></language>
    <additional_languages/>
    <datestamp><![CDATA[N]]></datestamp>
    <usecookie><![CDATA[N]]></usecookie>
    <allowregister><![CDATA[N]]></allowregister>
    <allowsave><![CDATA[Y]]></allowsave>
    <autonumber_start><![CDATA[0]]></autonumber_start>
    <autoredirect><![CDATA[N]]></autoredirect>
    <allowprev><![CDATA[Y]]></allowprev>
    <printanswers><![CDATA[N]]></printanswers>
    <ipaddr><![CDATA[N]]></ipaddr>
    <refurl><![CDATA[N]]></refurl>
    <publicstatistics><![CDATA[N]]></publicstatistics>
    <publicgraphs><![CDATA[N]]></publicgraphs>
    <listpublic><![CDATA[N]]></listpublic>
    <htmlemail><![CDATA[N]]></htmlemail>
    <sendconfirmation><![CDATA[Y]]></sendconfirmation>
    <tokenanswerspersistence><![CDATA[N]]></tokenanswerspersistence>
    <assessments><![CDATA[N]]></assessments>
    <usecaptcha><![CDATA[N]]></usecaptcha>
    <usetokens><![CDATA[N]]></usetokens>
    <bounce_email><![CDATA[ajw51@le.ac.uk]]></bounce_email>
    <emailresponseto/>
    <emailnotificationto/>
    <tokenlength><![CDATA[15]]></tokenlength>
    <showxquestions><![CDATA[Y]]></showxquestions>
    <showgroupinfo><![CDATA[B]]></showgroupinfo>
    <shownoanswer><![CDATA[Y]]></shownoanswer>
    <showqnumcode><![CDATA[X]]></showqnumcode>
    <bounceprocessing><![CDATA[N]]></bounceprocessing>
    <showwelcome><![CDATA[Y]]></showwelcome>
    <showprogress><![CDATA[Y]]></showprogress>
    <questionindex><![CDATA[0]]></questionindex>
    <navigationdelay><![CDATA[0]]></navigationdelay>
    <nokeyboard><![CDATA[N]]></nokeyboard>
    <alloweditaftercompletion><![CDATA[N]]></alloweditaftercompletion>
    <googleanalyticsstyle><![CDATA[0]]></googleanalyticsstyle>
    <googleanalyticsapikey/>
   </row>
  </rows>
 </surveys>
 <surveys_languagesettings>
  <fields>
   <fieldname>surveyls_survey_id</fieldname>
   <fieldname>surveyls_language</fieldname>
   <fieldname>surveyls_title</fieldname>
   <fieldname>surveyls_description</fieldname>
   <fieldname>surveyls_welcometext</fieldname>
   <fieldname>surveyls_endtext</fieldname>
   <fieldname>surveyls_url</fieldname>
   <fieldname>surveyls_urldescription</fieldname>
   <fieldname>surveyls_email_invite_subj</fieldname>
   <fieldname>surveyls_email_invite</fieldname>
   <fieldname>surveyls_email_remind_subj</fieldname>
   <fieldname>surveyls_email_remind</fieldname>
   <fieldname>surveyls_email_register_subj</fieldname>
   <fieldname>surveyls_email_register</fieldname>
   <fieldname>surveyls_email_confirm_subj</fieldname>
   <fieldname>surveyls_email_confirm</fieldname>
   <fieldname>surveyls_dateformat</fieldname>
   <fieldname>surveyls_attributecaptions</fieldname>
   <fieldname>email_admin_notification_subj</fieldname>
   <fieldname>email_admin_notification</fieldname>
   <fieldname>email_admin_responses_subj</fieldname>
   <fieldname>email_admin_responses</fieldname>
   <fieldname>surveyls_numberformat</fieldname>
   <fieldname>attachments</fieldname>
  </fields>
  <rows>
   <row>
    <surveyls_survey_id><![CDATA[345929]]></surveyls_survey_id>
    <surveyls_language><![CDATA[en]]></surveyls_language>
    <surveyls_title><![CDATA[Test survey]]></surveyls_title>
    <surveyls_description/>
    <surveyls_welcometext/>
    <surveyls_endtext/>
    <surveyls_url/>
    <surveyls_urldescription/>
    <surveyls_email_invite_subj><![CDATA[Invitation to participate in a survey]]></surveyls_email_invite_subj>
    <surveyls_email_invite><![CDATA[Dear {FIRSTNAME},

you have been invited to participate in a survey.

The survey is titled:
"{SURVEYNAME}"

"{SURVEYDESCRIPTION}"

To participate, please click on the link below.

Sincerely,

{ADMINNAME} ({ADMINEMAIL})

----------------------------------------------
Click here to do the survey:
{SURVEYURL}

If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:
{OPTOUTURL}

If you are blacklisted but want to participate in this survey and want to receive invitations please click the following link:
{OPTINURL}]]></surveyls_email_invite>
    <surveyls_email_remind_subj><![CDATA[Reminder to participate in a survey]]></surveyls_email_remind_subj>
    <surveyls_email_remind><![CDATA[Dear {FIRSTNAME},

Recently we invited you to participate in a survey.

We note that you have not yet completed the survey, and wish to remind you that the survey is still available should you wish to take part.

The survey is titled:
"{SURVEYNAME}"

"{SURVEYDESCRIPTION}"

To participate, please click on the link below.

Sincerely,

{ADMINNAME} ({ADMINEMAIL})

----------------------------------------------
Click here to do the survey:
{SURVEYURL}

If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:
{OPTOUTURL}]]></surveyls_email_remind>
    <surveyls_email_register_subj><![CDATA[Survey registration confirmation]]></surveyls_email_register_subj>
    <surveyls_email_register><![CDATA[Dear {FIRSTNAME},

You, or someone using your email address, have registered to participate in an online survey titled {SURVEYNAME}.

To complete this survey, click on the following URL:

{SURVEYURL}

If you have any questions about this survey, or if you did not register to participate and believe this email is in error, please contact {ADMINNAME} at {ADMINEMAIL}.]]></surveyls_email_register>
    <surveyls_email_confirm_subj><![CDATA[Confirmation of your participation in our survey]]></surveyls_email_confirm_subj>
    <surveyls_email_confirm><![CDATA[Dear {FIRSTNAME},

this email is to confirm that you have completed the survey titled {SURVEYNAME} and your response has been saved. Thank you for participating.

If you have any further questions about this email, please contact {ADMINNAME} on {ADMINEMAIL}.

Sincerely,

{ADMINNAME}]]></surveyls_email_confirm>
    <surveyls_dateformat><![CDATA[9]]></surveyls_dateformat>
    <email_admin_notification_subj><![CDATA[Response submission for survey {SURVEYNAME}]]></email_admin_notification_subj>
    <email_admin_notification><![CDATA[Hello,

A new response was submitted for your survey '{SURVEYNAME}'.

Click the following link to reload the survey:
{RELOADURL}

Click the following link to see the individual response:
{VIEWRESPONSEURL}

Click the following link to edit the individual response:
{EDITRESPONSEURL}

View statistics by clicking here:
{STATISTICSURL}]]></email_admin_notification>
    <email_admin_responses_subj><![CDATA[Response submission for survey {SURVEYNAME} with results]]></email_admin_responses_subj>
    <email_admin_responses><![CDATA[Hello,

A new response was submitted for your survey '{SURVEYNAME}'.

Click the following link to reload the survey:
{RELOADURL}

Click the following link to see the individual response:
{VIEWRESPONSEURL}

Click the following link to edit the individual response:
{EDITRESPONSEURL}

View statistics by clicking here:
{STATISTICSURL}


The following answers were given by the participant:
{ANSWERTABLE}]]></email_admin_responses>
    <surveyls_numberformat><![CDATA[0]]></surveyls_numberformat>
   </row>
  </rows>
 </surveys_languagesettings>
</document>
Bug heat4
Complete LimeSurvey version number (& build)150911
I will donate to the project if issue is resolvedNo
BrowserExplorer, Safari, Chrome
Database type & versionPostgres 9.1
Server OS (if known)Linux
Webserver software & version (if known)Apache 2
PHP Version5.3

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2015-11-19 17:14

developer   ~33608

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

DenisChenu

DenisChenu

2015-11-19 17:14

developer   ~33609

Fix by reporter :)

c_schmitz

c_schmitz

2015-12-04 15:13

administrator   ~33697

2.06+ Build 151205 released

Related Changesets

LimeSurvey: master 690fc319

2015-11-19 14:40:24

adamwebb

Details Diff
Fixed issue 10052: 0 as answer code in radio list causes problems when 'No answer' is enabled
Dev: Replaces (!$var) with !isset($var) to cope with situations where $var = 0
Dev: Fix only for radio list HTML rendering. Similar issues may exist for other question types
Affected Issues
10052
mod - application/helpers/qanda_helper.php Diff File

LimeSurvey: master 7bfb12c2

2015-11-19 16:14:04

DenisChenu

Details Diff
Merge pull request #387 from adamwebb/master

Fixed issue 10052: 0 as answer code in radio list causes problems when 'No answer…
Dev: thanks for catching, bug reported and fix !
Affected Issues
10052
mod - application/helpers/qanda_helper.php Diff File

Issue History

Date Modified Username Field Change
2015-11-19 15:38 adamwebb New Issue
2015-11-19 15:38 adamwebb File Added: limesurvey_survey_345929.lss.xml
2015-11-19 17:14 adamwebb Changeset attached => LimeSurvey master 690fc319
2015-11-19 17:14 DenisChenu Changeset attached => LimeSurvey master 7bfb12c2
2015-11-19 17:14 DenisChenu Note Added: 33608
2015-11-19 17:14 DenisChenu Assigned To => DenisChenu
2015-11-19 17:14 DenisChenu Resolution open => fixed
2015-11-19 17:14 DenisChenu Note Added: 33609
2015-11-19 17:14 DenisChenu Status new => resolved
2015-11-19 17:14 DenisChenu Fixed in Version => 2.06+
2015-12-04 15:13 c_schmitz Note Added: 33697
2015-12-04 15:13 c_schmitz Status resolved => closed