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 52fccc5 commit 392ef9d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
6 changes: 6 additions & 0 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -2890,6 +2890,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['survey_'.$surveyid]['startingValues']) && is_array($_SESSION['survey_'.$surveyid]['startingValues']) && count($_SESSION['survey_'.$surveyid]['startingValues']) > 0)
{
$startingValues = $_SESSION['survey_'.$surveyid]['startingValues'];
$LEM->_UpdateValuesInDatabase($startingValues);
}

return array(
'hasNext'=>true,
Expand Down
42 changes: 40 additions & 2 deletions application/helpers/frontend_helper.php
Expand Up @@ -2048,17 +2048,55 @@ function buildsurveysession($surveyid,$previewGroup=false)
// }
// }
// Prefill questions/answers from command line params
$startingValues=array();
if (isset($_SESSION['survey_'.$surveyid]['insertarray']))
{
foreach($_SESSION['survey_'.$surveyid]['insertarray'] as $field)
{
if (isset($_GET[$field]) && $field!='token')
{
$_SESSION['survey_'.$surveyid][$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['survey_'.$surveyid][$field] = $value;
$startingValues[$field] = array (
'type'=>$type,
'value'=>$value,
);
}
}
}
}

$_SESSION['survey_'.$surveyid]['startingValues']=$startingValues;

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

//Check if a passthru label and value have been included in the query url
Expand Down

0 comments on commit 392ef9d

Please sign in to comment.