diff --git a/application/helpers/expressions/em_manager_helper.php b/application/helpers/expressions/em_manager_helper.php index 0b7e1ee88be..6057cf32a28 100644 --- a/application/helpers/expressions/em_manager_helper.php +++ b/application/helpers/expressions/em_manager_helper.php @@ -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, diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php index 47d8ea4c168..ae9e499e77f 100644 --- a/application/helpers/frontend_helper.php +++ b/application/helpers/frontend_helper.php @@ -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