Index: lams_tool_assessment/web/pages/learning/learning.jsp =================================================================== diff -u -r8518d9067746b5286f01a9ed5679a8b60cff0e95 -r595c3aded62df8b73335d4c71df63d4b33691793 --- lams_tool_assessment/web/pages/learning/learning.jsp (.../learning.jsp) (revision 8518d9067746b5286f01a9ed5679a8b60cff0e95) +++ lams_tool_assessment/web/pages/learning/learning.jsp (.../learning.jsp) (revision 595c3aded62df8b73335d4c71df63d4b33691793) @@ -187,32 +187,31 @@ //autosave feature + + function autosave(){ + if (isWaitingForConfirmation) return; + + //copy value from CKEditor (only available in essay type of questions) to textarea before ajax submit + $("textarea[id^='question']").each(function() { + var ckeditorData = CKEDITOR.instances[this.name].getData(); + //skip out empty values + this.value = ((ckeditorData == null) || (ckeditorData.replace(/ | |
|\s|

|<\/p>|\xa0/g, "").length == 0)) ? "" : ckeditorData; + }); + + //ajax form submit + $('#answers').ajaxSubmit({ + url: "?sessionMapID=${sessionMapID}&date=" + new Date().getTime(), + success: function() { + $.jGrowl( + " ", + { life: 2000, closeTemplate: '' } + ); + } + }); + } var autosaveInterval = "30000"; // 30 seconds interval - window.setInterval( - function(){ - if (isWaitingForConfirmation) return; - - //copy value from CKEditor (only available in essay type of questions) to textarea before ajax submit - $("textarea[id^='question']").each(function() { - var ckeditorData = CKEDITOR.instances[this.name].getData(); - //skip out empty values - this.value = ((ckeditorData == null) || (ckeditorData.replace(/ | |
|\s|

|<\/p>|\xa0/g, "").length == 0)) ? "" : ckeditorData; - }); - - //ajax form submit - $('#answers').ajaxSubmit({ - url: "?sessionMapID=${sessionMapID}&date=" + new Date().getTime(), - success: function() { - $.jGrowl( - " ", - { life: 2000, closeTemplate: '' } - ); - } - }); - }, - autosaveInterval - ); + window.setInterval(autosave, autosaveInterval); //check if we came back due to failed answers' validation (missing required question's answer or min words limit not reached)