($thissurvey['active']=='Y'), 'allowsave'=>($thissurvey['allowsave']=='Y'), 'anonymized'=>($thissurvey['anonymized']!='N'), 'assessments'=>($thissurvey['assessments']=='Y'), 'datestamp'=>($thissurvey['datestamp']=='Y'), 'deletenonvalues'=>(isset($deletenonvalues)? $deletenonvalues: 1), 'hyperlinkSyntaxHighlighting'=>(($LEMdebugLevel & LEM_DEBUG_VALIDATION_SUMMARY) == LEM_DEBUG_VALIDATION_SUMMARY), // TODO set this to true if in admin mode but not if running a survey 'ipaddr'=>($thissurvey['ipaddr']=='Y'), 'radix'=>$radix, 'refurl'=>(($thissurvey['refurl'] == "Y") ? $_SESSION['refurl'] : NULL), 'rooturl'=>(isset($rooturl) ? $rooturl : ''), 'savetimings'=>($thissurvey['savetimings'] == "Y"), 'surveyls_dateformat'=>(isset($thissurvey['surveyls_dateformat']) ? $thissurvey['surveyls_dateformat'] : 1), 'startlanguage'=>(isset($clang->langcode) ? $clang->langcode : $thissurvey['language']), 'target'=>(isset($uploaddir) ? "{$uploaddir}/surveys/{$thissurvey['sid']}/files/" : "/temp/{$thissurvey['sid']}/files"), 'tempdir'=>(isset($tempdir) ? $tempdir : '/temp/'), 'timeadjust'=>(isset($timeadjust) ? $timeadjust : 0), 'token'=>(isset($clienttoken) ? $clienttoken : NULL), ); //Security Checked: POST, GET, SESSION, REQUEST, returnglobal, DB $previewgrp = false; if ( $surveyMode=='group' && isset($_REQUEST['action']) && ($_REQUEST['action']=='previewgroup')){ $previewgrp = true; } if (isset($_REQUEST['newtest'])) if ($_REQUEST['newtest']=="Y") setcookie("limesurvey_timers", "0"); $show_empty_group = false; if ($previewgrp) { $_SESSION['prevstep'] = 1; $_SESSION['maxstep'] = 0; } else { //RUN THIS IF THIS IS THE FIRST TIME , OR THE FIRST PAGE ######################################## if (!isset($_SESSION['step']) || $_SESSION['step'] == -1) // || !$_SESSION['step']) - don't do this for step 0, else rebuild the session { $totalquestions = buildsurveysession(); LimeExpressionManager::StartSurvey($thissurvey['sid'], $surveyMode, $surveyOptions, false,$LEMdebugLevel); // $_SESSION['step'] = 0; //if ($surveyMode == 'survey') { // $move = "movenext"; // to force a call to NavigateForwards() // } // else if (isset($thissurvey['showwelcome']) && $thissurvey['showwelcome'] == 'N') { //If explicitply set, hide the welcome screen // $_SESSION['step'] = 0; $_SESSION['step'] = 1; $move = "movenext"; // } } if (!isset($_SESSION['totalsteps'])) {$_SESSION['totalsteps']=0;} if (!isset($_SESSION['maxstep'])) {$_SESSION['maxstep']=0;} if (isset($_SESSION['LEMpostKey']) && isset($_POST['LEMpostKey']) && $_POST['LEMpostKey'] != $_SESSION['LEMpostKey']) { // then trying to resubmit (e.g. Next, Previous, Submit) from a cached copy of the page // Does not try to save anything from the page to the database $moveResult = LimeExpressionManager::GetLastMoveResult(true); if (isset($_POST['thisstep']) && isset($moveResult['seq']) && $_POST['thisstep'] == $moveResult['seq']) { // then pressing F5 or otherwise refreshing the current page, which is OK $LEMskipReprocessing=true; $move = "movenext"; // so will re-display the survey } else { // trying to use browser back buttons, which may be disallowed if no 'previous' button is present $LEMskipReprocessing=true; $move = "movenext"; // so will re-display the survey $invalidLastPage=true; $vpopup="\n"; } } if (!(isset($_POST['saveall']) || isset($_POST['saveprompt']) || isset($_POST['loadall']) || isset($_GET['sid']) || $LEMskipReprocessing || (isset($move) && (preg_match('/^changelang_/',$move))))) { $_SESSION['prevstep']=$_SESSION['step']; } if (!isset($_SESSION['prevstep'])) { $_SESSION['prevstep']=-1; // this only happens on re-load } if (isset($_SESSION['LEMtokenResume'])) { LimeExpressionManager::StartSurvey($thissurvey['sid'], $surveyMode, $surveyOptions, false,$LEMdebugLevel); $moveResult = LimeExpressionManager::JumpTo($_SESSION['step'],false,false); // if late in the survey, will re-validate contents, which may be overkill unset($_SESSION['LEMtokenResume']); unset($_SESSION['LEMreload']); } else if (!$LEMskipReprocessing) { //Move current step ########################################################################### if (isset($move) && $move == 'moveprev' && ($thissurvey['allowprev']=='Y' || $thissurvey['allowjumps']=='Y')) { $moveResult = LimeExpressionManager::NavigateBackwards(); if ($moveResult['at_start']) { $_SESSION['step']=0; unset($moveResult); // so display welcome page again } } if (isset($move) && $move == "movenext") { if (isset($_SESSION['LEMreload'])) { LimeExpressionManager::StartSurvey($thissurvey['sid'], $surveyMode, $surveyOptions, false,$LEMdebugLevel); $moveResult = LimeExpressionManager::JumpTo($_SESSION['step'],false,false); // if late in the survey, will re-validate contents, which may be overkill unset($_SESSION['LEMreload']); } else { $moveResult = LimeExpressionManager::NavigateForwards(); } } if (isset($move) && ($move == 'movesubmit')) { if ($surveyMode == 'survey') { $moveResult = LimeExpressionManager::NavigateForwards(); } else { // may be submitting from the navigation bar, in which case need to process all intervening questions // in order to update equations and ensure there are no intervening relevant mandatory or relevant invalid questions $moveResult = LimeExpressionManager::JumpTo($_SESSION['totalsteps']+1,false); } } if (isset($move) && (preg_match('/^changelang_/',$move))) { // jump to current step using new language, processing POST values $moveResult = LimeExpressionManager::JumpTo($_SESSION['step'],false,true,false,true); // do process the POST data } if (isset($move) && bIsNumericInt($move) && $thissurvey['allowjumps']=='Y') { $move = (int)$move; if ($move > 0 && (($move <= $_SESSION['step']) || (isset($_SESSION['maxstep']) && $move <= $_SESSION['maxstep']))) { $moveResult = LimeExpressionManager::JumpTo($move,false); } } if (!isset($moveResult) && !($surveyMode != 'survey' && $_SESSION['step'] == 0)) { // Just in case not set via any other means, but don't do this if it is the welcome page $moveResult = LimeExpressionManager::GetLastMoveResult(true); $LEMskipReprocessing=true; } } if (isset($moveResult)) { if ($moveResult['finished']==true) { $move = 'movesubmit'; } else { $_SESSION['step']= $moveResult['seq']+1; // step is index base 1 $stepInfo = LimeExpressionManager::GetStepIndexInfo($moveResult['seq']); } if ($move == "movesubmit" && $moveResult['finished'] == false) { // then there are errors, so don't finalize the survey $move = "movenext"; // so will re-display the survey $invalidLastPage=true; } } // We do not keep the participant session anymore when the same browser is used to answer a second time a survey (let's think of a library PC for instance). // Previously we used to keep the session and redirect the user to the // submit page. if ($surveyMode != 'survey' && $_SESSION['step'] == 0) { display_first_page(); exit; } //CHECK IF ALL MANDATORY QUESTIONS HAVE BEEN ANSWERED ############################################ //First, see if we are moving backwards or doing a Save so far, and its OK not to check: if ( (isset($move) && ($move == "moveprev" || (is_int($move) && $_SESSION['prevstep'] == $_SESSION['maxstep']) || $_SESSION['prevstep'] == $_SESSION['step'])) || (isset($_POST['saveall']) && $_POST['saveall'] == $clang->gT("Save your responses so far"))) { if ($allowmandbackwards==1) { $backok="Y"; } else { $backok="N"; } } else { $backok="N"; // NA, since not moving backwards } if ($thissurvey['active'] == "Y" && isset($_POST['saveall'])) { // must do this here to process the POSTed values //$moveResult = LimeExpressionManager::JumpTo($_SESSION['step'],false); // by jumping to current step, saves data so far //showsaveform(); // generates a form and exits, awaiting input if(!tableExists('tokens_'.$surveyid) || $thissurvey['anonymized']=='Y' || (tableExists('tokens_'.$surveyid) && $thissurvey['tokenanswerspersistence'] == 'N' )) { $moveResult = LimeExpressionManager::JumpTo($_SESSION['step'],false,true,false,false,true); // by jumping to current step, saves data so far //queXS Removal //showsaveform(); } else { $moveResult = LimeExpressionManager::JumpTo($_SESSION['step'],false,true,false,false,true); // by jumping to current step, saves data so far } } if ($thissurvey['active'] == "Y" && isset($_POST['saveprompt'])) { // The response from the save form // CREATE SAVED CONTROL RECORD USING SAVE FORM INFORMATION $flashmessage = savedcontrol(); if (isset($errormsg) && $errormsg != "") { showsaveform(); // reshow the form if there is an error } $moveResult = LimeExpressionManager::GetLastMoveResult(true); $LEMskipReprocessing=true; // TODO - does this work automatically for token answer persistence? Used to be savedsilent() } //Now, we check mandatory questions if necessary //CHECK IF ALL CONDITIONAL MANDATORY QUESTIONS THAT APPLY HAVE BEEN ANSWERED global $notanswered; if (isset($moveResult) && !$moveResult['finished']) { $unansweredSQList = $moveResult['unansweredSQs']; if (strlen($unansweredSQList) > 0 && $backok != "N") { $notanswered = explode('|',$unansweredSQList); } else { $notanswered = array(); } //CHECK INPUT $invalidSQList = $moveResult['invalidSQs']; if (strlen($invalidSQList) > 0 && $backok != "N") { $notvalidated = explode('|',$invalidSQList); } else { $notvalidated = array(); } } // CHECK UPLOADED FILES // TMSW - Move this into LEM::NavigateForwards? $filenotvalidated = checkUploadedFileValidity($move, $backok); //SEE IF THIS GROUP SHOULD DISPLAY $show_empty_group = false; if ($_SESSION['step']==0) $show_empty_group = true; //SUBMIT ############################################################################### if ((isset($move) && $move == "movesubmit")) { setcookie ("limesurvey_timers", "", time() - 3600);// remove the timers cookies if ($thissurvey['refurl'] == "Y") { if (!in_array("refurl", $_SESSION['insertarray'])) //Only add this if it doesn't already exist { $_SESSION['insertarray'][] = "refurl"; } } //COMMIT CHANGES TO DATABASE if ($thissurvey['active'] != "Y") //If survey is not active, don't really commit { if ($thissurvey['assessments']== "Y") { $assessments = doAssessment($surveyid); } sendcacheheaders(); doHeader(); echo templatereplace(file_get_contents("$thistpl/startpage.pstpl")); //Check for assessments if ($thissurvey['assessments']== "Y" && $assessments) { echo templatereplace(file_get_contents("$thistpl/assessment.pstpl")); } // fetch all filenames from $_SESSIONS['files'] and delete them all // from the /upload/tmp/ directory /*echo "
";print_r($_SESSION);echo ""; for($i = 1; isset($_SESSION['files'][$i]); $i++) { unlink('upload/tmp/'.$_SESSION['files'][$i]['filename']); } */ // can't kill session before end message, otherwise INSERTANS doesn't work. $completed = templatereplace($thissurvey['surveyls_endtext']); $completed .= "
| Group/Question Validation Results:".$moveResult['message']." |