alert("Important parameters are missing from the link! Please hit the browser\'s back button and try a valid action.")'; exit(); } $formSubmitLink ='admin_survey_update.php?id='.$_GET['id'].'&name='.urlencode($_GET['name']).'&active='.$_GET['active']; function StringToFloat( $val ) { preg_match( "#^([\+\-]|)([0-9]*)(\.([0-9]*?)|)(0*)$#", trim($val), $o ); if(count($o) == 0 ) return 'NaN'; return floatval($o[1].sprintf('%d',$o[2]).($o[3]!='.'?$o[3]:'')); } //when loading the survey, make sure it is not a postback to the page. if(!array_key_exists('btnUpdate', $_REQUEST)) { $setId = trim($_GET['id']); if(array_key_exists('name', $_GET)) $surveyName = $_GET['name']; if(array_key_exists('active', $_GET)) $isActiveUI = $_GET['active']; //if we are passed an id in URL, pull data from the DB $questions = $biz->GetQuestions(trim($setId)); if(!is_array($questions) || count($questions) == 0) $saveMessage = "Unable to find data for the selected survey! Please click here to search for a survey."; $quesCount = count($questions); } //do stuff only if Update button has been hit. if (array_key_exists('btnUpdate', $_REQUEST)) { $setId = $_REQUEST['setId']; $deletedQuestionIds = explode(',', trim($_REQUEST['questionsToDelete'], ',')); if(array_key_exists('isActive', $_REQUEST)) { $isActiveUI = 1; $isActiveDB = true; } else { $isActiveUI = 0; $isActiveDB = false; } //Confirm that survey name is not empty $surveyName = trim($_REQUEST['surveyName']); if(strlen($surveyName) == 0) { $errors['surveyNameError'] = 'Please enter name of the survey.'; $hasError = true; } //check if the survey name has been used already only if it has changed else if($surveyName != $_GET['name'] && !$biz->IsSurveyNameAvailable($surveyName)) { $errors['surveyNameError'] = 'This survey name is not available.'; $hasError = true; } //get all values of question and corresponding co-ordinates $quesCount = intval(trim($_REQUEST['quesCount'])); for($i = 0; $i<$quesCount; $i++) { $quesId = 'q'.$i; $question = array( 'text' => trim($_REQUEST[$quesId]), 'x' => trim($_REQUEST[$quesId.'x']), 'y' => trim($_REQUEST[$quesId.'y']), 'z' => trim($_REQUEST[$quesId.'z']), 'id' => trim($_REQUEST[$quesId.'Id']) ); $questions []= $question; //if either of the fields is full, check that all other fields are full //and x,y and z only have numbers in it. if(strlen($question['text']) > 0 || strlen($question['x']) > 0 || strlen($question['y']) > 0 || strlen($question['z']) > 0) { if(strlen($question['text']) == 0) { $errors[$quesId.'Error'] = 'Please enter some text for the question.'; $hasError = true; } //check for x values if(strlen($question['x']) == 0) { $errors[$quesId.'xError'] = '\'x\' cannot
be empty'; $hasError = true; } else if(strlen($question['x']) > 17) { $errors[$quesId.'xError'] = 'Please enter
less than
17 characters.'; $hasError = true; } else if(StringToFloat($question['x']) === 'NaN') { $errors[$quesId.'xError'] = 'Invalid decimal
number.'; $hasError = true; } //check for y values if(strlen($question['y']) == 0) { $errors[$quesId.'yError'] = '\'y\' cannot
be empty'; $hasError = true; } else if(strlen($question['y']) > 17) { $errors[$quesId.'yError'] = 'Please enter
less than
17 characters.'; $hasError = true; } else if(StringToFloat($question['y']) === 'NaN') { $errors[$quesId.'yError'] = 'Invalid decimal
number.'; $hasError = true; } //check for z values if(strlen($question['z']) == 0) { $errors[$quesId.'zError'] = '\'z\' cannot
be empty'; $hasError = true; } else if(strlen($question['z']) > 17) { $errors[$quesId.'zError'] = 'Please enter
less than
17 characters.'; $hasError = true; } else if(StringToFloat($question['z']) === 'NaN') { $errors[$quesId.'zError'] = 'Invalid decimal
number.'; $hasError = true; } } } if(!$hasError) { //if there are no errors, then try putting data in to database. $isSuccessfulUpdate = $biz->UpdateSurvey($surveyName, $setId, $isActiveDB, $questions, $deletedQuestionIds, array()); if($isSuccessfulUpdate === true) { //refetch the questions from the database. $questions = $biz->GetQuestions($setId); $deletedQuestionIds = array(); $errors = array(); $saveMessage = 'Changes were successfully saved to the database.'; $formSubmitLink ='admin_survey_update.php?id='.$_GET['id'].'&name='.urlencode($surveyName).'$active='.$isActiveUI; } else { $saveMessage = 'There was an error saving the survey to the database.
'.$isSuccessfulUpdate->errorDescription.'
'; } } else { $saveMessage = 'Kindly resolve the shown errors before saving the survey.'; } } $biz->CloseDatabaseConnection(); ?> Carview | VRoom 360 Edit Survey

A few things to keep in mind

  1. To Edit the question, please directly modify the data as you see it and hit update at the bottom of the page to save it.
  2. Delete does not delete the questions until you hit Update at the end of the page.
  3. You do not need to Update after every change. Please perform all edits and deletes and then hit Update once to save all changes at once.
  4. Changing the survey name after the users have taken it may cause confusion. This feature has been provided mainly to correct typographical errors.

Survey Name:   
Is Active: /> Will this survey be visible to end users as soon as the information is saved?

"; } ?>
  Hit this button to save the changes you made anywhere in this page.
Question
Number
Question Text x y z Action
$uiIndex. $charLeft characters left.
$quesTextError

$xError

$yError

$zError
  Hit this button to save the changes you made anywhere in this page.
' name='questionsToDelete' id='questionsToDelete' type='hidden' />