START NEW FEATURE - SAVE) How it used to work ------------------- 1. The old save method would save answers to the "survey_x" table only when the submit button was clicked. 2. If "allow saves" was turned on then answers were temporarily recorded in the "saved" table. Why change this feature? ------------------------ If a user did not complete a survey, ALL their answers were lost since no submit (database insert) was performed. Save Feature redesign --------------------- Benefits Partial survey answers are saved (provided at least Next/Prev/Last/Submit/Save so far clicked at least once). Details. 1. The answers are saved in the "survey_x" table only. The "saved" table is no longer used. 2. The "saved_control" table has new column (srid) that points to the "survey_x" record it corresponds to. 3. Answer are saved every time you move between pages (Next,Prev,Last,Submit, or Save so far). 4. Only the fields modified on the page are updated. A new hidden field "modfields" store which fields have changed. - REVERTED 5. Answered are reloaded from the database after the save so that if some other answers were modified by someone else the updates would be picked up for the current page. There is still an issue if two people modify the same answer at the same time.. the 'last one to save' wins. 6. The survey_x datestamp field is updated every time the record is updated. 7. Template can now contain {DATESTAMP} to show the last modified date/time. 8. A new field 'submitdate' has been added to the survey_x table and is written when the submit button is clicked. 9. Save So Far now displays on Submit page. This allows the user one last chance to create a saved_control record so they can return later. Notes ----- 1. A new column SRID has been added to saved_control. 2. saved table no longer exists. */ class Save { function showsaveform() { //Show 'SAVE FORM' only when click the 'Save so far' button the first time, or when duplicate is found on SAVE FORM. global $errormsg, $thissurvey, $surveyid, $clang, $clienttoken, $thisstep; $redata = compact(array_keys(get_defined_vars())); $sTemplatePath = $_SESSION['survey_'.$surveyid]['templatepath']; sendCacheHeaders(); doHeader(); echo templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"),array(),$redata); echo "\n\n\n" ."\t\n\n"; echo CHtml::form(array("/survey/index"), 'post')."\n"; //PRESENT OPTIONS SCREEN if (isset($errormsg) && $errormsg != "") { $errormsg .= "
".$clang->gT("Please try again.")."
"; } echo templatereplace(file_get_contents($sTemplatePath."save.pstpl"),array(),$redata); //END echo "\n"; echo "\n"; echo CHtml::hiddenField('token',$clienttoken)."\n"; echo "\n"; echo ""; echo templatereplace(file_get_contents($sTemplatePath."endpage.pstpl"),array(),$redata); echo "