gT("Save your responses so far"))))
{
$backok="Y";
}
else
{
$backok="N";
}
//Now, we check mandatory questions if necessary
//CHECK IF ALL CONDITIONAL MANDATORY QUESTIONS THAT APPLY HAVE BEEN ANSWERED
$notanswered=addtoarray_single(checkmandatorys($move,$backok),checkconditionalmandatorys($move,$backok));
//CHECK PREGS
$notvalidated=checkpregs($move,$backok);
//CHECK QUOTA
if ($thissurvey['active'] == "Y")
{
check_quota('enforce',$surveyid);
}
//SEE IF THIS GROUP SHOULD DISPLAY
if (isset($move) && $_SESSION['step'] != 0 && $move != "movesubmit")
{
while(checkgroupfordisplay($_SESSION['grouplist'][$_SESSION['step']-1][0]) === false)
{
if (isset($move) && $move == "moveprev")
{
$_SESSION['step']=$_SESSION['step']-1;
}
if (isset($move) && $move == "movenext")
{
$_SESSION['step']=$_SESSION['step']+1;
}
if ($_SESSION['step']>$_SESSION['totalsteps'])
{
$move = "movesubmit";
submitanswer(); // complete this answer (submitdate)
break;
}
}
}
//SUBMIT ###############################################################################
if ((isset($move) && $move == "movesubmit") && (!isset($notanswered) || !$notanswered) && (!isset($notvalidated) || !$notvalidated ))
{
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);
}
if($thissurvey['printanswers'] != 'Y')
{
killSession();
}
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"));
}
$completed = $thissurvey['surveyls_endtext'];
$completed .= "
".$clang->gT("Did Not Save")."
\n\n";
$completed .= $clang->gT("Your survey responses have not been recorded. This survey is not yet active.")."
\n";
if ($thissurvey['printanswers'] == 'Y')
{
// ClearAll link is only relevant for survey with printanswers enabled
// in other cases the session is cleared at submit time
$completed .= "".$clang->gT("Clear Responses")."
\n";
}
}
else //THE FOLLOWING DEALS WITH SUBMITTING ANSWERS AND COMPLETING AN ACTIVE SURVEY
{
if ($thissurvey['usecookie'] == "Y" && $tokensexist != 1) //don't use cookies if tokens are being used
{
$cookiename="PHPSID".returnglobal('sid')."STATUS";
setcookie("$cookiename", "COMPLETE", time() + 31536000); //Cookie will expire in 365 days
}
//Before doing the "templatereplace()" function, check the $thissurvey['url']
//field for limereplace stuff, and do transformations!
$thissurvey['surveyls_url']=insertansReplace($thissurvey['surveyls_url']);
$thissurvey['surveyls_url']=passthruReplace($thissurvey['surveyls_url'], $thissurvey);
$content='';
$content .= templatereplace(file_get_contents("$thistpl/startpage.pstpl"));
//Check for assessments
if ($thissurvey['assessments']== "Y")
{
$assessments = doAssessment($surveyid);
if ($assessments)
{
$content .= templatereplace(file_get_contents("$thistpl/assessment.pstpl"));
}
}
//Update the token if needed and send a confirmation email
if (isset($clienttoken) && $clienttoken)
{
submittokens();
}
//Send notification to survey administrator //Thanks to Jeff Clement http://jclement.ca
if ($thissurvey['sendnotification'] > 0 && $thissurvey['adminemail'])
{
sendsubmitnotification($thissurvey['sendnotification']);
}
$content='';
$content .= templatereplace(file_get_contents("$thistpl/startpage.pstpl"));
//echo $thissurvey['url'];
//Check for assessments
if ($thissurvey['assessments']== "Y")
{
$assessments = doAssessment($surveyid);
if ($assessments)
{
$content .= templatereplace(file_get_contents("$thistpl/assessment.pstpl"));
}
}
if (trim(strip_tags($thissurvey['surveyls_endtext']))=='')
{
$completed = "
".$clang->gT("Thank you!")."
\n\n"
. $clang->gT("Your survey responses have been recorded.")."
\n";
}
else
{
$completed = $thissurvey['surveyls_endtext'];
}
// Link to Print Answer Preview **********
if ($thissurvey['printanswers']=='Y')
{
$completed .= "
"
.""
.$clang->gT("Print your answers.")
."
\n";
}
//*****************************************
if ($thissurvey['publicstatistics']=='Y' && $thissurvey['printanswers']=='Y') {$completed .='
'.$clang->gT("or");}
// Link to Public statistics **********
if ($thissurvey['publicstatistics']=='Y')
{
$completed .= "
"
.""
.$clang->gT("View the statistics for this survey.")
."
\n";
}
//*****************************************
$_SESSION['finished']=true;
$_SESSION['sid']=$surveyid;
sendcacheheaders();
if (isset($thissurvey['autoredirect']) && $thissurvey['autoredirect'] == "Y" && $thissurvey['surveyls_url'])
{
//Automatically redirect the page to the "url" setting for the survey
$url = $thissurvey['surveyls_url'];
$url = insertansReplace($thissurvey['surveyls_url']);
$url = passthruReplace($url, $thissurvey);
$url=str_replace("{SAVEDID}",$saved_id, $url); // to activate the SAVEDID in the END URL
$url=str_replace("{TOKEN}",$clienttoken, $url); // to activate the TOKEN in the END URL
$url=str_replace("{SID}", $surveyid, $url); // to activate the SID in the END URL
$url=str_replace("{LANG}", $clang->getlangcode(), $url); // to activate the LANG in the END URL
//queXS Addition
include_once("quexs.php");
$quexs_url = get_start_interview_url();
$url = str_replace("{STARTINTERVIEWURL}", $quexs_url, $url);
header("Location: {$url}");
}
//if($thissurvey['printanswers'] != 'Y' && $thissurvey['usecookie'] != 'Y' && $tokensexist !=1)
if($thissurvey['printanswers'] != 'Y')
{
killSession();
}
doHeader();
echo $content;
}
echo templatereplace(file_get_contents("$thistpl/completed.pstpl"));
echo "\n
\n";
echo templatereplace(file_get_contents("$thistpl/endpage.pstpl"));
doFooter();
exit;
}
//SEE IF $surveyid EXISTS ####################################################################
if ($surveyexists <1)
{
//SURVEY DOES NOT EXIST. POLITELY EXIT.
echo templatereplace(file_get_contents("$thistpl/startpage.pstpl"));
echo "\t