Skip to content

Commit

Permalink
Fixed issue #05818: Values passed on the URL do not get saved when th…
Browse files Browse the repository at this point in the history
…e questions are hidden
  • Loading branch information
TMSWhite committed Feb 17, 2012
1 parent 29bcb61 commit 2bcbd19
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
8 changes: 7 additions & 1 deletion classes/eval/LimeExpressionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,7 @@ static function StartProcessingPage($allOnOnePage=false,$rooturl=NULL)
}
$LEM->initialized=true;
}

/**
* Initialize a survey so can use EM to manage navigation
* @param <type> $surveyid
Expand Down Expand Up @@ -2882,6 +2882,12 @@ static function StartSurvey($surveyid,$surveyMode='group',$options=NULL,$forceRe
$LEM->currentQuestionSeq=-1; // for question-by-question mode
$LEM->indexGseq=array();
$LEM->indexQseq=array();

if (isset($_SESSION['startingValues']) && is_array($_SESSION['startingValues']) && count($_SESSION['startingValues']) > 0)
{
$startingValues = $_SESSION['startingValues'];
$LEM->_UpdateValuesInDatabase($startingValues);
}

return array(
'hasNext'=>true,
Expand Down
40 changes: 39 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2225,16 +2225,54 @@ function buildsurveysession($previewGroup=false)
// }
// }
// Prefill questions/answers from command line params
$startingValues=array();
if (isset($_SESSION['insertarray']))
{
foreach($_SESSION['insertarray'] as $field)
{
if (isset($_GET[$field]) && $field!='token')
{
$_SESSION[$field]=$_GET[$field];
$value=$_GET[$field];
$type = $fieldmap[$field]['type'];
switch($type)
{
case 'D': //DATE
if (trim($value)=="")
{
$value = NULL;
}
else
{
$dateformatdatat=getDateFormatData($thissurvey['surveyls_dateformat']);
$datetimeobj = new Date_Time_Converter($value, $dateformatdatat['phpdate']);
$value=$datetimeobj->convert("Y-m-d");
}
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;
}
if (!is_null($value))
{
$_SESSION[$field] = $value;
$startingValues[$field] = array (
'type'=>$type,
'value'=>$value,
);
}
}
}
}
$_SESSION['startingValues']=$startingValues;

if (isset($_SESSION['fieldarray'])) $_SESSION['fieldarray']=array_values($_SESSION['fieldarray']);

Expand Down

0 comments on commit 2bcbd19

Please sign in to comment.