View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
10724Bug reportsSurvey editingpublic2016-05-25 09:03
Reporterwingman123 Assigned ToLouisGac 
PriorityhighSeveritypartial_block 
Status closedResolutionfixed 
Product Version2.50.x 
Summary10724: Date Question Default value inconsistent behavior w/ token persistence enabled
Description

Hi,

Within LimeSurvey 2.5 + https://github.com/LimeSurvey/LimeSurvey/commit/6cdbed03678cddf9cd3029742cd24433e46e79ec
For a survey with multiple groups in group by group mode with tokens and token persistence enabled and a date "D" question type within any group except for the first, if there is a default value for the date question, it will only show up the first time the survey is executed with that token if the survey is not saved on the group that has the date question.

Things I've tried:
Disable token persistence - Issue is not there
Date question on first page - Issue is not there because any navigation away will save the values on the page in an UPDATE to the db
No tokens - issue not there

Therefore the token persistence must be enabled to view this issue

Within the code:
// Format the date for output
$dateoutput=trim($SESSION['survey'.Yii::app()->getConfig('surveyID')][$ia[1]]);
if ($dateoutput!='' & $dateoutput!='INVALID')
{
$datetimeobj = new Date_Time_Converter($dateoutput , "Y-m-d H:i");
$dateoutput = $datetimeobj->convert($dateformatdetails['phpdate']);
}

in qanda_helper.php

  • there is no value available here, default value is still available elsewhere in the session variable however

Thanks for the help, this is a random one

Steps To Reproduce
  • Either use the survey I've attached or create a basic survey as such:

2 groups:
Group 1: any amount of questions but no date type question
Group 2: any amount of questions but at least one date type question
Date type question should be default with no attributes set
Date question type add default value such as: 2015-03-01 00:00:00

Enable Tokens
Enable Token response persistence in survey settings

Enable Full index and Prev button (although I've tried with just Next enabled as well)
Execute the survey with a token
When landing on Group 1 Hit "Next" or navigate to group 2 via Index
Date field should appear to have default value set
Close the survey without doing anything else (not changes or navigation)

Execute the survey again with the same token
When landing on Group 1 Hit "Next" or navigate to group 2 via Index
Date field should be empty

Entered data and saving work fine as do saving instead of closing the survey the first time.

TagsNo tags attached.
Attached Files
Bug heat6
Complete LimeSurvey version number (& build)Build 160309
I will donate to the project if issue is resolvedNo
BrowserChrome, Firefox
Database type & versionPostgres 9.4.4
Server OS (if known)Mac OSX 10.11
Webserver software & version (if known)Apache/2.4.16
PHP Version5.6.13

Users monitoring this issue

There are no users monitoring this issue.

Activities

wingman123

wingman123

2016-03-10 16:22

reporter   ~36304

This same behavior also appears to be happening with a numerical input type question

wingman123

wingman123

2016-03-10 16:32

reporter   ~36306

Also multiple numeric question types. Array question types seem to be fine however as are long free text

wingman123

wingman123

2016-03-10 17:52

reporter   ~36322

I noticed these question types have extra logic when looking at startingValues in em_manager_helper.php - not sure if thats the issue
case 'D': //DATE
if (trim($value)=="")
{
$value = NULL;
}
else
{
// We don't really validate date here, anyone can send anything : forced too
$dateformatdatat=getDateFormatData($LEM->surveyOptions['surveyls_dateformat']);
$datetimeobj = new Date_Time_Converter($value, $dateformatdatat['phpdate']);
$value=$datetimeobj->convert("Y-m-d H:i");
}
break;
case 'N': //NUMERICAL QUESTION TYPE
case 'K': //MULTIPLE NUMERICAL QUESTION
if (trim($value)=="") {
$value = NULL;
}
else {
$value = sanitize_float($value);
}
break;
case '|': //File Upload
$value=NULL; // can't upload a file via GET
break;

wingman123

wingman123

2016-03-10 19:07

reporter   ~36330

So this is actually the bit of logic causing the issue:
if (($SESSION['survey'.$surveyid]['fieldmap'][$column]['type'] == 'N' ||
$SESSION['survey'.$surveyid]['fieldmap'][$column]['type'] == 'K' ||
$SESSION['survey'.$surveyid]['fieldmap'][$column]['type'] == 'D') && $value == null)
{ // For type N,K,D NULL in DB is to be considered as NoAnswer in any case.
// We need to set the _SESSION[field] value to '' in order to evaluate conditions.
// This is especially important for the deletenonvalue feature,
// otherwise we would erase any answer with condition such as EQUALS-NO-ANSWER on such
// question types (NKD)
$SESSION['survey'.$surveyid][$column]='';
}

Is this to be expected? shouldn't this behave like the other questions even with token persistence on? Thanks for the help

LouisGac

LouisGac

2016-05-11 12:30

developer   ~38320

well thanks for your work !
you did most of it...
I will resolve this one soon

wingman123

wingman123

2016-05-17 16:56

reporter   ~38647

Thanks! looking forward to seeing the solution

LouisGac

LouisGac

2016-05-24 13:08

developer   ~38766

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

LouisGac

LouisGac

2016-05-24 13:09

developer   ~38767

thank you again for your help, you did a great job.

wingman123

wingman123

2016-05-24 22:49

reporter   ~38817

no problem, glad to help out. Very specific issue, thanks for the fix

wingman123

wingman123

2016-05-24 23:10

reporter   ~38818

I tested it and it seems to work

c_schmitz

c_schmitz

2016-05-25 09:03

administrator   ~38820

Version 2.50+ Build 160525 & Version 2.06LTS Build 160524 released

Related Changesets

LimeSurvey: master 749d240e

2016-05-24 11:08:49

LouisGac

Details Diff
Fixed issue 10724: Date Question Default value inconsistent behavior w/ token persistence enabled Affected Issues
10724
mod - application/helpers/frontend_helper.php Diff File

Issue History

Date Modified Username Field Change
2016-03-09 23:50 wingman123 New Issue
2016-03-09 23:50 wingman123 File Added: limesurvey_survey_542554.lss
2016-03-10 16:22 wingman123 Note Added: 36304
2016-03-10 16:32 wingman123 Note Added: 36306
2016-03-10 17:34 c_schmitz Priority none => low
2016-03-10 17:52 wingman123 Note Added: 36322
2016-03-10 19:07 wingman123 Note Added: 36330
2016-05-11 12:30 LouisGac Note Added: 38320
2016-05-11 12:30 LouisGac Priority low => high
2016-05-11 12:30 LouisGac Assigned To => LouisGac
2016-05-11 12:30 LouisGac Status new => assigned
2016-05-17 16:56 wingman123 Note Added: 38647
2016-05-24 12:23 LouisGac Sticky Issue No => Yes
2016-05-24 13:08 LouisGac Changeset attached => LimeSurvey master 749d240e
2016-05-24 13:08 LouisGac Note Added: 38766
2016-05-24 13:08 LouisGac Resolution open => fixed
2016-05-24 13:09 LouisGac Note Added: 38767
2016-05-24 13:09 LouisGac Status assigned => resolved
2016-05-24 13:10 LouisGac Sticky Issue Yes => No
2016-05-24 22:49 wingman123 Note Added: 38817
2016-05-24 23:10 wingman123 Note Added: 38818
2016-05-25 09:03 c_schmitz Note Added: 38820
2016-05-25 09:03 c_schmitz Status resolved => closed
2019-11-01 17:25 c_schmitz Category Survey design => Survey editing